[Home] [Help]
PACKAGE BODY: APPS.INV_UI_RCV_LOVS
Source
1 PACKAGE BODY INV_UI_RCV_LOVS AS
2 /* $Header: INVRCVLB.pls 120.31.12010000.6 2009/01/07 06:05:21 vssrivat ship $ */
3
4 -- Name: GET_PO_LOV
5 --
6 -- Input parameters:
7 -- p_Organization_Id which restricts LOV SQL to current org
8 -- p_po_number which restricts LOV SQL to the user input text
9 -- p_manual_po_num_type NUMERIC or ALPHANUMERIC
10 -- p_mobile_form which mobile form this LOV is for (RECEIPT or DELIVER)
11 -- SQL query will be different for these forms
12 --
13 -- Output parameters:
14 -- x_po_num_lov returns LOV rows as reference cursor
15 --
16 -- Functions: This API returns PO number for a given org
17 --
18
19 PROCEDURE GET_PO_LOV(x_po_num_lov OUT NOCOPY t_genref,
20 p_organization_id IN NUMBER,
21 p_po_number IN VARCHAR2,
22 p_mobile_form IN VARCHAR2,
23 p_shipment_header_id IN VARCHAR2)
24
25 IS
26
27 BEGIN
28
29 IF p_mobile_form = 'RCVTXN' THEN
30 OPEN x_po_num_lov FOR
31
32 /* SELECT DISTINCT poh.segment1
33 , poh.po_header_id
34 , poh.type_lookup_code
35 , MO_GLOBAL.get_ou_name(poh.org_id) --<R12 MOAC>
36 , PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID)
37 , poh.vendor_id
38 , poh.vendor_site_id
39 , 'Vendor'
40 , poh.note_to_receiver
41 , to_char(poh.org_id) --<R12 MOAC>
42 FROM rcv_supply ms
43 , rcv_transactions rt
44 , po_headers_all poh
45 , po_lines_all pol
46 , po_line_types plt
47 , mtl_parameters mp
48 WHERE poh.po_header_id = ms.po_header_id
49 AND ms.quantity > 0
50 AND ms.supply_type_code = 'RECEIVING'
51 AND ms.to_organization_id = p_organization_id
52 AND ms.supply_source_id = rt.transaction_id
53 AND rt.organization_id = ms.to_organization_id
54 AND rt.transaction_type <> 'UNORDERED'
55 AND mp.organization_id = ms.to_organization_id
56 AND poh.po_header_id = pol.po_header_id
57 AND pol.line_type_id = plt.line_type_id
58 AND (mp.wms_enabled_flag = 'N' OR (mp.wms_enabled_flag = 'Y'
59 AND (plt.outside_operation_flag = 'Y'
60 OR pol.item_id is NULL
61 OR exists (SELECT 1
62 FROM mtl_system_items_kfv msik
63 WHERE msik.inventory_item_id = pol.item_id
64 AND msik.organization_id = p_organization_id
65 AND msik.mtl_transactions_enabled_flag = 'N'))))
66 AND poh.segment1 LIKE (p_po_number)
67 AND (exists
68 (SELECT 1
69 FROM rcv_transactions rt1
70 WHERE rt1.transaction_id = rt.transaction_id
71 AND rt1.inspection_status_code <> 'NOT INSPECTED'
72 AND rt1.routing_header_id = 2)
73 OR rt.routing_header_id <> 2
74 OR rt.routing_header_id IS NULL)
75 ORDER BY decode(rtrim(poh.segment1,'0123456789'),null,null,poh.segment1),
76 decode(rtrim(poh.segment1,'0123456789'),null,to_number(poh.segment1),null); --<R12 MOAC> */
77
78 /* Modified the above Query for Bug # 7113772. Removed the join from po_lines_all and po_line_types due to bad performance */
79
80 SELECT DISTINCT poh.Segment1 ,
81 poh.po_Header_Id ,
82 poh.Type_LookUp_Code ,
83 MO_GLOBAL.get_ou_name(poh.org_id) ,--<R12 MOAC>
84 po_Vendors_sv2.Get_vendor_name_func(poh.Vendor_Id),
85 poh.Vendor_Id ,
86 poh.Vendor_Site_Id ,
87 'Vendor' ,
88 poh.Note_To_Receiver ,
89 to_char(poh.org_id) --<R12 MOAC>
90
91 FROM rcv_Supply ms ,
92 rcv_Transactions rt,
93 po_Headers_All poh ,
94 mtl_Parameters mp
95 WHERE poh.po_Header_Id = ms.po_Header_Id
96 AND ms.Quantity > 0
97 AND ms.Supply_Type_Code = 'RECEIVING'
98 AND ms.To_Organization_Id = p_organization_id
99 AND ms.Supply_Source_Id = rt.Transaction_Id
100 AND rt.Organization_Id = ms.To_Organization_Id
101 AND rt.Transaction_Type <> 'UNORDERED'
102 AND mp.Organization_Id = ms.To_Organization_Id
103 AND (mp.wms_Enabled_Flag = 'N'
104 OR (mp.wms_Enabled_Flag = 'Y'
105 AND ( EXISTS
106 (SELECT 1
107 FROM po_Line_Types
108 WHERE Outside_Operation_Flag = 'Y'
109 AND Line_Type_Id IN
110 (SELECT Line_Type_Id
111 FROM po_Lines_All
112 WHERE po_Header_Id = poh.po_Header_Id
113 )
114 )
115 OR EXISTS
116 (SELECT 1
117 FROM po_Lines_All
118 WHERE po_Header_Id = poh.po_Header_Id
119 AND Item_Id IS NULL
120 )
121 OR EXISTS
122 (SELECT 1
123 FROM mtl_System_Items_kfv msik
124 WHERE msik.Inventory_Item_Id IN
125 (SELECT Item_Id
126 FROM po_Lines_All
127 WHERE po_Header_Id = poh.po_Header_Id
128 )
129 AND msik.Organization_Id = p_organization_id
130 AND msik.mtl_Transactions_Enabled_Flag = 'N'
131 ))))
132 AND poh.Segment1 LIKE (p_po_number)
133 AND (EXISTS
134 (SELECT 1
135 FROM rcv_Transactions rt1
136 WHERE rt1.Transaction_Id = rt.Transaction_Id
137 AND rt1.Inspection_Status_Code <> 'NOT INSPECTED'
138 AND rt1.RoutIng_Header_Id = 2
139 )
140 OR rt.RoutIng_Header_Id <> 2
141 OR rt.RoutIng_Header_Id IS NULL )
142 ORDER BY decode(rtrim(poh.segment1,'0123456789'),null,null,poh.segment1),
143 decode(rtrim(poh.segment1,'0123456789'),null,to_number(poh.segment1),null); --<R12 MOAC>
144
145
146 ELSIF p_mobile_form = 'RECEIPT' THEN
147 OPEN x_po_num_lov FOR
148
149 SELECT DISTINCT poh.segment1
150 , poh.po_header_id
151 , poh.type_lookup_code
152 , MO_GLOBAL.get_ou_name(poh.org_id) --<R12 MOAC>
153 , PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID)
154 , poh.vendor_id
155 , poh.vendor_site_id
156 , 'Vendor'
157 , poh.note_to_receiver
158 , to_char(poh.org_id) --<R12 MOAC>
159 FROM po_headers poh
160 WHERE exists (SELECT 'Valid PO Shipments'
161 FROM po_line_locations_all poll
162 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
163 , mtl_parameters mp,
164 rcv_parameters rp
165 -- End for Bug 7440217
166 WHERE poh.po_header_id = poll.po_header_id
167 AND Nvl(poll.approved_flag,'N') = 'Y'
168 AND Nvl(poll.cancel_flag,'N') = 'N'
169 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
170 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
171 AND poll.ship_to_organization_id = p_organization_id
172 -- For Bug 7440217 Checking if it is LCM enabled
173 AND mp.organization_id = p_organization_id
174 AND rp.organization_id = p_organization_id
175 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
176 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
177 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
178 )
179 -- End for Bug 7440217
180 )
181 AND poh.segment1 LIKE (p_po_number)
182 AND POH.TYPE_LOOKUP_CODE IN ('STANDARD','PLANNED', 'BLANKET','CONTRACT')
183 AND NVL(POH.CANCEL_FLAG, 'N') IN ('N', 'I')
184 AND NVL(POH.CLOSED_CODE, 'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3152693
185 ORDER BY decode(rtrim(poh.segment1,'0123456789'),null,null,poh.segment1),
186 decode(rtrim(poh.segment1,'0123456789'),null,to_number(poh.segment1),null);--<R12 MOAC>
187
188 ELSIF p_mobile_form = 'RCPTASN' THEN
189 OPEN x_po_num_lov FOR
190
191 SELECT DISTINCT poh.segment1
192 , poh.po_header_id
193 , poh.type_lookup_code
194 , MO_GLOBAL.get_ou_name(poh.org_id) --<R12 MOAC>
195 , PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID)
196 , poh.vendor_id
197 , poh.vendor_site_id
198 , 'Vendor'
199 , poh.note_to_receiver
200 , to_char(poh.org_id) --<R12 MOAC>
201 FROM po_headers_all poh
202 , rcv_shipment_lines rsl
203 WHERE exists (SELECT 'Valid PO Shipments'
204 FROM po_line_locations poll
205 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
206 , mtl_parameters mp,
207 rcv_parameters rp
208 -- End for Bug 7440217
209 WHERE poh.po_header_id = poll.po_header_id
210 AND Nvl(poll.approved_flag,'N') = 'Y'
211 AND Nvl(poll.cancel_flag,'N') = 'N'
212 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
213 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
214 AND poll.ship_to_organization_id = p_organization_id
215 -- For Bug 7440217 Checking if it is LCM enabled
216 AND mp.organization_id = p_organization_id
217 AND rp.organization_id = p_organization_id
218 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
219 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
220 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
221 )
222 -- End for Bug 7440217
223 )
224 AND poh.segment1 LIKE (p_po_number)
225 AND poh.po_header_id = rsl.po_header_id
226 AND POH.TYPE_LOOKUP_CODE IN ('STANDARD','PLANNED', 'BLANKET','CONTRACT')
227 AND NVL(POH.CANCEL_FLAG, 'N') IN ('N', 'I')
228 AND NVL(POH.CLOSED_CODE, 'OPEN') NOT IN ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED') -- 3152693
229 AND rsl.shipment_header_id = Nvl(To_number(p_shipment_header_id), rsl.shipment_header_id)
230 ORDER BY Decode(rtrim(poh.segment1,'0123456789'),null,null,poh.segment1),
231 Decode(rtrim(poh.segment1,'0123456789'),null,to_number(poh.segment1),null); --<R12 MOAC>
232
233 ELSIF p_mobile_form = 'INSPECT' THEN
234 OPEN x_po_num_lov FOR
235 /*Bug: 4951739
236 Modified query: Referencing base table instead of
237 RCV_TRANSACTIONS_V
238 */
239 SELECT DISTINCT poh.segment1 ,
240 poh.po_header_id ,
241 poh.type_lookup_code ,
242 MO_GLOBAL.get_ou_name(poh.org_id) ,
243 PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID) ,
244 poh.vendor_id ,
245 poh.vendor_site_id ,
246 'Vendor' ,
247 poh.note_to_receiver ,
248 to_char(poh.org_id)
249 FROM RCV_SUPPLY RSUP,
250 RCV_TRANSACTIONS RT,
251 PO_LOOKUP_CODES PLC,
252 PO_LINES_ALL pol,
253 PO_LINE_LOCATIONS_ALL PLL,
254 PO_HEADERS_ALL POH,
255 po_line_types plt,--BUG 5166887
256 mtl_parameters mp --BUG 5166887
257 -- For Bug 7440217 Added RCV_PRAMETERS to find out if the organization is LCM enabled or not
258 , rcv_parameters rp
259 -- End for Bug 7440217
260 WHERE RSUP.SUPPLY_TYPE_CODE = 'RECEIVING'
261 AND RT.TRANSACTION_TYPE <> 'UNORDERED'
262 AND RT.TRANSACTION_TYPE = PLC.LOOKUP_CODE
263 AND PLC.LOOKUP_TYPE = 'RCV TRANSACTION TYPE'
264 AND RT.TRANSACTION_ID = RSUP.RCV_TRANSACTION_ID
265 AND PLL.LINE_LOCATION_ID(+) = RSUP.PO_LINE_LOCATION_ID
266 AND NVL(PLL.MATCHING_BASIS(+),'QUANTITY') <> 'AMOUNT'
267 AND PLL.PAYMENT_TYPE IS NULL
268 AND RSUP.po_header_id = poh.po_header_id
269 AND RSUP.to_organization_id = p_organization_id
270 AND RT.inspection_status_code = 'NOT INSPECTED'
271 AND RT.routing_header_id = 2 /* Inspection routing */
272 AND poh.segment1 LIKE (p_po_number)
273
274 -- BUG 5166887: Do not return any rows if user access WMS org through the
275 -- MSCA menu option
276 AND poh.po_header_id = pol.po_header_id
277 AND pol.line_type_id = plt.line_type_id
278 AND nvl(pol.item_id,-1) = nvl(rsup.item_id,-1)
279 AND mp.organization_id = p_organization_id
280 AND (mp.wms_enabled_flag = 'N'
281 OR (mp.wms_enabled_flag = 'Y'
282 AND (plt.outside_operation_flag = 'Y'
283 OR pol.item_id is NULL
284 OR exists (SELECT 1
285 FROM mtl_system_items_kfv msik
286 WHERE msik.inventory_item_id = pol.item_id
287 AND msik.organization_id = p_organization_id
288 AND msik.mtl_transactions_enabled_flag = 'N'))))
289 -- END BUG 5166887
290 ORDER BY Decode(rtrim(poh.segment1,'0123456789'), null,null, poh.segment1),
291 Decode(rtrim(poh.segment1,'0123456789'), null,to_number(poh.segment1), null); --<R12 MOAC>
292 END IF;
293
294 END get_po_lov;
295
296
297
298 PROCEDURE GET_PO_RELEASE_LOV(x_po_release_num_lov OUT NOCOPY t_genref,
299 p_organization_id IN NUMBER,
300 p_po_header_id IN NUMBER,
301 p_mobile_form IN VARCHAR2,
302 p_po_release_num IN VARCHAR2)
303 IS
304 po_release_number VARCHAR2(20);
305 BEGIN
306 BEGIN
307 /* Start - Fix for Bug# 6640083 */
308 -- po_release_number := to_char(to_number(p_po_release_num));
309 -- This will convert String to number - Bug#6012703
310 -- Commented the code for Bug#6640083
311 SELECT TRIM(LEADING '0' FROM p_po_release_num ) INTO po_release_number FROM Dual;
312 -- This will trim leading zeroes - Bug#6640083
313 /* End - Fix for Bug# 6640083 */
314 EXCEPTION
315 WHEN OTHERS then
316 po_release_number := p_po_release_num;
317 END;
318 IF p_mobile_form = 'RECEIPT' THEN
319 OPEN x_po_release_num_lov FOR
320 select distinct pr.release_num
321 , pr.po_release_id
322 , pr.release_date
323 from po_releases_all pr
324 where pr.po_header_id = p_po_header_id
325 --AND pr.org_id = p_organization_id
326 and nvl(pr.cancel_flag, 'N') = 'N'
327 and nvl(pr.approved_flag, 'N') <> 'N'
328 and nvl(pr.closed_code, 'OPEN') NOT IN ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
329 AND exists (SELECT 'Valid PO Shipments' --Added the exists to fix bug4350175
330 FROM po_line_locations_all poll
331 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
332 , mtl_parameters mp,
333 rcv_parameters rp
334 -- End for Bug 7440217
335 WHERE pr.po_header_id = poll.po_header_id
336 AND pr.po_release_id = poll.po_release_id
337 AND Nvl(poll.approved_flag,'N') = 'Y'
338 AND Nvl(poll.cancel_flag,'N') = 'N'
339 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
340 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING','CLOSED')
341 AND poll.ship_to_organization_id = p_organization_id
342 -- For Bug 7440217 Checking if it is LCM enabled
343 AND mp.organization_id = p_organization_id
344 AND rp.organization_id = p_organization_id
345 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
346 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
347 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
348 )
349 -- End for Bug 7440217
350 )
351 AND pr.release_num LIKE (po_release_number)
352 order by pr.release_num;
353 ELSE
354 OPEN x_po_release_num_lov FOR
355 select distinct pr.release_num
356 , pr.po_release_id
357 , pr.release_date
358 from rcv_supply rsup
359 , po_releases_all pr
360 where rsup.po_header_id = p_po_header_id
361 --AND pr.org_id = p_organization_id
362 and nvl(pr.cancel_flag, 'N') = 'N'
363 and nvl(pr.approved_flag, 'N') <> 'N'
364 AND rsup.po_release_id = pr.po_release_id
365 AND pr.release_num LIKE (po_release_number)
366 order by pr.release_num;
367 END IF;
368 END GET_PO_RELEASE_LOV;
369
370
371
372 -- Name: GET_PO_LINE_NUM_LOV
373 --
374 -- Input parameters:
375 -- p_Organization_Id which restricts LOV SQL to current org
376 -- p_po_header_id which restricts LOV SQL to the PO
377 -- p_po_line_num which restricts the LOV to the user input text.
378 --
379 -- Output parameters:
380 -- x_po_line_num_lov returns LOV rows as reference cursor
381 --
382 -- Functions: This API returns PO Line numbers for a given PO
383 --
384 PROCEDURE GET_PO_LINE_NUM_LOV(x_po_line_num_lov OUT NOCOPY t_genref,
385 p_organization_id IN NUMBER,
386 p_po_header_id IN NUMBER,
387 p_mobile_form IN VARCHAR2,
388 p_po_line_num IN VARCHAR2)
389 IS
390 po_line_number VARCHAR2(20);
391 BEGIN
392 BEGIN
393 /* Start - Fix for Bug# 6640083 */
394 -- po_line_number := to_char(to_number(p_po_line_num));
395 -- This will convert String to number - Bug#6012703
396 -- Commented the code for Bug#6640083
397 SELECT TRIM(LEADING '0' FROM p_po_line_num ) INTO po_line_number FROM Dual;
398 -- This will trim leading zeroes - Bug#6640083
399 /* End - Fix for Bug# 6640083 */
400 EXCEPTION
401 WHEN OTHERS then
402 po_line_number := p_po_line_num;
403 END;
404 IF p_mobile_form = 'RECEIPT' THEN
405 OPEN x_po_line_num_lov FOR
406 select distinct pl.line_num
407 , pl.po_line_id
408 --Bug 7274407
409 , NVL(msi.description, pl.item_description)
410 , pl.item_id
411 , pl.item_revision
412 , msi.concatenated_segments
413 , msi.outside_operation_flag
414 from po_lines_all pl
415 , mtl_system_items_vl msi
416 where pl.item_id = msi.inventory_item_id (+)
417 and Nvl(msi.organization_id, p_organization_id) = p_organization_id
418 and pl.po_header_id = p_po_header_id
419 and exists (SELECT 'Valid PO Shipments'
420 FROM po_line_locations_all poll
421 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
422 , mtl_parameters mp,
423 rcv_parameters rp
424 -- End for Bug 7440217
425 WHERE poll.po_header_id = pl.po_header_id
426 AND poll.po_line_id = pl.po_line_id
427 AND Nvl(poll.approved_flag,'N') = 'Y'
428 AND Nvl(poll.cancel_flag,'N') = 'N'
429 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
430 --AND poll.closed_code = 'OPEN'
431 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
432 AND poll.ship_to_organization_id = p_organization_id
433 -- For Bug 7440217 Checking if it is LCM enabled
434 AND mp.organization_id = p_organization_id
435 AND rp.organization_id = p_organization_id
436 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
437 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
438 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
439 )
440 -- End for Bug 7440217
441 )
442 AND pl.line_num LIKE (po_line_number)
443 order by pl.line_num;
444 ELSE
445 OPEN x_po_line_num_lov FOR
446 select distinct pl.line_num
447 , pl.po_line_id
448 --Bug 7274407
449 , NVL(msi.description, pl.item_description)
450 , pl.item_id
451 , pl.item_revision
452 , msi.concatenated_segments
453 , msi.outside_operation_flag
454 -- bug 2805640
455 , inv_ui_item_lovs.get_conversion_rate(mum.uom_code,
456 p_organization_id,
457 pl.Item_Id)
458 uom_code
459 FROM rcv_supply rsup
460 -- bug 2805640
461 , mtl_units_of_measure mum
462 , po_lines_all pl
463 , mtl_system_items_vl msi
464 WHERE rsup.po_line_id = pl.po_line_id
465 -- bug 2805640
466 and mum.UNIT_OF_MEASURE(+) = pl.UNIT_MEAS_LOOKUP_CODE
467 AND pl.item_id = msi.inventory_item_id (+)
468 and Nvl(msi.organization_id, p_organization_id) = p_organization_id
469 and rsup.po_header_id = p_po_header_id
470 AND pl.line_num LIKE (po_line_number)
471 AND rsup.to_organization_id = p_organization_id --BUG 4108624
472 order by pl.line_num;
473 END IF;
474 END GET_PO_LINE_NUM_LOV;
475
476
477
478
479 -- Name: GET_LOCATION_LOV
480 --
481 -- Input parameters:
482 -- p_Organization_Id which restricts LOV SQL to current org
483 -- p_location_code which restricts LOV SQL to the user input text
484 --
485 --
486 -- Output parameters:
487 -- x_location returns LOV rows as reference cursor
488 --
489 -- Functions: This API returns location for given org
490
491
492 PROCEDURE get_location_lov (x_location OUT NOCOPY t_genref,
493 p_organization_id IN NUMBER,
494 p_location_code IN VARCHAR2)
495 IS
496 BEGIN
497 -- this query is returning more than 50,000 record in dom1151
498 -- it is caused by nvl(inventory_organization_id,0) = 0 )
499 -- need to confirm
500 OPEN x_location FOR
501 SELECT location_code
502 , location_id
503 , description
504 FROM hr_locations hrl
505 WHERE (inventory_organization_id = p_organization_id
506 OR Nvl(inventory_organization_id,0) = 0)
507 AND receiving_site_flag = 'Y'
508 AND (inactive_date IS NULL OR inactive_date > Sysdate)
509 AND location_code LIKE (p_location_code)
510 ORDER BY Upper(location_code);
511 END get_location_lov;
512
513
514
515 -- Name: get_freight_carrier_lov
516 --
517 -- Input parameters:
518 -- p_Organization_Id which restricts LOV SQL to current org
519 -- p_freight_carrier which restricts LOV SQL to the user input text
520 --
521 --
522 -- Output parameters:
523 -- x_location returns LOV rows as reference cursor
524 --
525 -- Functions: This API returns freight carrier for given org
526
527
528 PROCEDURE get_freight_carrier_lov (x_freight_carrier OUT NOCOPY t_genref,
529 p_organization_id IN NUMBER,
530 p_freight_carrier IN VARCHAR2)
531 IS
532 BEGIN
533 OPEN x_freight_carrier FOR
534 select freight_code
535 , description
536 from org_freight
537 where organization_id = p_organization_id
538 and nvl(disable_date, sysdate+1) > sysdate
539 AND freight_code LIKE (p_freight_carrier)
540 order by upper(freight_code);
541 END get_freight_carrier_lov;
542
543
544 -- Name: GET_SHIPMENT_NUM_LOV
545 --
546 -- Input parameters:
547 -- p_Organization_Id which restricts LOV SQL to current org
548 -- p_shipment_num which restricts LOV SQL to the user input text
549 -- p_mobile_form which mobile form this LOV is for (RECEIPT or DELIVER)
550 -- SQL query will be different for these forms
551 --
552 -- Output parameters:
553 -- x_shipment_num_lov returns LOV rows as reference cursor
554 --
555 -- Functions: This API returns Shipment number for a given org
556 -- Also it returns an ASN numner for ASN receipt
557
558 PROCEDURE GET_SHIPMENT_NUM_LOV(x_shipment_num_lov OUT NOCOPY t_genref,
559 p_organization_id IN NUMBER,
560 p_shipment_num IN VARCHAR2,
561 p_mobile_form IN VARCHAR2,
562 p_po_header_id IN VARCHAR2)
563
564 IS
565
566 BEGIN
567
568
569 IF p_mobile_form = 'RCVTXN' THEN
570 OPEN x_shipment_num_lov FOR
571
572 SELECT DISTINCT rsh.shipment_num,
573 rsh.shipment_header_id,
574 rsh.shipped_date,
575 rsh.expected_receipt_date,
576 rsl.from_organization_id,
577 ood.organization_name,
578 'Organization',
579 rsh.packing_slip,
580 rsh.bill_of_lading,
581 rsh.waybill_airbill_num,
582 rsh.freight_carrier_code
583 FROM
584 rcv_shipment_headers rsh,
585 rcv_shipment_lines rsl,
586 rcv_supply ms,
587 rcv_transactions rt,
588 org_organization_definitions ood
589 WHERE rsh.shipment_header_id = ms.shipment_header_id
590 AND ms.to_organization_id = p_organization_id
591 AND rt.organization_id = p_organization_id
592 AND rsl.from_organization_id = ood.organization_id(+)
593 AND ms.supply_source_id = rt.transaction_id
594 AND ms.supply_type_code = 'RECEIVING'
595 AND rt.transaction_type <> 'UNORDERED'
596 AND rsl.shipment_header_id = rsh.shipment_header_id
597 AND Nvl(ms.quantity,0) > 0
598 AND (exists
599 (SELECT 1
600 FROM rcv_transactions rt1
601 WHERE rt1.transaction_id = rt.transaction_id
602 AND rt1.inspection_status_code <> 'NOT INSPECTED'
603 AND rt1.routing_header_id = 2)
604 OR rt.routing_header_id <> 2
605 OR rt.routing_header_id IS NULL)
606 AND rsh.shipment_num IS NOT NULL
607 AND rsh.shipment_num LIKE (p_shipment_num)
608 ORDER BY rsh.shipment_header_id DESC;
609
610 ELSIF p_mobile_form = 'RECEIPT' THEN
611 OPEN x_shipment_num_lov FOR
612
613 SELECT DISTINCT sh.shipment_num,
614 sh.shipment_header_id,
615 sh.shipped_date,
616 sh.expected_receipt_date,
617 Decode(sh.receipt_source_code,'VENDOR',sh.vendor_id, sl.from_organization_id) from_organization_id,
618 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id,sl.from_organization_id),1,80) organization_name,
619 /* Bug 4253199 ** Receipt source code is fetched properly
620 Decode(sh.receipt_source_code,'VENDOR','Vendor','Organization'),
621 */
622 Decode(sh.receipt_source_code,'VENDOR','Vendor',sh.receipt_source_code),
623 sh.packing_slip,
624 sh.bill_of_lading,
625 sh.waybill_airbill_num,
626 sh.freight_carrier_code
627 FROM rcv_shipment_headers sh,
628 rcv_shipment_lines sl
629 WHERE sh.shipment_num IS NOT NULL
630 AND sh.shipment_header_id = sl.shipment_header_id
631 AND sl.to_organization_id = p_organization_id
632 AND sh.receipt_source_code IN ('INTERNAL ORDER','INVENTORY')
633 AND exists
634 (SELECT 'available supply'
635 FROM mtl_supply ms
636 WHERE ms.to_organization_id = p_organization_id
637 AND ms.shipment_header_id = sh.shipment_header_id)
638 -- This was fix for bug 2740648/2752094
639 AND sl.shipment_line_status_code in ('EXPECTED','PARTIALLY RECEIVED')
640 AND sh.shipment_num LIKE (p_shipment_num)
641 ORDER BY sh.shipment_num;
642
643 ELSIF p_mobile_form = 'RCPTASN' THEN
644 OPEN x_shipment_num_lov FOR
645
646 SELECT DISTINCT sh.shipment_num,
647 sh.shipment_header_id,
648 sh.shipped_date,
649 sh.expected_receipt_date,
650 Decode(sh.receipt_source_code,'VENDOR',sh.vendor_id, sl.from_organization_id) from_organization_id,
651 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id,sl.from_organization_id),1,80) organization_name,
652 Decode(sh.receipt_source_code,'VENDOR','Vendor','Organization'),
653 sh.packing_slip,
654 sh.bill_of_lading,
655 sh.waybill_airbill_num,
656 sh.freight_carrier_code
657 FROM rcv_shipment_headers sh,
658 rcv_shipment_lines sl
659 WHERE sh.shipment_num IS NOT NULL
660 AND sh.shipment_header_id = sl.shipment_header_id
661 AND sl.to_organization_id = p_organization_id
662 AND sl.po_header_id = Nvl(To_number(p_po_header_id), sl.po_header_id)
663 AND sh.receipt_source_code = 'VENDOR'
664 AND sl.shipment_line_status_code <> 'CANCELLED'
665 AND sh.shipment_header_id = sl.shipment_header_id
666 -- This was fix for bug 2740648/2752094
667 AND sh.asn_type in ('ASN','ASBN')
668 AND sl.shipment_line_status_code in ('EXPECTED','PARTIALLY RECEIVED')
669 AND sl.to_organization_id = p_organization_id
670 AND sh.shipment_num LIKE (p_shipment_num)
671 ORDER BY sh.shipment_num;
672 ELSIF p_mobile_form = 'INSPECT' THEN
673 OPEN x_shipment_num_lov FOR
674 /*Bug: 4951739
675 Modified query: Referencing base table instead of
676 RCV_TRANSACTIONS_V
677 */
678 SELECT DISTINCT rsh.shipment_num,
679 rsh.shipment_header_id,
680 rsh.shipped_date,
681 rsh.expected_receipt_date,
682 rsl.from_organization_id,
683 ood.name organization_name,
684 'Organization',
685 rsh.packing_slip,
686 rsh.bill_of_lading,
687 rsh.waybill_airbill_num,
688 rsh.freight_carrier_code
689 FROM RCV_SUPPLY RSUP,
690 RCV_SHIPMENT_LINES RSL,
691 RCV_TRANSACTIONS RT,
692 RCV_SHIPMENT_HEADERS RSH,
693 PO_LOOKUP_CODES PLC,
694 PO_LINE_LOCATIONS_ALL PLL,
695 HR_ALL_ORGANIZATION_UNITS_TL OOD
696 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
697 , mtl_parameters mp,
698 rcv_parameters rp
699 -- End for Bug 7440217
700 WHERE RSH.receipt_source_code <> 'VENDOR'
701 AND RSUP.SUPPLY_TYPE_CODE = 'RECEIVING'
702 AND RT.TRANSACTION_TYPE <> 'UNORDERED'
703 AND RT.TRANSACTION_TYPE = PLC.LOOKUP_CODE
704 AND PLC.LOOKUP_TYPE = 'RCV TRANSACTION TYPE'
705 AND RSL.SHIPMENT_LINE_ID = RSUP.SHIPMENT_LINE_ID
706 AND RT.TRANSACTION_ID = RSUP.RCV_TRANSACTION_ID
707 AND RSH.SHIPMENT_HEADER_ID = RSUP.SHIPMENT_HEADER_ID
708 AND PLL.LINE_LOCATION_ID(+) = RSUP.PO_LINE_LOCATION_ID
709 AND NVL(PLL.MATCHING_BASIS(+),'QUANTITY') <> 'AMOUNT'
710 AND PLL.PAYMENT_TYPE IS NULL
711 AND RSUP.to_organization_id = p_organization_id
712 AND RT.inspection_status_code = 'NOT INSPECTED'
713 AND RT.routing_header_id = 2 /* Inspection Routing */
714 AND RSL.from_organization_id = OOD.organization_id(+)
715 AND OOD.LANGUAGE(+) = USERENV('LANG')
716 AND RSL.shipment_header_id = rsh.shipment_header_id
717 AND RSH.shipment_num IS NOT NULL
718 AND RSH.shipment_num LIKE (p_shipment_num)
719 ORDER BY RSH.shipment_header_id DESC;
720 END IF;
721
722 END GET_SHIPMENT_NUM_LOV;
723
724
725 -- Name: GET_REQ_NUM_LOV
726 --
727 -- Input parameters:
728 -- p_Organization_Id which restricts LOV SQL to current org
729 -- p_requisition_num which restricts LOV SQL to the user input text
730 -- p_mobile_form which mobile form this LOV is for (RECEIPT or DELIVER)
731 -- SQL query will be different for these forms
732 --
733 -- Output parameters:
734 -- x_requisition_num_lov returns LOV rows as reference cursor
735 --
736 -- Functions: This API returns Shipment number for a given org
737 -- Also it returns an ASN numner for ASN receipt
738
739
740 PROCEDURE GET_REQ_NUM_LOV(x_requisition_num_lov OUT NOCOPY t_genref,
741 p_organization_id IN NUMBER,
742 p_requisition_num IN VARCHAR2,
743 p_mobile_form IN VARCHAR2
744 )
745 IS
746
747 BEGIN
748
749 IF p_mobile_form = 'RCVTXN' THEN
750 OPEN x_requisition_num_lov FOR
751
752 SELECT DISTINCT
753 prh.segment1,
754 MO_GLOBAL.get_ou_name(prh.org_id), --<R12 MOAC>
755 prh.requisition_header_id,
756 prh.description,
757 NULL,
758 to_char(prh.org_id) --<R12 MOAC>
759 FROM
760 po_requisition_headers prh,
761 rcv_supply ms,
762 po_requisition_lines prl,
763 rcv_transactions rt
764 WHERE
765 prh.requisition_header_id = ms.req_header_id
766 AND prl.requisition_header_id = prh.requisition_header_id
767 AND prl.destination_organization_id = p_organization_id
768 AND prl.source_type_code = 'INVENTORY'
769 AND ms.supply_source_id = rt.transaction_id
770 AND rt.transaction_type <> 'UNORDERED'
771 AND ms.quantity > 0
772 AND ms.supply_type_code = 'RECEIVING'
773 AND ms.to_organization_id = p_organization_id
774 AND rt.organization_id = p_organization_id
775 -- Bug# 3631580: Performance Fixes
776 -- Added the following line to avoid a full table scan
777 AND rt.requisition_line_id = prl.requisition_line_id
778 AND (exists
779 (SELECT 1
780 FROM rcv_transactions rt1
781 WHERE rt1.transaction_id = rt.transaction_id
782 AND rt1.inspection_status_code <> 'NOT INSPECTED'
783 AND rt1.routing_header_id = 2)
784 OR rt.routing_header_id <> 2
785 OR rt.routing_header_id IS NULL)
786 AND prh.segment1 LIKE (p_requisition_num)
787 ORDER BY prh.segment1;
788
789 ELSIF p_mobile_form = 'RECEIPT' THEN
790 OPEN x_requisition_num_lov FOR
791
792 SELECT DISTINCT
793 prh.segment1,
794 MO_GLOBAL.get_ou_name(prh.org_id), --<R12 MOAC>
795 prh.requisition_header_id,
796 prh.description,
797 null,
798 to_char(prh.org_id) --<R12 MOAC>
799 FROM
800 po_requisition_headers prh,
801 po_requisition_lines prl
802 WHERE
803 Nvl(prl.cancel_flag,'N') = 'N'
804 AND prl.destination_organization_id = p_organization_id
805 AND prh.requisition_header_id = prl.requisition_header_id
806 AND prh.authorization_status || '' = 'APPROVED'
807 AND prh.segment1 LIKE (p_requisition_num)
808 AND exists
809 (SELECT 1
810 FROM rcv_shipment_lines rsl
811 WHERE rsl.requisition_line_id = prl.requisition_line_id
812 AND rsl.routing_header_id > 0
813 AND rsl.shipment_line_status_code <> 'FULLY RECEIVED')
814 ORDER BY prh.segment1;
815 ELSIF p_mobile_form = 'INSPECT' THEN
816 --BUG 3421219: Returns the IR that needs to be inspected
817 --Look at RTV for routing_id = 2 and inspection_status_code =
818 --'NOT INSPECTED'
819 OPEN x_requisition_num_lov FOR
820 SELECT DISTINCT
821 prh.segment1,
822 MO_GLOBAL.get_ou_name(prh.org_id), --<R12 MOAC>
823 prh.requisition_header_id,
824 prh.description,
825 null,
826 to_char(prh.org_id) --<R12 MOAC>
827 FROM
828 po_requisition_headers prh,
829 po_requisition_lines prl
830 WHERE
831 Nvl(prl.cancel_flag,'N') = 'N'
832 AND prl.destination_organization_id = p_organization_id
833 AND prh.requisition_header_id = prl.requisition_header_id
834 AND prh.authorization_status || '' = 'APPROVED'
835 AND prh.segment1 LIKE (p_requisition_num)
836 AND exists
837 (SELECT 1
838 FROM rcv_shipment_lines rsl,
839 rcv_shipment_headers rsh,
840 rcv_transactions_v rtv
841 WHERE rsl.requisition_line_id = prl.requisition_line_id
842 AND rsh.shipment_header_id = rsl.shipment_header_id
843 AND rtv.shipment_header_id = rsh.shipment_header_id
844 AND rtv.shipment_line_id = rsl.shipment_line_id
845 AND rtv.receipt_source_code <> 'VENDOR'
846 AND rtv.inspection_status_code = 'NOT INSPECTED'
847 AND rtv.routing_id = 2
848 AND rsl.routing_header_id > 0
849 )
850 ORDER BY prh.segment1;
851 END IF;
852
853 END get_req_num_lov;
854
855
856
857 -- LOV for the pack slip numbers of a shipment (mainly sfor ASN)
858 -- Almost exactly same as shipment LOV
859
860
861 PROCEDURE GET_PACK_SLIP_NUM_LOV(x_pack_slip_num_lov OUT NOCOPY t_genref,
862 p_organization_id IN NUMBER,
863 p_pack_slip_num IN VARCHAR2,
864 p_po_header_id IN VARCHAR2)
865 IS
866
867 BEGIN
868 IF p_po_header_id IS NOT NULL THEN
869 OPEN x_pack_slip_num_lov FOR
870 SELECT DISTINCT sh.packing_slip,
871 sh.shipment_num,
872 sh.shipment_header_id,
873 sh.shipped_date,
874 sh.expected_receipt_date,
875 Decode(sh.receipt_source_code,'VENDOR',sh.vendor_id, sl.from_organization_id) from_organization_id,
876 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id,sl.from_organization_id),1,80) organization_name,
877 Decode(sh.receipt_source_code,'VENDOR','Vendor','Organization')
878 FROM rcv_shipment_headers sh,
879 rcv_shipment_lines sl
880 WHERE sh.packing_slip IS NOT NULL
881 AND sh.shipment_header_id = sl.shipment_header_id
882 AND sl.to_organization_id = p_organization_id
883 AND sl.po_header_id = To_number(p_po_header_id)
884 AND ( sh.receipt_source_code = 'VENDOR'
885 AND sl.shipment_line_status_code <> 'CANCELLED')
886 AND sh.packing_slip LIKE (p_pack_slip_num)
887 ORDER BY sh.packing_slip;
888 ELSE
889 OPEN x_pack_slip_num_lov FOR
890 SELECT DISTINCT sh.packing_slip,
891 sh.shipment_num,
892 sh.shipment_header_id,
893 sh.shipped_date,
894 sh.expected_receipt_date,
895 Decode(sh.receipt_source_code,'VENDOR',sh.vendor_id, sl.from_organization_id) from_organization_id,
896 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id,sl.from_organization_id),1,80) organization_name,
897 Decode(sh.receipt_source_code,'VENDOR','Vendor','Organization')
898 FROM rcv_shipment_headers sh,
899 rcv_shipment_lines sl
900 WHERE sh.packing_slip IS NOT NULL
901 AND sh.shipment_header_id = sl.shipment_header_id
902 AND sl.to_organization_id = p_organization_id
903 AND sl.po_header_id = Nvl(To_number(p_po_header_id), sl.po_header_id)
904 AND ( sh.receipt_source_code = 'VENDOR'
905 AND sl.shipment_line_status_code <> 'CANCELLED')
906 AND sh.packing_slip LIKE (p_pack_slip_num)
907 ORDER BY sh.packing_slip;
908 END IF;
909 END GET_PACK_SLIP_NUM_LOV;
910
911
912 -- LOV for the possible receipt numbers that can be used.
913 PROCEDURE GET_RECEIPT_NUMBER_LOV(x_getRcptNumLOV OUT NOCOPY t_genref,
914 p_organization_id IN NUMBER,
915 p_receipt_number IN VARCHAR2)
916 IS
917 BEGIN
918 OPEN x_getRcptNumLOV FOR
919 SELECT DISTINCT rsh.receipt_num
920 , Trunc(ms.receipt_date)
921 , rsh.shipment_header_id
922 , rsh.shipment_num
923 , rt.po_header_id
924 , rt.oe_order_header_id
925 FROM rcv_supply ms
926 , rcv_transactions rt
927 , rcv_shipment_headers rsh
928 , rcv_shipment_lines rsl
929 , mtl_parameters mp
930 WHERE rsh.shipment_header_id = ms.shipment_header_id
931 AND rsh.shipment_header_id = rt.shipment_header_id
932 AND ms.to_organization_id = p_organization_id
933 and mp.organization_id = ms.to_organization_id
934 and rsl.to_organization_id = ms.to_organization_id
935 and rsl.shipment_header_id = rsh.shipment_header_id
936 and (mp.wms_enabled_flag = 'N'
937 OR (mp.wms_enabled_flag = 'Y' AND (rsl.item_id is NULL
938 OR exists (SELECT 1
939 FROM mtl_system_items_kfv msik
940 WHERE msik.inventory_item_id = rsl.item_id
941 AND msik.organization_id = p_organization_id
942 AND msik.mtl_transactions_enabled_flag = 'N')
943 OR exists
944 (select '1' from po_headers_all poh
945 , po_lines_all pol
946 , po_line_types plt
947 where rt.po_header_id is not null
948 and rt.po_header_id = poh.po_header_id
949 and poh.po_header_id = pol.po_header_id
950 and pol.line_type_id = plt.line_type_id
951 and rsl.item_id = pol.item_id
952 AND plt.outside_operation_flag = 'Y'))))
953 AND rt.transaction_id = ms.supply_source_id
954 AND ms.quantity > 0
955 AND ms.supply_type_code = 'RECEIVING'
956 --and rt.SOURCE_DOCUMENT_CODE <> 'RMA'
957 AND rt.transaction_type IN ('ACCEPT','MATCH','RECEIVE',
958 'REJECT','RETURN TO RECEIVING','TRANSFER')
959 AND (exists
960 (SELECT 1
961 FROM rcv_transactions rt1
962 WHERE rt1.transaction_id = rt.transaction_id
963 AND rt1.inspection_status_code <> 'NOT INSPECTED'
964 AND rt1.routing_header_id = 2)
965 OR rt.routing_header_id <> 2
966 OR rt.routing_header_id IS NULL)
967 AND rsh.receipt_num LIKE (p_receipt_number)
968 ORDER BY Decode(rtrim(rsh.receipt_num,'0123456789'),null,null,rsh.receipt_num),
969 Decode(rtrim(rsh.receipt_num,'0123456789'),null,to_number(rsh.receipt_num),null);
970 --<R12 MOAC>
971
972 END GET_RECEIPT_NUMBER_LOV;
973
974 -- This LOV is used in ORG Tranfer Transaction
975 -- for Mobile Inventory.
976
977
978 PROCEDURE GET_CARRIER(x_getcarrierLOV OUT NOCOPY t_genref,
979 p_FromOrganization_Id IN NUMBER,
980 p_ToOrganization_Id IN NUMBER,
981 p_carrier IN VARCHAR2)
982 IS
983 BEGIN
984 OPEN x_getcarrierLOV FOR
985 select freight_code, description, distribution_account
986 from
987 org_enabled_freight_val_v
988 where organization_id = (SELECT decode(FOB_POINT,1,TO_ORGANIZATION_ID,2, FROM_ORGANIZATION_ID) from mtl_interorg_parameters where TO_ORGANIZATION_ID = p_ToOrganization_Id and from_organization_id =p_FromOrganization_Id )
989 AND freight_code LIKE (p_carrier)
990 order by freight_code;
991 END GET_CARRIER;
992
993 --
994 -- LOV for the possible quality codes for mobile inspection form
995 --
996 PROCEDURE GET_QUALITY_CODES_LOV(
997 x_getQltyCodesLOV OUT NOCOPY t_genref
998 ,p_quality_code IN VARCHAR2)
999 is
1000 begin
1001 open x_getQltyCodesLOV for
1002 select
1003 code
1004 , ranking
1005 , description
1006 from po_quality_codes
1007 where nvl(inactive_date,sysdate + 1) > sysdate
1008 and code like (p_quality_code)
1009 order by ranking;
1010 end GET_QUALITY_CODES_LOV;
1011
1012 --
1013 -- LOV for the possible reason codes for mobile inspection form
1014 --
1015 PROCEDURE GET_REASON_CODES_LOV(
1016 x_getReasonCodesLOV OUT NOCOPY t_genref
1017 ,p_reason_code IN VARCHAR2)
1018 IS
1019 BEGIN
1020 OPEN x_getReasonCodesLOV FOR
1021 SELECT reason_name ,description ,reason_id
1022 FROM mtl_transaction_reasons
1023 WHERE NVL(disable_date,SYSDATE + 1) > SYSDATE
1024 AND reason_name LIKE (p_reason_code)
1025 ORDER BY upper(reason_name);
1026
1027 END GET_REASON_CODES_LOV;
1028
1029 --
1030 -- Procedure overloaded for Transaction Reason Security build.
1031 -- 4505091, nsrivast
1032
1033 PROCEDURE GET_REASON_CODES_LOV(
1034 x_getReasonCodesLOV OUT NOCOPY t_genref
1035 ,p_reason_code IN VARCHAR2
1036 ,p_txn_type_id IN VARCHAR2 )
1037
1038 IS
1039 BEGIN
1040 OPEN x_getReasonCodesLOV FOR
1041 SELECT reason_name ,description ,reason_id
1042 FROM mtl_transaction_reasons
1043 WHERE NVL(disable_date,SYSDATE + 1) > SYSDATE
1044 AND reason_name LIKE (p_reason_code)
1045 -- nsrivast, invconv , transaction reason security
1046 AND ( NVL ( fnd_profile.value_wnps('INV_TRANS_REASON_SECURITY'), 'N') = 'N'
1047 OR
1048 reason_id IN (SELECT reason_id FROM mtl_trans_reason_security mtrs
1049 WHERE(( responsibility_id = fnd_global.resp_id OR NVL(responsibility_id, -1) = -1 )
1050 AND
1051 ( mtrs.transaction_type_id = p_txn_type_id OR NVL(mtrs.transaction_type_id, -1) = -1 )
1052 )-- where ends
1053 )-- select ends
1054 ) -- and condn ends ,-- nsrivast, invconv
1055 ORDER BY upper(reason_name);
1056
1057 END GET_REASON_CODES_LOV;
1058
1059
1060
1061
1062 -- LOV for the possible receipt numbers for inspection
1063 PROCEDURE GET_RECEIPT_NUMBER_INSPECT_LOV(
1064 x_getRcptNumLOV OUT NOCOPY t_genref
1065 , p_organization_id IN NUMBER
1066 , p_receipt_number IN VARCHAR2)
1067 is
1068 begin
1069 OPEN x_getRcptNumLOV FOR
1070 /*Bug: 4951739
1071 Modified query: Referencing base table instead of
1072 RCV_TRANSACTIONS_V
1073 */
1074 SELECT DISTINCT rsh.receipt_num ,
1075 null ,
1076 rsup.shipment_header_id ,
1077 null ,
1078 null ,
1079 null
1080 FROM RCV_SUPPLY RSUP,
1081 RCV_TRANSACTIONS RT,
1082 RCV_SHIPMENT_HEADERS RSH,
1083 RCV_SHIPMENT_LINES RSL,
1084 PO_LOOKUP_CODES PLC,
1085 PO_LINE_LOCATIONS_ALL PLL,
1086 mtl_parameters mp --BUG 5166887
1087 WHERE RSUP.SUPPLY_TYPE_CODE = 'RECEIVING'
1088 AND RT.TRANSACTION_TYPE <> 'UNORDERED'
1089 AND RT.TRANSACTION_TYPE = PLC.LOOKUP_CODE
1090 AND PLC.LOOKUP_TYPE = 'RCV TRANSACTION TYPE'
1091 AND RT.TRANSACTION_ID = RSUP.RCV_TRANSACTION_ID
1092 AND RSH.SHIPMENT_HEADER_ID = RSUP.SHIPMENT_HEADER_ID
1093 AND PLL.LINE_LOCATION_ID(+) = RSUP.PO_LINE_LOCATION_ID
1094 AND NVL(PLL.MATCHING_BASIS(+),'QUANTITY') <> 'AMOUNT'
1095 AND PLL.PAYMENT_TYPE IS NULL
1096 AND RSUP.to_organization_id = p_organization_id
1097 AND RT.inspection_status_code = 'NOT INSPECTED'
1098 AND RT.routing_header_id = 2 /* Inspection Routing */
1099 AND RSH.receipt_num LIKE (p_receipt_number)
1100
1101 -- BUG 5166887: Do not return any rows if user access WMS org through the
1102 -- MSCA menu option
1103 AND rsl.shipment_header_id = rsh.shipment_header_id
1104 AND rsl.to_organization_id = rsup.to_organization_id
1105 AND mp.organization_id = rsup.to_organization_id
1106 AND (mp.wms_enabled_flag = 'N'
1107 OR (mp.wms_enabled_flag = 'Y'
1108 AND (rsl.item_id is NULL
1109 OR exists (SELECT 1
1110 FROM mtl_system_items_kfv msik
1111 WHERE msik.inventory_item_id = rsl.item_id
1112 AND msik.organization_id = p_organization_id
1113 AND msik.mtl_transactions_enabled_flag = 'N')
1114 OR exists (select '1'
1115 from po_headers_all poh
1116 , po_lines_all pol
1117 , po_line_types plt
1118 where rt.po_header_id is not null
1119 and rt.po_header_id = poh.po_header_id
1120 and poh.po_header_id = pol.po_header_id
1121 and pol.line_type_id = plt.line_type_id
1122 and rsl.item_id = pol.item_id
1123 AND plt.outside_operation_flag = 'Y'))))
1124 -- END BUG 5166887
1125 ORDER BY Decode(rtrim(RSH.receipt_num,'0123456789'), null,null, RSH.receipt_num),
1126 Decode(rtrim(RSH.receipt_num,'0123456789'), null,to_number(RSH.receipt_num), null); --<R12 MOAC>
1127 end GET_RECEIPT_NUMBER_INSPECT_LOV;
1128
1129
1130 -- LOV for RMA
1131 PROCEDURE get_rma_lov
1132 (x_getRMALOV OUT NOCOPY t_genref,
1133 p_organization_id IN NUMBER,
1134 p_rma_number IN VARCHAR,
1135 p_mobile_form IN VARCHAR2)
1136 IS
1137 BEGIN
1138
1139 IF p_mobile_form = 'RCVTXN' THEN
1140 OPEN x_getrmalov FOR
1141
1142 SELECT DISTINCT
1143 oeh.order_number ,
1144 oeh.header_id ,
1145 -- oet.name ,
1146 -- oet.ORDER_CATEGORY_CODE ,
1147 OTT_TL.NAME ORDER_TYPE, --OLT.NAME ORDER_TYPE,
1148 OTT_ALL.ORDER_CATEGORY_CODE ORDER_TYPE_CODE, --OLT.ORDER_CATEGORY_CODE ORDER_TYPE_CODE,
1149 oec.customer_id,
1150 oec.name customer_name,
1151 oec.customer_number
1152 FROM rcv_transactions rt,
1153 rcv_supply ms,
1154 oe_order_headers_all oeh,
1155 oe_order_lines_all oel,
1156 -- oe_line_types_v oet,
1157 OE_TRANSACTION_TYPES_TL OTT_TL,
1158 OE_TRANSACTION_TYPES_ALL OTT_ALL,
1159 oe_sold_to_orgs_v oec
1160 WHERE oeh.header_id = rt.oe_order_header_id
1161 -- AND oet.order_category_code = 'RETURN'
1162 AND rt.source_document_code = 'RMA'
1163 AND rt.oe_order_header_id = ms.oe_order_header_id
1164 AND ms.quantity > 0
1165 AND ms.supply_type_code = 'RECEIVING'
1166 AND ms.to_organization_id = p_organization_id
1167 AND ms.supply_source_id = rt.transaction_id
1168 AND rt.organization_id = ms.to_organization_id
1169 AND rt.transaction_type <> 'UNORDERED'
1170 AND oeh.HEADER_ID = oel.HEADER_ID
1171 and oeh.order_type_id = ott_all.transaction_type_id
1172 and ott_all.order_category_code in ('MIXED', 'RETURN')
1173 and ott_all.transaction_type_id = ott_tl.transaction_type_id
1174 and ott_tl.language = userenv('LANG')
1175 -- AND oel.line_type_id = oet.line_type_id
1176 AND oeh.sold_to_org_id = oec.customer_id
1177 AND (exists
1178 (SELECT 1
1179 FROM rcv_transactions rt1
1180 WHERE rt1.transaction_id = rt.transaction_id
1181 AND rt1.inspection_status_code <> 'NOT INSPECTED'
1182 AND rt1.routing_header_id = 2)
1183 OR rt.routing_header_id <> 2
1184 OR rt.routing_header_id IS NULL)
1185 AND oeh.order_number LIKE (p_rma_number)
1186 ORDER BY oeh.order_number;
1187
1188 ELSIF p_mobile_form = 'RECEIPT' THEN
1189
1190 OPEN x_getrmalov FOR
1191 SELECT DISTINCT
1192 OEH.ORDER_NUMBER OE_ORDER_NUM,
1193 OEL.HEADER_ID OE_ORDER_HEADER_ID,
1194 -- OLT.NAME ORDER_TYPE,
1195 OTT_TL.NAME ORDER_TYPE,
1196 -- OLT.ORDER_CATEGORY_CODE ORDER_TYPE_CODE,
1197 OTT_ALL.ORDER_CATEGORY_CODE ORDER_TYPE_CODE,
1198 OESOLD.CUSTOMER_ID,
1199 --TCA Cleanup
1200 --OEC.customer_name,
1201 --OEC.customer_number
1202 PARTY.PARTY_NAME CUSTOMER_NAME,
1203 PARTY.PARTY_NUMBER CUSTOMER_NUMBER
1204 FROM
1205 OE_ORDER_LINES_all OEL,
1206 OE_ORDER_HEADERS_all OEH,
1207 OE_TRANSACTION_TYPES_TL OTT_TL,
1208 OE_TRANSACTION_TYPES_ALL OTT_ALL,
1209
1210 -- OE_LINE_TYPES_V OLT,
1211 OE_SOLD_TO_ORGS_V OESOLD,
1212 WF_ITEM_ACTIVITY_STATUSES WF,
1213 WF_PROCESS_ACTIVITIES WPA,
1214 --RA_CUSTOMERS OEC /*TCA Cleanup */
1215 HZ_PARTIES PARTY,
1216 HZ_CUST_ACCOUNTS CUST_ACCT
1217 WHERE
1218 OEL.LINE_CATEGORY_CODE='RETURN'
1219 AND nvl(OEL.SHIP_FROM_ORG_ID, OEH.SHIP_FROM_ORG_ID) = p_organization_id
1220 AND OEL.HEADER_ID = OEH.HEADER_ID
1221 AND OEL.SOLD_TO_ORG_ID = OESOLD.ORGANIZATION_ID
1222 --AND OESOLD.CUSTOMER_ID = oec.customer_id /*TCA Cleanup */
1223 --Bug5417779: oesold.customer_id should be joined with cust_acct.cust_account_id
1224 AND OESOLD.CUSTOMER_ID = CUST_ACCT.CUST_ACCOUNT_ID
1225 AND CUST_ACCT.PARTY_ID = PARTY.PARTY_ID
1226 and oeh.order_type_id = ott_all.transaction_type_id
1227 and ott_all.order_category_code in ('MIXED', 'RETURN')
1228 and ott_all.transaction_type_id = ott_tl.transaction_type_id
1229 and ott_tl.language = userenv('LANG')
1230
1231 -- AND OEL.LINE_TYPE_ID = OLT.LINE_TYPE_ID
1232 AND OEH.BOOKED_FLAG='Y'
1233 AND OEH.OPEN_FLAG='Y'
1234 AND OEL.ORDERED_QUANTITY > NVL(OEL.SHIPPED_QUANTITY,0)
1235 AND WPA.ACTIVITY_ITEM_TYPE = 'OEOL'
1236 AND WPA.ACTIVITY_NAME = 'RMA_WAIT_FOR_RECEIVING'
1237 AND WF.ITEM_TYPE = 'OEOL'
1238 AND WF.PROCESS_ACTIVITY = WPA.INSTANCE_ID
1239 AND WF.ACTIVITY_STATUS = 'NOTIFIED'
1240 AND OEL.LINE_ID = TO_NUMBER(WF.ITEM_KEY)
1241 AND oeh.order_number LIKE (p_rma_number)
1242 ORDER BY oeh.order_number;
1243
1244 ELSIF p_mobile_form = 'INSPECT' THEN
1245
1246 OPEN x_getrmalov FOR
1247 SELECT DISTINCT
1248 oeh.order_number ,
1249 oeh.header_id ,
1250 OTT_TL.NAME ORDER_TYPE, --OLT.NAME ORDER_TYPE,
1251 OTT_ALL.ORDER_CATEGORY_CODE ORDER_TYPE_CODE,
1252 -- oet.name ,
1253 -- oet.ORDER_CATEGORY_CODE ,
1254 oec.customer_id,
1255 oec.name customer_name,
1256 oec.customer_number
1257 FROM rcv_transactions_v rtv,
1258 oe_order_headers_all oeh,
1259 OE_TRANSACTION_TYPES_TL OTT_TL,
1260 OE_TRANSACTION_TYPES_ALL OTT_ALL,
1261 oe_order_lines_all oel,
1262 -- oe_line_types_v oet,
1263 oe_sold_to_orgs_v oec
1264 WHERE oeh.header_id = rtv.oe_order_header_id
1265 AND rtv.receipt_source_code = 'CUSTOMER'
1266 AND rtv.to_organization_id = p_organization_id
1267 AND rtv.inspection_status_code = 'NOT INSPECTED'
1268 AND rtv.routing_id = 2 /* Inspection Routing */
1269 AND oeh.HEADER_ID = oel.HEADER_ID
1270 -- AND oel.line_type_id = oet.line_type_id
1271 -- AND oet.order_category_code = 'RETURN'
1272 and oeh.order_type_id = ott_all.transaction_type_id
1273 and ott_all.order_category_code in ('MIXED', 'RETURN')
1274 and ott_all.transaction_type_id = ott_tl.transaction_type_id
1275 and ott_tl.language = userenv('LANG')
1276
1277 AND oeh.sold_to_org_id = oec.customer_id
1278 AND oeh.order_number LIKE (p_rma_number);
1279
1280 END IF;
1281 END get_rma_lov;
1282
1283 --
1284 --
1285 -- Bug 2192815
1286 -- UOM Lov for Expense Items
1287 --
1288 --
1289 FUNCTION get_conversion_rate_expense(p_from_uom_code varchar2,
1290 p_organization_id NUMBER,
1291 p_item_id NUMBER,
1292 p_primary_uom_code varchar2 )
1293 RETURN VARCHAR2 IS
1294 l_primary_uom_code VARCHAR2(3) := p_primary_uom_code;
1295 l_conversion_rate NUMBER;
1296 l_return_string VARCHAR2(50);
1297 BEGIN
1298 inv_convert.inv_um_conversion(p_from_uom_code,
1299 l_primary_uom_code,
1300 p_item_id,
1301 l_conversion_rate);
1302 IF l_conversion_rate IS NOT NULL AND l_conversion_rate > 0 THEN
1303 l_return_string :=
1304 p_from_uom_code||'('||To_char(TRUNC(l_conversion_rate,4))||' '||l_primary_uom_code||')';
1305 RETURN l_return_string;
1306 END IF;
1307 RETURN p_from_uom_code;
1308 END;
1309
1310 PROCEDURE get_uom_lov_expense(x_uoms OUT NOCOPY t_genref,
1311 p_organization_id IN NUMBER,
1312 p_item_id IN NUMBER,
1313 p_uom_type IN NUMBER,
1314 p_uom_code IN VARCHAR2,
1315 p_primary_uom_code IN VARCHAR2)
1316 IS
1317 p_primary_uom_class varchar2(10);
1318 l_code VARCHAR2(20):=p_UOM_Code;
1319 BEGIN
1320
1321 IF (INSTR(l_code,'(') > 0) THEN
1322 l_code := SUBSTR(p_UOM_Code,1,INSTR(p_UOM_Code,'(')-1);
1323 END IF;
1324
1325
1326 -- Find the Class from Primary UOM
1327 Begin
1328
1329 select uom_class
1330 into p_primary_uom_class
1331 from mtl_units_of_measure muom
1332 where muom.uom_code = p_primary_uom_code;
1333
1334 Exception
1335 When others then p_primary_uom_class := '';
1336 End;
1337
1338 OPEN x_uoms FOR
1339 SELECT
1340 get_conversion_rate_expense(muom.uom_code,
1341 p_Organization_Id,
1342 0,
1343 p_primary_uom_code )
1344 uom_code
1345 , muc.unit_of_measure unit_of_measure
1346 , ''
1347 , muc.uom_class uom_class
1348 from
1349 mtl_uom_conversions_val_v muc ,
1350 mtl_units_of_measure muom
1351 where muc.uom_class = p_primary_uom_class
1352 and muc.item_id = 0
1353 and nvl(muc.disable_date,sysdate+1)>sysdate
1354 and muc.unit_of_measure = muom.unit_of_measure
1355 and nvl(muom.disable_date,sysdate+1) > sysdate
1356 and muom.uom_code like (l_code)
1357 order by muc.unit_of_measure;
1358
1359 --FROM mtl_units_of_measure
1360 --WHERE base_uom_flag = 'Y'
1361 --AND uom_code LIKE (p_uom_code || '%')
1362 --ORDER BY Upper(uom_code);
1363
1364 END get_uom_lov_expense;
1365
1366
1367 /* Direct Shipping */
1368 -- LOV for Location (used in Delivery Info Page )
1369 PROCEDURE get_directship_location_lov (
1370 x_location OUT NOCOPY t_genref
1371 , p_organization_id IN NUMBER
1372 , p_location_code IN VARCHAR2) IS
1373 BEGIN
1374
1375 OPEN x_location FOR
1376 SELECT address1
1377 , wsh_location_id
1378 , ui_location_code
1379 FROM wsh_locations
1380 WHERE (inactive_date IS NULL OR inactive_date > Sysdate)
1381 AND address1 LIKE (p_location_code)
1382 ORDER BY Upper (address1);
1383
1384 END get_directship_location_lov;
1385
1386
1387 -- LOV for Location Code
1388 PROCEDURE get_locationcode_lov (
1389 x_locationcode OUT NOCOPY t_genref
1390 , p_location_code IN VARCHAR2) IS
1391 BEGIN
1392
1393 OPEN x_locationcode FOR
1394 SELECT lookup_code, meaning, description
1395 FROM ar_lookups
1396 WHERE lookup_type = 'FOB'
1397 AND nvl(start_date_active, sysdate)<=sysdate
1398 AND nvl(end_date_active,sysdate)>=sysdate
1399 AND enabled_flag = 'Y'
1400 AND meaning like (p_location_code)
1401 ORDER BY Upper (lookup_code);
1402 --Bug 2961355:Changed the query to query from ar_lookups as fnd_lookup_values_vl had duplicate entries based on application id
1403 END get_locationcode_lov;
1404
1405 /* Direct Shipping */
1406
1407 -- Name: GET_DOC_LOV
1408 --
1409 -- Input parameters:
1410 -- p_Organization_Id which restricts LOV SQL to current org
1411 -- p_doc_number which restricts LOV SQL to the user input text
1412 -- p_manual_po_num_type NUMERIC or ALPHANUMERIC
1413 -- p_mobile_form which mobile form this LOV is for (RECEIPT or DELIVER)
1414 -- SQL query will be different for these forms
1415 --
1416 -- Output parameters:
1417 -- x_doc_num_lov returns LOV rows as reference cursor
1418 --
1419 -- Functions: This API returns PO number for a given org
1420 --
1421
1422 PROCEDURE GET_DOC_LOV
1423 (
1424 x_doc_num_lov OUT NOCOPY t_genref,
1425 p_organization_id IN NUMBER,
1426 p_doc_number IN VARCHAR2,
1427 p_mobile_form IN VARCHAR2,
1428 p_shipment_header_id IN VARCHAR2,
1429 p_inventory_item_id IN VARCHAR2,
1430 p_item_description IN VARCHAR2,
1431 p_doc_type IN VARCHAR2,
1432 p_vendor_prod_num IN VARCHAR2
1433 )
1434 IS
1435
1436 /* bug 4638235
1437 New local variables
1438 */
1439
1440 l_doc_num_passed BOOLEAN := FALSE ;
1441 l_doc_num_length NUMBER := NVL(LENGTH(p_doc_number),0) ;
1442 l_instr_pos NUMBER := INSTR(p_doc_number , '%' , 1 , 1) ;
1443
1444
1445 BEGIN
1446
1447 /*
1448 As part of the fix for the Performance Bug 3908402 the following changes have
1449 been done with the help of Apps Performance Team.
1450 1. The single query has been split into multiple queries based on the Doc Type
1451 and the original query has been placed at last if the Doc Type is ALL.
1452 2. Removed the following condition " AND nvl(p_doc_type,'ALL') in ('PO', 'ALL') "
1453 because this check has been already incorporated through if/else.
1454 3. For the Doc Type of PO and ASN, query has been split further based on the
1455 value passed for p_inventory_item_id and p_item_description parameters.
1456
1457 The following changes have been done while selecting Purchase Orders.
1458 i.e. doc type of PO.
1459 a. In the condition, "AND NVL(poll.approved_flag,'N') = 'Y' " ,
1460 nvl() has been removed.
1461 b. Removed the tables mtl_system_items_kfv and mtl_units_of_measure which are
1462 joined with po_lines_all table through outer join.
1463 c. Added the hint " +index(POH PO_HEADERS_U2) " to use the index PO_HEADERS_U2.
1464 d. Removed the Distinct clause from the select statement.
1465 */
1466
1467 -- Fix for the performance Bug 4638235
1468 -- We are determining whether the Doc Number has been passed with some value
1469 -- other than % and the % shouldn't be at the beginning.
1470 -- For Eg. P101% or % or %P101% or %P1%01% or P1%01
1471 -- Based on the variable l_doc_num_passed and parameter p_inventory_item_id
1472 -- the queries have been formed.
1473
1474 IF p_doc_number IS NOT NULL THEN
1475 IF l_doc_num_length > 1
1476 AND
1477 (
1478 l_instr_pos = l_doc_num_length
1479 OR (l_instr_pos = 0 OR l_instr_pos > 1)
1480 )
1481 THEN
1482 l_doc_num_passed := TRUE ;
1483 END IF;
1484 ELSE
1485 l_doc_num_passed := FALSE ;
1486 END IF;
1487 -- End of fix
1488
1489 IF p_mobile_form = 'RECEIPT' THEN
1490 IF NVL(p_doc_type,'ALL') = 'PO' THEN
1491 IF l_doc_num_passed AND p_inventory_item_id IS NOT NULL THEN
1492 --bug 4638235 added checking for l_doc_number passed
1493 -- This select takes care of Vendor Item and any non-expense item
1494 -- and cross ref item case.
1495 OPEN x_doc_num_lov FOR
1496 SELECT /*+index(POH PO_HEADERS_U2) */
1497 -- DISTINCT
1498 -- DOCTYPE PO
1499 meaning FIELD0 ,
1500 poh.segment1 FIELD1 ,
1501 to_char(poh.po_header_id) FIELD2 ,
1502 poh.type_lookup_code FIELD3 ,
1503 MO_GLOBAL.get_ou_name(poh.org_id) FIELD4, --<R12 MOAC>
1504 PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID) FIELD5 ,
1505 to_char(poh.vendor_id) FIELD6 ,
1506 to_char(poh.vendor_site_id) FIELD7 ,
1507 'Vendor' FIELD8 ,
1508 poh.note_to_receiver FIELD9 ,
1509 NULL FIELD10 ,
1510 NULL FIELD11 ,
1511 NULL FIELD12 ,
1512 lookup_code FIELD13 ,
1513 to_char(poh.org_id) FIELD14 --<R12 MOAC>
1514 FROM po_headers poh,
1515 fnd_lookup_values_vl flv
1516 WHERE flv.lookup_code = 'PO'
1517 AND flv.lookup_type = 'DOC_TYPE'
1518 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
1519 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
1520 AND flv.enabled_flag = 'Y'
1521 -- Bug 2859355 Added the Extra conditions for poh.
1522 AND POH.TYPE_LOOKUP_CODE IN ('STANDARD','PLANNED', 'BLANKET','CONTRACT')
1523 AND NVL(POH.CANCEL_FLAG, 'N') IN ('N', 'I')
1524 AND NVL(POH.CLOSED_CODE, 'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3152693
1525 AND poh.segment1 LIKE (p_doc_number)
1526 AND EXISTS
1527 (
1528 SELECT
1529 'Valid PO Shipments'
1530 FROM po_lines_all pl,
1531 po_line_locations_all poll
1532 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
1533 , mtl_parameters mp,
1534 rcv_parameters rp
1535 -- End for Bug 7440217
1536 WHERE pl.item_id = p_inventory_item_id
1537 AND pl.po_header_id = poh.po_header_id
1538 AND Nvl(pl.vendor_product_num,' ') = Nvl(p_vendor_prod_num, Nvl(pl.vendor_product_num,' '))
1539 AND poh.po_header_id = poll.po_header_id
1540 AND pl.po_line_id = poll.po_line_id
1541 AND poll.approved_flag = 'Y'
1542 AND Nvl(poll.cancel_flag,'N') = 'N'
1543 -- AND poll.closed_code = 'OPEN' -- Bug 2859335
1544 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
1545 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
1546 AND poll.ship_to_organization_id = p_organization_id
1547 AND poll.payment_type IS NULL --R12 excludes all Complex Work POs (Bug4236155)
1548 -- For Bug 7440217 Checking if it is LCM enabled
1549 AND mp.organization_id = p_organization_id
1550 AND rp.organization_id = p_organization_id
1551 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
1552 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
1553 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
1554 )
1555 -- End for Bug 7440217
1556 )
1557 UNION
1558 -- This Select Handles Substitute Items
1559 SELECT /*+index(POH PO_HEADERS_U2) */
1560 -- DISTINCT
1561 -- DOCTYPE PO
1562 meaning FIELD0 ,
1563 poh.segment1 FIELD1 ,
1564 to_char(poh.po_header_id) FIELD2 ,
1565 poh.type_lookup_code FIELD3 ,
1566 MO_GLOBAL.get_ou_name(poh.org_id) FIELD4, --<R12 MOAC>
1567 PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID) FIELD5 ,
1568 to_char(poh.vendor_id) FIELD6 ,
1569 to_char(poh.vendor_site_id) FIELD7 ,
1570 'Vendor' FIELD8 ,
1571 poh.note_to_receiver FIELD9 ,
1572 NULL FIELD10 ,
1573 NULL FIELD11 ,
1574 NULL FIELD12 ,
1575 lookup_code FIELD13 ,
1576 to_char(poh.org_id) FIELD14 --<R12 MOAC>
1577 FROM po_headers poh,
1578 fnd_lookup_values_vl flv
1579 WHERE flv.lookup_code = 'PO'
1580 AND flv.lookup_type = 'DOC_TYPE'
1581 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
1582 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
1583 AND flv.enabled_flag = 'Y'
1584 -- Bug 2859355 Added the Extra conditions for poh.
1585 AND POH.TYPE_LOOKUP_CODE IN ('STANDARD','PLANNED', 'BLANKET','CONTRACT')
1586 AND NVL(POH.CANCEL_FLAG, 'N') IN ('N', 'I')
1587 AND NVL(POH.CLOSED_CODE, 'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3152693
1588 AND poh.segment1 LIKE (p_doc_number)
1589 AND EXISTS
1590 (
1591 SELECT
1592 'Valid PO Shipments'
1593 FROM po_lines_all pl ,
1594 mtl_related_items mri ,
1595 mtl_system_items_kfv msi ,
1596 po_line_locations_all poll
1597 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
1598 , mtl_parameters mp,
1599 rcv_parameters rp
1600 -- End for Bug 7440217
1601 WHERE msi.organization_id = p_organization_id
1602 AND pl.po_header_id = poh.po_header_id
1603 AND
1604 (
1605 (
1606 mri.related_item_id = msi.inventory_item_id
1607 AND pl.item_id = mri.inventory_item_id
1608 AND msi.inventory_item_id LIKE p_inventory_item_id
1609 )
1610 OR
1611 (
1612 mri.inventory_item_id = msi.inventory_item_id
1613 AND pl.item_id = mri.related_item_id
1614 AND mri.reciprocal_flag = 'Y'
1615 AND msi.inventory_item_id LIKE p_inventory_item_id
1616 )
1617 )
1618 AND Nvl(pl.vendor_product_num,' ') = Nvl(p_vendor_prod_num,Nvl(pl.vendor_product_num,' '))
1619 AND poh.po_header_id = poll.po_header_id
1620 AND pl.po_line_id = poll.po_line_id
1621 AND poll.approved_flag = 'Y'
1622 AND Nvl(poll.cancel_flag,'N') = 'N'
1623 -- AND poll.closed_code = 'OPEN' -- Bug 2859355
1624 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
1625 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
1626 AND poll.ship_to_organization_id = p_organization_id
1627 AND poll.payment_type IS NULL --R12 excludes all Complex Work POs (Bug4236155)
1628 -- For Bug 7440217 Checking if it is LCM enabled
1629 AND mp.organization_id = p_organization_id
1630 AND rp.organization_id = p_organization_id
1631 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
1632 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
1633 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
1634 )
1635 -- End for Bug 7440217
1636 )
1637 ORDER BY 1,2 ;
1638
1639 ELSIF NOT l_doc_num_passed AND p_inventory_item_id IS NOT NULL THEN
1640 -- This select takes care of Vendor Item and any non-expense item
1641 -- and cross ref item case.
1642
1643 -- Added the Hint /*+LEADING(PL)*/ as part of Fix for Bug 4638235
1644 -- incase Item ID is given and Doc No is not given.
1645 -- Query needs to be driven from PO_LINES_ALL table. Here subquery
1646 -- has been made as join.
1647 OPEN x_doc_num_lov FOR
1648 SELECT /*+LEADING(PL)*/
1649 -- DISTINCT
1650 -- DOCTYPE PO
1651 meaning FIELD0 ,
1652 poh.segment1 FIELD1 ,
1653 to_char(poh.po_header_id) FIELD2 ,
1654 poh.type_lookup_code FIELD3 ,
1655 MO_GLOBAL.get_ou_name(poh.org_id) FIELD4, --<R12 MOAC>
1656 PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID) FIELD5 ,
1657 to_char(poh.vendor_id) FIELD6 ,
1658 to_char(poh.vendor_site_id) FIELD7 ,
1659 'Vendor' FIELD8 ,
1660 poh.note_to_receiver FIELD9 ,
1661 NULL FIELD10,
1662 NULL FIELD11,
1663 NULL FIELD12,
1664 lookup_code FIELD13,
1665 to_char(poh.org_id) FIELD14 --<R12 MOAC>
1666 FROM po_headers poh,
1667 fnd_lookup_values_vl flv ,
1668 po_lines_all pl,
1669 po_line_locations_all poll
1670 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
1671 , mtl_parameters mp,
1672 rcv_parameters rp
1673 -- End for Bug 7440217
1674 WHERE flv.lookup_code = 'PO'
1675 AND flv.lookup_type = 'DOC_TYPE'
1676 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
1677 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
1678 AND flv.enabled_flag = 'Y'
1679 -- Bug 2859355 Added the Extra conditions for poh.
1680 AND POH.TYPE_LOOKUP_CODE IN ('STANDARD','PLANNED', 'BLANKET','CONTRACT')
1681 AND NVL(POH.CANCEL_FLAG, 'N') IN ('N', 'I')
1682 AND NVL(POH.CLOSED_CODE, 'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3152693
1683 AND poh.segment1 LIKE (p_doc_number)
1684 AND pl.item_id = p_inventory_item_id
1685 AND pl.po_header_id = poh.po_header_id
1686 AND Nvl(pl.vendor_product_num,' ') = Nvl(p_vendor_prod_num, Nvl(pl.vendor_product_num,' '))
1687 AND poh.po_header_id = poll.po_header_id
1688 AND pl.po_line_id = poll.po_line_id
1689 AND poll.approved_flag = 'Y'
1690 AND Nvl(poll.cancel_flag,'N') = 'N'
1691 -- AND poll.closed_code = 'OPEN' -- Bug 2859335
1692 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
1693 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
1694 AND poll.ship_to_organization_id = p_organization_id
1695 AND poll.payment_type IS NULL --R12 excludes all Complex Work POs (Bug4236155)
1696 -- For Bug 7440217 Checking if it is LCM enabled
1697 AND mp.organization_id = p_organization_id
1698 AND rp.organization_id = p_organization_id
1699 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
1700 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
1701 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
1702 )
1703 -- End for Bug 7440217
1704 UNION
1705 -- This Select Handles Substitute Items
1706 SELECT /*+LEADING(MRI)*/ -- Bug 6600650
1707 -- DISTINCT
1708 -- DOCTYPE PO
1709 meaning FIELD0 ,
1710 poh.segment1 FIELD1 ,
1711 to_char(poh.po_header_id) FIELD2 ,
1712 poh.type_lookup_code FIELD3 ,
1713 MO_GLOBAL.get_ou_name(poh.org_id) FIELD4, --<R12 MOAC>
1714 PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID) FIELD5 ,
1715 to_char(poh.vendor_id) FIELD6 ,
1716 to_char(poh.vendor_site_id) FIELD7 ,
1717 'Vendor' FIELD8 ,
1718 poh.note_to_receiver FIELD9 ,
1719 NULL FIELD10 ,
1720 NULL FIELD11 ,
1721 NULL FIELD12 ,
1722 lookup_code FIELD13,
1723 to_char(poh.org_id) FIELD14 --<R12 MOAC>
1724 FROM po_headers poh,
1725 fnd_lookup_values_vl flv ,
1726 po_lines_all pl ,
1727 mtl_related_items mri ,
1728 mtl_system_items_kfv msi ,
1729 po_line_locations_all poll
1730 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
1731 , mtl_parameters mp,
1732 rcv_parameters rp
1733 -- End for Bug 7440217
1734 WHERE flv.lookup_code = 'PO'
1735 AND flv.lookup_type = 'DOC_TYPE'
1736 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
1737 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
1738 AND flv.enabled_flag = 'Y'
1739 -- Bug 2859355 Added the Extra conditions for poh.
1740 AND POH.TYPE_LOOKUP_CODE IN ('STANDARD','PLANNED', 'BLANKET','CONTRACT')
1741 AND NVL(POH.CANCEL_FLAG, 'N') IN ('N', 'I')
1742 AND NVL(POH.CLOSED_CODE, 'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3152693
1743 AND poh.segment1 LIKE (p_doc_number)
1744 AND msi.organization_id = p_organization_id
1745 AND pl.po_header_id = poh.po_header_id
1746 AND mri.related_item_id = msi.inventory_item_id
1747 AND pl.item_id = mri.inventory_item_id
1748 AND msi.inventory_item_id = TO_NUMBER(p_inventory_item_id)
1749 AND Nvl(pl.vendor_product_num,' ') = Nvl(p_vendor_prod_num,Nvl(pl.vendor_product_num,' '))
1750 AND poh.po_header_id = poll.po_header_id
1751 AND pl.po_line_id = poll.po_line_id
1752 AND poll.approved_flag = 'Y'
1753 AND Nvl(poll.cancel_flag,'N') = 'N'
1754 -- AND poll.closed_code = 'OPEN' -- Bug 2859355
1755 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
1756 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
1757 AND poll.ship_to_organization_id = p_organization_id
1758 AND poll.payment_type IS NULL --R12 excludes all Complex Work POs (Bug4236155)
1759 -- For Bug 7440217 Checking if it is LCM enabled
1760 AND mp.organization_id = p_organization_id
1761 AND rp.organization_id = p_organization_id
1762 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
1763 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
1764 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
1765 )
1766 -- End for Bug 7440217
1767 UNION
1768 SELECT /*+LEADING(MRI)*/ -- Bug 6600650
1769 -- DISTINCT
1770 -- DOCTYPE PO
1771 meaning FIELD0 ,
1772 poh.segment1 FIELD1 ,
1773 to_char(poh.po_header_id) FIELD2 ,
1774 poh.type_lookup_code FIELD3 ,
1775 MO_GLOBAL.get_ou_name(poh.org_id) FIELD4, --<R12 MOAC>
1776 PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID) FIELD5 ,
1777 to_char(poh.vendor_id) FIELD5 ,
1778 to_char(poh.vendor_site_id) FIELD7 ,
1779 'Vendor' FIELD8 ,
1780 poh.note_to_receiver FIELD9 ,
1781 NULL FIELD10 ,
1782 NULL FIELD11 ,
1783 NULL FIELD12 ,
1784 lookup_code FIELD13,
1785 to_char(poh.org_id) FIELD14 --<R12 MOAC>
1786 FROM po_headers poh,
1787 fnd_lookup_values_vl flv ,
1788 po_lines_all pl ,
1789 mtl_related_items mri ,
1790 mtl_system_items_kfv msi ,
1791 po_line_locations_all poll
1792 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
1793 , mtl_parameters mp,
1794 rcv_parameters rp
1795 -- End for Bug 7440217
1796 WHERE flv.lookup_code = 'PO'
1797 AND flv.lookup_type = 'DOC_TYPE'
1798 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
1799 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
1800 AND flv.enabled_flag = 'Y'
1801 -- Bug 2859355 Added the Extra conditions for poh.
1802 AND POH.TYPE_LOOKUP_CODE IN ('STANDARD','PLANNED', 'BLANKET','CONTRACT')
1803 AND NVL(POH.CANCEL_FLAG, 'N') IN ('N', 'I')
1804 AND NVL(POH.CLOSED_CODE, 'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3152693
1805 AND poh.segment1 LIKE (p_doc_number)
1806 AND msi.organization_id = p_organization_id
1807 AND pl.po_header_id = poh.po_header_id
1808 AND mri.inventory_item_id = msi.inventory_item_id
1809 AND pl.item_id = mri.related_item_id
1810 AND mri.reciprocal_flag = 'Y'
1811 AND msi.inventory_item_id = TO_NUMBER(p_inventory_item_id)
1812 AND Nvl(pl.vendor_product_num,' ') = Nvl(p_vendor_prod_num,Nvl(pl.vendor_product_num,' '))
1813 AND poh.po_header_id = poll.po_header_id
1814 AND pl.po_line_id = poll.po_line_id
1815 AND poll.approved_flag = 'Y'
1816 AND Nvl(poll.cancel_flag,'N') = 'N'
1817 -- AND poll.closed_code = 'OPEN' -- Bug 2859355
1818 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
1819 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
1820 AND poll.ship_to_organization_id = p_organization_id
1821 AND poll.payment_type IS NULL --R12 excludes all Complex Work POs (Bug4236155)
1822 -- For Bug 7440217 Checking if it is LCM enabled
1823 AND mp.organization_id = p_organization_id
1824 AND rp.organization_id = p_organization_id
1825 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
1826 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
1827 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
1828 )
1829 -- End for Bug 7440217
1830 ORDER BY 1,2 ;
1831
1832 ELSIF p_item_description IS NOT NULL THEN
1833 OPEN x_doc_num_lov FOR
1834 -- This Select Handles Expense Items
1835 SELECT /*+index(POH PO_HEADERS_U2) */
1836 -- DISTINCT
1837 -- DOCTYPE PO
1838 meaning FIELD0 ,
1839 poh.segment1 FIELD1 ,
1840 to_char(poh.po_header_id) FIELD2 ,
1841 poh.type_lookup_code FIELD3 ,
1842 MO_GLOBAL.get_ou_name(poh.org_id) FIELD4 , --<R12 MOAC>
1843 PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID) FIELD5 ,
1844 to_char(poh.vendor_id) FIELD6 ,
1845 to_char(poh.vendor_site_id) FIELD7 ,
1846 'Vendor' FIELD8 ,
1847 poh.note_to_receiver FIELD9 ,
1848 NULL FIELD10 ,
1849 NULL FIELD11 ,
1850 NULL FIELD12 ,
1851 lookup_code FIELD13 ,
1852 to_char(poh.org_id) FIELD14 --<R12 MOAC>
1853 FROM po_headers poh,
1854 fnd_lookup_values_vl flv
1855 WHERE flv.lookup_code = 'PO'
1856 AND flv.lookup_type = 'DOC_TYPE'
1857 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
1858 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
1859 AND flv.enabled_flag = 'Y'
1860 -- Bug 2859355 Added the Extra conditions for poh.
1861 AND POH.TYPE_LOOKUP_CODE IN ('STANDARD','PLANNED', 'BLANKET','CONTRACT')
1862 AND NVL(POH.CANCEL_FLAG, 'N') IN ('N', 'I')
1863 AND NVL(POH.CLOSED_CODE, 'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3152693
1864 AND poh.segment1 LIKE (p_doc_number)
1865 AND EXISTS
1866 (
1867 SELECT
1868 'Valid PO Shipments'
1869 FROM po_lines_all pl ,
1870 po_line_locations_all poll
1871 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
1872 , mtl_parameters mp,
1873 rcv_parameters rp
1874 -- End for Bug 7440217
1875 WHERE pl.ITEM_ID IS NULL
1876 AND pl.item_description LIKE p_item_description||'%'
1877 AND pl.po_header_id = poh.po_header_id
1878 AND Nvl(pl.vendor_product_num,' ') = Nvl(p_vendor_prod_num,Nvl(pl.vendor_product_num,' '))
1879 AND poh.po_header_id = poll.po_header_id
1880 AND pl.po_line_id = poll.po_line_id
1881 AND poll.approved_flag = 'Y'
1882 AND Nvl(poll.cancel_flag,'N') = 'N'
1883 -- AND poll.closed_code = 'OPEN' --Bug 2859355
1884 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
1885 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
1886 AND poll.ship_to_organization_id = p_organization_id
1887 AND poll.payment_type IS NULL --R12 excludes all Complex Work POs (Bug4236155)
1888 -- For Bug 7440217 Checking if it is LCM enabled
1889 AND mp.organization_id = p_organization_id
1890 AND rp.organization_id = p_organization_id
1891 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
1892 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
1893 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
1894 )
1895 -- End for Bug 7440217
1896 )
1897 ORDER BY 1,2 ;
1898 ELSE
1899 --Both Inventory Item Id and Item Desc are Null
1900 --And also Both Item Id and Item Desc won't be passed together.
1901 OPEN x_doc_num_lov FOR
1902 SELECT /*+index(POH PO_HEADERS_U2) */
1903 -- DISTINCT
1904 -- DOCTYPE PO
1905 meaning FIELD0 ,
1906 poh.segment1 FIELD1 ,
1907 to_char(poh.po_header_id) FIELD2 ,
1908 poh.type_lookup_code FIELD3 ,
1909 MO_GLOBAL.get_ou_name(poh.org_id) FIELD4 , --<R12 MOAC>
1910 PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID) FIELD5 ,
1911 to_char(poh.vendor_id) FIELD6 ,
1912 to_char(poh.vendor_site_id) FIELD7 ,
1913 'Vendor' FIELD8 ,
1914 poh.note_to_receiver FIELD9 ,
1915 NULL FIELD10 ,
1916 NULL FIELD11 ,
1917 NULL FIELD12 ,
1918 lookup_code FIELD13 ,
1919 to_char(poh.org_id) FIELD14 --<R12 MOAC>
1920 FROM po_headers poh,
1921 fnd_lookup_values_vl flv
1922 WHERE flv.lookup_code = 'PO'
1923 AND flv.lookup_type = 'DOC_TYPE'
1924 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
1925 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
1926 AND flv.enabled_flag = 'Y'
1927 -- Bug 2859355 Added the Extra conditions for poh.
1928 AND POH.TYPE_LOOKUP_CODE IN ('STANDARD','PLANNED', 'BLANKET','CONTRACT')
1929 AND NVL(POH.CANCEL_FLAG, 'N') IN ('N', 'I')
1930 AND NVL(POH.CLOSED_CODE, 'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3152693
1931 AND poh.segment1 LIKE (p_doc_number)
1932 AND EXISTS
1933 (
1934 SELECT
1935 'Valid PO Shipments'
1936 FROM po_line_locations_all poll
1937 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
1938 , mtl_parameters mp,
1939 rcv_parameters rp
1940 -- End for Bug 7440217
1941 WHERE poh.po_header_id = poll.po_header_id
1942 AND poll.approved_flag = 'Y'
1943 AND Nvl(poll.cancel_flag,'N') = 'N'
1944 -- AND poll.closed_code = 'OPEN' --Bug 2859355
1945 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
1946 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
1947 AND poll.ship_to_organization_id = p_organization_id
1948 AND poll.payment_type IS NULL --R12 excludes all Complex Work POs (Bug4236155)
1949 -- For Bug 7440217 Checking if it is LCM enabled
1950 AND mp.organization_id = p_organization_id
1951 AND rp.organization_id = p_organization_id
1952 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
1953 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
1954 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
1955 )
1956 -- End for Bug 7440217
1957 )
1958 ORDER BY 1,2 ;
1959 END IF; --Check for Item Id or Desc value
1960 ELSIF NVL(p_doc_type,'ALL') = 'RMA' THEN
1961 OPEN x_doc_num_lov FOR
1962 -- This Select Handles RMAs
1963 SELECT DISTINCT
1964 -- DOCTYPE RMA
1965 meaning FIELD0,
1966 to_char(OEH.ORDER_NUMBER) FIELD1,
1967 to_char(OEL.HEADER_ID) FIELD2,
1968 OTT_TL.NAME FIELD3, --OLT.NAME FIELD3,--bug3173013
1969 NULL FIELD4,
1970 OTT_ALL.ORDER_CATEGORY_CODE FIELD5, --OLT.ORDER_CATEGORY_CODE FIELD5,
1971 to_char(OESOLD.CUSTOMER_ID) FIELD6,
1972 /*TCA Cleanup */
1973 --OEC.customer_name FIELD6,
1974 --OEC.customer_number FIELD7,
1975 PARTY.party_name FIELD7,
1976 PARTY.party_number FIELD8,
1977 NULL FIELD9,
1978 NULL FIELD10,
1979 NULL FIELD11,
1980 NULL FIELD12,
1981 lookup_code FIELD13 ,
1982 to_char(oel.org_id) FIELD14
1983 FROM fnd_lookup_values_vl flv,
1984 OE_ORDER_LINES_all OEL,
1985 OE_ORDER_HEADERS_all OEH,
1986 --OE_LINE_TYPES_V OLT, --bug3173013
1987 OE_TRANSACTION_TYPES_TL OTT_TL,
1988 OE_TRANSACTION_TYPES_ALL OTT_ALL,
1989 OE_SOLD_TO_ORGS_V OESOLD,
1990 --WF_ITEM_ACTIVITY_STATUSES WF,
1991 --WF_PROCESS_ACTIVITIES WPA,
1992 --RA_CUSTOMERS OEC
1993 HZ_PARTIES PARTY,
1994 HZ_CUST_ACCOUNTS CUST_ACCT
1995 WHERE flv.lookup_code = 'RMA'
1996 AND flv.lookup_type = 'DOC_TYPE'
1997 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
1998 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
1999 AND flv.enabled_flag = 'Y'
2000 AND OEL.LINE_CATEGORY_CODE='RETURN'
2001 AND nvl(OEL.SHIP_FROM_ORG_ID, OEH.SHIP_FROM_ORG_ID) = p_organization_id
2002 AND OEL.HEADER_ID = OEH.HEADER_ID
2003 AND OEL.SOLD_TO_ORG_ID = OESOLD.ORGANIZATION_ID
2004 --AND OESOLD.CUSTOMER_ID = oec.customer_id /*TCA Cleanup */
2005 --Bug5417779: oesold.customer_id should be joined with cust_acct.cust_account_id
2006 AND OESOLD.CUSTOMER_ID = CUST_ACCT.CUST_ACCOUNT_ID
2007 AND CUST_ACCT.party_id = PARTY.party_id
2008 --AND OEL.LINE_TYPE_ID = OLT.LINE_TYPE_ID--bug3173013
2009 AND OEH.ORDER_TYPE_ID = OTT_ALL.TRANSACTION_TYPE_ID
2010 AND OTT_ALL.ORDER_CATEGORY_CODE in ('MIXED', 'RETURN')
2011 AND OTT_ALL.TRANSACTION_TYPE_ID = OTT_TL.TRANSACTION_TYPE_ID
2012 AND OTT_TL.LANGUAGE = USERENV('LANG')
2013 AND OEH.BOOKED_FLAG='Y'
2014 AND OEH.OPEN_FLAG='Y'
2015 AND OEL.ORDERED_QUANTITY > NVL(OEL.SHIPPED_QUANTITY,0)
2016 AND OEL.FLOW_STATUS_CODE = 'AWAITING_RETURN'
2017 --
2018 -- The following lines are commented for Performance Improvement
2019 -- instead flow_status_code is used from oel
2020 --AND WPA.ACTIVITY_ITEM_TYPE = 'OEOL'
2021 --AND WPA.ACTIVITY_NAME = 'RMA_WAIT_FOR_RECEIVING'
2022 --AND WF.ITEM_TYPE = 'OEOL'
2023 --AND WF.PROCESS_ACTIVITY = WPA.INSTANCE_ID
2024 --AND WF.ACTIVITY_STATUS = 'NOTIFIED'
2025 --AND OEL.LINE_ID = TO_NUMBER(WF.ITEM_KEY)
2026 --
2027 AND oeh.order_number LIKE (p_doc_number)
2028 AND OEL.inventory_item_id LIKE Nvl(p_inventory_item_id,'%')
2029 ORDER BY 1,2 ;
2030 ELSIF NVL(p_doc_type,'ALL') = 'INTSHIP' THEN
2031 OPEN x_doc_num_lov FOR
2032 -- This Select Handles Internal Sales Order , Org Transfer
2033 SELECT DISTINCT
2034 -- DOCTYPE INTSHIP
2035 meaning FIELD0,
2036 sh.shipment_num FIELD1,
2037 to_char(sh.shipment_header_id) FIELD2,
2038 to_char(sh.shipped_date) FIELD3,
2039 NULL FIELD4 , --<R12 MOAC>
2040 to_char(sh.expected_receipt_date) FIELD5,
2041 to_char(Decode(sh.receipt_source_code, 'VENDOR',sh.vendor_id, sl.from_organization_id)) FIELD6,
2042 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id, sl.from_organization_id),1,80) FIELD7,
2043 Decode(sh.receipt_source_code,'VENDOR','Vendor',sh.receipt_source_code) FIELD8, --bug fix 3939003
2044 sh.packing_slip FIELD9,
2045 sh.bill_of_lading FIELD10,
2046 sh.waybill_airbill_num FIELD11,
2047 sh.freight_carrier_code FIELD12,
2048 lookup_code FIELD13,
2049 NULL FIELD14 --<R12 MOAC>
2050 FROM fnd_lookup_values_vl flv,
2051 rcv_shipment_headers sh,
2052 rcv_shipment_lines sl
2053 WHERE flv.lookup_code = 'INTSHIP'
2054 AND flv.lookup_type = 'DOC_TYPE'
2055 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2056 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2057 AND flv.enabled_flag = 'Y'
2058 AND sh.shipment_num IS NOT NULL
2059 AND sh.shipment_header_id = sl.shipment_header_id
2060 AND sl.to_organization_id = p_organization_id
2061 AND sh.receipt_source_code IN ('INTERNAL ORDER','INVENTORY')
2062 AND EXISTS
2063 (
2064 SELECT
2065 'available supply'
2066 FROM mtl_supply ms
2067 WHERE ms.to_organization_id = p_organization_id
2068 AND ms.shipment_header_id = sh.shipment_header_id
2069 )
2070 -- This was fix for bug 2740648/2752094
2071 AND sl.shipment_line_status_code IN ('EXPECTED','PARTIALLY RECEIVED')
2072 AND sh.shipment_num LIKE (p_doc_number)
2073 AND sl.item_id LIKE Nvl(p_inventory_item_id,'%')
2074 AND p_item_description IS NULL
2075 ORDER BY 1,2 ;
2076 ELSIF NVL(p_doc_type,'ALL') = 'ASN' THEN
2077 IF p_inventory_item_id IS NOT NULL THEN
2078 OPEN x_doc_num_lov FOR
2079 -- This Select Handles ASN
2080 SELECT DISTINCT
2081 -- DOCTYPE ASN
2082 meaning FIELD0,
2083 sh.shipment_num FIELD1,
2084 to_char(sh.shipment_header_id) FIELD2,
2085 to_char(sh.shipped_date) FIELD3,
2086 NULL FIELD4 , --<R12 MOAC>
2087 to_char(sh.expected_receipt_date) FIELD5,
2088 to_char(Decode(sh.receipt_source_code, 'VENDOR',sh.vendor_id, sl.from_organization_id)) FIELD6,
2089 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id, sl.from_organization_id),1,80) FIELD7,
2090 Decode(sh.receipt_source_code,'VENDOR','Vendor','Organization') FIELD8,
2091 sh.packing_slip FIELD9,
2092 sh.bill_of_lading FIELD10,
2093 sh.waybill_airbill_num FIELD11,
2094 sh.freight_carrier_code FIELD12,
2095 lookup_code FIELD13,
2096 NULL FIELD14 --<R12 MOAC>
2097 FROM fnd_lookup_values_vl flv,
2098 rcv_shipment_headers sh,
2099 rcv_shipment_lines sl
2100 WHERE flv.lookup_code = 'ASN'
2101 AND flv.lookup_type = 'DOC_TYPE'
2102 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2103 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2104 AND flv.enabled_flag = 'Y'
2105 AND sh.shipment_num IS NOT NULL
2106 AND sh.shipment_header_id = sl.shipment_header_id
2107 AND sl.to_organization_id = p_organization_id
2108 AND sh.receipt_source_code = 'VENDOR'
2109 AND sl.shipment_line_status_code <> 'CANCELLED'
2110 AND sh.shipment_header_id = sl.shipment_header_id
2111 AND sl.to_organization_id = p_organization_id
2112 -- This was fix for bug 2740648/2752094
2113 AND sh.asn_type in ('ASN','ASBN')
2114 AND sl.shipment_line_status_code in ('EXPECTED','PARTIALLY RECEIVED')
2115 AND sh.shipment_num LIKE (p_doc_number)
2116 -- This was fix for bug 2774080
2117 AND sl.item_id = p_inventory_item_id
2118 ORDER BY 1,2 ;
2119 ELSIF p_item_description IS NOT NULL THEN
2120 OPEN x_doc_num_lov FOR
2121 -- This Select Handles ASN
2122 SELECT DISTINCT
2123 -- DOCTYPE ASN
2124 meaning FIELD0,
2125 sh.shipment_num FIELD1,
2126 to_char(sh.shipment_header_id) FIELD2,
2127 to_char(sh.shipped_date) FIELD3,
2128 NULL FIELD4 , --<R12 MOAC>
2129 to_char(sh.expected_receipt_date) FIELD5,
2130 to_char(Decode(sh.receipt_source_code, 'VENDOR',sh.vendor_id, sl.from_organization_id)) FIELD6,
2131 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id, sl.from_organization_id),1,80) FIELD7,
2132 Decode(sh.receipt_source_code,'VENDOR','Vendor','Organization') FIELD8,
2133 sh.packing_slip FIELD9,
2134 sh.bill_of_lading FIELD10,
2135 sh.waybill_airbill_num FIELD11,
2136 sh.freight_carrier_code FIELD12,
2137 lookup_code FIELD13,
2138 NULL FIELD14 --<R12 MOAC>
2139 FROM fnd_lookup_values_vl flv,
2140 rcv_shipment_headers sh,
2141 rcv_shipment_lines sl
2142 WHERE flv.lookup_code = 'ASN'
2143 AND flv.lookup_type = 'DOC_TYPE'
2144 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2145 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2146 AND flv.enabled_flag = 'Y'
2147 AND sh.shipment_num IS NOT NULL
2148 AND sh.shipment_header_id = sl.shipment_header_id
2149 AND sl.to_organization_id = p_organization_id
2150 AND sh.receipt_source_code = 'VENDOR'
2151 AND sl.shipment_line_status_code <> 'CANCELLED'
2152 AND sh.shipment_header_id = sl.shipment_header_id
2153 AND sl.to_organization_id = p_organization_id
2154 -- This was fix for bug 2740648/2752094
2155 AND sh.asn_type in ('ASN','ASBN')
2156 AND sl.shipment_line_status_code in ('EXPECTED','PARTIALLY RECEIVED')
2157 AND sh.shipment_num LIKE (p_doc_number)
2158 -- This was fix for bug 2774080
2159 AND sl.item_description like p_item_description || '%'
2160 ORDER BY 1,2 ;
2161 ELSE
2162 --Both Inventory Item Id and Item Desc are Null
2163 --And also Both Item Id and Item Desc won't be passed together.
2164 OPEN x_doc_num_lov FOR
2165 SELECT DISTINCT
2166 -- DOCTYPE ASN
2167 meaning FIELD0,
2168 sh.shipment_num FIELD1,
2169 to_char(sh.shipment_header_id) FIELD2,
2170 to_char(sh.shipped_date) FIELD3,
2171 NULL FIELD4 , --<R12 MOAC>
2172 to_char(sh.expected_receipt_date) FIELD5,
2173 to_char(Decode(sh.receipt_source_code, 'VENDOR',sh.vendor_id, sl.from_organization_id)) FIELD6,
2174 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id, sl.from_organization_id),1,80) FIELD7,
2175 Decode(sh.receipt_source_code,'VENDOR','Vendor','Organization') FIELD8,
2176 sh.packing_slip FIELD9,
2177 sh.bill_of_lading FIELD10,
2178 sh.waybill_airbill_num FIELD11,
2179 sh.freight_carrier_code FIELD12,
2180 lookup_code FIELD13 ,
2181 NULL FIELD14 --<R12 MOAC>
2182 FROM fnd_lookup_values_vl flv,
2183 rcv_shipment_headers sh,
2184 rcv_shipment_lines sl
2185 WHERE flv.lookup_code = 'ASN'
2186 AND flv.lookup_type = 'DOC_TYPE'
2187 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2188 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2189 AND flv.enabled_flag = 'Y'
2190 AND sh.shipment_num IS NOT NULL
2191 AND sh.shipment_header_id = sl.shipment_header_id
2192 AND sl.to_organization_id = p_organization_id
2193 AND sh.receipt_source_code = 'VENDOR'
2194 AND sl.shipment_line_status_code <> 'CANCELLED'
2195 AND sh.shipment_header_id = sl.shipment_header_id
2196 AND sl.to_organization_id = p_organization_id
2197 -- This was fix for bug 2740648/2752094
2198 AND sh.asn_type IN ('ASN','ASBN')
2199 AND sl.shipment_line_status_code IN ('EXPECTED','PARTIALLY RECEIVED')
2200 AND sh.shipment_num LIKE (p_doc_number)
2201 ORDER BY 1,2 ;
2202 END IF ; --Check for Item Id or Desc value
2203 -- For Bug 7440217 Added a the followign code for the documnet type as LCM
2204 ELSIF NVL(p_doc_type,'ALL') = 'LCM' THEN
2205 IF p_inventory_item_id IS NOT NULL THEN
2206 OPEN x_doc_num_lov FOR
2207 -- This Select Handles LCM
2208 SELECT DISTINCT
2209 -- DOCTYPE LCM
2210 meaning FIELD0,
2211 sh.shipment_num FIELD1,
2212 to_char(sh.shipment_header_id) FIELD2,
2213 to_char(sh.shipped_date) FIELD3,
2214 NULL FIELD4 , --<R12 MOAC>
2215 to_char(sh.expected_receipt_date) FIELD5,
2216 to_char(Decode(sh.receipt_source_code, 'VENDOR',sh.vendor_id, sl.from_organization_id)) FIELD6,
2217 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id, sl.from_organization_id),1,80) FIELD7,
2218 Decode(sh.receipt_source_code,'VENDOR','Vendor','Organization') FIELD8,
2219 sh.packing_slip FIELD9,
2220 sh.bill_of_lading FIELD10,
2221 sh.waybill_airbill_num FIELD11,
2222 sh.freight_carrier_code FIELD12,
2223 lookup_code FIELD13,
2224 NULL FIELD14 --<R12 MOAC>
2225 FROM fnd_lookup_values_vl flv,
2226 rcv_shipment_headers sh,
2227 rcv_shipment_lines sl
2228 WHERE flv.lookup_code = 'LCM'
2229 AND flv.lookup_type = 'DOC_TYPE'
2230 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2231 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2232 AND flv.enabled_flag = 'Y'
2233 AND sh.shipment_num IS NOT NULL
2234 AND sh.shipment_header_id = sl.shipment_header_id
2235 AND sl.to_organization_id = p_organization_id
2236 AND sh.receipt_source_code = 'VENDOR'
2237 AND sl.shipment_line_status_code <> 'CANCELLED'
2238 AND sh.shipment_header_id = sl.shipment_header_id
2239 AND sl.to_organization_id = p_organization_id
2240 -- This was fix for bug 2740648/2752094
2241 AND sh.asn_type in ('LCM')
2242 AND sl.shipment_line_status_code in ('EXPECTED','PARTIALLY RECEIVED')
2243 AND sh.shipment_num LIKE (p_doc_number)
2244 -- This was fix for bug 2774080
2245 AND sl.item_id = p_inventory_item_id
2246 ORDER BY 1,2 ;
2247 ELSIF p_item_description IS NOT NULL THEN
2248 OPEN x_doc_num_lov FOR
2249 -- This Select Handles LCM
2250 SELECT DISTINCT
2251 -- DOCTYPE LCM
2252 meaning FIELD0,
2253 sh.shipment_num FIELD1,
2254 to_char(sh.shipment_header_id) FIELD2,
2255 to_char(sh.shipped_date) FIELD3,
2256 NULL FIELD4 , --<R12 MOAC>
2257 to_char(sh.expected_receipt_date) FIELD5,
2258 to_char(Decode(sh.receipt_source_code, 'VENDOR',sh.vendor_id, sl.from_organization_id)) FIELD6,
2259 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id, sl.from_organization_id),1,80) FIELD7,
2260 Decode(sh.receipt_source_code,'VENDOR','Vendor','Organization') FIELD8,
2261 sh.packing_slip FIELD9,
2262 sh.bill_of_lading FIELD10,
2263 sh.waybill_airbill_num FIELD11,
2264 sh.freight_carrier_code FIELD12,
2265 lookup_code FIELD13,
2266 NULL FIELD14 --<R12 MOAC>
2267 FROM fnd_lookup_values_vl flv,
2268 rcv_shipment_headers sh,
2269 rcv_shipment_lines sl
2270 WHERE flv.lookup_code = 'LCM'
2271 AND flv.lookup_type = 'DOC_TYPE'
2272 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2273 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2274 AND flv.enabled_flag = 'Y'
2275 AND sh.shipment_num IS NOT NULL
2276 AND sh.shipment_header_id = sl.shipment_header_id
2277 AND sl.to_organization_id = p_organization_id
2278 AND sh.receipt_source_code = 'VENDOR'
2279 AND sl.shipment_line_status_code <> 'CANCELLED'
2280 AND sh.shipment_header_id = sl.shipment_header_id
2281 AND sl.to_organization_id = p_organization_id
2282 -- This was fix for bug 2740648/2752094
2283 AND sh.asn_type in ('LCM')
2284 AND sl.shipment_line_status_code in ('EXPECTED','PARTIALLY RECEIVED')
2285 AND sh.shipment_num LIKE (p_doc_number)
2286 -- This was fix for bug 2774080
2287 AND sl.item_description like p_item_description || '%'
2288 ORDER BY 1,2 ;
2289 ELSE
2290 --Both Inventory Item Id and Item Desc are Null
2291 --And also Both Item Id and Item Desc won't be passed together.
2292 OPEN x_doc_num_lov FOR
2293 SELECT DISTINCT
2294 -- DOCTYPE LCM
2295 meaning FIELD0,
2296 sh.shipment_num FIELD1,
2297 to_char(sh.shipment_header_id) FIELD2,
2298 to_char(sh.shipped_date) FIELD3,
2299 NULL FIELD4 , --<R12 MOAC>
2300 to_char(sh.expected_receipt_date) FIELD5,
2301 to_char(Decode(sh.receipt_source_code, 'VENDOR',sh.vendor_id, sl.from_organization_id)) FIELD6,
2302 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id, sl.from_organization_id),1,80) FIELD7,
2303 Decode(sh.receipt_source_code,'VENDOR','Vendor','Organization') FIELD8,
2304 sh.packing_slip FIELD9,
2305 sh.bill_of_lading FIELD10,
2306 sh.waybill_airbill_num FIELD11,
2307 sh.freight_carrier_code FIELD12,
2308 lookup_code FIELD13 ,
2309 NULL FIELD14 --<R12 MOAC>
2310 FROM fnd_lookup_values_vl flv,
2311 rcv_shipment_headers sh,
2312 rcv_shipment_lines sl
2313 WHERE flv.lookup_code = 'LCM'
2314 AND flv.lookup_type = 'DOC_TYPE'
2315 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2316 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2317 AND flv.enabled_flag = 'Y'
2318 AND sh.shipment_num IS NOT NULL
2319 AND sh.shipment_header_id = sl.shipment_header_id
2320 AND sl.to_organization_id = p_organization_id
2321 AND sh.receipt_source_code = 'VENDOR'
2322 AND sl.shipment_line_status_code <> 'CANCELLED'
2323 AND sh.shipment_header_id = sl.shipment_header_id
2324 AND sl.to_organization_id = p_organization_id
2325 -- This was fix for bug 2740648/2752094
2326 AND sh.asn_type IN ('LCM')
2327 AND sl.shipment_line_status_code IN ('EXPECTED','PARTIALLY RECEIVED')
2328 AND sh.shipment_num LIKE (p_doc_number)
2329 ORDER BY 1,2 ;
2330 END IF ; --Check for Item Id or Desc value
2331 -- End for Bug 7440217
2332 ELSIF NVL(p_doc_type,'ALL') = 'REQ' THEN
2333 OPEN x_doc_num_lov FOR
2334 -- This Select Handles Requisitions
2335 SELECT DISTINCT
2336 meaning FIELD0,
2337 prh.segment1 FIELD1,
2338 to_char(prh.requisition_header_id) FIELD2,
2339 prh.description FIELD3,
2340 MO_GLOBAL.get_ou_name (prh.org_id) FIELD4 , --<R12 MOAC>
2341 NULL FIELD5,
2342 NULL FIELD6,
2343 NULL FIELD7,
2344 NULL FIELD8,
2345 NULL FIELD9,
2346 NULL FIELD10,
2347 NULL FIELD11,
2348 NULL FIELD12,
2349 lookup_code FIELD13 ,
2350 to_char(prh.org_id) FIELD14 --<R12 MOAC>
2351 FROM fnd_lookup_values_vl flv,
2352 po_requisition_headers prh,
2353 po_requisition_lines prl
2354 WHERE flv.lookup_code = 'REQ'
2355 AND flv.lookup_type = 'DOC_TYPE'
2356 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2357 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2358 AND flv.enabled_flag = 'Y'
2359 AND Nvl(prl.cancel_flag,'N') = 'N'
2360 AND prl.destination_organization_id = p_organization_id
2361 AND prh.requisition_header_id = prl.requisition_header_id
2362 AND prh.authorization_status || '' = 'APPROVED'
2363 AND prh.segment1 LIKE (p_doc_number)
2364 AND EXISTS
2365 (
2366 SELECT
2367 1
2368 FROM rcv_shipment_lines rsl
2369 WHERE rsl.requisition_line_id = prl.requisition_line_id
2370 AND rsl.routing_header_id > 0 --Bug 3349131
2371 AND rsl.shipment_line_status_code <> 'FULLY RECEIVED'
2372 AND rsl.item_id LIKE Nvl(p_inventory_item_id,rsl.item_id)
2373 )
2374 AND p_item_description IS NULL
2375 ORDER BY 1,2 ;
2376 ELSIF NVL(p_doc_type,'ALL') = 'ALL' THEN
2377 OPEN x_doc_num_lov FOR
2378 -- This select takes care of Vendor Item and any non-expense item
2379 -- and cross ref item case.
2380 SELECT /*+index(POH PO_HEADERS_U2) */
2381 DISTINCT
2382 -- DOCTYPE PO
2383 meaning FIELD0 ,
2384 poh.segment1 FIELD1 ,
2385 to_char(poh.po_header_id) FIELD2 ,
2386 poh.type_lookup_code FIELD3 ,
2387 MO_GLOBAL.get_ou_name(poh.org_id) FIELD4 , --<R12 MOAC>
2388 PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID) FIELD5 ,
2389 to_char(poh.vendor_id) FIELD6 ,
2390 to_char(poh.vendor_site_id) FIELD7 ,
2391 'Vendor' FIELD8 ,
2392 poh.note_to_receiver FIELD9 ,
2393 NULL FIELD10 ,
2394 NULL FIELD11 ,
2395 NULL FIELD12 ,
2396 lookup_code FIELD13 ,
2397 to_char(poh.org_id) FIELD14 --<R12 MOAC>
2398 FROM po_headers poh,
2399 fnd_lookup_values_vl flv
2400 WHERE flv.lookup_code = 'PO'
2401 AND flv.lookup_type = 'DOC_TYPE'
2402 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2403 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2404 AND flv.enabled_flag = 'Y'
2405 -- Bug 2859355 Added the Extra conditions for poh.
2406 AND POH.TYPE_LOOKUP_CODE IN ('STANDARD','PLANNED', 'BLANKET','CONTRACT')
2407 AND NVL(POH.CANCEL_FLAG, 'N') IN ('N', 'I')
2408 AND NVL(POH.CLOSED_CODE, 'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3152693
2409 AND poh.segment1 LIKE (p_doc_number)
2410 AND EXISTS
2411 (
2412 SELECT
2413 'Valid PO Shipments'
2414 FROM po_lines_all pl ,
2415 po_line_locations_all poll
2416 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
2417 , mtl_parameters mp,
2418 rcv_parameters rp
2419 -- End for Bug 7440217
2420 WHERE pl.po_header_id = poh.po_header_id
2421 AND Nvl(pl.vendor_product_num,' ') = Nvl(p_vendor_prod_num, Nvl(pl.vendor_product_num,' '))
2422 AND Nvl(pl.item_id,-999) LIKE Nvl(p_inventory_item_id,'%')
2423 AND poh.po_header_id = poll.po_header_id
2424 AND pl.po_line_id = poll.po_line_id
2425 AND poll.approved_flag = 'Y'
2426 AND Nvl(poll.cancel_flag,'N') = 'N'
2427 -- AND poll.closed_code = 'OPEN' -- Bug 2859335
2428 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
2429 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
2430 AND poll.ship_to_organization_id = p_organization_id
2431 AND poll.payment_type IS NULL --R12 excludes all Complex Work POs (Bug4236155)
2432 -- For Bug 7440217 Checking if it is LCM enabled
2433 AND mp.organization_id = p_organization_id
2434 AND rp.organization_id = p_organization_id
2435 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
2436 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
2437 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
2438 )
2439 -- End for Bug 7440217
2440 )
2441 AND p_item_description IS NULL
2442 UNION
2443 -- This Select Handles Substitute Items
2444 SELECT /*+index(POH PO_HEADERS_U2) */
2445 DISTINCT
2446 -- DOCTYPE PO
2447 meaning FIELD0 ,
2448 poh.segment1 FIELD1 ,
2449 to_char(poh.po_header_id) FIELD2 ,
2450 poh.type_lookup_code FIELD3 ,
2451 MO_GLOBAL.get_ou_name(poh.org_id) FIELD4, --<R12 MOAC>
2452 PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID) FIELD5 ,
2453 to_char(poh.vendor_id) FIELD6 ,
2454 to_char(poh.vendor_site_id) FIELD7 ,
2455 'Vendor' FIELD8 ,
2456 poh.note_to_receiver FIELD9 ,
2457 NULL FIELD10 ,
2458 NULL FIELD11 ,
2459 NULL FIELD12 ,
2460 lookup_code FIELD13 ,
2461 to_char(poh.org_id) FIELD14 --<R12 MOAC>
2462 FROM po_headers poh,
2463 fnd_lookup_values_vl flv
2464 WHERE flv.lookup_code = 'PO'
2465 AND flv.lookup_type = 'DOC_TYPE'
2466 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2467 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2468 AND flv.enabled_flag = 'Y'
2469 -- Bug 2859355 Added the Extra conditions for poh.
2470 AND POH.TYPE_LOOKUP_CODE IN ('STANDARD','PLANNED', 'BLANKET','CONTRACT')
2471 AND NVL(POH.CANCEL_FLAG, 'N') IN ('N', 'I')
2472 AND NVL(POH.CLOSED_CODE, 'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3152693
2473 AND poh.segment1 LIKE (p_doc_number)
2474 AND EXISTS
2475 (
2476 SELECT
2477 'Valid PO Shipments'
2478 FROM po_lines_all pl ,
2479 mtl_related_items mri ,
2480 mtl_system_items_kfv msi ,
2481 po_line_locations_all poll
2482 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
2483 , mtl_parameters mp,
2484 rcv_parameters rp
2485 -- End for Bug 7440217
2486 WHERE msi.organization_id = p_organization_id
2487 AND
2488 (
2489 (
2490 mri.related_item_id = msi.inventory_item_id
2491 AND pl.item_id = mri.inventory_item_id
2492 AND msi.inventory_item_id LIKE p_inventory_item_id
2493 )
2494 OR
2495 (
2496 mri.inventory_item_id = msi.inventory_item_id
2497 AND pl.item_id = mri.related_item_id
2498 AND mri.reciprocal_flag = 'Y'
2499 AND msi.inventory_item_id LIKE p_inventory_item_id
2500 )
2501 )
2502 AND pl.po_header_id = poh.po_header_id
2503 AND Nvl(pl.vendor_product_num,' ') = Nvl(p_vendor_prod_num,Nvl(pl.vendor_product_num,' '))
2504 AND poh.po_header_id = poll.po_header_id
2505 AND pl.po_line_id = poll.po_line_id
2506 AND poll.approved_flag = 'Y'
2507 AND Nvl(poll.cancel_flag,'N') = 'N'
2508 -- AND poll.closed_code = 'OPEN' -- Bug 2859355
2509 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
2510 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
2511 AND poll.ship_to_organization_id = p_organization_id
2512 AND poll.payment_type IS NULL --R12 excludes all Complex Work POs (Bug4236155)
2513 -- For Bug 7440217 Checking if it is LCM enabled
2514 AND mp.organization_id = p_organization_id
2515 AND rp.organization_id = p_organization_id
2516 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
2517 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
2518 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
2519 )
2520 -- End for Bug 7440217
2521 )
2522 AND p_item_description IS NULL
2523 UNION
2524 -- This Select Handles Expense Items
2525 SELECT /*+index(POH PO_HEADERS_U2) */
2526 DISTINCT
2527 -- DOCTYPE PO
2528 meaning FIELD0 ,
2529 poh.segment1 FIELD1 ,
2530 to_char(poh.po_header_id) FIELD2 ,
2531 poh.type_lookup_code FIELD3 ,
2532 MO_GLOBAL.get_ou_name(poh.org_id) FIELD4 , --<R12 MOAC>
2533 PO_VENDORS_SV2.GET_VENDOR_NAME_FUNC(POH.VENDOR_ID) FIELD5 ,
2534 to_char(poh.vendor_id) FIELD6 ,
2535 to_char(poh.vendor_site_id) FIELD7 ,
2536 'Vendor' FIELD8 ,
2537 poh.note_to_receiver FIELD9 ,
2538 NULL FIELD10 ,
2539 NULL FIELD11 ,
2540 NULL FIELD12 ,
2541 lookup_code FIELD13 ,
2542 to_char(poh.org_id) FIELD14 --<R12 MOAC>
2543 FROM po_headers poh,
2544 fnd_lookup_values_vl flv
2545 WHERE flv.lookup_code = 'PO'
2546 AND flv.lookup_type = 'DOC_TYPE'
2547 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2548 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2549 AND flv.enabled_flag = 'Y'
2550 -- Bug 2859355 Added the Extra conditions for poh.
2551 AND POH.TYPE_LOOKUP_CODE IN ('STANDARD','PLANNED', 'BLANKET','CONTRACT')
2552 AND NVL(POH.CANCEL_FLAG, 'N') IN ('N', 'I')
2553 AND NVL(POH.CLOSED_CODE, 'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3152693
2554 AND poh.segment1 LIKE (p_doc_number)
2555 AND EXISTS
2556 (
2557 SELECT
2558 'Valid PO Shipments'
2559 FROM po_lines_all pl ,
2560 po_line_locations_all poll
2561 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
2562 , mtl_parameters mp,
2563 rcv_parameters rp
2564 -- End for Bug 7440217
2565 WHERE pl.item_id IS NULL
2566 AND pl.item_description LIKE p_item_description||'%'
2567 AND pl.po_header_id = poh.po_header_id
2568 AND Nvl(pl.vendor_product_num,' ') = Nvl(p_vendor_prod_num,Nvl(pl.vendor_product_num,' '))
2569 AND poh.po_header_id = poll.po_header_id
2570 AND pl.po_line_id = poll.po_line_id
2571 AND Nvl(poll.approved_flag,'N') = 'Y'
2572 AND Nvl(poll.cancel_flag,'N') = 'N'
2573 -- AND poll.closed_code = 'OPEN' --Bug 2859355
2574 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
2575 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
2576 AND poll.ship_to_organization_id = p_organization_id
2577 AND poll.payment_type IS NULL --R12 excludes all Complex Work POs (Bug4236155)
2578 -- For Bug 7440217 Checking if it is LCM enabled
2579 AND mp.organization_id = p_organization_id
2580 AND rp.organization_id = p_organization_id
2581 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
2582 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
2583 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
2584 )
2585 -- End for Bug 7440217
2586 )
2587 AND p_item_description IS NOT NULL
2588 UNION ALL
2589 -- This Select Handles RMAs
2590 SELECT DISTINCT
2591 -- DOCTYPE RMA
2592 meaning FIELD0,
2593 to_char(OEH.ORDER_NUMBER) FIELD1,
2594 to_char(OEL.HEADER_ID) FIELD2,
2595 OTT_TL.NAME FIELD3, --OLT.NAME FIELD3,--bug3173013
2596 NULL FIELD4, --<R12 MOAC>
2597 OTT_ALL.ORDER_CATEGORY_CODE FIELD5, --OLT.ORDER_CATEGORY_CODE FIELD5,
2598 to_char(OESOLD.CUSTOMER_ID) FIELD6,
2599 /* TCA Cleanup */
2600 PARTY.party_name FIELD7,
2601 PARTY.party_number FIELD8,
2602 --OEC.customer_name FIELD7,
2603 --OEC.customer_number FIELD8,
2604 NULL FIELD9,
2605 NULL FIELD10,
2606 NULL FIELD11,
2607 NULL FIELD12,
2608 lookup_code FIELD13 ,
2609 to_char(oel.org_id) FIELD14 --<R12 MOAC>
2610 FROM fnd_lookup_values_vl flv,
2611 OE_ORDER_LINES_all OEL,
2612 OE_ORDER_HEADERS_all OEH,
2613 --OE_LINE_TYPES_V OLT, --bug3173013
2614 OE_TRANSACTION_TYPES_TL OTT_TL,
2615 OE_TRANSACTION_TYPES_ALL OTT_ALL,
2616 OE_SOLD_TO_ORGS_V OESOLD,
2617 --WF_ITEM_ACTIVITY_STATUSES WF,
2618 --WF_PROCESS_ACTIVITIES WPA,
2619 --RA_CUSTOMERS OEC /*TCA Cleanup */
2620 HZ_PARTIES PARTY,
2621 HZ_CUST_ACCOUNTS CUST_ACCT
2622 WHERE flv.lookup_code = 'RMA'
2623 AND flv.lookup_type = 'DOC_TYPE'
2624 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2625 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2626 AND flv.enabled_flag = 'Y'
2627 AND OEL.LINE_CATEGORY_CODE='RETURN'
2628 AND nvl(OEL.SHIP_FROM_ORG_ID, OEH.SHIP_FROM_ORG_ID) = p_organization_id
2629 AND OEL.HEADER_ID = OEH.HEADER_ID
2630 AND OEL.SOLD_TO_ORG_ID = OESOLD.ORGANIZATION_ID
2631 --AND OESOLD.CUSTOMER_ID = oec.customer_id /*TCA Cleanup */
2632 --Bug5417779: oesold.customer_id should be joined with cust_acct.cust_account_id
2633 AND OESOLD.CUSTOMER_ID = CUST_ACCT.CUST_ACCOUNT_ID
2634 AND CUST_ACCT.PARTY_ID = PARTY.party_id
2635 --AND OEL.LINE_TYPE_ID = OLT.LINE_TYPE_ID--bug3173013
2636 AND OEH.ORDER_TYPE_ID = OTT_ALL.TRANSACTION_TYPE_ID
2637 AND OTT_ALL.ORDER_CATEGORY_CODE in ('MIXED', 'RETURN')
2638 AND OTT_ALL.TRANSACTION_TYPE_ID = OTT_TL.TRANSACTION_TYPE_ID
2639 AND OTT_TL.LANGUAGE = USERENV('LANG')
2640 AND OEH.BOOKED_FLAG='Y'
2641 AND OEH.OPEN_FLAG='Y'
2642 AND OEL.ORDERED_QUANTITY > NVL(OEL.SHIPPED_QUANTITY,0)
2643 AND OEL.FLOW_STATUS_CODE = 'AWAITING_RETURN'
2644 --
2645 -- The following lines are commented for Performance Improvement
2646 -- instead flow_status_code is used from oel
2647 --AND WPA.ACTIVITY_ITEM_TYPE = 'OEOL'
2648 --AND WPA.ACTIVITY_NAME = 'RMA_WAIT_FOR_RECEIVING'
2649 --AND WF.ITEM_TYPE = 'OEOL'
2650 --AND WF.PROCESS_ACTIVITY = WPA.INSTANCE_ID
2651 --AND WF.ACTIVITY_STATUS = 'NOTIFIED'
2652 --AND OEL.LINE_ID = TO_NUMBER(WF.ITEM_KEY)
2653 --
2654 AND oeh.order_number LIKE (p_doc_number)
2655 AND OEL.inventory_item_id LIKE Nvl(p_inventory_item_id,'%')
2656 AND p_item_description IS NULL
2657 UNION ALL
2658 -- This Select Handles Internal Sales Order , Org Transfer
2659 SELECT DISTINCT
2660 -- DOCTYPE INTSHIP
2661 meaning FIELD0,
2662 sh.shipment_num FIELD1,
2663 to_char(sh.shipment_header_id) FIELD2,
2664 to_char(sh.shipped_date) FIELD3,
2665 NULL FIELD4 , --<R12 MOAC>
2666 to_char(sh.expected_receipt_date) FIELD5,
2667 to_char(Decode(sh.receipt_source_code, 'VENDOR',sh.vendor_id, sl.from_organization_id)) FIELD6,
2668 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id, sl.from_organization_id),1,80) FIELD7,
2669 Decode(sh.receipt_source_code,'VENDOR','Vendor',sh.receipt_source_code) FIELD8, --bug fix 3939003
2670 sh.packing_slip FIELD9,
2671 sh.bill_of_lading FIELD10,
2672 sh.waybill_airbill_num FIELD11,
2673 sh.freight_carrier_code FIELD12,
2674 lookup_code FIELD13,
2675 NULL FIELD14 --<R12 MOAC>
2676 FROM fnd_lookup_values_vl flv,
2677 rcv_shipment_headers sh,
2678 rcv_shipment_lines sl
2679 WHERE flv.lookup_code = 'INTSHIP'
2680 AND flv.lookup_type = 'DOC_TYPE'
2681 AND nvl(flv.start_date_active, SYSDATE )<= SYSDATE
2682 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2683 AND flv.enabled_flag = 'Y'
2684 AND sh.shipment_num IS NOT NULL
2685 AND sh.shipment_header_id = sl.shipment_header_id
2686 AND sl.to_organization_id = p_organization_id
2687 AND sh.receipt_source_code IN ('INTERNAL ORDER','INVENTORY')
2688 AND EXISTS
2689 (
2690 SELECT
2691 'available supply'
2692 FROM mtl_supply ms
2693 WHERE ms.to_organization_id = p_organization_id
2694 AND ms.shipment_header_id = sh.shipment_header_id
2695 )
2696 -- This was fix for bug 2740648/2752094
2697 AND sl.shipment_line_status_code IN ('EXPECTED','PARTIALLY RECEIVED')
2698 AND sh.shipment_num LIKE (p_doc_number)
2699 AND sl.item_id like Nvl(p_inventory_item_id,'%')
2700 AND p_item_description IS NULL
2701 UNION ALL
2702 -- This Select Handles ASN
2703 SELECT DISTINCT
2704 -- DOCTYPE ASN
2705 meaning FIELD0,
2706 sh.shipment_num FIELD1,
2707 to_char(sh.shipment_header_id) FIELD2,
2708 to_char(sh.shipped_date) FIELD3,
2709 NULL FIELD4 , --<R12 MOAC>
2710 to_char(sh.expected_receipt_date) FIELD5,
2711 to_char(Decode(sh.receipt_source_code, 'VENDOR',sh.vendor_id, sl.from_organization_id)) FIELD6,
2712 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id, sl.from_organization_id),1,80) FIELD7,
2713 Decode(sh.receipt_source_code,'VENDOR','Vendor','Organization') FIELD8,
2714 sh.packing_slip FIELD9,
2715 sh.bill_of_lading FIELD10,
2716 sh.waybill_airbill_num FIELD11,
2717 sh.freight_carrier_code FIELD12,
2718 lookup_code FIELD13,
2719 NULL FIELD14 --<R12 MOAC>
2720 FROM fnd_lookup_values_vl flv,
2721 rcv_shipment_headers sh,
2722 rcv_shipment_lines sl
2723 WHERE flv.lookup_code = 'ASN'
2724 AND flv.lookup_type = 'DOC_TYPE'
2725 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2726 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2727 AND flv.enabled_flag = 'Y'
2728 AND sh.shipment_num IS NOT NULL
2729 AND sh.shipment_header_id = sl.shipment_header_id
2730 AND sl.to_organization_id = p_organization_id
2731 AND sh.receipt_source_code = 'VENDOR'
2732 AND sl.shipment_line_status_code <> 'CANCELLED'
2733 AND sh.shipment_header_id = sl.shipment_header_id
2734 AND sl.to_organization_id = p_organization_id
2735 -- This was fix for bug 2740648/2752094
2736 AND sh.asn_type in ('ASN','ASBN')
2737 AND sl.shipment_line_status_code IN ('EXPECTED','PARTIALLY RECEIVED')
2738 AND sh.shipment_num LIKE (p_doc_number)
2739 -- This was fix for bug 2774080
2740 AND
2741 (
2742 (
2743 p_item_description IS NULL
2744 AND sl.item_id LIKE Nvl(p_inventory_item_id,'%')
2745
2746 )
2747 OR
2748 (
2749 p_inventory_item_id IS NULL
2750 AND sl.item_description LIKE Nvl(p_item_description , '%' )
2751 )
2752 )
2753 -- For Bug 7440217 adding all LCM Docs also to the LOV query
2754 UNION ALL
2755 -- This Select Handles LCM
2756 SELECT DISTINCT
2757 -- DOCTYPE LCM
2758 meaning FIELD0,
2759 sh.shipment_num FIELD1,
2760 to_char(sh.shipment_header_id) FIELD2,
2761 to_char(sh.shipped_date) FIELD3,
2762 NULL FIELD4 , --<R12 MOAC>
2763 to_char(sh.expected_receipt_date) FIELD5,
2764 to_char(Decode(sh.receipt_source_code, 'VENDOR',sh.vendor_id, sl.from_organization_id)) FIELD6,
2765 Substr( rcv_intransit_sv.rcv_get_org_name(sh.receipt_source_code,sh.vendor_id, sl.from_organization_id),1,80) FIELD7,
2766 Decode(sh.receipt_source_code,'VENDOR','Vendor','Organization') FIELD8,
2767 sh.packing_slip FIELD9,
2768 sh.bill_of_lading FIELD10,
2769 sh.waybill_airbill_num FIELD11,
2770 sh.freight_carrier_code FIELD12,
2771 lookup_code FIELD13,
2772 NULL FIELD14 --<R12 MOAC>
2773 FROM fnd_lookup_values_vl flv,
2774 rcv_shipment_headers sh,
2775 rcv_shipment_lines sl
2776 WHERE flv.lookup_code = 'LCM'
2777 AND flv.lookup_type = 'DOC_TYPE'
2778 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2779 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2780 AND flv.enabled_flag = 'Y'
2781 AND sh.shipment_num IS NOT NULL
2782 AND sh.shipment_header_id = sl.shipment_header_id
2783 AND sl.to_organization_id = p_organization_id
2784 AND sh.receipt_source_code = 'VENDOR'
2785 AND sl.shipment_line_status_code <> 'CANCELLED'
2786 AND sh.shipment_header_id = sl.shipment_header_id
2787 AND sl.to_organization_id = p_organization_id
2788 -- This was fix for bug 2740648/2752094
2789 AND sh.asn_type in ('LCM')
2790 AND sl.shipment_line_status_code IN ('EXPECTED','PARTIALLY RECEIVED')
2791 AND sh.shipment_num LIKE (p_doc_number)
2792 -- This was fix for bug 2774080
2793 AND
2794 (
2795 (
2796 p_item_description IS NULL
2797 AND sl.item_id LIKE Nvl(p_inventory_item_id,'%')
2798
2799 )
2800 OR
2801 (
2802 p_inventory_item_id IS NULL
2803 AND sl.item_description LIKE Nvl(p_item_description , '%' )
2804 )
2805 )
2806 -- End for Bug 7440217
2807 UNION ALL
2808 -- This Select Handles Requisitions
2809 SELECT DISTINCT
2810 meaning FIELD0,
2811 prh.segment1 FIELD1,
2812 to_char(prh.requisition_header_id) FIELD2,
2813 prh.description FIELD3,
2814 MO_GLOBAL.get_ou_name (prh.org_id) FIELD4 , --<R12 MOAC>
2815 NULL FIELD5,
2816 NULL FIELD6,
2817 NULL FIELD7,
2818 NULL FIELD8,
2819 NULL FIELD9,
2820 NULL FIELD10,
2821 NULL FIELD11,
2822 NULL FIELD12,
2823 lookup_code FIELD13 ,
2824 to_char(prh.org_id) FIELD14 --<R12 MOAC>
2825 FROM fnd_lookup_values_vl flv,
2826 po_requisition_headers prh,
2827 po_requisition_lines prl
2828 WHERE flv.lookup_code = 'REQ'
2829 AND flv.lookup_type = 'DOC_TYPE'
2830 AND nvl(flv.start_date_active, SYSDATE) <= SYSDATE
2831 AND nvl(flv.end_date_active,sysdate) >= SYSDATE
2832 AND flv.enabled_flag = 'Y'
2833 AND Nvl(prl.cancel_flag,'N') = 'N'
2834 AND prl.destination_organization_id = p_organization_id
2835 AND prh.requisition_header_id = prl.requisition_header_id
2836 AND prh.authorization_status || '' = 'APPROVED'
2837 AND prh.segment1 LIKE (p_doc_number)
2838 AND EXISTS
2839 (
2840 SELECT
2841 1
2842 FROM rcv_shipment_lines rsl
2843 WHERE rsl.requisition_line_id = prl.requisition_line_id
2844 AND rsl.routing_header_id > 0 --Bug 3349131
2845 AND rsl.shipment_line_status_code <> 'FULLY RECEIVED'
2846 AND rsl.item_id LIKE Nvl(p_inventory_item_id,rsl.item_id)
2847 )
2848 AND p_item_description IS NULL
2849 ORDER BY 1,2 ;
2850 END IF; -- Check for p_doc_type
2851 END IF ; -- Check for p_mobile_form
2852 END GET_DOC_LOV ;
2853
2854 -- Name: GET_PO_LINE_ITEM NUM_LOV
2855 --
2856 -- Input parameters:
2857 -- p_Organization_Id which restricts LOV SQL to current org
2858 -- p_po_header_id which restricts LOV SQL to the PO
2859 -- p_po_line_num which restricts the LOV to the user input text.
2860 --
2861 -- Output parameters:
2862 -- x_po_line_num_lov returns LOV rows as reference cursor
2863 --
2864 -- Functions: This API returns PO Line numbers for a given PO and Item Id
2865 --
2866 PROCEDURE GET_PO_LINE_ITEM_NUM_LOV(x_po_line_num_lov OUT NOCOPY t_genref,
2867 p_organization_id IN NUMBER,
2868 p_po_header_id IN NUMBER,
2869 p_mobile_form IN VARCHAR2,
2870 p_po_line_num IN VARCHAR2,
2871 p_inventory_item_id IN VARCHAR2)
2872 IS
2873 po_line_number VARCHAR2(20);
2874 BEGIN
2875 BEGIN
2876 /* Start - Fix for Bug# 6640083 */
2877 -- po_line_number := to_char(to_number(p_po_line_num));
2878 -- This will convert String to number - Bug#6012703
2879 -- Commented the code for Bug#6640083
2880 SELECT TRIM(LEADING '0' FROM p_po_line_num ) INTO po_line_number FROM Dual;
2881 -- This will trim leading zeroes - Bug#6640083
2882 /* End - Fix for Bug# 6640083 */
2883 EXCEPTION
2884 WHEN OTHERS then
2885 po_line_number := p_po_line_num;
2886 END;
2887 IF p_mobile_form = 'RECEIPT' THEN
2888 /*Bug#5612236. In the below query, replaced 'MTL_SYSTEM_ITEMS_KFV' with
2889 'MTL_SYSTEM_ITEMS_VL' and item desc is selected from this table.*/
2890 OPEN x_po_line_num_lov FOR
2891 -- Bug 6437363 : Modified the query for better performance.
2892 select distinct pl.line_num
2893 , pl.po_line_id
2894 , msi.description
2895 , pl.item_id
2896 , pl.item_revision
2897 , msi.concatenated_segments
2898 , msi.outside_operation_flag
2899 , inv_ui_item_lovs.get_conversion_rate(mum.uom_code,
2900 p_organization_id,
2901 pl.Item_Id)
2902 uom_code
2903 from po_lines_all pl
2904 , mtl_units_of_measure mum
2905 , mtl_system_items_vl msi
2906 where pl.item_id = msi.inventory_item_id (+)
2907 and mum.UNIT_OF_MEASURE(+) = pl.UNIT_MEAS_LOOKUP_CODE
2908 and msi.organization_id = p_organization_id -- Bug 6437363
2909 and pl.po_header_id = p_po_header_id
2910 and exists (SELECT 'Valid PO Shipments'
2911 FROM po_line_locations_all poll
2912 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
2913 , mtl_parameters mp,
2914 rcv_parameters rp
2915 -- End for Bug 7440217
2916 WHERE poll.po_header_id = pl.po_header_id
2917 AND poll.po_line_id = pl.po_line_id
2918 AND Nvl(poll.approved_flag,'N') = 'Y'
2919 AND Nvl(poll.cancel_flag,'N') = 'N'
2920 -- AND poll.closed_code = 'OPEN' -- Bug 2859355
2921 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
2922 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
2923 AND poll.ship_to_organization_id = p_organization_id
2924 -- For Bug 7440217 Checking if it is LCM enabled
2925 AND mp.organization_id = p_organization_id
2926 AND rp.organization_id = p_organization_id
2927 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
2928 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
2929 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
2930 )
2931 -- End for Bug 7440217
2932 )
2933 AND pl.line_num LIKE (po_line_number)
2934 AND nvl(pl.item_id,-999) LIKE nvl(p_inventory_item_id,'%')
2935 UNION ALL
2936 select distinct pl.line_num
2937 , pl.po_line_id
2938 , msi.description
2939 , pl.item_id
2940 , pl.item_revision
2941 , msi.concatenated_segments
2942 , msi.outside_operation_flag
2943 , inv_ui_item_lovs.get_conversion_rate(mum.uom_code,
2944 p_organization_id,
2945 pl.Item_Id)
2946 uom_code
2947 from po_lines_all pl
2948 , mtl_units_of_measure mum
2949 , mtl_system_items_vl msi
2950 , mtl_related_items mri
2951 where msi.organization_id = p_organization_id -- Bug 6437363
2952 and msi.inventory_item_id = p_inventory_item_id -- Bug 6311550
2953 and mum.UNIT_OF_MEASURE(+) = pl.UNIT_MEAS_LOOKUP_CODE
2954 and pl.po_header_id = p_po_header_id
2955 and exists (SELECT 'Valid PO Shipments'
2956 FROM po_line_locations_all poll
2957 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
2958 , mtl_parameters mp,
2959 rcv_parameters rp
2960 -- End for Bug 7440217
2961 WHERE poll.po_header_id = pl.po_header_id
2962 AND poll.po_line_id = pl.po_line_id
2963 AND Nvl(poll.approved_flag,'N') = 'Y'
2964 AND Nvl(poll.cancel_flag,'N') = 'N'
2965 -- AND poll.closed_code = 'OPEN' --Bug 2859355
2966 AND Nvl(poll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
2967 AND poll.shipment_type IN ('STANDARD','BLANKET','SCHEDULED')
2968 AND poll.ship_to_organization_id = p_organization_id
2969 -- For Bug 7440217 Checking if it is LCM enabled
2970 AND mp.organization_id = p_organization_id
2971 AND rp.organization_id = p_organization_id
2972 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
2973 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
2974 OR (NVL(poll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
2975 )
2976 -- End for Bug 7440217
2977 )
2978 AND pl.line_num LIKE (po_line_number)
2979 AND exists (select 'c' -- Bug 6437363
2980 from MTL_RELATED_ITEMS MRI
2981 where MRI.RELATED_ITEM_ID = MSI.INVENTORY_ITEM_ID
2982 AND PL.ITEM_ID = MRI.INVENTORY_ITEM_ID
2983 union all
2984 select 'c'
2985 from MTL_RELATED_ITEMS MRI
2986 where MRI.INVENTORY_ITEM_ID = MSI.INVENTORY_ITEM_ID
2987 AND PL.ITEM_ID = MRI.RELATED_ITEM_ID
2988 AND MRI.RECIPROCAL_FLAG = 'Y' )
2989 order by 1;
2990 ELSE
2991 OPEN x_po_line_num_lov FOR
2992 select distinct pl.line_num
2993 , pl.po_line_id
2994 -- Bug 7274407
2995 , NVL(msi.description, pl.item_description)
2996 , pl.item_id
2997 , pl.item_revision
2998 , msi.concatenated_segments
2999 , msi.outside_operation_flag
3000 , inv_ui_item_lovs.get_conversion_rate(mum.uom_code,
3001 p_organization_id,
3002 pl.Item_Id)
3003 uom_code
3004 FROM rcv_supply rsup
3005 , mtl_units_of_measure mum
3006 , po_lines_all pl
3007 , mtl_system_items_vl msi
3008 WHERE rsup.po_line_id = pl.po_line_id
3009 and mum.UNIT_OF_MEASURE(+) = pl.UNIT_MEAS_LOOKUP_CODE
3010 AND pl.item_id = msi.inventory_item_id (+)
3011 and Nvl(msi.organization_id, p_organization_id) = p_organization_id
3012 and rsup.po_header_id = p_po_header_id
3013 AND pl.line_num LIKE (po_line_number)
3014 order by pl.line_num;
3015 END IF;
3016 END GET_PO_LINE_ITEM_NUM_LOV;
3017
3018
3019 PROCEDURE get_job_lov (x_job_lov OUT NOCOPY t_genref,
3020 p_organization_id IN NUMBER,
3021 p_po_header_id IN NUMBER,
3022 p_po_line_id IN NUMBER,
3023 p_item_id IN NUMBER,
3024 p_Job IN VARCHAR2,
3025 p_po_release_id IN NUMBER DEFAULT NULL) --Bug #3883926
3026 IS
3027 BEGIN
3028 --Fix for Bug # 3883926
3029 --Added the IF clause to check whether Release Id is
3030 --passed or not and execute the appropriate query.
3031 IF p_po_release_id IS NOT NULL THEN
3032 OPEN x_job_lov FOR
3033 SELECT wojv.wip_entity_name
3034 , wojv.wip_entity_id
3035 , wolv.line_code
3036 , woov.operation_seq_num
3037 , woov.department_code
3038 , pda.po_distribution_id
3039 , (pda.quantity_ordered - pda.quantity_delivered)
3040 , woov.repetitive_schedule_id
3041 FROM po_headers_all phl
3042 , po_lines_all pla
3043 , po_distributions_all pda
3044 , po_releases_all prl
3045 , wip_osp_jobs_val_v wojv
3046 , wip_osp_lines_val_v wolv
3047 , wip_osp_operations_val_v woov
3048 WHERE phl.po_header_id = p_po_header_id
3049 AND phl.po_header_id = pla.po_header_id
3050 AND pla.po_line_id = nvl (p_po_line_id, pla.po_line_id)
3051 AND pla.item_id = nvl (p_item_id, pla.item_id)
3052 AND pla.po_line_id = pda.po_line_id
3053 --Bug # 3883926
3054 AND prl.po_header_id = phl.po_header_id
3055 AND prl.po_release_id = p_po_release_id
3056 AND prl.po_release_id = pda.po_release_id
3057 --Bug # 3883926
3058 AND wojv.wip_entity_id = pda.wip_entity_id
3059 AND wojv.organization_id = pda.destination_organization_id
3060 AND wojv.organization_id = p_organization_id
3061 AND wolv.line_id (+) = pda.wip_line_id
3062 AND wolv.organization_id (+) = pda.destination_organization_id
3063 AND woov.wip_entity_id = pda.wip_entity_id
3064 AND woov.organization_id = pda.destination_organization_id
3065 AND woov.operation_seq_num (+) = pda.wip_operation_seq_num
3066 AND nvl (woov.repetitive_schedule_id, -1) = nvl (pda.wip_repetitive_schedule_id, -1)
3067 AND wojv.wip_entity_name like (p_job)
3068 ORDER BY wojv.wip_entity_name;
3069 ELSE
3070 OPEN x_job_lov FOR
3071 SELECT wojv.wip_entity_name
3072 , wojv.wip_entity_id
3073 , wolv.line_code
3074 , woov.operation_seq_num
3075 , woov.department_code
3076 , pda.po_distribution_id
3077 , (pda.quantity_ordered - pda.quantity_delivered)
3078 , woov.repetitive_schedule_id
3079 FROM po_headers_all phl
3080 , po_lines_all pla
3081 , po_distributions_all pda
3082 , wip_osp_jobs_val_v wojv
3083 , wip_osp_lines_val_v wolv
3084 , wip_osp_operations_val_v woov
3085 WHERE phl.po_header_id = p_po_header_id
3086 AND phl.po_header_id = pla.po_header_id
3087 AND pla.po_line_id = nvl (p_po_line_id, pla.po_line_id)
3088 AND pla.item_id = nvl (p_item_id, pla.item_id)
3089 AND pla.po_line_id = pda.po_line_id
3090 AND wojv.wip_entity_id = pda.wip_entity_id
3091 AND wojv.organization_id = pda.destination_organization_id
3092 AND wojv.organization_id = p_organization_id
3093 AND wolv.line_id (+) = pda.wip_line_id
3094 AND wolv.organization_id (+) = pda.destination_organization_id
3095 AND woov.wip_entity_id = pda.wip_entity_id
3096 AND woov.organization_id = pda.destination_organization_id
3097 AND woov.operation_seq_num (+) = pda.wip_operation_seq_num
3098 AND nvl (woov.repetitive_schedule_id, -1) = nvl (pda.wip_repetitive_schedule_id, -1)
3099 AND wojv.wip_entity_name like (p_job)
3100 ORDER BY wojv.wip_entity_name;
3101 END IF;
3102 END get_job_lov;
3103
3104 PROCEDURE GET_PO_RELEASE_ITEM_LOV(x_po_release_num_lov OUT NOCOPY t_genref,
3105 p_organization_id IN NUMBER,
3106 p_po_header_id IN NUMBER,
3107 p_mobile_form IN VARCHAR2,
3108 p_po_release_num IN VARCHAR2,
3109 p_item_id IN NUMBER)
3110 IS
3111 po_release_number VARCHAR2(20);
3112 BEGIN
3113 BEGIN
3114 /* Start - Fix for Bug# 6640083 */
3115 -- po_release_number := to_char(to_number(p_po_release_num));
3116 -- This will convert String to number - Bug#6012703
3117 -- Commented the code for Bug#6640083
3118 SELECT TRIM(LEADING '0' FROM p_po_release_num ) INTO po_release_number FROM Dual;
3119 -- This will trim leading zeroes - Bug#6640083
3120 /* End - Fix for Bug# 6640083 */
3121 EXCEPTION
3122 WHEN OTHERS then
3123 po_release_number := p_po_release_num;
3124 END;
3125 IF p_mobile_form = 'RECEIPT' THEN
3126 OPEN x_po_release_num_lov FOR
3127 select distinct pr.release_num
3128 , pr.po_release_id
3129 , pr.release_date
3130 from po_releases_all pr
3131 , po_line_locations_all pll
3132 , po_lines_all pl
3133 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
3134 , mtl_parameters mp
3135 , rcv_parameters rp
3136 -- End for Bug 7440217
3137 where pr.po_header_id = p_po_header_id
3138 and nvl(pr.cancel_flag, 'N') = 'N'
3139 and nvl(pr.approved_flag, 'N') <> 'N'
3140 --and nvl(pr.closed_code, 'OPEN') NOT IN ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
3141 and nvl(pll.closed_code, 'OPEN') NOT IN ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED') --4350175
3142 AND pll.po_release_id = pr.po_release_id
3143 AND pll.po_header_id = pr.po_header_id
3144 AND pll.po_line_id = pl.po_line_id
3145 AND pll.po_header_id = pl.po_header_id
3146 AND ((p_item_id IS NOT NULL AND pl.item_id = p_item_id) OR
3147 p_item_id IS NULL)
3148 AND pr.release_num LIKE (po_release_number)
3149 -- For Bug 7440217 Checking if it is LCM enabled
3150 AND mp.organization_id = p_organization_id
3151 AND rp.organization_id = p_organization_id
3152 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
3153 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
3154 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
3155 )
3156 -- End for Bug 7440217
3157 order by pr.release_num;
3158 ELSE
3159 OPEN x_po_release_num_lov FOR
3160 select distinct pr.release_num
3161 , pr.po_release_id
3162 , pr.release_date
3163 from rcv_supply rsup
3164 , po_releases_all pr
3165 where rsup.po_header_id = p_po_header_id
3166 --AND pr.org_id = p_organization_id
3167 and nvl(pr.cancel_flag, 'N') = 'N'
3168 and nvl(pr.approved_flag, 'N') <> 'N'
3169 AND rsup.po_release_id = pr.po_release_id
3170 AND pr.release_num LIKE (po_release_number)
3171 order by pr.release_num;
3172 END IF;
3173 END GET_PO_RELEASE_ITEM_LOV;
3174
3175 -- Start of Bug 2442518
3176
3177 PROCEDURE GET_ITEM_LOV_RECEIVING (
3178 x_Items OUT NOCOPY t_genref,
3179 p_Organization_Id IN NUMBER,
3180 p_Concatenated_Segments IN VARCHAR2,
3181 p_poHeaderID IN VARCHAR2,
3182 p_poReleaseID IN VARCHAR2,
3183 p_poLineID IN VARCHAR2,
3184 p_shipmentHeaderID IN VARCHAR2,
3185 p_oeOrderHeaderID IN VARCHAR2,
3186 p_reqHeaderID IN VARCHAR2,
3187 p_projectId IN VARCHAR2,
3188 p_taskId IN VARCHAR2,
3189 p_pjmorg IN VARCHAR2,
3190 p_crossreftype IN VARCHAR2,
3191 p_from_lpn_id IN VARCHAR2
3192 )
3193
3194 IS
3195 -- Changes for GTIN CrossRef Type
3196 --
3197 g_gtin_cross_ref_type VARCHAR2(25) := fnd_profile.value('INV:GTIN_CROSS_REFERENCE_TYPE');
3198 g_gtin_code_length NUMBER := 14;
3199 g_crossref VARCHAR2(40) := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
3200 l_from_lpn_id VARCHAR2(400) := p_from_lpn_id;
3201
3202 BEGIN
3203
3204 -- if ( ( p_doctype = 'PO') or (p_doctype = 'RMA') or (p_doctype = 'REQ') or (p_doctype = 'SHIP') )
3205 -- then
3206
3207 if (p_poHeaderID is not null or
3208 p_poReleaseID is not null or
3209 p_oeOrderHeaderID is not null or
3210 p_shipmentHeaderID is not null or
3211 p_reqHeaderID is not null or
3212 p_projectId is not null or
3213 p_taskId is not null )
3214 then
3215
3216 IF (p_from_lpn_id IS NULL) THEN
3217 l_from_lpn_id := NULL;
3218 ELSIF (p_from_lpn_id IS NOT NULL AND p_from_lpn_id = '0') THEN
3219 l_from_lpn_id := NULL;
3220 END IF;
3221
3222 -- *****************************
3223 ---- Case for Document Info already entered in the session , txn starts with document ID
3224 -- *****************************
3225
3226 if (p_poHeaderID is not null ) then
3227 -- *****************************
3228 --- START OF PO HEADER ID SECTION
3229 -- *****************************
3230
3231 if ( p_pjmorg = 1) then --and ( p_projectId is not null ) ) then
3232
3233 -- *****************************
3234 ---- Start of PJM BASED Tran.
3235 -- *****************************
3236
3237 if (p_poReleaseID is not null) then
3238 -- *****************************
3239 --- releaseBased PJM Transaction
3240 -- *****************************
3241 open x_items for
3242 -- Bug# 6747729
3243 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
3244 select concatenated_segments,
3245 inventory_item_id,
3246 description,
3247 Nvl(revision_qty_control_code,1),
3248 Nvl(lot_control_code, 1),
3249 Nvl(serial_number_control_code, 1),
3250 Nvl(restrict_subinventories_code, 2),
3251 Nvl(restrict_locators_code, 2),
3252 Nvl(location_control_code, 1),
3253 primary_uom_code,
3254 Nvl(inspection_required_flag, 'N'),
3255 Nvl(shelf_life_code, 1),
3256 Nvl(shelf_life_days,0),
3257 Nvl(allowed_units_lookup_code, 2),
3258 Nvl(effectivity_control,1),
3259 0,
3260 0,
3261 Nvl(default_serial_status_id,1),
3262 Nvl(serial_status_enabled,'N'),
3263 Nvl(default_lot_status_id,0),
3264 Nvl(lot_status_enabled,'N'),
3265 '',
3266 'N',
3267 inventory_item_flag,
3268 0,
3269 inventory_asset_flag,
3270 outside_operation_flag,
3271 --Bug 3952081
3272 --Select DUOM Attributes for every Item
3273 NVL(GRADE_CONTROL_FLAG,'N'),
3274 NVL(DEFAULT_GRADE,''),
3275 NVL(EXPIRATION_ACTION_INTERVAL,0),
3276 NVL(EXPIRATION_ACTION_CODE,''),
3277 NVL(HOLD_DAYS,0),
3278 NVL(MATURITY_DAYS,0),
3279 NVL(RETEST_INTERVAL,0),
3280 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
3281 NVL(CHILD_LOT_FLAG,'N'),
3282 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
3283 NVL(LOT_DIVISIBLE_FLAG,'Y'),
3284 NVL(SECONDARY_UOM_CODE,''),
3285 NVL(SECONDARY_DEFAULT_IND,''),
3286 NVL(TRACKING_QUANTITY_IND,'P'),
3287 NVL(DUAL_UOM_DEVIATION_HIGH,0),
3288 NVL(DUAL_UOM_DEVIATION_LOW,0),
3289 stock_enabled_flag
3290 from mtl_system_items_vl /* Bug 5581528 */
3291 WHERE organization_id = p_Organization_Id
3292 and concatenated_segments like p_concatenated_segments
3293 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
3294 and inventory_item_id IN (SELECT pol.item_id FROM po_lines_all pol
3295 where pol.po_header_id = p_poHeaderID
3296 and exists (select 1
3297 from po_line_locations_all pll
3298 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
3299 , mtl_parameters mp,
3300 rcv_parameters rp
3301 -- End for Bug 7440217
3302 WHERE NVL(pll.closed_code,'OPEN')
3303 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED')
3304 and pll.po_header_id = p_poHeaderID
3305 and pll.po_release_id = p_poReleaseID
3306 and pll.po_line_id = pol.po_line_id
3307 and pll.ship_to_organization_id = p_Organization_Id
3308 -- For Bug 7440217 Checking if it is LCM enabled
3309 AND mp.organization_id = p_Organization_Id
3310 AND rp.organization_id = p_Organization_Id
3311 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
3312 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
3313 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
3314 )
3315 -- End for Bug 7440217
3316 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
3317 and exists (select 1 from po_distributions_all pd where pd.po_header_id = p_poHeaderID
3318 and pd.po_line_id = pol.po_line_id
3319 and pd.po_release_id = p_poReleaseID
3320 and ((p_projectId is null or pd.project_id = p_projectId)
3321 and (p_taskId is null or pd.task_id = p_taskId)
3322 )
3323 )
3324 )
3325 UNION ALL
3326 -- Substitute Item SQL
3327 -- Bug# 6747729
3328 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
3329 select distinct msi.concatenated_segments,
3330 msi.inventory_item_id,
3331 msi.description,
3332 Nvl(msi.revision_qty_control_code,1),
3333 Nvl(msi.lot_control_code, 1),
3334 Nvl(msi.serial_number_control_code, 1),
3335 Nvl(msi.restrict_subinventories_code, 2),
3336 Nvl(msi.restrict_locators_code,2),
3337 Nvl(msi.location_control_code,1),
3338 msi.primary_uom_code,
3339 Nvl(msi.inspection_required_flag,'N'),
3340 Nvl(msi.shelf_life_code, 1),
3341 Nvl(msi.shelf_life_days,0),
3342 Nvl(msi.allowed_units_lookup_code, 2),
3343 Nvl(msi.effectivity_control,1),
3344 0,
3345 0,
3346 Nvl(msi.default_serial_status_id,1),
3347 Nvl(msi.serial_status_enabled,'N'),
3348 Nvl(msi.default_lot_status_id,0),
3349 Nvl(msi.lot_status_enabled,'N'),
3350 msi.concatenated_segments,
3351 'S',
3352 msi.inventory_item_flag,
3353 0,
3354 msi.inventory_asset_flag,
3355 msi.outside_operation_flag,
3356 --Bug 3952081
3357 --Select DUOM Attributes for every Item
3358 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
3359 NVL(MSI.DEFAULT_GRADE,''),
3360 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
3361 NVL(MSI.EXPIRATION_ACTION_CODE,''),
3362 NVL(MSI.HOLD_DAYS,0),
3363 NVL(MSI.MATURITY_DAYS,0),
3364 NVL(MSI.RETEST_INTERVAL,0),
3365 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3366 NVL(MSI.CHILD_LOT_FLAG,'N'),
3367 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
3368 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
3369 NVL(MSI.SECONDARY_UOM_CODE,''),
3370 NVL(MSI.SECONDARY_DEFAULT_IND,''),
3371 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
3372 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
3373 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
3374 msi.stock_enabled_flag
3375 from po_lines_all pol
3376 ,mtl_related_items mri
3377 ,mtl_system_items_vl msi /* Bug 5581528 */
3378 /*,mtl_system_items_kfv msia */ /* Bug 6334679*/
3379 where msi.organization_id = p_organization_id
3380 and msi.concatenated_segments like p_concatenated_segments
3381 and pol.po_header_id = p_poHeaderID
3382 and pol.item_id = msi.inventory_item_id
3383 and msi.organization_id = p_organization_id
3384 and (( mri.related_item_id = msi.inventory_item_id
3385 and pol.item_id = mri.inventory_item_id) or
3386 ( mri.inventory_item_id = msi.inventory_item_id
3387 and pol.item_id = mri.related_item_id
3388 and mri.reciprocal_flag = 'Y'))
3389 and exists (select 1
3390 from po_line_locations_all pll
3391 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
3392 , mtl_parameters mp,
3393 rcv_parameters rp
3394 -- End for Bug 7440217
3395 where NVL(pll.closed_code,'OPEN')
3396 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED')
3397 and Nvl(pll.allow_substitute_receipts_flag, 'N') = 'Y'
3398 and pll.po_header_id = pol.po_header_id
3399 and pll.po_line_id = pol.po_line_id
3400 and pll.po_release_id = p_poReleaseID
3401 and pll.ship_to_organization_id = p_Organization_Id
3402 -- For Bug 7440217 Checking if it is LCM enabled
3403 AND mp.organization_id = p_Organization_Id
3404 AND rp.organization_id = p_Organization_Id
3405 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
3406 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
3407 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
3408 )
3409 -- End for Bug 7440217
3410 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
3411 and exists (select 1 from po_distributions_all pd where pd.po_header_id = p_poHeaderID
3412 and pd.po_line_id = pol.po_line_id
3413 and pd.po_release_id = p_poReleaseID
3414 and ((p_projectId is null or pd.project_id = p_projectId)
3415 and (p_taskId is null or pd.task_id = p_taskId)
3416 )
3417 )
3418 UNION ALL
3419 -- Vendor Item SQL
3420 -- Bug# 6747729
3421 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
3422 select distinct pol.vendor_product_num,
3423 msi.inventory_item_id,
3424 msi.description,
3425 Nvl(msi.revision_qty_control_code,1),
3426 Nvl(msi.lot_control_code, 1),
3427 Nvl(msi.serial_number_control_code, 1),
3428 Nvl(msi.restrict_subinventories_code, 2),
3429 Nvl(msi.restrict_locators_code,2),
3430 Nvl(msi.location_control_code,1),
3431 msi.primary_uom_code,
3432 Nvl(msi.inspection_required_flag,'N'),
3433 Nvl(msi.shelf_life_code, 1),
3434 Nvl(msi.shelf_life_days,0),
3435 Nvl(msi.allowed_units_lookup_code, 2),
3436 Nvl(msi.effectivity_control,1),
3437 0,
3438 0,
3439 Nvl(msi.default_serial_status_id,1),
3440 Nvl(msi.serial_status_enabled,'N'),
3441 Nvl(msi.default_lot_status_id,0),
3442 Nvl(msi.lot_status_enabled,'N'),
3443 msi.concatenated_segments,
3444 'Y',
3445 msi.inventory_item_flag,
3446 0,
3447 msi.inventory_asset_flag,
3448 msi.outside_operation_flag,
3449 --Bug 3952081
3450 --Select DUOM Attributes for every Item
3451 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
3452 NVL(MSI.DEFAULT_GRADE,''),
3453 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
3454 NVL(MSI.EXPIRATION_ACTION_CODE,''),
3455 NVL(MSI.HOLD_DAYS,0),
3456 NVL(MSI.MATURITY_DAYS,0),
3457 NVL(MSI.RETEST_INTERVAL,0),
3458 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3459 NVL(MSI.CHILD_LOT_FLAG,'N'),
3460 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
3461 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
3462 NVL(MSI.SECONDARY_UOM_CODE,''),
3463 NVL(MSI.SECONDARY_DEFAULT_IND,''),
3464 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
3465 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
3466 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
3467 msi.stock_enabled_flag
3468 from po_lines_all pol
3469 , mtl_system_items_vl msi /* Bug 5581528 */
3470 where organization_id = p_organization_id
3471 and pol.vendor_product_num like p_concatenated_segments
3472 and pol.item_id = msi.inventory_item_id
3473 and pol.vendor_product_num IS NOT NULL
3474 and pol.po_header_id = p_poHeaderID
3475 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
3476 and inventory_item_id IN (SELECT pol.item_id FROM po_lines_all pol
3477 where pol.po_header_id = p_poHeaderID
3478 and exists (select 1
3479 from po_line_locations_all pll
3480 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
3481 , mtl_parameters mp,
3482 rcv_parameters rp
3483 -- End for Bug 7440217
3484 WHERE NVL(pll.closed_code,'OPEN')
3485 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED')
3486 and pll.po_header_id = p_poHeaderID
3487 and pll.po_release_id = p_poReleaseID
3488 and pll.po_line_id = pol.po_line_id
3489 and pll.ship_to_organization_id = p_Organization_Id
3490 -- For Bug 7440217 Checking if it is LCM enabled
3491 AND mp.organization_id = p_Organization_Id
3492 AND rp.organization_id = p_Organization_Id
3493 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
3494 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
3495 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
3496 )
3497 -- End for Bug 7440217
3498 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
3499 and exists (select 1 from po_distributions_all pd where pd.po_header_id = p_poHeaderID
3500 and pd.po_line_id = pol.po_line_id
3501 and pd.po_release_id = p_poReleaseID
3502 and ((p_projectId is null or pd.project_id = p_projectId)
3503 and (p_taskId is null or pd.task_id = p_taskId)
3504 )
3505 )
3506 )
3507 UNION ALL
3508 -- non item Master
3509 -- Bug# 6747729
3510 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
3511 select distinct pol.item_description,
3512 to_number(''),
3513 pol.item_description,
3514 1,
3515 1,
3516 1,
3517 2,
3518 2,
3519 1,
3520 mum.uom_code,
3521 'N',
3522 1,
3523 0,
3524 2,
3525 1,
3526 0,
3527 0,
3528 1,
3529 'N',
3530 0,
3531 'N',
3532 '',
3533 'N',
3534 'N',
3535 0,
3536 to_char(NULL),
3537 'N' ,
3538 --Bug 3952081
3539 --Select DUOM Attributes for every Item
3540 'N',
3541 '',
3542 0,
3543 '',
3544 0,
3545 0,
3546 0,
3547 'N',
3548 'N',
3549 'N',
3550 'Y',
3551 '',
3552 '',
3553 'P',
3554 0,
3555 0,
3556 'N'
3557 from po_lines_all pol
3558 , mtl_units_of_measure mum
3559 -- Bug 2619063, 2614016
3560 -- Modified to select the base uom for the uom class defined on po.
3561 where mum.uom_class = (SELECT mum2.uom_class
3562 FROM mtl_units_of_measure mum2
3563 WHERE mum2.unit_of_measure(+) = pol.unit_meas_lookup_code)
3564 and mum.base_uom_flag = 'Y'
3565 and pol.ITEM_ID is null
3566 and pol.item_description is not null
3567 and pol.po_header_id = p_poHeaderID
3568 and pol.item_description like p_concatenated_segments
3569 and exists (select 1 from po_distributions_all pd where pd.po_header_id = p_poHeaderID
3570 and pd.po_line_id = pol.po_line_id
3571 and pd.po_release_id = p_poReleaseID
3572 and ((p_projectId is null or pd.project_id = p_projectId)
3573 and (p_taskId is null or pd.task_id = p_taskId)
3574 )
3575 )
3576 /* Bug 3972931-Added the following exists condition to restrict the PO receipt
3577 to shipments due to be received only in the organizationientered with.*/
3578 and exists (select 1
3579 from po_line_locations_all pll
3580 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
3581 , mtl_parameters mp,
3582 rcv_parameters rp
3583 -- End for Bug 7440217
3584 where pll.po_header_id = p_poHeaderID
3585 and pll.po_line_id = pol.po_line_id
3586 and pll.ship_to_organization_id = p_Organization_Id
3587 -- For Bug 7440217 Checking if it is LCM enabled
3588 AND mp.organization_id = p_Organization_Id
3589 AND rp.organization_id = p_Organization_Id
3590 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
3591 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
3592 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
3593 )
3594 -- End for Bug 7440217
3595 )
3596 --End of fix for Bug 3972931
3597 UNION ALL
3598 -- Cross Ref SQL
3599 -- Bug# 6747729
3600 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
3601 select distinct mcr.cross_reference,
3602 msi.inventory_item_id,
3603 msi.description,
3604 Nvl(msi.revision_qty_control_code,1),
3605 Nvl(msi.lot_control_code, 1),
3606 Nvl(msi.serial_number_control_code, 1),
3607 Nvl(msi.restrict_subinventories_code, 2),
3608 Nvl(msi.restrict_locators_code,2),
3609 Nvl(msi.location_control_code,1),
3610 msi.primary_uom_code,
3611 Nvl(msi.inspection_required_flag,'N'),
3612 Nvl(msi.shelf_life_code, 1),
3613 Nvl(msi.shelf_life_days,0),
3614 Nvl(msi.allowed_units_lookup_code, 2),
3615 Nvl(msi.effectivity_control,1),
3616 0,
3617 0,
3618 Nvl(msi.default_serial_status_id,1),
3619 Nvl(msi.serial_status_enabled,'N'),
3620 Nvl(msi.default_lot_status_id,0),
3621 Nvl(msi.lot_status_enabled,'N'),
3622 msi.concatenated_segments,
3623 'C',
3624 msi.inventory_item_flag,
3625 0,
3626 msi.inventory_asset_flag,
3627 msi.outside_operation_flag,
3628 --Bug 3952081
3629 --Select DUOM Attributes for every Item
3630 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
3631 NVL(MSI.DEFAULT_GRADE,''),
3632 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
3633 NVL(MSI.EXPIRATION_ACTION_CODE,''),
3634 NVL(MSI.HOLD_DAYS,0),
3635 NVL(MSI.MATURITY_DAYS,0),
3636 NVL(MSI.RETEST_INTERVAL,0),
3637 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3638 NVL(MSI.CHILD_LOT_FLAG,'N'),
3639 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
3640 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
3641 NVL(MSI.SECONDARY_UOM_CODE,''),
3642 NVL(MSI.SECONDARY_DEFAULT_IND,''),
3643 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
3644 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
3645 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
3646 msi.stock_enabled_flag
3647 from po_lines_all pol
3648 ,mtl_system_items_vl msi /* Bug 5581528 */
3649 ,mtl_cross_references mcr
3650 where msi.organization_id = p_organization_id
3651 and ( (mcr.cross_reference_type = p_crossreftype
3652 and mcr.cross_reference like p_concatenated_segments
3653 ) or
3654 ( mcr.cross_reference_type = g_gtin_cross_ref_type
3655 AND mcr.cross_reference LIKE g_crossref )
3656 )
3657 and ( (mcr.org_independent_flag = 'Y') or (mcr.org_independent_flag = 'N'
3658 and mcr.organization_id = p_organization_id
3659 ) )
3660 and mcr.inventory_item_id = msi.inventory_item_id
3661 and pol.item_id = msi.inventory_item_id
3662 and pol.po_header_id = p_poHeaderID
3663 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
3664 and msi.inventory_item_id IN (SELECT pol.item_id FROM po_lines_all pol
3665 where pol.po_header_id = p_poHeaderID
3666 and exists (select 1
3667 from po_line_locations_all pll
3668 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
3669 , mtl_parameters mp,
3670 rcv_parameters rp
3671 -- End for Bug 7440217
3672 WHERE NVL(pll.closed_code,'OPEN')
3673 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED')
3674 and pll.po_header_id = p_poHeaderID
3675 and pll.po_release_id = p_poReleaseID
3676 and pll.po_line_id = pol.po_line_id
3677 and pll.ship_to_organization_id = p_Organization_Id
3678 -- For Bug 7440217 Checking if it is LCM enabled
3679 AND mp.organization_id = p_Organization_Id
3680 AND rp.organization_id = p_Organization_Id
3681 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
3682 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
3683 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
3684 )
3685 -- End for Bug 7440217
3686 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
3687 and exists (select 1 from po_distributions_all pd where pd.po_header_id =
3688 p_poHeaderID
3689 and pd.po_line_id = pol.po_line_id
3690 and pd.po_release_id = p_poReleaseID
3691 and ((p_projectId is null or pd.project_id = p_projectId)
3692 and (p_taskId is null or pd.task_id = p_taskId)
3693 )
3694 )
3695 )
3696 ;
3697 elsif (p_poLineID IS NOT NULL) then
3698 -- *****************************
3699 ----- lineBased PJM Transaction
3700 -- *****************************
3701 open x_items for
3702 -- Bug# 6747729
3703 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
3704 select concatenated_segments,
3705 inventory_item_id,
3706 description,
3707 Nvl(revision_qty_control_code,1),
3708 Nvl(lot_control_code, 1),
3709 Nvl(serial_number_control_code, 1),
3710 Nvl(restrict_subinventories_code, 2),
3711 Nvl(restrict_locators_code, 2),
3712 Nvl(location_control_code, 1),
3713 primary_uom_code,
3714 Nvl(inspection_required_flag, 'N'),
3715 Nvl(shelf_life_code, 1),
3716 Nvl(shelf_life_days,0),
3717 Nvl(allowed_units_lookup_code, 2),
3718 Nvl(effectivity_control,1),
3719 0,
3720 0,
3721 Nvl(default_serial_status_id,1),
3722 Nvl(serial_status_enabled,'N'),
3723 Nvl(default_lot_status_id,0),
3724 Nvl(lot_status_enabled,'N'),
3725 '',
3726 'N',
3727 inventory_item_flag,
3728 0,
3729 inventory_asset_flag,
3730 outside_operation_flag,
3731 --Bug 3952081
3732 --Select DUOM Attributes for every Item
3733 NVL(GRADE_CONTROL_FLAG,'N'),
3734 NVL(DEFAULT_GRADE,''),
3735 NVL(EXPIRATION_ACTION_INTERVAL,0),
3736 NVL(EXPIRATION_ACTION_CODE,''),
3737 NVL(HOLD_DAYS,0),
3738 NVL(MATURITY_DAYS,0),
3739 NVL(RETEST_INTERVAL,0),
3740 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
3741 NVL(CHILD_LOT_FLAG,'N'),
3742 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
3743 NVL(LOT_DIVISIBLE_FLAG,'Y'),
3744 NVL(SECONDARY_UOM_CODE,''),
3745 NVL(SECONDARY_DEFAULT_IND,''),
3746 NVL(TRACKING_QUANTITY_IND,'P'),
3747 NVL(DUAL_UOM_DEVIATION_HIGH,0),
3748 NVL(DUAL_UOM_DEVIATION_LOW,0),
3749 stock_enabled_flag
3750 from mtl_system_items_vl /* Bug 5581528 */
3751 WHERE organization_id = p_Organization_Id
3752 and concatenated_segments like p_concatenated_segments
3753 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
3754 and inventory_item_id IN (SELECT pol.item_id FROM po_lines_all pol WHERE
3755 pol.po_header_id = p_poHeaderID
3756 and pol.po_line_id = p_poLineID
3757 and exists (select 1
3758 from po_line_locations_all pll
3759 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
3760 , mtl_parameters mp,
3761 rcv_parameters rp
3762 -- End for Bug 7440217
3763 where NVL(pll.closed_code, 'OPEN')
3764 not in ('FINALLY CLOSED' , 'CLOSED FOR RECEIVING', 'CLOSED' )
3765 and pll.po_header_id = p_poHeaderID
3766 and pll.po_line_id = p_poLineID
3767 and pll.ship_to_organization_id = p_Organization_Id
3768 -- For Bug 7440217 Checking if it is LCM enabled
3769 AND mp.organization_id = p_Organization_Id
3770 AND rp.organization_id = p_Organization_Id
3771 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
3772 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
3773 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
3774 )
3775 -- End for Bug 7440217
3776 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
3777 and exists (select 1 from po_distributions_all pd
3778 where pd.po_header_id = p_poHeaderID
3779 and pd.po_line_id = p_poLineID
3780 and pd.po_line_id = pol.po_line_id
3781 and ((p_projectId is null or pd.project_id = p_projectId)
3782 and (p_taskId is null or pd.task_id = p_taskId)
3783 )
3784 )
3785 )
3786 UNION ALL
3787 -- Substitute Item SQL
3788 -- Bug# 6747729
3789 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
3790 select distinct msi.concatenated_segments,
3791 msi.inventory_item_id,
3792 msi.description,
3793 Nvl(msi.revision_qty_control_code,1),
3794 Nvl(msi.lot_control_code, 1),
3795 Nvl(msi.serial_number_control_code, 1),
3796 Nvl(msi.restrict_subinventories_code, 2),
3797 Nvl(msi.restrict_locators_code,2),
3798 Nvl(msi.location_control_code,1),
3799 msi.primary_uom_code,
3800 Nvl(msi.inspection_required_flag,'N'),
3801 Nvl(msi.shelf_life_code, 1),
3802 Nvl(msi.shelf_life_days,0),
3803 Nvl(msi.allowed_units_lookup_code, 2),
3804 Nvl(msi.effectivity_control,1),
3805 0,
3806 0,
3807 Nvl(msi.default_serial_status_id,1),
3808 Nvl(msi.serial_status_enabled,'N'),
3809 Nvl(msi.default_lot_status_id,0),
3810 Nvl(msi.lot_status_enabled,'N'),
3811 msi.concatenated_segments,
3812 'S',
3813 msi.inventory_item_flag,
3814 0,
3815 msi.inventory_asset_flag,
3816 msi.outside_operation_flag ,
3817 --Bug 3952081
3818 --Select DUOM Attributes for every Item
3819 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
3820 NVL(MSI.DEFAULT_GRADE,''),
3821 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
3822 NVL(MSI.EXPIRATION_ACTION_CODE,''),
3823 NVL(MSI.HOLD_DAYS,0),
3824 NVL(MSI.MATURITY_DAYS,0),
3825 NVL(MSI.RETEST_INTERVAL,0),
3826 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3827 NVL(MSI.CHILD_LOT_FLAG,'N'),
3828 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
3829 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
3830 NVL(MSI.SECONDARY_UOM_CODE,''),
3831 NVL(MSI.SECONDARY_DEFAULT_IND,''),
3832 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
3833 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
3834 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
3835 msi.stock_enabled_flag
3836 from po_lines_all pol
3837 ,mtl_related_items mri
3838 ,mtl_system_items_vl msi /* Bug 5581528 */
3839 /*,mtl_system_items_kfv msia */ /* Bug 6334679 */
3840 where msi.organization_id = p_organization_id
3841 and msi.concatenated_segments like p_concatenated_segments
3842 and pol.po_header_id = p_poHeaderID
3843 and pol.item_id = msi.inventory_item_id
3844 and msi.organization_id = p_organization_id
3845 and (( mri.related_item_id = msi.inventory_item_id
3846 and pol.item_id = mri.inventory_item_id) or
3847 ( mri.inventory_item_id = msi.inventory_item_id
3848 and pol.item_id = mri.related_item_id
3849 and mri.reciprocal_flag = 'Y'))
3850 and pol.po_line_id = p_poLineID
3851 and exists (select 1
3852 from po_line_locations_all pll
3853 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
3854 , mtl_parameters mp,
3855 rcv_parameters rp
3856 -- End for Bug 7440217
3857 where NVL(pll.closed_code,'OPEN')
3858 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
3859 and Nvl(pll.allow_substitute_receipts_flag, 'N') = 'Y'
3860 and pll.po_header_id = pol.po_header_id
3861 and pll.po_line_id = pol.po_line_id
3862 and pll.ship_to_organization_id = p_Organization_Id
3863 -- For Bug 7440217 Checking if it is LCM enabled
3864 AND mp.organization_id = p_Organization_Id
3865 AND rp.organization_id = p_Organization_Id
3866 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
3867 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
3868 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
3869 )
3870 -- End for Bug 7440217
3871 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
3872 and exists ( select 1 from po_distributions_all pd
3873 where pd.po_header_id = p_poHeaderID
3874 and pd.po_line_id = p_poLineID
3875 and pd.po_line_id = pol.po_line_id
3876 and ((p_projectId is null or pd.project_id = p_projectId)
3877 and (p_taskId is null or pd.task_id = p_taskId)
3878 )
3879 )
3880 UNION ALL
3881 -- Vendor Item SQL
3882 -- Bug# 6747729
3883 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
3884 select distinct pol.vendor_product_num,
3885 msi.inventory_item_id,
3886 msi.description,
3887 Nvl(msi.revision_qty_control_code,1),
3888 Nvl(msi.lot_control_code, 1),
3889 Nvl(msi.serial_number_control_code, 1),
3890 Nvl(msi.restrict_subinventories_code, 2),
3891 Nvl(msi.restrict_locators_code,2),
3892 Nvl(msi.location_control_code,1),
3893 msi.primary_uom_code,
3894 Nvl(msi.inspection_required_flag,'N'),
3895 Nvl(msi.shelf_life_code, 1),
3896 Nvl(msi.shelf_life_days,0),
3897 Nvl(msi.allowed_units_lookup_code, 2),
3898 Nvl(msi.effectivity_control,1),
3899 0,
3900 0,
3901 Nvl(msi.default_serial_status_id,1),
3902 Nvl(msi.serial_status_enabled,'N'),
3903 Nvl(msi.default_lot_status_id,0),
3904 Nvl(msi.lot_status_enabled,'N'),
3905 msi.concatenated_segments,
3906 'Y',
3907 msi.inventory_item_flag,
3908 0,
3909 msi.inventory_asset_flag,
3910 msi.outside_operation_flag ,
3911 --Bug 3952081
3912 --Select DUOM Attributes for every Item
3913 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
3914 NVL(MSI.DEFAULT_GRADE,''),
3915 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
3916 NVL(MSI.EXPIRATION_ACTION_CODE,''),
3917 NVL(MSI.HOLD_DAYS,0),
3918 NVL(MSI.MATURITY_DAYS,0),
3919 NVL(MSI.RETEST_INTERVAL,0),
3920 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3921 NVL(MSI.CHILD_LOT_FLAG,'N'),
3922 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
3923 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
3924 NVL(MSI.SECONDARY_UOM_CODE,''),
3925 NVL(MSI.SECONDARY_DEFAULT_IND,''),
3926 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
3927 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
3928 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
3929 msi.stock_enabled_flag
3930 from po_lines_all pol
3931 , mtl_system_items_vl msi /* Bug 5581528 */
3932 where organization_id = p_organization_id
3933 and pol.vendor_product_num like p_concatenated_segments
3934 and pol.item_id = msi.inventory_item_id
3935 and pol.vendor_product_num IS NOT NULL
3936 and pol.po_header_id = p_poHeaderID
3937 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
3938 and inventory_item_id IN (SELECT pl.item_id FROM po_lines_all pl WHERE
3939 pl.po_header_id = p_poHeaderID
3940 and pl.po_line_id = p_poLineID
3941 and exists (select 1
3942 from po_line_locations_all pll
3943 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
3944 , mtl_parameters mp,
3945 rcv_parameters rp
3946 -- End for Bug 7440217
3947 where NVL(pll.closed_code, 'OPEN')
3948 not in ('FINALLY CLOSED' , 'CLOSED FOR RECEIVING' , 'CLOSED') -- 3687249
3949 and pll.po_header_id = p_poHeaderID
3950 and pll.po_line_id = p_poLineID
3951 and pll.ship_to_organization_id = p_Organization_Id
3952 -- For Bug 7440217 Checking if it is LCM enabled
3953 AND mp.organization_id = p_Organization_Id
3954 AND rp.organization_id = p_Organization_Id
3955 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
3956 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
3957 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
3958 )
3959 -- End for Bug 7440217
3960 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
3961 and exists (select 1 from po_distributions_all pd
3962 where pd.po_header_id = p_poHeaderID
3963 and pd.po_line_id = pol.po_line_id
3964 and pd.po_line_id = p_poLineID
3965 and ((p_projectId is null or pd.project_id = p_projectId)
3966 and (p_taskId is null or pd.task_id = p_taskId)
3967 )
3968 )
3969 )
3970 UNION ALL
3971 -- non item Master
3972 -- Bug# 6747729
3973 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
3974 select distinct pol.item_description,
3975 to_number(''),
3976 pol.item_description,
3977 1,
3978 1,
3979 1,
3980 2,
3981 2,
3982 1,
3983 mum.uom_code,
3984 'N',
3985 1,
3986 0,
3987 2,
3988 1,
3989 0,
3990 0,
3991 1,
3992 'N',
3993 0,
3994 'N',
3995 '',
3996 'N',
3997 'N',
3998 0,
3999 to_char(NULL),
4000 'N' ,
4001 --Bug 3952081
4002 --Select DUOM Attributes for every Item
4003 'N',
4004 '',
4005 0,
4006 '',
4007 0,
4008 0,
4009 0,
4010 'N',
4011 'N',
4012 'N',
4013 'Y',
4014 '',
4015 '',
4016 'P',
4017 0,
4018 0,
4019 'N'
4020 from po_lines_all pol
4021 , mtl_units_of_measure mum
4022 -- Bug 2619063, 2614016
4023 -- Modified to select the base uom for the uom class defined on po.
4024 where mum.uom_class = (SELECT mum2.uom_class
4025 FROM mtl_units_of_measure mum2
4026 WHERE mum2.unit_of_measure(+) = pol.unit_meas_lookup_code)
4027 and mum.base_uom_flag = 'Y'
4028 and pol.ITEM_ID is null
4029 and pol.item_description is not null
4030 and pol.po_header_id = p_poHeaderID
4031 and pol.item_description like p_concatenated_segments
4032 and exists ( select 1 from po_distributions_all pd
4033 where pd.po_header_id = p_poHeaderID
4034 and pd.po_line_id = p_poLineID
4035 and pd.po_line_id = pol.po_line_id
4036 and ((p_projectId is null or pd.project_id = p_projectId)
4037 and (p_taskId is null or pd.task_id = p_taskId)
4038 )
4039 )
4040 /* Bug 3972931-Added the following exists condition to restrict the PO receipt
4041 to shipments due to be received only in the organization entered with.*/
4042 and exists (select 1
4043 from po_line_locations_all pll
4044 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
4045 , mtl_parameters mp,
4046 rcv_parameters rp
4047 -- End for Bug 7440217
4048 where pll.po_header_id = p_poHeaderID
4049 and pll.po_line_id = pol.po_line_id
4050 and pll.ship_to_organization_id = p_Organization_Id
4051 -- For Bug 7440217 Checking if it is LCM enabled
4052 AND mp.organization_id = p_Organization_Id
4053 AND rp.organization_id = p_Organization_Id
4054 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
4055 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
4056 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
4057 )
4058 -- End for Bug 7440217
4059 )
4060 --End of fix for Bug 3972931
4061 UNION ALL
4062 -- Cross Ref SQL
4063 -- Bug# 6747729
4064 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
4065 select distinct mcr.cross_reference,
4066 msi.inventory_item_id,
4067 msi.description,
4068 Nvl(msi.revision_qty_control_code,1),
4069 Nvl(msi.lot_control_code, 1),
4070 Nvl(msi.serial_number_control_code, 1),
4071 Nvl(msi.restrict_subinventories_code, 2),
4072 Nvl(msi.restrict_locators_code,2),
4073 Nvl(msi.location_control_code,1),
4074 msi.primary_uom_code,
4075 Nvl(msi.inspection_required_flag,'N'),
4076 Nvl(msi.shelf_life_code, 1),
4077 Nvl(msi.shelf_life_days,0),
4078 Nvl(msi.allowed_units_lookup_code, 2),
4079 Nvl(msi.effectivity_control,1),
4080 0,
4081 0,
4082 Nvl(msi.default_serial_status_id,1),
4083 Nvl(msi.serial_status_enabled,'N'),
4084 Nvl(msi.default_lot_status_id,0),
4085 Nvl(msi.lot_status_enabled,'N'),
4086 msi.concatenated_segments,
4087 'C',
4088 msi.inventory_item_flag,
4089 0,
4090 msi.inventory_asset_flag,
4091 msi.outside_operation_flag,
4092 --Bug 3952081
4093 --Select DUOM Attributes for every Item
4094 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
4095 NVL(MSI.DEFAULT_GRADE,''),
4096 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
4097 NVL(MSI.EXPIRATION_ACTION_CODE,''),
4098 NVL(MSI.HOLD_DAYS,0),
4099 NVL(MSI.MATURITY_DAYS,0),
4100 NVL(MSI.RETEST_INTERVAL,0),
4101 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4102 NVL(MSI.CHILD_LOT_FLAG,'N'),
4103 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
4104 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
4105 NVL(MSI.SECONDARY_UOM_CODE,''),
4106 NVL(MSI.SECONDARY_DEFAULT_IND,''),
4107 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
4108 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
4109 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
4110 msi.stock_enabled_flag
4111 from po_lines_all pol
4112 ,mtl_system_items_vl msi /* Bug 5581528 */
4113 ,mtl_cross_references mcr
4114 where msi.organization_id = p_organization_id
4115 and ( (mcr.cross_reference_type = p_crossreftype
4116 and mcr.cross_reference like p_concatenated_segments
4117 ) or
4118 ( mcr.cross_reference_type = g_gtin_cross_ref_type
4119 AND mcr.cross_reference LIKE g_crossref )
4120 )
4121 and ( (mcr.org_independent_flag = 'Y') or (mcr.org_independent_flag = 'N'
4122 and mcr.organization_id = p_organization_id
4123 ) )
4124 and mcr.inventory_item_id = msi.inventory_item_id
4125 and pol.item_id = msi.inventory_item_id
4126 and pol.po_header_id = p_poHeaderID
4127 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
4128 and msi.inventory_item_id IN (SELECT pl.item_id FROM po_lines_all pl WHERE
4129 pl.po_header_id = p_poHeaderID
4130 and pl.po_line_id = p_poLineID
4131 and exists (select 1
4132 from po_line_locations_all pll
4133 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
4134 , mtl_parameters mp,
4135 rcv_parameters rp
4136 -- End for Bug 7440217
4137 where NVL(pll.closed_code, 'OPEN')
4138 not in ('FINALLY CLOSED' , 'CLOSED FOR RECEIVING', 'CLOSED' ) -- 3687249
4139 and pll.po_header_id = p_poHeaderID
4140 and pll.po_line_id = p_poLineID
4141 and pll.ship_to_organization_id = p_Organization_Id
4142 -- For Bug 7440217 Checking if it is LCM enabled
4143 AND mp.organization_id = p_Organization_Id
4144 AND rp.organization_id = p_Organization_Id
4145 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
4146 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
4147 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
4148 )
4149 -- End for Bug 7440217
4150 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
4151 and exists (select 1 from po_distributions_all pd
4152 where pd.po_header_id = p_poHeaderID
4153 and pd.po_line_id = pol.po_line_id
4154 and pd.po_line_id = p_poLineID
4155 and ((p_projectId is null or pd.project_id = p_projectId)
4156 and (p_taskId is null or pd.task_id = p_taskId)
4157 )
4158 )
4159 )
4160 ;
4161 else
4162 -- *****************************
4163 --- headerBased PJM Transaction
4164 -- Bug 4602289
4165 -- In the first query PO_LINES_ALL is
4166 -- joined to enforce a nested loop
4167 -- which would perform better for queries
4168 -- with/without item
4169 -- HeaderBased PJM PO_LINES_U2 is enforced
4170 -- In the query for Vendor item
4171 --
4172 -- *****************************
4173 open x_items for
4174 -- Bug# 6747729
4175 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
4176 select concatenated_segments,
4177 inventory_item_id,
4178 description,
4179 Nvl(revision_qty_control_code,1),
4180 Nvl(lot_control_code, 1),
4181 Nvl(serial_number_control_code, 1),
4182 Nvl(restrict_subinventories_code, 2),
4183 Nvl(restrict_locators_code, 2),
4184 Nvl(location_control_code, 1),
4185 primary_uom_code,
4186 Nvl(mtl_system_items_vl.inspection_required_flag, 'N'), -- bug 4610452
4187 Nvl(shelf_life_code, 1),
4188 Nvl(shelf_life_days,0),
4189 Nvl(allowed_units_lookup_code, 2),
4190 Nvl(effectivity_control,1),
4191 0,
4192 0,
4193 Nvl(default_serial_status_id,1),
4194 Nvl(serial_status_enabled,'N'),
4195 Nvl(default_lot_status_id,0),
4196 Nvl(lot_status_enabled,'N'),
4197 '',
4198 'N',
4199 inventory_item_flag,
4200 0,
4201 inventory_asset_flag,
4202 outside_operation_flag,
4203 --Bug 3952081
4204 --Select DUOM Attributes for every Item
4205 NVL(GRADE_CONTROL_FLAG,'N'),
4206 NVL(DEFAULT_GRADE,''),
4207 NVL(EXPIRATION_ACTION_INTERVAL,0),
4208 NVL(EXPIRATION_ACTION_CODE,''),
4209 NVL(HOLD_DAYS,0),
4210 NVL(MATURITY_DAYS,0),
4211 NVL(RETEST_INTERVAL,0),
4212 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
4213 NVL(CHILD_LOT_FLAG,'N'),
4214 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
4215 NVL(LOT_DIVISIBLE_FLAG,'Y'),
4216 NVL(SECONDARY_UOM_CODE,''),
4217 NVL(SECONDARY_DEFAULT_IND,''),
4218 NVL(TRACKING_QUANTITY_IND,'P'),
4219 NVL(DUAL_UOM_DEVIATION_HIGH,0),
4220 NVL(DUAL_UOM_DEVIATION_LOW,0),
4221 stock_enabled_flag
4222 from mtl_system_items_vl , /* Bug 5581528 */
4223 po_lines_all pol -- bug 4602289
4224 WHERE organization_id = p_Organization_Id
4225 and concatenated_segments like p_concatenated_segments
4226 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
4227 and inventory_item_id = pol.item_id -- bug 4602289
4228 and pol.po_header_id = p_poHeaderID -- bug 4602289
4229 and exists (select 1
4230 from po_line_locations_all pll
4231 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
4232 , mtl_parameters mp,
4233 rcv_parameters rp
4234 -- End for Bug 7440217
4235 where NVL(pll.closed_code,'OPEN')
4236 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED')
4237 and pll.po_header_id = p_poHeaderID
4238 and pll.po_line_id = pol.po_line_id
4239 and pll.ship_to_organization_id = p_Organization_Id
4240 -- For Bug 7440217 Checking if it is LCM enabled
4241 AND mp.organization_id = p_Organization_Id
4242 AND rp.organization_id = p_Organization_Id
4243 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
4244 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
4245 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
4246 )
4247 -- End for Bug 7440217
4248 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
4249 and exists
4250 (select 1 from po_distributions_all pd
4251 where pd.po_header_id = p_poHeaderID
4252 and pd.po_line_id = pol.po_line_id
4253 and ((p_projectId is null or pd.project_id = p_projectId)
4254 and (p_taskId is null or pd.task_id = p_taskId)
4255 )
4256 )
4257
4258 UNION ALL
4259 -- Substitute Item SQL
4260 -- Bug# 6747729
4261 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
4262 select distinct msi.concatenated_segments,
4263 msi.inventory_item_id,
4264 msi.description,
4265 Nvl(msi.revision_qty_control_code,1),
4266 Nvl(msi.lot_control_code, 1),
4267 Nvl(msi.serial_number_control_code, 1),
4268 Nvl(msi.restrict_subinventories_code, 2),
4269 Nvl(msi.restrict_locators_code,2),
4270 Nvl(msi.location_control_code,1),
4271 msi.primary_uom_code,
4272 Nvl(msi.inspection_required_flag,'N'),
4273 Nvl(msi.shelf_life_code, 1),
4274 Nvl(msi.shelf_life_days,0),
4275 Nvl(msi.allowed_units_lookup_code, 2),
4276 Nvl(msi.effectivity_control,1),
4277 0,
4278 0,
4279 Nvl(msi.default_serial_status_id,1),
4280 Nvl(msi.serial_status_enabled,'N'),
4281 Nvl(msi.default_lot_status_id,0),
4282 Nvl(msi.lot_status_enabled,'N'),
4283 msi.concatenated_segments,
4284 'S',
4285 msi.inventory_item_flag,
4286 0,
4287 msi.inventory_asset_flag,
4288 msi.outside_operation_flag ,
4289 --Bug 3952081
4290 --Select DUOM Attributes for every Item
4291 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
4292 NVL(MSI.DEFAULT_GRADE,''),
4293 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
4294 NVL(MSI.EXPIRATION_ACTION_CODE,''),
4295 NVL(MSI.HOLD_DAYS,0),
4296 NVL(MSI.MATURITY_DAYS,0),
4297 NVL(MSI.RETEST_INTERVAL,0),
4298 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4299 NVL(MSI.CHILD_LOT_FLAG,'N'),
4300 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
4301 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
4302 NVL(MSI.SECONDARY_UOM_CODE,''),
4303 NVL(MSI.SECONDARY_DEFAULT_IND,''),
4304 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
4305 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
4306 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
4307 msi.stock_enabled_flag
4308 from po_lines_all pol
4309 ,mtl_related_items mri
4310 ,mtl_system_items_vl msi /* Bug 5581528 */
4311 /*,mtl_system_items_kfv msia */ /* Bug 6334679 */
4312 where msi.organization_id = p_organization_id
4313 and msi.concatenated_segments like p_concatenated_segments
4314 and pol.po_header_id = p_poHeaderID
4315 and pol.item_id = msi.inventory_item_id
4316 and msi.organization_id = p_organization_id
4317 and (( mri.related_item_id = msi.inventory_item_id
4318 and pol.item_id = mri.inventory_item_id) or
4319 ( mri.inventory_item_id = msi.inventory_item_id
4320 and pol.item_id = mri.related_item_id
4321 and mri.reciprocal_flag = 'Y'))
4322 and exists (select 1
4323 from po_line_locations_all pll
4324 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
4325 , mtl_parameters mp,
4326 rcv_parameters rp
4327 -- End for Bug 7440217
4328 where NVL(pll.closed_code,'OPEN') not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED')
4329 and Nvl(pll.allow_substitute_receipts_flag, 'N') = 'Y'
4330 and pll.po_header_id = pol.po_header_id
4331 and pll.po_line_id = pol.po_line_id
4332 and pll.ship_to_organization_id = p_Organization_Id
4333 -- For Bug 7440217 Checking if it is LCM enabled
4334 AND mp.organization_id = p_Organization_Id
4335 AND rp.organization_id = p_Organization_Id
4336 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
4337 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
4338 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
4339 )
4340 -- End for Bug 7440217
4341 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
4342 and exists
4343 (select 1 from po_distributions_all pd
4344 where pd.po_header_id = p_poHeaderID
4345 and pd.po_line_id = pol.po_line_id
4346 and ((p_projectId is null or pd.project_id = p_projectId)
4347 and (p_taskId is null or pd.task_id = p_taskId)
4348 )
4349 )
4350 UNION ALL
4351 -- Vendor Item SQL
4352 -- Bug# 6747729
4353 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
4354 select /*+ INDEX(PO_LINES_ALL PO_LINES_U2) */ --bug 4602289
4355 distinct pol.vendor_product_num,
4356 msi.inventory_item_id,
4357 msi.description,
4358 Nvl(msi.revision_qty_control_code,1),
4359 Nvl(msi.lot_control_code, 1),
4360 Nvl(msi.serial_number_control_code, 1),
4361 Nvl(msi.restrict_subinventories_code, 2),
4362 Nvl(msi.restrict_locators_code,2),
4363 Nvl(msi.location_control_code,1),
4364 msi.primary_uom_code,
4365 Nvl(msi.inspection_required_flag,'N'),
4366 Nvl(msi.shelf_life_code, 1),
4367 Nvl(msi.shelf_life_days,0),
4368 Nvl(msi.allowed_units_lookup_code, 2),
4369 Nvl(msi.effectivity_control,1),
4370 0,
4371 0,
4372 Nvl(msi.default_serial_status_id,1),
4373 Nvl(msi.serial_status_enabled,'N'),
4374 Nvl(msi.default_lot_status_id,0),
4375 Nvl(msi.lot_status_enabled,'N'),
4376 msi.concatenated_segments,
4377 'Y',
4378 msi.inventory_item_flag,
4379 0,
4380 msi.inventory_asset_flag,
4381 msi.outside_operation_flag ,
4382 --Bug 3952081
4383 --Select DUOM Attributes for every Item
4384 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
4385 NVL(MSI.DEFAULT_GRADE,''),
4386 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
4387 NVL(MSI.EXPIRATION_ACTION_CODE,''),
4388 NVL(MSI.HOLD_DAYS,0),
4389 NVL(MSI.MATURITY_DAYS,0),
4390 NVL(MSI.RETEST_INTERVAL,0),
4391 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4392 NVL(MSI.CHILD_LOT_FLAG,'N'),
4393 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
4394 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
4395 NVL(MSI.SECONDARY_UOM_CODE,''),
4396 NVL(MSI.SECONDARY_DEFAULT_IND,''),
4397 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
4398 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
4399 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
4400 msi.stock_enabled_flag
4401 from po_lines_all pol
4402 , mtl_system_items_vl msi /* Bug 5581528 */
4403 where organization_id = p_organization_id
4404 and pol.vendor_product_num like p_concatenated_segments
4405 and pol.item_id = msi.inventory_item_id
4406 and pol.vendor_product_num IS NOT NULL
4407 and pol.po_header_id = p_poHeaderID
4408 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
4409 and inventory_item_id IN
4410 ( SELECT pl.item_id FROM po_lines_all pl WHERE pl.po_header_id =
4411 p_poHeaderID
4412 and exists (select 1
4413 from po_line_locations_all pll
4414 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
4415 , mtl_parameters mp,
4416 rcv_parameters rp
4417 -- End for Bug 7440217
4418 where NVL(pll.closed_code,'OPEN') not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED')
4419 and pll.po_header_id = p_poHeaderID
4420 and pll.po_line_id = pl.po_line_id
4421 and pll.ship_to_organization_id = p_Organization_Id
4422 -- For Bug 7440217 Checking if it is LCM enabled
4423 AND mp.organization_id = p_Organization_Id
4424 AND rp.organization_id = p_Organization_Id
4425 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
4426 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
4427 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
4428 )
4429 -- End for Bug 7440217
4430 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
4431 and exists
4432 (select 1 from po_distributions_all pd
4433 where pd.po_header_id = p_poHeaderID
4434 and pd.po_line_id = pol.po_line_id
4435 and ((p_projectId is null or pd.project_id = p_projectId)
4436 and (p_taskId is null or pd.task_id = p_taskId)
4437 )
4438 )
4439 )
4440 UNION ALL
4441 -- non item Master
4442 -- Bug# 6747729
4443 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
4444 select distinct pol.item_description,
4445 to_number(''),
4446 pol.item_description,
4447 1,
4448 1,
4449 1,
4450 2,
4451 2,
4452 1,
4453 mum.uom_code,
4454 'N',
4455 1,
4456 0,
4457 2,
4458 1,
4459 0,
4460 0,
4461 1,
4462 'N',
4463 0,
4464 'N',
4465 '',
4466 'N',
4467 'N',
4468 0,
4469 to_char(NULL),
4470 'N' ,
4471 --Bug 3952081
4472 --Select DUOM Attributes for every Item
4473 'N',
4474 '',
4475 0,
4476 '',
4477 0,
4478 0,
4479 0,
4480 'N',
4481 'N',
4482 'N',
4483 'Y',
4484 '',
4485 '',
4486 'P',
4487 0,
4488 0,
4489 'N'
4490 from po_lines_all pol
4491 , mtl_units_of_measure mum
4492 -- Bug 2619063, 2614016
4493 -- Modified to select the base uom for the uom class defined on po.
4494 where mum.uom_class = (SELECT mum2.uom_class
4495 FROM mtl_units_of_measure mum2
4496 WHERE mum2.unit_of_measure(+) = pol.unit_meas_lookup_code)
4497 and mum.base_uom_flag = 'Y'
4498 and pol.ITEM_ID is null
4499 and pol.item_description is not null
4500 and pol.po_header_id = p_poHeaderID
4501 and pol.item_description like p_concatenated_segments
4502 and exists
4503 (select 1 from po_distributions_all pd
4504 where pd.po_header_id = p_poHeaderID
4505 and pd.po_line_id = pol.po_line_id
4506 and ((p_projectId is null or pd.project_id = p_projectId)
4507 and (p_taskId is null or pd.task_id = p_taskId)
4508 )
4509 )
4510 /* Bug 3972931-Added the following exists condition to restrict the PO receipt
4511 to shipments due to be received only in the organizationientered with.*/
4512 and exists (select 1
4513 from po_line_locations_all pll
4514 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
4515 , mtl_parameters mp,
4516 rcv_parameters rp
4517 -- End for Bug 7440217
4518 where pll.po_header_id = p_poHeaderID
4519 and pll.po_line_id = pol.po_line_id
4520 and pll.ship_to_organization_id = p_Organization_Id
4521 -- For Bug 7440217 Checking if it is LCM enabled
4522 AND mp.organization_id = p_Organization_Id
4523 AND rp.organization_id = p_Organization_Id
4524 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
4525 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
4526 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
4527 )
4528 -- End for Bug 7440217
4529 )
4530 --End of fix for Bug 3972931
4531 UNION ALL
4532 -- Cross Ref SQL
4533 -- Bug# 6747729
4534 -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
4535 select distinct mcr.cross_reference,
4536 msi.inventory_item_id,
4537 msi.description,
4538 Nvl(msi.revision_qty_control_code,1),
4539 Nvl(msi.lot_control_code, 1),
4540 Nvl(msi.serial_number_control_code, 1),
4541 Nvl(msi.restrict_subinventories_code, 2),
4542 Nvl(msi.restrict_locators_code,2),
4543 Nvl(msi.location_control_code,1),
4544 msi.primary_uom_code,
4545 Nvl(msi.inspection_required_flag,'N'),
4546 Nvl(msi.shelf_life_code, 1),
4547 Nvl(msi.shelf_life_days,0),
4548 Nvl(msi.allowed_units_lookup_code, 2),
4549 Nvl(msi.effectivity_control,1),
4550 0,
4551 0,
4552 Nvl(msi.default_serial_status_id,1),
4553 Nvl(msi.serial_status_enabled,'N'),
4554 Nvl(msi.default_lot_status_id,0),
4555 Nvl(msi.lot_status_enabled,'N'),
4556 msi.concatenated_segments,
4557 'C',
4558 msi.inventory_item_flag,
4559 0,
4560 msi.inventory_asset_flag,
4561 msi.outside_operation_flag,
4562 --Bug 3952081
4563 --Select DUOM Attributes for every Item
4564 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
4565 NVL(MSI.DEFAULT_GRADE,''),
4566 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
4567 NVL(MSI.EXPIRATION_ACTION_CODE,''),
4568 NVL(MSI.HOLD_DAYS,0),
4569 NVL(MSI.MATURITY_DAYS,0),
4570 NVL(MSI.RETEST_INTERVAL,0),
4571 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4572 NVL(MSI.CHILD_LOT_FLAG,'N'),
4573 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
4574 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
4575 NVL(MSI.SECONDARY_UOM_CODE,''),
4576 NVL(MSI.SECONDARY_DEFAULT_IND,''),
4577 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
4578 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
4579 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
4580 msi.stock_enabled_flag
4581 from po_lines_all pol
4582 ,mtl_system_items_vl msi /* Bug 5581528 */
4583 ,mtl_cross_references mcr
4584 where msi.organization_id = p_organization_id
4585 and ( (mcr.cross_reference_type = p_crossreftype
4586 and mcr.cross_reference like p_concatenated_segments
4587 ) or
4588 ( mcr.cross_reference_type = g_gtin_cross_ref_type
4589 AND mcr.cross_reference LIKE g_crossref )
4590 )
4591 and ( (mcr.org_independent_flag = 'Y') or (mcr.org_independent_flag = 'N'
4592 and mcr.organization_id = p_organization_id
4593 ) )
4594 and mcr.inventory_item_id = msi.inventory_item_id
4595 and pol.item_id = msi.inventory_item_id
4596 and pol.po_header_id = p_poHeaderID
4597 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
4598 and msi.inventory_item_id IN
4599 ( SELECT pl.item_id FROM po_lines_all pl WHERE pl.po_header_id =
4600 p_poHeaderID
4601 and exists (select 1
4602 from po_line_locations_all pll
4603 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
4604 , mtl_parameters mp,
4605 rcv_parameters rp
4606 -- End for Bug 7440217
4607 where NVL(pll.closed_code,'OPEN')
4608 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
4609 and pll.po_header_id = p_poHeaderID and pll.po_line_id = pl.po_line_id
4610 and pll.ship_to_organization_id = p_Organization_Id
4611 -- For Bug 7440217 Checking if it is LCM enabled
4612 AND mp.organization_id = p_Organization_Id
4613 AND rp.organization_id = p_Organization_Id
4614 AND ( (NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
4615 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
4616 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
4617 )
4618 -- End for Bug 7440217
4619 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
4620 and exists (select 1
4621 from po_distributions_all pd
4622 where pd.po_header_id = p_poHeaderID
4623 and pd.po_line_id = pol.po_line_id
4624 and ((p_projectId is null or pd.project_id = p_projectId)
4625 and (p_taskId is null or pd.task_id = p_taskId)
4626 )
4627 )
4628 )
4629 ;
4630 end if;
4631 -- End of PJM Based Tran
4632 else
4633
4634 -- *****************************
4635 --- Start of not PJM BASED Tran.
4636 -- *****************************
4637
4638 if (p_poReleaseID is not null) then
4639 -- *****************************
4640 -- Release Based Transaction
4641 -- *****************************
4642 open x_items for
4643 -- Bug# 6747729
4644 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
4645 select concatenated_segments,
4646 inventory_item_id,
4647 description,
4648 Nvl(revision_qty_control_code,1),
4649 Nvl(lot_control_code, 1),
4650 Nvl(serial_number_control_code, 1),
4651 Nvl(restrict_subinventories_code, 2),
4652 Nvl(restrict_locators_code, 2),
4653 Nvl(location_control_code, 1),
4654 primary_uom_code,
4655 Nvl(inspection_required_flag, 'N'),
4656 Nvl(shelf_life_code, 1),
4657 Nvl(shelf_life_days,0),
4658 Nvl(allowed_units_lookup_code, 2),
4659 Nvl(effectivity_control,1),
4660 0,
4661 0,
4662 Nvl(default_serial_status_id,1),
4663 Nvl(serial_status_enabled,'N'),
4664 Nvl(default_lot_status_id,0),
4665 Nvl(lot_status_enabled,'N'),
4666 '',
4667 'N',
4668 inventory_item_flag,
4669 0,
4670 inventory_asset_flag,
4671 outside_operation_flag,
4672 --Bug 3952081
4673 --Select DUOM Attributes for every Item
4674 NVL(GRADE_CONTROL_FLAG,'N'),
4675 NVL(DEFAULT_GRADE,''),
4676 NVL(EXPIRATION_ACTION_INTERVAL,0),
4677 NVL(EXPIRATION_ACTION_CODE,''),
4678 NVL(HOLD_DAYS,0),
4679 NVL(MATURITY_DAYS,0),
4680 NVL(RETEST_INTERVAL,0),
4681 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
4682 NVL(CHILD_LOT_FLAG,'N'),
4683 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
4684 NVL(LOT_DIVISIBLE_FLAG,'Y'),
4685 NVL(SECONDARY_UOM_CODE,''),
4686 NVL(SECONDARY_DEFAULT_IND,''),
4687 NVL(TRACKING_QUANTITY_IND,'P'),
4688 NVL(DUAL_UOM_DEVIATION_HIGH,0),
4689 NVL(DUAL_UOM_DEVIATION_LOW,0),
4690 stock_enabled_flag
4691 from mtl_system_items_vl /* Bug 5581528 */
4692 WHERE organization_id = p_Organization_Id
4693 and concatenated_segments like p_concatenated_segments
4694 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
4695 and inventory_item_id IN (SELECT pol.item_id FROM po_lines_all pol
4696 where pol.po_header_id = p_poHeaderID
4697 and exists (select 1
4698 from po_line_locations_all pll
4699 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
4700 , mtl_parameters mp,
4701 rcv_parameters rp
4702 -- End for Bug 7440217
4703 WHERE NVL(pll.closed_code,'OPEN')
4704 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED')
4705 and pll.po_header_id = p_poHeaderID
4706 and pll.po_release_id = p_poReleaseID
4707 and pll.po_line_id = pol.po_line_id
4708 and pll.ship_to_organization_id = p_Organization_Id
4709 -- For Bug 7440217 Checking if it is LCM enabled
4710 AND mp.organization_id = p_organization_id
4711 AND rp.organization_id = p_organization_id
4712 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
4713 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
4714 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
4715 )
4716 -- End for Bug 7440217
4717 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
4718 )
4719 UNION ALL
4720 -- Substitute ITEM SQL
4721 -- Bug# 6747729
4722 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
4723 select distinct msi.concatenated_segments,
4724 msi.inventory_item_id,
4725 msi.description,
4726 Nvl(msi.revision_qty_control_code,1),
4727 Nvl(msi.lot_control_code, 1),
4728 Nvl(msi.serial_number_control_code, 1),
4729 Nvl(msi.restrict_subinventories_code, 2),
4730 Nvl(msi.restrict_locators_code,2),
4731 Nvl(msi.location_control_code,1),
4732 msi.primary_uom_code,
4733 Nvl(msi.inspection_required_flag,'N'),
4734 Nvl(msi.shelf_life_code, 1),
4735 Nvl(msi.shelf_life_days,0),
4736 Nvl(msi.allowed_units_lookup_code, 2),
4737 Nvl(msi.effectivity_control,1),
4738 0,
4739 0,
4740 Nvl(msi.default_serial_status_id,1),
4741 Nvl(msi.serial_status_enabled,'N'),
4742 Nvl(msi.default_lot_status_id,0),
4743 Nvl(msi.lot_status_enabled,'N'),
4744 msi.concatenated_segments,
4745 'S',
4746 msi.inventory_item_flag,
4747 0,
4748 msi.inventory_asset_flag,
4749 msi.outside_operation_flag ,
4750 --Bug 3952081
4751 --Select DUOM Attributes for every Item
4752 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
4753 NVL(MSI.DEFAULT_GRADE,''),
4754 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
4755 NVL(MSI.EXPIRATION_ACTION_CODE,''),
4756 NVL(MSI.HOLD_DAYS,0),
4757 NVL(MSI.MATURITY_DAYS,0),
4758 NVL(MSI.RETEST_INTERVAL,0),
4759 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4760 NVL(MSI.CHILD_LOT_FLAG,'N'),
4761 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
4762 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
4763 NVL(MSI.SECONDARY_UOM_CODE,''),
4764 NVL(MSI.SECONDARY_DEFAULT_IND,''),
4765 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
4766 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
4767 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
4768 msi.stock_enabled_flag
4769 from po_lines_all pol
4770 ,mtl_related_items mri
4771 ,mtl_system_items_vl msi /* Bug 5581528 */
4772 /*,mtl_system_items_kfv msia */ /* Bug 6334679 */
4773 where msi.organization_id = p_organization_id
4774 and msi.concatenated_segments like p_concatenated_segments
4775 and pol.po_header_id = p_poHeaderID
4776 and pol.item_id = msi.inventory_item_id
4777 and msi.organization_id = p_organization_id
4778 and (( mri.related_item_id = msi.inventory_item_id
4779 and pol.item_id = mri.inventory_item_id) or
4780 ( mri.inventory_item_id = msi.inventory_item_id
4781 and pol.item_id = mri.related_item_id
4782 and mri.reciprocal_flag = 'Y'))
4783 and exists (select 1
4784 from po_line_locations_all pll
4785 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
4786 , mtl_parameters mp,
4787 rcv_parameters rp
4788 -- End for Bug 7440217
4789 where NVL(pll.closed_code,'OPEN')
4790 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
4791 and Nvl(pll.allow_substitute_receipts_flag, 'N') = 'Y'
4792 and pll.po_header_id = pol.po_header_id
4793 and pll.po_line_id = pol.po_line_id
4794 and pll.po_release_id = p_poReleaseID
4795 and pll.ship_to_organization_id = p_Organization_Id
4796 -- For Bug 7440217 Checking if it is LCM enabled
4797 AND mp.organization_id = p_organization_id
4798 AND rp.organization_id = p_organization_id
4799 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
4800 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
4801 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
4802 )
4803 -- End for Bug 7440217
4804 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
4805 UNION ALL
4806 -- Vendor Item SQL
4807 -- Bug# 6747729
4808 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
4809 select distinct pol.vendor_product_num,
4810 msi.inventory_item_id,
4811 msi.description,
4812 Nvl(msi.revision_qty_control_code,1),
4813 Nvl(msi.lot_control_code, 1),
4814 Nvl(msi.serial_number_control_code, 1),
4815 Nvl(msi.restrict_subinventories_code, 2),
4816 Nvl(msi.restrict_locators_code,2),
4817 Nvl(msi.location_control_code,1),
4818 msi.primary_uom_code,
4819 Nvl(msi.inspection_required_flag,'N'),
4820 Nvl(msi.shelf_life_code, 1),
4821 Nvl(msi.shelf_life_days,0),
4822 Nvl(msi.allowed_units_lookup_code, 2),
4823 Nvl(msi.effectivity_control,1),
4824 0,
4825 0,
4826 Nvl(msi.default_serial_status_id,1),
4827 Nvl(msi.serial_status_enabled,'N'),
4828 Nvl(msi.default_lot_status_id,0),
4829 Nvl(msi.lot_status_enabled,'N'),
4830 msi.concatenated_segments,
4831 'Y',
4832 msi.inventory_item_flag,
4833 0,
4834 msi.inventory_asset_flag,
4835 msi.outside_operation_flag ,
4836 --Bug 3952081
4837 --Select DUOM Attributes for every Item
4838 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
4839 NVL(MSI.DEFAULT_GRADE,''),
4840 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
4841 NVL(MSI.EXPIRATION_ACTION_CODE,''),
4842 NVL(MSI.HOLD_DAYS,0),
4843 NVL(MSI.MATURITY_DAYS,0),
4844 NVL(MSI.RETEST_INTERVAL,0),
4845 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4846 NVL(MSI.CHILD_LOT_FLAG,'N'),
4847 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
4848 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
4849 NVL(MSI.SECONDARY_UOM_CODE,''),
4850 NVL(MSI.SECONDARY_DEFAULT_IND,''),
4851 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
4852 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
4853 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
4854 msi.stock_enabled_flag
4855 from po_lines_all pol
4856 , mtl_system_items_vl msi /* Bug 5581528 */
4857 where organization_id = p_organization_id
4858 and pol.vendor_product_num like p_concatenated_segments
4859 and pol.item_id = msi.inventory_item_id
4860 and pol.vendor_product_num IS NOT NULL
4861 and pol.po_header_id = p_poHeaderID
4862 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
4863 and inventory_item_id IN (SELECT pol.item_id FROM po_lines_all pol
4864 where pol.po_header_id = p_poHeaderID
4865 and exists (select 1
4866 from po_line_locations_all pll
4867 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
4868 , mtl_parameters mp,
4869 rcv_parameters rp
4870 -- End for Bug 7440217
4871 WHERE NVL(pll.closed_code,'OPEN')
4872 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED')
4873 and pll.po_header_id = p_poHeaderID
4874 and pll.po_release_id = p_poReleaseID
4875 and pll.po_line_id = pol.po_line_id
4876 and pll.ship_to_organization_id = p_Organization_Id
4877 -- For Bug 7440217 Checking if it is LCM enabled
4878 AND mp.organization_id = p_organization_id
4879 AND rp.organization_id = p_organization_id
4880 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
4881 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
4882 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
4883 )
4884 -- End for Bug 7440217
4885 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
4886 )
4887 UNION ALL
4888 -- non item Master
4889 -- Bug# 6747729
4890 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
4891 select distinct pol.item_description,
4892 to_number(''),
4893 pol.item_description,
4894 1,
4895 1,
4896 1,
4897 2,
4898 2,
4899 1,
4900 mum.uom_code,
4901 'N',
4902 1,
4903 0,
4904 2,
4905 1,
4906 0,
4907 0,
4908 1,
4909 'N',
4910 0,
4911 'N',
4912 '',
4913 'N',
4914 'N',
4915 0,
4916 to_char(NULL),
4917 'N' ,
4918 --Bug 3952081
4919 --Select DUOM Attributes for every Item
4920 'N',
4921 '',
4922 0,
4923 '',
4924 0,
4925 0,
4926 0,
4927 'N',
4928 'N',
4929 'N',
4930 'Y',
4931 '',
4932 '',
4933 'P',
4934 0,
4935 0,
4936 'N'
4937 from po_lines_all pol
4938 , mtl_units_of_measure mum
4939 -- Bug 2619063, 2614016
4940 -- Modified to select the base uom for the uom class defined on po.
4941 where mum.uom_class = (SELECT mum2.uom_class
4942 FROM mtl_units_of_measure mum2
4943 WHERE mum2.unit_of_measure(+) = pol.unit_meas_lookup_code)
4944 and mum.base_uom_flag = 'Y'
4945 and pol.ITEM_ID is null
4946 and pol.item_description is not null
4947 and pol.po_header_id = p_poHeaderID
4948 and pol.item_description like p_concatenated_segments
4949 /* Bug 3972931-Added the following exists condition to restrict the PO receipt
4950 to shipments due to be received only in the organizationientered with.*/
4951 and exists (select 1
4952 from po_line_locations_all pll
4953 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
4954 , mtl_parameters mp,
4955 rcv_parameters rp
4956 -- End for Bug 7440217
4957 where pll.po_header_id = p_poHeaderID
4958 and pll.po_line_id = pol.po_line_id
4959 and pll.ship_to_organization_id = p_Organization_Id
4960 -- For Bug 7440217 Checking if it is LCM enabled
4961 AND mp.organization_id = p_organization_id
4962 AND rp.organization_id = p_organization_id
4963 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
4964 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
4965 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
4966 )
4967 -- End for Bug 7440217
4968
4969 )
4970 --End of fix for Bug 3972931
4971 UNION ALL
4972 -- Cross Ref SQL
4973 -- Bug# 6747729
4974 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
4975 select distinct mcr.cross_reference,
4976 msi.inventory_item_id,
4977 msi.description,
4978 Nvl(msi.revision_qty_control_code,1),
4979 Nvl(msi.lot_control_code, 1),
4980 Nvl(msi.serial_number_control_code, 1),
4981 Nvl(msi.restrict_subinventories_code, 2),
4982 Nvl(msi.restrict_locators_code,2),
4983 Nvl(msi.location_control_code,1),
4984 msi.primary_uom_code,
4985 Nvl(msi.inspection_required_flag,'N'),
4986 Nvl(msi.shelf_life_code, 1),
4987 Nvl(msi.shelf_life_days,0),
4988 Nvl(msi.allowed_units_lookup_code, 2),
4989 Nvl(msi.effectivity_control,1),
4990 0,
4991 0,
4992 Nvl(msi.default_serial_status_id,1),
4993 Nvl(msi.serial_status_enabled,'N'),
4994 Nvl(msi.default_lot_status_id,0),
4995 Nvl(msi.lot_status_enabled,'N'),
4996 msi.concatenated_segments,
4997 'C',
4998 msi.inventory_item_flag,
4999 0,
5000 msi.inventory_asset_flag,
5001 msi.outside_operation_flag,
5002 --Bug 3952081
5003 --Select DUOM Attributes for every Item
5004 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
5005 NVL(MSI.DEFAULT_GRADE,''),
5006 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
5007 NVL(MSI.EXPIRATION_ACTION_CODE,''),
5008 NVL(MSI.HOLD_DAYS,0),
5009 NVL(MSI.MATURITY_DAYS,0),
5010 NVL(MSI.RETEST_INTERVAL,0),
5011 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5012 NVL(MSI.CHILD_LOT_FLAG,'N'),
5013 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
5014 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
5015 NVL(MSI.SECONDARY_UOM_CODE,''),
5016 NVL(MSI.SECONDARY_DEFAULT_IND,''),
5017 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
5018 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
5019 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
5020 msi.stock_enabled_flag
5021 from po_lines_all pol
5022 ,mtl_system_items_vl msi /* Bug 5581528 */
5023 ,mtl_cross_references mcr
5024 where msi.organization_id = p_organization_id
5025 and ( (mcr.cross_reference_type = p_crossreftype
5026 and mcr.cross_reference like p_concatenated_segments
5027 ) or
5028 ( mcr.cross_reference_type = g_gtin_cross_ref_type
5029 AND mcr.cross_reference LIKE g_crossref )
5030 )
5031 and ( (mcr.org_independent_flag = 'Y') or (mcr.org_independent_flag = 'N'
5032 and mcr.organization_id = p_organization_id
5033 ) )
5034 and mcr.inventory_item_id = msi.inventory_item_id
5035 and pol.item_id = msi.inventory_item_id
5036 and pol.po_header_id = p_poHeaderID
5037 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
5038 and msi.inventory_item_id IN (SELECT pol.item_id FROM po_lines_all pol
5039 where pol.po_header_id = p_poHeaderID
5040 and exists (select 1
5041 from po_line_locations_all pll
5042 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
5043 , mtl_parameters mp,
5044 rcv_parameters rp
5045 -- End for Bug 7440217
5046 WHERE NVL(pll.closed_code,'OPEN')
5047 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED')
5048 and pll.po_header_id = p_poHeaderID
5049 and pll.po_release_id = p_poReleaseID
5050 and pll.po_line_id = pol.po_line_id
5051 and pll.ship_to_organization_id = p_Organization_Id
5052 -- For Bug 7440217 Checking if it is LCM enabled
5053 AND mp.organization_id = p_organization_id
5054 AND rp.organization_id = p_organization_id
5055 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
5056 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
5057 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
5058 )
5059 -- End for Bug 7440217
5060 )--Bug 3972931-Added the filter condition based on ship_to_organization_id
5061 )
5062 ;
5063 elsif (p_poLineID IS NOT NULL) then
5064 -- *****************************
5065 -- Deafult Line Based Tran
5066 --- ***************************
5067 open x_items for
5068 -- Bug# 6747729
5069 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
5070 select concatenated_segments,
5071 inventory_item_id,
5072 description,
5073 Nvl(revision_qty_control_code,1),
5074 Nvl(lot_control_code, 1),
5075 Nvl(serial_number_control_code, 1),
5076 Nvl(restrict_subinventories_code, 2),
5077 Nvl(restrict_locators_code, 2),
5078 Nvl(location_control_code, 1),
5079 primary_uom_code,
5080 Nvl(inspection_required_flag, 'N'),
5081 Nvl(shelf_life_code, 1),
5082 Nvl(shelf_life_days,0),
5083 Nvl(allowed_units_lookup_code, 2),
5084 Nvl(effectivity_control,1),
5085 0,
5086 0,
5087 Nvl(default_serial_status_id,1),
5088 Nvl(serial_status_enabled,'N'),
5089 Nvl(default_lot_status_id,0),
5090 Nvl(lot_status_enabled,'N'),
5091 '',
5092 'N',
5093 inventory_item_flag,
5094 0,
5095 inventory_asset_flag,
5096 outside_operation_flag,
5097 --Bug 3952081
5098 --Select DUOM Attributes for every Item
5099 NVL(GRADE_CONTROL_FLAG,'N'),
5100 NVL(DEFAULT_GRADE,''),
5101 NVL(EXPIRATION_ACTION_INTERVAL,0),
5102 NVL(EXPIRATION_ACTION_CODE,''),
5103 NVL(HOLD_DAYS,0),
5104 NVL(MATURITY_DAYS,0),
5105 NVL(RETEST_INTERVAL,0),
5106 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
5107 NVL(CHILD_LOT_FLAG,'N'),
5108 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
5109 NVL(LOT_DIVISIBLE_FLAG,'Y'),
5110 NVL(SECONDARY_UOM_CODE,''),
5111 NVL(SECONDARY_DEFAULT_IND,''),
5112 NVL(TRACKING_QUANTITY_IND,'P'),
5113 NVL(DUAL_UOM_DEVIATION_HIGH,0),
5114 NVL(DUAL_UOM_DEVIATION_LOW,0),
5115 stock_enabled_flag
5116 from mtl_system_items_vl /* Bug 5581528 */
5117 WHERE organization_id = p_Organization_Id
5118 and concatenated_segments like p_concatenated_segments
5119 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
5120 and inventory_item_id IN (SELECT pl.item_id FROM po_lines_all pl WHERE
5121 pl.po_header_id = p_poHeaderID
5122 and pl.po_line_id = p_poLineID
5123 and exists (select 1
5124 from po_line_locations_all pll
5125 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
5126 , mtl_parameters mp,
5127 rcv_parameters rp
5128 -- End for Bug 7440217
5129 where NVL(pll.closed_code, 'OPEN')
5130 not in ('FINALLY CLOSED' , 'CLOSED FOR RECEIVING', 'CLOSED' ) -- 3687249
5131 and pll.po_header_id = p_poHeaderID
5132 and pll.po_line_id = p_poLineID
5133 and pll.ship_to_organization_id = p_Organization_Id
5134 -- For Bug 7440217 Checking if it is LCM enabled
5135 AND mp.organization_id = p_organization_id
5136 AND rp.organization_id = p_organization_id
5137 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
5138 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
5139 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
5140 )
5141 -- End for Bug 7440217
5142 ))--Bug 3972931-Added the filter condition based on ship_to_organization_id
5143 UNION ALL
5144 -- Substitute Item SQL
5145 -- Bug# 6747729
5146 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
5147 select distinct msi.concatenated_segments,
5148 msi.inventory_item_id,
5149 msi.description,
5150 Nvl(msi.revision_qty_control_code,1),
5151 Nvl(msi.lot_control_code, 1),
5152 Nvl(msi.serial_number_control_code, 1),
5153 Nvl(msi.restrict_subinventories_code, 2),
5154 Nvl(msi.restrict_locators_code,2),
5155 Nvl(msi.location_control_code,1),
5156 msi.primary_uom_code,
5157 Nvl(msi.inspection_required_flag,'N'),
5158 Nvl(msi.shelf_life_code, 1),
5159 Nvl(msi.shelf_life_days,0),
5160 Nvl(msi.allowed_units_lookup_code, 2),
5161 Nvl(msi.effectivity_control,1),
5162 0,
5163 0,
5164 Nvl(msi.default_serial_status_id,1),
5165 Nvl(msi.serial_status_enabled,'N'),
5166 Nvl(msi.default_lot_status_id,0),
5167 Nvl(msi.lot_status_enabled,'N'),
5168 msi.concatenated_segments,
5169 'S',
5170 msi.inventory_item_flag,
5171 0,
5172 msi.inventory_asset_flag,
5173 msi.outside_operation_flag ,
5174 --Bug 3952081
5175 --Select DUOM Attributes for every Item
5176 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
5177 NVL(MSI.DEFAULT_GRADE,''),
5178 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
5179 NVL(MSI.EXPIRATION_ACTION_CODE,''),
5180 NVL(MSI.HOLD_DAYS,0),
5181 NVL(MSI.MATURITY_DAYS,0),
5182 NVL(MSI.RETEST_INTERVAL,0),
5183 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5184 NVL(MSI.CHILD_LOT_FLAG,'N'),
5185 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
5186 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
5187 NVL(MSI.SECONDARY_UOM_CODE,''),
5188 NVL(MSI.SECONDARY_DEFAULT_IND,''),
5189 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
5190 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
5191 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
5192 msi.stock_enabled_flag
5193 from po_lines_all pol
5194 ,mtl_related_items mri
5195 ,mtl_system_items_vl msi /* Bug 5581528 */
5196 /*,mtl_system_items_kfv msia*/ /* Bug 6334679 */
5197 where msi.organization_id = p_organization_id
5198 and msi.concatenated_segments like p_concatenated_segments
5199 and pol.po_header_id = p_poHeaderID
5200 and pol.item_id = msi.inventory_item_id
5201 and msi.organization_id = p_organization_id
5202 and (( mri.related_item_id = msi.inventory_item_id
5203 and pol.item_id = mri.inventory_item_id) or
5204 ( mri.inventory_item_id = msi.inventory_item_id
5205 and pol.item_id = mri.related_item_id
5206 and mri.reciprocal_flag = 'Y'))
5207 and pol.po_line_id = p_poLineID
5208 and exists (select 1
5209 from po_line_locations_all pll
5210 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
5211 , mtl_parameters mp,
5212 rcv_parameters rp
5213 -- End for Bug 7440217
5214 where NVL(pll.closed_code,'OPEN')
5215 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
5216 -- For Bug 7440217 Checking if it is LCM enabled
5217 AND mp.organization_id = p_organization_id
5218 AND rp.organization_id = p_organization_id
5219 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
5220 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
5221 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
5222 )
5223 -- End for Bug 7440217
5224 and Nvl(pll.allow_substitute_receipts_flag, 'N') = 'Y'
5225 and pll.po_header_id = pol.po_header_id
5226 and pll.po_line_id = pol.po_line_id
5227 and pll.ship_to_organization_id = p_Organization_Id)--Bug 3972931-Added the filter condition based on ship_to_organization_id
5228 UNION ALL
5229 -- Vendor Item SQL
5230 -- Bug# 6747729
5231 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
5232 select distinct pol.vendor_product_num,
5233 msi.inventory_item_id,
5234 msi.description,
5235 Nvl(msi.revision_qty_control_code,1),
5236 Nvl(msi.lot_control_code, 1),
5237 Nvl(msi.serial_number_control_code, 1),
5238 Nvl(msi.restrict_subinventories_code, 2),
5239 Nvl(msi.restrict_locators_code,2),
5240 Nvl(msi.location_control_code,1),
5241 msi.primary_uom_code,
5242 Nvl(msi.inspection_required_flag,'N'),
5243 Nvl(msi.shelf_life_code, 1),
5244 Nvl(msi.shelf_life_days,0),
5245 Nvl(msi.allowed_units_lookup_code, 2),
5246 Nvl(msi.effectivity_control,1),
5247 0,
5248 0,
5249 Nvl(msi.default_serial_status_id,1),
5250 Nvl(msi.serial_status_enabled,'N'),
5251 Nvl(msi.default_lot_status_id,0),
5252 Nvl(msi.lot_status_enabled,'N'),
5253 msi.concatenated_segments,
5254 'Y',
5255 msi.inventory_item_flag,
5256 0,
5257 msi.inventory_asset_flag,
5258 msi.outside_operation_flag ,
5259 --Bug 3952081
5260 --Select DUOM Attributes for every Item
5261 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
5262 NVL(MSI.DEFAULT_GRADE,''),
5263 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
5264 NVL(MSI.EXPIRATION_ACTION_CODE,''),
5265 NVL(MSI.HOLD_DAYS,0),
5266 NVL(MSI.MATURITY_DAYS,0),
5267 NVL(MSI.RETEST_INTERVAL,0),
5268 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5269 NVL(MSI.CHILD_LOT_FLAG,'N'),
5270 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
5271 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
5272 NVL(MSI.SECONDARY_UOM_CODE,''),
5273 NVL(MSI.SECONDARY_DEFAULT_IND,''),
5274 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
5275 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
5276 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
5277 msi.stock_enabled_flag
5278 from po_lines_all pol
5279 ,mtl_system_items_vl msi /* Bug 5581528 */
5280 where organization_id = p_organization_id
5281 and pol.vendor_product_num like p_concatenated_segments
5282 and pol.item_id = msi.inventory_item_id
5283 and pol.vendor_product_num IS NOT NULL
5284 and pol.po_header_id = p_poHeaderID
5285 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
5286 and inventory_item_id IN (SELECT pl.item_id FROM po_lines_all pl WHERE
5287 pl.po_header_id = p_poHeaderID
5288 and pl.po_line_id = p_poLineID
5289 and exists (select 1
5290 from po_line_locations_all pll
5291 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
5292 , mtl_parameters mp,
5293 rcv_parameters rp
5294 -- End for Bug 7440217
5295 where NVL(pll.closed_code, 'OPEN')
5296 not in ('FINALLY CLOSED' , 'CLOSED FOR RECEIVING', 'CLOSED' ) -- 3687249
5297 -- For Bug 7440217 Checking if it is LCM enabled
5298 AND mp.organization_id = p_organization_id
5299 AND rp.organization_id = p_organization_id
5300 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
5301 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
5302 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
5303 )
5304 -- End for Bug 7440217
5305 and pll.po_header_id = p_poHeaderID
5306 and pll.po_line_id = p_poLineID
5307 and pll.ship_to_organization_id = p_Organization_Id)--Bug 3972931-Added the filter condition based on ship_to_organization_id
5308 )
5309 UNION ALL
5310 -- non item Master
5311 -- Bug# 6747729
5312 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
5313 select distinct pol.item_description,
5314 to_number(''),
5315 pol.item_description,
5316 1,
5317 1,
5318 1,
5319 2,
5320 2,
5321 1,
5322 mum.uom_code,
5323 'N',
5324 1,
5325 0,
5326 2,
5327 1,
5328 0,
5329 0,
5330 1,
5331 'N',
5332 0,
5333 'N',
5334 '',
5335 'N',
5336 'N',
5337 0,
5338 to_char(NULL),
5339 'N' ,
5340 --Bug 3952081
5341 --Select DUOM Attributes for every Item
5342 'N',
5343 '',
5344 0,
5345 '',
5346 0,
5347 0,
5348 0,
5349 'N',
5350 'N',
5351 'N',
5352 'Y',
5353 '',
5354 '',
5355 'P',
5356 0,
5357 0,
5358 'N'
5359 from po_lines_all pol
5360 , mtl_units_of_measure mum
5361 -- Bug 2619063, 2614016
5362 -- Modified to select the base uom for the uom class defined on po.
5363 where mum.uom_class = (SELECT mum2.uom_class
5364 FROM mtl_units_of_measure mum2
5365 WHERE mum2.unit_of_measure(+) = pol.unit_meas_lookup_code)
5366 and mum.base_uom_flag = 'Y'
5367 and pol.ITEM_ID is null
5368 and pol.item_description is not null
5369 and pol.po_header_id = p_poHeaderID
5370 and pol.item_description like p_concatenated_segments
5371 /* Bug 3972931-Added the following exists condition to restrict the PO receipt
5372 to shipments due to be received only in the organizationientered with.*/
5373 and exists (select 1
5374 from po_line_locations_all pll
5375 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
5376 , mtl_parameters mp,
5377 rcv_parameters rp
5378 -- End for Bug 7440217
5379 where pll.po_header_id = p_poHeaderID
5380 -- For Bug 7440217 Checking if it is LCM enabled
5381 AND mp.organization_id = p_organization_id
5382 AND rp.organization_id = p_organization_id
5383 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
5384 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
5385 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
5386 )
5387 -- End for Bug 7440217
5388 and pll.po_line_id = pol.po_line_id
5389 and pll.ship_to_organization_id = p_Organization_Id)
5390 --End of fix for Bug 3972931
5391 UNION ALL
5392 -- Cross Ref SQL
5393 -- Bug# 6747729
5394 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
5395 select distinct mcr.cross_reference,
5396 msi.inventory_item_id,
5397 msi.description,
5398 Nvl(msi.revision_qty_control_code,1),
5399 Nvl(msi.lot_control_code, 1),
5400 Nvl(msi.serial_number_control_code, 1),
5401 Nvl(msi.restrict_subinventories_code, 2),
5402 Nvl(msi.restrict_locators_code,2),
5403 Nvl(msi.location_control_code,1),
5404 msi.primary_uom_code,
5405 Nvl(msi.inspection_required_flag,'N'),
5406 Nvl(msi.shelf_life_code, 1),
5407 Nvl(msi.shelf_life_days,0),
5408 Nvl(msi.allowed_units_lookup_code, 2),
5409 Nvl(msi.effectivity_control,1),
5410 0,
5411 0,
5412 Nvl(msi.default_serial_status_id,1),
5413 Nvl(msi.serial_status_enabled,'N'),
5414 Nvl(msi.default_lot_status_id,0),
5415 Nvl(msi.lot_status_enabled,'N'),
5416 msi.concatenated_segments,
5417 'C',
5418 msi.inventory_item_flag,
5419 0,
5420 msi.inventory_asset_flag,
5421 msi.outside_operation_flag,
5422 --Bug 3952081
5423 --Select DUOM Attributes for every Item
5424 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
5425 NVL(MSI.DEFAULT_GRADE,''),
5426 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
5427 NVL(MSI.EXPIRATION_ACTION_CODE,''),
5428 NVL(MSI.HOLD_DAYS,0),
5429 NVL(MSI.MATURITY_DAYS,0),
5430 NVL(MSI.RETEST_INTERVAL,0),
5431 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5432 NVL(MSI.CHILD_LOT_FLAG,'N'),
5433 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
5434 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
5435 NVL(MSI.SECONDARY_UOM_CODE,''),
5436 NVL(MSI.SECONDARY_DEFAULT_IND,''),
5437 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
5438 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
5439 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
5440 msi.stock_enabled_flag
5441 from po_lines_all pol
5442 ,mtl_system_items_vl msi /* Bug 5581528 */
5443 ,mtl_cross_references mcr
5444 where msi.organization_id = p_organization_id
5445 and ( (mcr.cross_reference_type = p_crossreftype
5446 and mcr.cross_reference like p_concatenated_segments
5447 ) or
5448 ( mcr.cross_reference_type = g_gtin_cross_ref_type
5449 AND mcr.cross_reference LIKE g_crossref )
5450 )
5451 and ( (mcr.org_independent_flag = 'Y') or (mcr.org_independent_flag = 'N'
5452 and mcr.organization_id = p_organization_id
5453 ) )
5454 and mcr.inventory_item_id = msi.inventory_item_id
5455 and pol.item_id = msi.inventory_item_id
5456 and pol.po_header_id = p_poHeaderID
5457 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
5458 and msi.inventory_item_id IN (SELECT pl.item_id FROM po_lines_all pl WHERE
5459 pl.po_header_id = p_poHeaderID
5460 and pl.po_line_id = p_poLineID
5461 and exists (select 1
5462 from po_line_locations_all pll
5463 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
5464 , mtl_parameters mp,
5465 rcv_parameters rp
5466 -- End for Bug 7440217
5467 where NVL(pll.closed_code, 'OPEN')
5468 not in ('FINALLY CLOSED' , 'CLOSED FOR RECEIVING', 'CLOSED' ) -- 3687249
5469 -- For Bug 7440217 Checking if it is LCM enabled
5470 AND mp.organization_id = p_organization_id
5471 AND rp.organization_id = p_organization_id
5472 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
5473 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
5474 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
5475 )
5476 -- End for Bug 7440217
5477 and pll.po_header_id = p_poHeaderID
5478 and pll.po_line_id = p_poLineID
5479 and pll.ship_to_organization_id = p_Organization_Id)--Bug 3972931-Added the filter condition based on ship_to_organization_id
5480 )
5481 ;
5482 else
5483 -- *****************************
5484 -- Deafult headerBased Tran
5485 -- ***************************
5486
5487 open x_Items for
5488 -- Bug# 6747729
5489 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
5490 select concatenated_segments,
5491 inventory_item_id,
5492 description,
5493 Nvl(revision_qty_control_code,1),
5494 Nvl(lot_control_code, 1),
5495 Nvl(serial_number_control_code, 1),
5496 Nvl(restrict_subinventories_code, 2),
5497 Nvl(restrict_locators_code, 2),
5498 Nvl(location_control_code, 1),
5499 primary_uom_code,
5500 Nvl(inspection_required_flag, 'N'),
5501 Nvl(shelf_life_code, 1),
5502 Nvl(shelf_life_days,0),
5503 Nvl(allowed_units_lookup_code, 2),
5504 Nvl(effectivity_control,1),
5505 0,
5506 0,
5507 Nvl(default_serial_status_id,1),
5508 Nvl(serial_status_enabled,'N'),
5509 Nvl(default_lot_status_id,0),
5510 Nvl(lot_status_enabled,'N'),
5511 '',
5512 'N',
5513 inventory_item_flag,
5514 0,
5515 inventory_asset_flag,
5516 outside_operation_flag,
5517 --Bug 3952081
5518 --Select DUOM Attributes for every Item
5519 NVL(GRADE_CONTROL_FLAG,'N'),
5520 NVL(DEFAULT_GRADE,''),
5521 NVL(EXPIRATION_ACTION_INTERVAL,0),
5522 NVL(EXPIRATION_ACTION_CODE,''),
5523 NVL(HOLD_DAYS,0),
5524 NVL(MATURITY_DAYS,0),
5525 NVL(RETEST_INTERVAL,0),
5526 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
5527 NVL(CHILD_LOT_FLAG,'N'),
5528 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
5529 NVL(LOT_DIVISIBLE_FLAG,'Y'),
5530 NVL(SECONDARY_UOM_CODE,''),
5531 NVL(SECONDARY_DEFAULT_IND,''),
5532 NVL(TRACKING_QUANTITY_IND,'P'),
5533 NVL(DUAL_UOM_DEVIATION_HIGH,0),
5534 NVL(DUAL_UOM_DEVIATION_LOW,0),
5535 stock_enabled_flag
5536 from mtl_system_items_vl /* Bug 5581528 */
5537 WHERE organization_id = p_Organization_Id
5538 and concatenated_segments like p_concatenated_segments
5539 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
5540 and inventory_item_id IN
5541 ( SELECT pl.item_id FROM po_lines_all pl WHERE pl.po_header_id = p_poHeaderID
5542 and exists (select 1
5543 from po_line_locations_all pll
5544 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
5545 , mtl_parameters mp,
5546 rcv_parameters rp
5547 -- End for Bug 7440217
5548 where NVL(pll.closed_code,'OPEN')
5549 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
5550 -- For Bug 7440217 Checking if it is LCM enabled
5551 AND mp.organization_id = p_organization_id
5552 AND rp.organization_id = p_organization_id
5553 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
5554 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
5555 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
5556 )
5557 -- End for Bug 7440217
5558 and pll.po_header_id = p_poHeaderID
5559 and pll.po_line_id = pl.po_line_id
5560 and pll.ship_to_organization_id = p_Organization_Id)--Bug 3972931-Added the filter condition based on ship_to_organization_id
5561 )
5562 UNION ALL
5563 -- Substitute Item SQL
5564 -- Bug# 6747729
5565 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
5566 select distinct msi.concatenated_segments,
5567 msi.inventory_item_id,
5568 msi.description,
5569 Nvl(msi.revision_qty_control_code,1),
5570 Nvl(msi.lot_control_code, 1),
5571 Nvl(msi.serial_number_control_code, 1),
5572 Nvl(msi.restrict_subinventories_code, 2),
5573 Nvl(msi.restrict_locators_code,2),
5574 Nvl(msi.location_control_code,1),
5575 msi.primary_uom_code,
5576 Nvl(msi.inspection_required_flag,'N'),
5577 Nvl(msi.shelf_life_code, 1),
5578 Nvl(msi.shelf_life_days,0),
5579 Nvl(msi.allowed_units_lookup_code, 2),
5580 Nvl(msi.effectivity_control,1),
5581 0,
5582 0,
5583 Nvl(msi.default_serial_status_id,1),
5584 Nvl(msi.serial_status_enabled,'N'),
5585 Nvl(msi.default_lot_status_id,0),
5586 Nvl(msi.lot_status_enabled,'N'),
5587 msi.concatenated_segments,
5588 'S',
5589 msi.inventory_item_flag,
5590 0,
5591 msi.inventory_asset_flag,
5592 msi.outside_operation_flag ,
5593 --Bug 3952081
5594 --Select DUOM Attributes for every Item
5595 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
5596 NVL(MSI.DEFAULT_GRADE,''),
5597 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
5598 NVL(MSI.EXPIRATION_ACTION_CODE,''),
5599 NVL(MSI.HOLD_DAYS,0),
5600 NVL(MSI.MATURITY_DAYS,0),
5601 NVL(MSI.RETEST_INTERVAL,0),
5602 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5603 NVL(MSI.CHILD_LOT_FLAG,'N'),
5604 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
5605 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
5606 NVL(MSI.SECONDARY_UOM_CODE,''),
5607 NVL(MSI.SECONDARY_DEFAULT_IND,''),
5608 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
5609 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
5610 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
5611 msi.stock_enabled_flag
5612 from po_lines_all pol
5613 ,mtl_related_items mri
5614 ,mtl_system_items_vl msi /* Bug 5581528 */
5615 /*,mtl_system_items_kfv msia */ /* Bug 6334679 */
5616 where msi.organization_id = p_organization_id
5617 and msi.concatenated_segments like p_concatenated_segments
5618 and pol.po_header_id = p_poHeaderID
5619 and pol.item_id = msi.inventory_item_id
5620 and msi.organization_id = p_organization_id
5621 and (( mri.related_item_id = msi.inventory_item_id
5622 and pol.item_id = mri.inventory_item_id) or
5623 ( mri.inventory_item_id = msi.inventory_item_id
5624 and pol.item_id = mri.related_item_id
5625 and mri.reciprocal_flag = 'Y'))
5626 and exists (select 1
5627 from po_line_locations_all pll
5628 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
5629 , mtl_parameters mp,
5630 rcv_parameters rp
5631 -- End for Bug 7440217
5632 where NVL(pll.closed_code,'OPEN')
5633 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
5634 -- For Bug 7440217 Checking if it is LCM enabled
5635 AND mp.organization_id = p_organization_id
5636 AND rp.organization_id = p_organization_id
5637 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
5638 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
5639 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
5640 )
5641 -- End for Bug 7440217
5642 and Nvl(pll.allow_substitute_receipts_flag, 'N') = 'Y'
5643 and pll.po_header_id = pol.po_header_id
5644 and pll.po_line_id = pol.po_line_id
5645 and pll.ship_to_organization_id = p_Organization_Id)--Bug 3972931-Added the filter condition based on ship_to_organization_id
5646 UNION ALL
5647 -- Vendor Item SQL
5648 -- Bug# 6747729
5649 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
5650 select distinct pol.vendor_product_num,
5651 msi.inventory_item_id,
5652 msi.description,
5653 Nvl(msi.revision_qty_control_code,1),
5654 Nvl(msi.lot_control_code, 1),
5655 Nvl(msi.serial_number_control_code, 1),
5656 Nvl(msi.restrict_subinventories_code, 2),
5657 Nvl(msi.restrict_locators_code,2),
5658 Nvl(msi.location_control_code,1),
5659 msi.primary_uom_code,
5660 Nvl(msi.inspection_required_flag,'N'),
5661 Nvl(msi.shelf_life_code, 1),
5662 Nvl(msi.shelf_life_days,0),
5663 Nvl(msi.allowed_units_lookup_code, 2),
5664 Nvl(msi.effectivity_control,1),
5665 0,
5666 0,
5667 Nvl(msi.default_serial_status_id,1),
5668 Nvl(msi.serial_status_enabled,'N'),
5669 Nvl(msi.default_lot_status_id,0),
5670 Nvl(msi.lot_status_enabled,'N'),
5671 msi.concatenated_segments,
5672 'Y',
5673 msi.inventory_item_flag,
5674 0,
5675 msi.inventory_asset_flag,
5676 msi.outside_operation_flag ,
5677 --Bug 3952081
5678 --Select DUOM Attributes for every Item
5679 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
5680 NVL(MSI.DEFAULT_GRADE,''),
5681 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
5682 NVL(MSI.EXPIRATION_ACTION_CODE,''),
5683 NVL(MSI.HOLD_DAYS,0),
5684 NVL(MSI.MATURITY_DAYS,0),
5685 NVL(MSI.RETEST_INTERVAL,0),
5686 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5687 NVL(MSI.CHILD_LOT_FLAG,'N'),
5688 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
5689 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
5690 NVL(MSI.SECONDARY_UOM_CODE,''),
5691 NVL(MSI.SECONDARY_DEFAULT_IND,''),
5692 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
5693 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
5694 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
5695 msi.stock_enabled_flag
5696 from po_lines_all pol
5697 , mtl_system_items_vl msi /* Bug 5581528 */
5698 where organization_id = p_organization_id
5699 and pol.vendor_product_num like p_concatenated_segments
5700 and pol.item_id = msi.inventory_item_id
5701 and pol.vendor_product_num IS NOT NULL
5702 and pol.po_header_id = p_poHeaderID
5703 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
5704 and inventory_item_id IN
5705 ( SELECT pl.item_id FROM po_lines_all pl WHERE pl.po_header_id =
5706 p_poHeaderID
5707 and exists (select 1
5708 from po_line_locations_all pll
5709 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
5710 , mtl_parameters mp,
5711 rcv_parameters rp
5712 -- End for Bug 7440217
5713 where NVL(pll.closed_code,'OPEN')
5714 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
5715 -- For Bug 7440217 Checking if it is LCM enabled
5716 AND mp.organization_id = p_organization_id
5717 AND rp.organization_id = p_organization_id
5718 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
5719 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
5720 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
5721 )
5722 -- End for Bug 7440217
5723 and pll.po_header_id = p_poHeaderID
5724 and pll.po_line_id = pl.po_line_id
5725 and pll.ship_to_organization_id = p_Organization_Id)--Bug 3972931-Added the filter condition based on ship_to_organization_id
5726 )
5727 UNION ALL
5728 -- non item Master
5729 -- Bug# 6747729
5730 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
5731 select distinct pol.item_description,
5732 to_number(''),
5733 pol.item_description,
5734 1,
5735 1,
5736 1,
5737 2,
5738 2,
5739 1,
5740 mum.uom_code,
5741 'N',
5742 1,
5743 0,
5744 2,
5745 1,
5746 0,
5747 0,
5748 1,
5749 'N',
5750 0,
5751 'N',
5752 '',
5753 'N',
5754 'N',
5755 0,
5756 to_char(NULL),
5757 'N' ,
5758 --Bug 3952081
5759 --Select DUOM Attributes for every Item
5760 'N',
5761 '',
5762 0,
5763 '',
5764 0,
5765 0,
5766 0,
5767 'N',
5768 'N',
5769 'N',
5770 'Y',
5771 '',
5772 '',
5773 'P',
5774 0,
5775 0,
5776 'N'
5777 from po_lines_all pol
5778 , mtl_units_of_measure mum
5779 -- Bug 2619063, 2614016
5780 -- Modified to select the base uom for the uom class defined on po.
5781 where mum.uom_class = (SELECT mum2.uom_class
5782 FROM mtl_units_of_measure mum2
5783 WHERE mum2.unit_of_measure(+) = pol.unit_meas_lookup_code)
5784 and mum.base_uom_flag = 'Y'
5785 and pol.ITEM_ID is null
5786 and pol.item_description is not null
5787 and pol.po_header_id = p_poHeaderID
5788 and pol.item_description like p_concatenated_segments
5789 /* Bug 3972931-Added the following exists condition to restrict the PO receipt
5790 to shipments due to be received only in the organizationientered with.*/
5791 and exists (select 1
5792 from po_line_locations_all pll
5793 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
5794 , mtl_parameters mp,
5795 rcv_parameters rp
5796 -- End for Bug 7440217
5797 where pll.po_header_id = p_poHeaderID
5798 -- For Bug 7440217 Checking if it is LCM enabled
5799 AND mp.organization_id = p_organization_id
5800 AND rp.organization_id = p_organization_id
5801 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
5802 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
5803 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
5804 )
5805 -- End for Bug 7440217
5806 and pll.po_line_id = pol.po_line_id
5807 and pll.ship_to_organization_id = p_Organization_Id)
5808 --End of fix for Bug 3972931
5809 UNION ALL
5810 -- Cross Ref SQL
5811 -- Bug# 6747729
5812 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
5813 select distinct mcr.cross_reference,
5814 msi.inventory_item_id,
5815 msi.description,
5816 Nvl(msi.revision_qty_control_code,1),
5817 Nvl(msi.lot_control_code, 1),
5818 Nvl(msi.serial_number_control_code, 1),
5819 Nvl(msi.restrict_subinventories_code, 2),
5820 Nvl(msi.restrict_locators_code,2),
5821 Nvl(msi.location_control_code,1),
5822 msi.primary_uom_code,
5823 Nvl(msi.inspection_required_flag,'N'),
5824 Nvl(msi.shelf_life_code, 1),
5825 Nvl(msi.shelf_life_days,0),
5826 Nvl(msi.allowed_units_lookup_code, 2),
5827 Nvl(msi.effectivity_control,1),
5828 0,
5829 0,
5830 Nvl(msi.default_serial_status_id,1),
5831 Nvl(msi.serial_status_enabled,'N'),
5832 Nvl(msi.default_lot_status_id,0),
5833 Nvl(msi.lot_status_enabled,'N'),
5834 msi.concatenated_segments,
5835 'C',
5836 msi.inventory_item_flag,
5837 0,
5838 msi.inventory_asset_flag,
5839 msi.outside_operation_flag,
5840 --Bug 3952081
5841 --Select DUOM Attributes for every Item
5842 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
5843 NVL(MSI.DEFAULT_GRADE,''),
5844 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
5845 NVL(MSI.EXPIRATION_ACTION_CODE,''),
5846 NVL(MSI.HOLD_DAYS,0),
5847 NVL(MSI.MATURITY_DAYS,0),
5848 NVL(MSI.RETEST_INTERVAL,0),
5849 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5850 NVL(MSI.CHILD_LOT_FLAG,'N'),
5851 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
5852 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
5853 NVL(MSI.SECONDARY_UOM_CODE,''),
5854 NVL(MSI.SECONDARY_DEFAULT_IND,''),
5855 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
5856 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
5857 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
5858 msi.stock_enabled_flag
5859 from po_lines_all pol
5860 ,mtl_system_items_vl msi /* Bug 5581528 */
5861 ,mtl_cross_references mcr
5862 where msi.organization_id = p_organization_id
5863 and ( (mcr.cross_reference_type = p_crossreftype
5864 and mcr.cross_reference like p_concatenated_segments
5865 ) or
5866 ( mcr.cross_reference_type = g_gtin_cross_ref_type
5867 AND mcr.cross_reference LIKE g_crossref )
5868 )
5869 and ( (mcr.org_independent_flag = 'Y') or (mcr.org_independent_flag = 'N'
5870 and mcr.organization_id = p_organization_id
5871 ) )
5872 and mcr.inventory_item_id = msi.inventory_item_id
5873 and pol.item_id = msi.inventory_item_id
5874 and pol.po_header_id = p_poHeaderID
5875 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
5876 and msi.inventory_item_id IN
5877 ( SELECT pl.item_id FROM po_lines_all pl WHERE pl.po_header_id = p_poHeaderID
5878 and exists (select 1
5879 from po_line_locations_all pll
5880 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
5881 , mtl_parameters mp,
5882 rcv_parameters rp
5883 -- End for Bug 7440217
5884 where NVL(pll.closed_code,'OPEN')
5885 not in ('FINALLY CLOSED', 'CLOSED FOR RECEIVING', 'CLOSED') -- 3687249
5886 -- For Bug 7440217 Checking if it is LCM enabled
5887 AND mp.organization_id = p_organization_id
5888 AND rp.organization_id = p_organization_id
5889 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
5890 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
5891 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
5892 )
5893 -- End for Bug 7440217
5894 and pll.po_header_id = p_poHeaderID
5895 and pll.po_line_id = pl.po_line_id
5896 and pll.ship_to_organization_id = p_Organization_Id)--Bug 3972931-Added the filter condition based on ship_to_organization_id
5897 )
5898 ;
5899
5900 end if;
5901
5902 -- *****************************
5903 -- End of not PJM Based Tran
5904 -- *****************************
5905
5906 end if;
5907
5908 -- *****************************
5909 --- END OF PO HEADER ID SECTION
5910 -- *****************************
5911
5912 elsif (p_shipmentHeaderID is not null ) then
5913 -- *****************************
5914 --- START OF SHIPMENT HEADER ID SECTION
5915 -- *****************************
5916 open x_Items for
5917 -- Bug# 6747729
5918 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
5919 select concatenated_segments,
5920 inventory_item_id,
5921 description,
5922 Nvl(revision_qty_control_code,1),
5923 Nvl(lot_control_code, 1),
5924 Nvl(serial_number_control_code, 1),
5925 Nvl(restrict_subinventories_code, 2),
5926 Nvl(restrict_locators_code, 2),
5927 Nvl(location_control_code, 1),
5928 primary_uom_code,
5929 Nvl(inspection_required_flag, 'N'),
5930 Nvl(shelf_life_code, 1),
5931 Nvl(shelf_life_days,0),
5932 Nvl(allowed_units_lookup_code, 2),
5933 Nvl(effectivity_control,1),
5934 0,
5935 0,
5936 Nvl(default_serial_status_id,1),
5937 Nvl(serial_status_enabled,'N'),
5938 Nvl(default_lot_status_id,0),
5939 Nvl(lot_status_enabled,'N'),
5940 '',
5941 'N',
5942 inventory_item_flag,
5943 0,
5944 inventory_asset_flag,
5945 outside_operation_flag,
5946 --Bug 3952081
5947 --Select DUOM Attributes for every Item
5948 NVL(GRADE_CONTROL_FLAG,'N'),
5949 NVL(DEFAULT_GRADE,''),
5950 NVL(EXPIRATION_ACTION_INTERVAL,0),
5951 NVL(EXPIRATION_ACTION_CODE,''),
5952 NVL(HOLD_DAYS,0),
5953 NVL(MATURITY_DAYS,0),
5954 NVL(RETEST_INTERVAL,0),
5955 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
5956 NVL(CHILD_LOT_FLAG,'N'),
5957 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
5958 NVL(LOT_DIVISIBLE_FLAG,'Y'),
5959 NVL(SECONDARY_UOM_CODE,''),
5960 NVL(SECONDARY_DEFAULT_IND,''),
5961 NVL(TRACKING_QUANTITY_IND,'P'),
5962 NVL(DUAL_UOM_DEVIATION_HIGH,0),
5963 NVL(DUAL_UOM_DEVIATION_LOW,0),
5964 stock_enabled_flag
5965 from mtl_system_items_vl msn, /* Bug 5581528 */
5966 rcv_shipment_lines rsl
5967 WHERE msn.organization_id = p_Organization_Id
5968 and msn.concatenated_segments like p_concatenated_segments
5969 and (msn.purchasing_enabled_flag = 'Y' OR msn.stock_enabled_flag = 'Y')
5970 and rsl.SHIPMENT_HEADER_ID = p_shipmentHeaderID
5971 -- This was fix for bug 2740648/2752094
5972 AND rsl.shipment_line_status_code in ('EXPECTED','PARTIALLY RECEIVED')
5973 AND rsl.to_organization_id= p_Organization_Id--Bug 3972931-Added the condiotn to filter based on organization_id
5974 and rsl.item_id = msn.inventory_item_id
5975 and ( (l_from_lpn_id is null) or (l_from_lpn_id is not null and
5976 exists ( select '1' from wms_lpn_contents wlc
5977 where wlc.parent_lpn_id = l_from_lpn_id
5978 and wlc.inventory_item_id = rsl.item_id
5979 ) )
5980 )
5981 UNION
5982 -- bug 2775596
5983 -- added unions for the substitute item and vendor item
5984 -- if receiving an ASN.
5985 -- Vendor Item SQL
5986 -- Bug# 6747729
5987 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
5988 select distinct pol.vendor_product_num,
5989 msi.inventory_item_id,
5990 msi.description,
5991 Nvl(msi.revision_qty_control_code,1),
5992 Nvl(msi.lot_control_code, 1),
5993 Nvl(msi.serial_number_control_code, 1),
5994 Nvl(msi.restrict_subinventories_code, 2),
5995 Nvl(msi.restrict_locators_code,2),
5996 Nvl(msi.location_control_code,1),
5997 msi.primary_uom_code,
5998 Nvl(msi.inspection_required_flag,'N'),
5999 Nvl(msi.shelf_life_code, 1),
6000 Nvl(msi.shelf_life_days,0),
6001 Nvl(msi.allowed_units_lookup_code, 2),
6002 Nvl(msi.effectivity_control,1),
6003 0,
6004 0,
6005 Nvl(msi.default_serial_status_id,1),
6006 Nvl(msi.serial_status_enabled,'N'),
6007 Nvl(msi.default_lot_status_id,0),
6008 Nvl(msi.lot_status_enabled,'N'),
6009 msi.concatenated_segments,
6010 'Y',
6011 msi.inventory_item_flag,
6012 0,
6013 msi.inventory_asset_flag,
6014 msi.outside_operation_flag ,
6015 --Bug 3952081
6016 --Select DUOM Attributes for every Item
6017 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
6018 NVL(MSI.DEFAULT_GRADE,''),
6019 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
6020 NVL(MSI.EXPIRATION_ACTION_CODE,''),
6021 NVL(MSI.HOLD_DAYS,0),
6022 NVL(MSI.MATURITY_DAYS,0),
6023 NVL(MSI.RETEST_INTERVAL,0),
6024 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
6025 NVL(MSI.CHILD_LOT_FLAG,'N'),
6026 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
6027 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
6028 NVL(MSI.SECONDARY_UOM_CODE,''),
6029 NVL(MSI.SECONDARY_DEFAULT_IND,''),
6030 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
6031 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
6032 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
6033 msi.stock_enabled_flag
6034 from po_lines_all pol
6035 ,mtl_system_items_vl msi /* Bug 5581528 */
6036 , rcv_shipment_lines rsl
6037 where organization_id = p_Organization_Id
6038 and pol.vendor_product_num like p_concatenated_segments
6039 and pol.item_id = msi.inventory_item_id
6040 and pol.vendor_product_num IS NOT NULL
6041 and pol.po_header_id = Nvl(p_poheaderid,pol.po_header_id)
6042 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
6043 and inventory_item_id IN (SELECT pl.item_id
6044 FROM po_lines_all pl
6045 WHERE pl.po_header_id = rsl.po_header_id
6046 and pl.po_line_id = rsl.po_line_id
6047 and exists (select 1
6048 from po_line_locations_all pll
6049 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
6050 , mtl_parameters mp,
6051 rcv_parameters rp
6052 -- End for Bug 7440217
6053 where NVL(pll.closed_code,'OPEN')
6054 not in ('FINALLY CLOSED' , 'CLOSED FOR RECEIVING', 'CLOSED' ) -- 3687249
6055 -- For Bug 7440217 Checking if it is LCM enabled
6056 AND mp.organization_id = p_organization_id
6057 AND rp.organization_id = p_organization_id
6058 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
6059 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
6060 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
6061 )
6062 -- End for Bug 7440217
6063 and pll.po_header_id = rsl.po_header_id
6064 and pll.po_line_id = rsl.po_line_id
6065 and pll.ship_to_organization_id = p_Organization_Id)--Bug 3972931-Added the filter condition based on ship_to_organization_id
6066 )
6067 AND pol.po_line_id = rsl.po_line_id
6068 and rsl.SHIPMENT_HEADER_ID = p_shipmentHeaderID
6069 AND rsl.shipment_line_status_code in ('EXPECTED','PARTIALLY RECEIVED')
6070 AND rsl.source_document_code = 'PO'
6071 and ( (l_from_lpn_id is null) or (l_from_lpn_id is not null and
6072 exists ( select '1' from wms_lpn_contents wlc
6073 where wlc.parent_lpn_id = l_from_lpn_id
6074 and wlc.inventory_item_id = msi.inventory_item_id
6075 ) )
6076 )
6077 UNION
6078 -- Bug 2775532
6079 -- This section is non item master stuff for ASNs
6080 -- Bug# 6747729
6081 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
6082 select distinct pol.item_description,
6083 to_number(''),
6084 pol.item_description,
6085 1,
6086 1,
6087 1,
6088 2,
6089 2,
6090 1,
6091 mum.uom_code,
6092 'N',
6093 1,
6094 0,
6095 2,
6096 1,
6097 0,
6098 0,
6099 1,
6100 'N',
6101 0,
6102 'N',
6103 '',
6104 'N',
6105 'N',
6106 0,
6107 to_char(NULL),
6108 'N' ,
6109 --Bug 3952081
6110 --Select DUOM Attributes for every Item
6111 'N',
6112 '',
6113 0,
6114 '',
6115 0,
6116 0,
6117 0,
6118 'N',
6119 'N',
6120 'N',
6121 'Y',
6122 '',
6123 '',
6124 'P',
6125 0,
6126 0,
6127 'N'
6128 from po_lines_all pol
6129 , mtl_units_of_measure mum
6130 , rcv_shipment_lines rsl
6131 -- Bug 2619063, 2614016
6132 -- Modified to select the base uom for the uom class defined on po.
6133 where mum.uom_class = (SELECT mum2.uom_class
6134 FROM mtl_units_of_measure mum2
6135 WHERE mum2.unit_of_measure(+) = pol.unit_meas_lookup_code)
6136 and mum.base_uom_flag = 'Y'
6137 and pol.ITEM_ID is null
6138 and pol.item_description is not null
6139 and pol.po_header_id = Nvl(p_poheaderid,pol.po_header_id)
6140 and pol.item_description like p_concatenated_segments
6141 AND pol.po_line_id = rsl.po_line_id
6142 and rsl.SHIPMENT_HEADER_ID = p_shipmentHeaderID
6143 AND rsl.shipment_line_status_code in ('EXPECTED','PARTIALLY RECEIVED')
6144 AND rsl.source_document_code = 'PO'
6145 /* Bug 3972931-Added the following exists condition to restrict the PO receipt
6146 to shipments due to be received only in the organizationientered with.*/
6147 and exists (select 1
6148 from po_line_locations_all pll
6149 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
6150 , mtl_parameters mp,
6151 rcv_parameters rp
6152 -- End for Bug 7440217
6153 where pll.po_header_id = p_poHeaderID
6154 -- For Bug 7440217 Checking if it is LCM enabled
6155 AND mp.organization_id = p_organization_id
6156 AND rp.organization_id = p_organization_id
6157 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
6158 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
6159 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
6160 )
6161 -- End for Bug 7440217
6162 and pll.po_line_id = pol.po_line_id
6163 and pll.ship_to_organization_id = p_Organization_Id)
6164 --End of fix for Bug 3972931
6165 UNION
6166 -- This Section for GTIN Cross Ref
6167 -- Bug# 6747729
6168 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
6169 select mcr.cross_reference,
6170 msn.inventory_item_id,
6171 msn.description,
6172 Nvl(msn.revision_qty_control_code,1),
6173 Nvl(msn.lot_control_code, 1),
6174 Nvl(msn.serial_number_control_code, 1),
6175 Nvl(msn.restrict_subinventories_code, 2),
6176 Nvl(msn.restrict_locators_code, 2),
6177 Nvl(msn.location_control_code, 1),
6178 msn.primary_uom_code,
6179 Nvl(msn.inspection_required_flag, 'N'),
6180 Nvl(msn.shelf_life_code, 1),
6181 Nvl(msn.shelf_life_days,0),
6182 Nvl(msn.allowed_units_lookup_code, 2),
6183 Nvl(msn.effectivity_control,1),
6184 0,
6185 0,
6186 Nvl(msn.default_serial_status_id,1),
6187 Nvl(msn.serial_status_enabled,'N'),
6188 Nvl(msn.default_lot_status_id,0),
6189 Nvl(msn.lot_status_enabled,'N'),
6190 msn.concatenated_segments,
6191 'C',
6192 msn.inventory_item_flag,
6193 0,
6194 msn.inventory_asset_flag,
6195 msn.outside_operation_flag,
6196 --Bug 3952081
6197 --Select DUOM Attributes for every Item
6198 NVL(MSN.GRADE_CONTROL_FLAG,'N'),
6199 NVL(MSN.DEFAULT_GRADE,''),
6200 NVL(MSN.EXPIRATION_ACTION_INTERVAL,0),
6201 NVL(MSN.EXPIRATION_ACTION_CODE,''),
6202 NVL(MSN.HOLD_DAYS,0),
6203 NVL(MSN.MATURITY_DAYS,0),
6204 NVL(MSN.RETEST_INTERVAL,0),
6205 NVL(MSN.COPY_LOT_ATTRIBUTE_FLAG,'N'),
6206 NVL(MSN.CHILD_LOT_FLAG,'N'),
6207 NVL(MSN.CHILD_LOT_VALIDATION_FLAG,'N'),
6208 NVL(MSN.LOT_DIVISIBLE_FLAG,'Y'),
6209 NVL(MSN.SECONDARY_UOM_CODE,''),
6210 NVL(MSN.SECONDARY_DEFAULT_IND,''),
6211 NVL(MSN.TRACKING_QUANTITY_IND,'P'),
6212 NVL(MSN.DUAL_UOM_DEVIATION_HIGH,0),
6213 NVL(MSN.DUAL_UOM_DEVIATION_LOW,0),
6214 msn.stock_enabled_flag
6215 from mtl_system_items_vl msn, /* Bug 5581528 */
6216 rcv_shipment_lines rsl,
6217 mtl_cross_references mcr
6218 WHERE msn.organization_id = p_Organization_Id
6219 and ( mcr.cross_reference_type = g_gtin_cross_ref_type
6220 AND mcr.cross_reference LIKE g_crossref
6221 )
6222 and ( (mcr.org_independent_flag = 'Y') or (mcr.org_independent_flag = 'N'
6223 and mcr.organization_id = p_organization_id
6224 ) )
6225 and mcr.inventory_item_id = msn.inventory_item_id
6226 and (msn.purchasing_enabled_flag = 'Y' OR msn.stock_enabled_flag = 'Y')
6227 and rsl.SHIPMENT_HEADER_ID = p_shipmentHeaderID
6228 and rsl.to_organization_id= p_Organization_Id--Bug 3972931-Added the condiotn to filter based on organization_id
6229 and rsl.item_id = msn.inventory_item_id
6230 and ( (l_from_lpn_id is null) or (l_from_lpn_id is not null and
6231 exists ( select '1' from wms_lpn_contents wlc
6232 where wlc.parent_lpn_id = l_from_lpn_id
6233 and wlc.inventory_item_id = rsl.item_id
6234 ) )
6235 )
6236 ;
6237
6238
6239 -- *****************************
6240 --- END OF SHIPMENT HEADER ID SECTION
6241 -- *****************************
6242
6243 elsif (p_oeOrderHeaderID is not null) then
6244
6245 -- *****************************
6246 --- START OF OE ORDER HEADER ID SECTION
6247 -- *****************************
6248
6249 open x_items for
6250 -- Bug# 6747729
6251 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
6252 select concatenated_segments,
6253 inventory_item_id,
6254 description,
6255 Nvl(revision_qty_control_code,1),
6256 Nvl(lot_control_code, 1),
6257 Nvl(serial_number_control_code, 1),
6258 Nvl(restrict_subinventories_code, 2),
6259 Nvl(restrict_locators_code, 2),
6260 Nvl(location_control_code, 1),
6261 primary_uom_code,
6262 Nvl(inspection_required_flag, 'N'),
6263 Nvl(shelf_life_code, 1),
6264 Nvl(shelf_life_days,0),
6265 Nvl(allowed_units_lookup_code, 2),
6266 Nvl(effectivity_control,1),
6267 0,
6268 0,
6269 Nvl(default_serial_status_id,1),
6270 Nvl(serial_status_enabled,'N'),
6271 Nvl(default_lot_status_id,0),
6272 Nvl(lot_status_enabled,'N'),
6273 '',
6274 'N',
6275 inventory_item_flag,
6276 0,
6277 inventory_asset_flag,
6278 outside_operation_flag,
6279 --Bug 3952081
6280 --Select DUOM Attributes for every Item
6281 NVL(GRADE_CONTROL_FLAG,'N'),
6282 NVL(DEFAULT_GRADE,''),
6283 NVL(EXPIRATION_ACTION_INTERVAL,0),
6284 NVL(EXPIRATION_ACTION_CODE,''),
6285 NVL(HOLD_DAYS,0),
6286 NVL(MATURITY_DAYS,0),
6287 NVL(RETEST_INTERVAL,0),
6288 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
6289 NVL(CHILD_LOT_FLAG,'N'),
6290 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
6291 NVL(LOT_DIVISIBLE_FLAG,'Y'),
6292 NVL(SECONDARY_UOM_CODE,''),
6293 NVL(SECONDARY_DEFAULT_IND,''),
6294 NVL(TRACKING_QUANTITY_IND,'P'),
6295 NVL(DUAL_UOM_DEVIATION_HIGH,0),
6296 NVL(DUAL_UOM_DEVIATION_LOW,0),
6297 stock_enabled_flag
6298 from mtl_system_items_vl /* Bug 5581528 */
6299 WHERE organization_id = p_Organization_Id
6300 and concatenated_segments like p_concatenated_segments
6301 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
6302 and inventory_item_id IN (SELECT oel.inventory_item_id FROM
6303 oe_order_lines_all oel,oe_order_headers_all oeh--Bug 3972931-Added the table oe_order_headers_all
6304 WHERE oel.HEADER_ID = p_oeOrderHeaderID
6305 and oel.header_id = oeh.header_id --Bug4060261 -Added the join between the tables.
6306 and oel.ORDERED_QUANTITY > NVL(oel.SHIPPED_QUANTITY,0)
6307 and ((p_projectId is null or oel.project_id = p_projectId)
6308 and (p_taskID is null or oel.task_id = p_taskId ))
6309 and nvl(oel.ship_from_org_id, nvl(oeh.ship_from_org_id,p_Organization_Id)) = p_Organization_Id
6310 and oel.line_category_code = 'RETURN' --added for bug 4417549
6311 )
6312 --Bug 3972931-Added the filter condition based on ship_from_org_id
6313 UNION
6314 -- This Section Added for GTIN Cross Ref
6315 -- Bug# 6747729
6316 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
6317 select mcr.cross_reference,
6318 msi.inventory_item_id,
6319 msi.description,
6320 Nvl(msi.revision_qty_control_code,1),
6321 Nvl(msi.lot_control_code, 1),
6322 Nvl(msi.serial_number_control_code, 1),
6323 Nvl(msi.restrict_subinventories_code, 2),
6324 Nvl(msi.restrict_locators_code, 2),
6325 Nvl(msi.location_control_code, 1),
6326 msi.primary_uom_code,
6327 Nvl(msi.inspection_required_flag, 'N'),
6328 Nvl(msi.shelf_life_code, 1),
6329 Nvl(msi.shelf_life_days,0),
6330 Nvl(msi.allowed_units_lookup_code, 2),
6331 Nvl(msi.effectivity_control,1),
6332 0,
6333 0,
6334 Nvl(msi.default_serial_status_id,1),
6335 Nvl(msi.serial_status_enabled,'N'),
6336 Nvl(msi.default_lot_status_id,0),
6337 Nvl(msi.lot_status_enabled,'N'),
6338 msi.concatenated_segments,
6339 'C',
6340 msi.inventory_item_flag,
6341 0,
6342 msi.inventory_asset_flag,
6343 msi.outside_operation_flag,
6344 --Bug 3952081
6345 --Select DUOM Attributes for every Item
6346 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
6347 NVL(MSI.DEFAULT_GRADE,''),
6348 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
6349 NVL(MSI.EXPIRATION_ACTION_CODE,''),
6350 NVL(MSI.HOLD_DAYS,0),
6351 NVL(MSI.MATURITY_DAYS,0),
6352 NVL(MSI.RETEST_INTERVAL,0),
6353 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
6354 NVL(MSI.CHILD_LOT_FLAG,'N'),
6355 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
6356 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
6357 NVL(MSI.SECONDARY_UOM_CODE,''),
6358 NVL(MSI.SECONDARY_DEFAULT_IND,''),
6359 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
6360 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
6361 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
6362 msi.stock_enabled_flag
6363 from mtl_system_items_vl msi /* Bug 5581528 */
6364 ,mtl_cross_references mcr
6365 WHERE msi.organization_id = p_Organization_Id
6366 and ( mcr.cross_reference_type = g_gtin_cross_ref_type
6367 AND mcr.cross_reference LIKE g_crossref
6368 )
6369 and ( (mcr.org_independent_flag = 'Y') or (mcr.org_independent_flag = 'N'
6370 and mcr.organization_id = p_organization_id
6371 ) )
6372 and mcr.inventory_item_id = msi.inventory_item_id
6373 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
6374 and msi.inventory_item_id IN (SELECT oel.inventory_item_id FROM
6375 oe_order_lines_all oel,oe_order_headers_all oeh--Bug 3972931-Added the table oe_order_headers_all
6376 WHERE oel.HEADER_ID = p_oeOrderHeaderID
6377 and oel.header_id = oeh.header_id --Bug4060261-Added the join between the tables.
6378 and oel.ORDERED_QUANTITY > NVL(oel.SHIPPED_QUANTITY,0)
6379 and ((p_projectId is null or oel.project_id = p_projectId)
6380 and (p_taskID is null or oel.task_id = p_taskId ))
6381 and nvl(oel.ship_from_org_id, nvl(oeh.ship_from_org_id,p_Organization_id)) = p_Organization_Id);
6382 --Bug 3972931-Added the filter condition based on ship_from_org_id
6383
6384 -- *****************************
6385 --- END OF OE ORDER HEADER ID SECTION
6386 -- *****************************
6387
6388 elsif (p_reqHeaderID is not null) then
6389
6390 -- *****************************
6391 --- START OF REQ HEADER ID SECTION
6392 -- *****************************
6393
6394 open x_items for
6395 -- Bug# 6747729
6396 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
6397 /* select concatenated_segments,
6398 inventory_item_id,
6399 description,
6400 Nvl(revision_qty_control_code,1),
6401 Nvl(lot_control_code, 1),
6402 Nvl(serial_number_control_code, 1),
6403 Nvl(restrict_subinventories_code, 2),
6404 Nvl(restrict_locators_code, 2),
6405 Nvl(location_control_code, 1),
6406 primary_uom_code,
6407 Nvl(inspection_required_flag, 'N'),
6408 Nvl(shelf_life_code, 1),
6409 Nvl(shelf_life_days,0),
6410 Nvl(allowed_units_lookup_code, 2),
6411 Nvl(effectivity_control,1),
6412 0,
6413 0,
6414 Nvl(default_serial_status_id,1),
6415 Nvl(serial_status_enabled,'N'),
6416 Nvl(default_lot_status_id,0),
6417 Nvl(lot_status_enabled,'N'),
6418 '',
6419 'N',
6420 inventory_item_flag,
6421 0,
6422 inventory_asset_flag,
6423 outside_operation_flag,
6424 --Bug 3952081
6425 --Select DUOM Attributes for every Item
6426 NVL(GRADE_CONTROL_FLAG,'N'),
6427 NVL(DEFAULT_GRADE,''),
6428 NVL(EXPIRATION_ACTION_INTERVAL,0),
6429 NVL(EXPIRATION_ACTION_CODE,''),
6430 NVL(HOLD_DAYS,0),
6431 NVL(MATURITY_DAYS,0),
6432 NVL(RETEST_INTERVAL,0),
6433 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
6434 NVL(CHILD_LOT_FLAG,'N'),
6435 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
6436 NVL(LOT_DIVISIBLE_FLAG,'Y'),
6437 NVL(SECONDARY_UOM_CODE,''),
6438 NVL(SECONDARY_DEFAULT_IND,''),
6439 NVL(TRACKING_QUANTITY_IND,'P'),
6440 NVL(DUAL_UOM_DEVIATION_HIGH,0),
6441 NVL(DUAL_UOM_DEVIATION_LOW,0),
6442 stock_enabled_flag
6443 from mtl_system_items_vl Bug 5581528
6444 WHERE organization_id = p_Organization_Id
6445 and concatenated_segments like p_concatenated_segments
6446 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
6447 and exists (SELECT 1 FROM po_requisition_lines_all prl,
6448 rcv_shipment_lines rsl , po_req_distributions_all prd
6449 WHERE prl.requisition_header_id = p_reqHeaderID
6450 and rsl.item_id = inventory_item_id
6451 and ( (l_from_lpn_id is null)
6452 or (l_from_lpn_id is not null and exists
6453 ( select '1' from wms_lpn_contents wlc
6454 where wlc.parent_lpn_id = l_from_lpn_id
6455 and wlc.inventory_item_id = rsl.item_id
6456 )
6457 )
6458 )
6459 and prl.requisition_line_id = rsl.requisition_line_id
6460 and prl.requisition_line_id = prd.requisition_line_id
6461 and prl.destination_organization_id=p_Organization_Id--Bug 3972931- Added the condition to filter based on destination org
6462 and (p_projectId is null or prd.project_id = p_projectId)
6463 and (p_taskId is null or prd.task_id = p_taskId)
6464 )
6465 UNION
6466 -- Section for GTIN Cross Ref.
6467 -- Bug# 6747729
6468 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
6469 select mcr.cross_reference,
6470 msi.inventory_item_id,
6471 msi.description,
6472 Nvl(msi.revision_qty_control_code,1),
6473 Nvl(msi.lot_control_code, 1),
6474 Nvl(msi.serial_number_control_code, 1),
6475 Nvl(msi.restrict_subinventories_code, 2),
6476 Nvl(msi.restrict_locators_code, 2),
6477 Nvl(msi.location_control_code, 1),
6478 msi.primary_uom_code,
6479 Nvl(msi.inspection_required_flag, 'N'),
6480 Nvl(msi.shelf_life_code, 1),
6481 Nvl(msi.shelf_life_days,0),
6482 Nvl(msi.allowed_units_lookup_code, 2),
6483 Nvl(msi.effectivity_control,1),
6484 0,
6485 0,
6486 Nvl(msi.default_serial_status_id,1),
6487 Nvl(msi.serial_status_enabled,'N'),
6488 Nvl(msi.default_lot_status_id,0),
6489 Nvl(msi.lot_status_enabled,'N'),
6490 msi.concatenated_segments,
6491 'C',
6492 msi.inventory_item_flag,
6493 0,
6494 msi.inventory_asset_flag,
6495 msi.outside_operation_flag,
6496 --Bug 3952081
6497 --Select DUOM Attributes for every Item
6498 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
6499 NVL(MSI.DEFAULT_GRADE,''),
6500 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
6501 NVL(MSI.EXPIRATION_ACTION_CODE,''),
6502 NVL(MSI.HOLD_DAYS,0),
6503 NVL(MSI.MATURITY_DAYS,0),
6504 NVL(MSI.RETEST_INTERVAL,0),
6505 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
6506 NVL(MSI.CHILD_LOT_FLAG,'N'),
6507 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
6508 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
6509 NVL(MSI.SECONDARY_UOM_CODE,''),
6510 NVL(MSI.SECONDARY_DEFAULT_IND,''),
6511 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
6512 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
6513 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
6514 msi.stock_enabled_flag
6515 from mtl_system_items_vl msi Bug 5581528
6516 ,mtl_cross_references mcr
6517 WHERE msi.organization_id = p_Organization_Id
6518 and ( mcr.cross_reference_type = g_gtin_cross_ref_type
6519 AND mcr.cross_reference LIKE g_crossref
6520 )
6521 and ( (mcr.org_independent_flag = 'Y') or (mcr.org_independent_flag = 'N'
6522 and mcr.organization_id = p_organization_id
6523 ) )
6524 and mcr.inventory_item_id = msi.inventory_item_id
6525 and (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
6526 and exists (SELECT 1 FROM po_requisition_lines_all prl,
6527 rcv_shipment_lines rsl , po_req_distributions_all prd
6528 WHERE prl.requisition_header_id = p_reqHeaderID
6529 and rsl.item_id = msi.inventory_item_id
6530 and ( (l_from_lpn_id is null)
6531 or (l_from_lpn_id is not null and exists
6532 ( select '1' from wms_lpn_contents wlc
6533 where wlc.parent_lpn_id = l_from_lpn_id
6534 and wlc.inventory_item_id = rsl.item_id
6535 )
6536 )
6537 )
6538 and prl.requisition_line_id = rsl.requisition_line_id
6539 and prl.requisition_line_id = prd.requisition_line_id
6540 and prl.destination_organization_id=p_Organization_Id--Bug 3972931- Added the condition to filter based on destination org
6541 and (p_projectId is null or prd.project_id = p_projectId)
6542 and (p_taskId is null or prd.task_id = p_taskId)
6543 ) ; */
6544
6545 --Commented the above query for Bug# 7216416
6546 --Start of Fix for Bug# 7216416
6547
6548 SELECT /*+ leading(rsl1) use_nl(rsl1 mtl_system_items_vl)
6549 index(mtl_system_items_vl MTL_SYSTEM_ITEMS_B_U1) */
6550
6551 concatenated_segments ,
6552 inventory_item_id ,
6553 description ,
6554 NVL(revision_qty_control_code,1) ,
6555 NVL(lot_control_code, 1) ,
6556 NVL(serial_number_control_code, 1) ,
6557 NVL(restrict_subinventories_code, 2),
6558 NVL(restrict_locators_code, 2) ,
6559 NVL(location_control_code, 1) ,
6560 primary_uom_code ,
6561 NVL(inspection_required_flag, 'N') ,
6562 NVL(shelf_life_code, 1) ,
6563 NVL(shelf_life_days,0) ,
6564 NVL(allowed_units_lookup_code, 2) ,
6565 NVL(effectivity_control,1) ,
6566 0 ,
6567 0 ,
6568 NVL(default_serial_status_id,1) ,
6569 NVL(serial_status_enabled,'N') ,
6570 NVL(default_lot_status_id,0) ,
6571 NVL(lot_status_enabled,'N') ,
6572 '' ,
6573 'N' ,
6574 inventory_item_flag ,
6575 0 ,
6576 inventory_asset_flag ,
6577 outside_operation_flag ,
6578 --Bug 3952081
6579 --Select DUOM Attributes for every Item
6580 NVL(GRADE_CONTROL_FLAG,'N') ,
6581 NVL(DEFAULT_GRADE,'') ,
6582 NVL(EXPIRATION_ACTION_INTERVAL,0) ,
6583 NVL(EXPIRATION_ACTION_CODE,'') ,
6584 NVL(HOLD_DAYS,0) ,
6585 NVL(MATURITY_DAYS,0) ,
6586 NVL(RETEST_INTERVAL,0) ,
6587 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N') ,
6588 NVL(CHILD_LOT_FLAG,'N') ,
6589 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
6590 NVL(LOT_DIVISIBLE_FLAG,'Y') ,
6591 NVL(SECONDARY_UOM_CODE,'') ,
6592 NVL(SECONDARY_DEFAULT_IND,'') ,
6593 NVL(TRACKING_QUANTITY_IND,'P') ,
6594 NVL(DUAL_UOM_DEVIATION_HIGH,0) ,
6595 NVL(DUAL_UOM_DEVIATION_LOW,0) ,
6596 stock_enabled_flag
6597 FROM mtl_system_items_vl,
6598 /* Bug 5581528 */
6599 (
6600 SELECT DISTINCT rsl.Item_Id
6601 FROM po_Requisition_Lines_All prl,
6602 rcv_Shipment_Lines rsl ,
6603 po_req_Distributions_All prd
6604 WHERE prl.Requisition_Header_Id = p_reqHeadeRid
6605 AND l_From_lpn_Id IS NOT NULL
6606 AND EXISTS
6607 (SELECT '1'
6608 FROM wms_lpn_Contents wlc
6609 WHERE wlc.Parent_lpn_Id = l_From_lpn_Id
6610 AND wlc.Inventory_Item_Id = rsl.Item_Id
6611 )
6612 AND prl.Requisition_Line_Id = rsl.Requisition_Line_Id
6613 AND prl.Requisition_Line_Id = prd.Requisition_Line_Id
6614 AND prl.Destination_Organization_Id = p_Organization_Id--Bug 3972931- Added the condition to filter based on destination org
6615 AND (p_ProjectId IS NULL
6616 OR prd.Project_Id = p_ProjectId)
6617 AND (p_TaskId IS NULL
6618 OR prd.Task_Id = p_TaskId)
6619 ) rsl1
6620 WHERE organization_id = p_Organization_Id
6621 AND concatenated_segments LIKE p_concatenated_segments
6622 AND (purchasing_enabled_flag = 'Y'
6623 OR stock_enabled_flag = 'Y')
6624 AND Inventory_Item_Id = rsl1.Item_Id
6625
6626 UNION
6627
6628 SELECT /*+ leading(rsl1) use_nl(rsl1 msiv1)
6629 index(msiv1 MTL_SYSTEM_ITEMS_B_U1) */
6630
6631 concatenated_segments ,
6632 inventory_item_id ,
6633 description ,
6634 NVL(revision_qty_control_code,1) ,
6635 NVL(lot_control_code, 1) ,
6636 NVL(serial_number_control_code, 1) ,
6637 NVL(restrict_subinventories_code, 2),
6638 NVL(restrict_locators_code, 2) ,
6639 NVL(location_control_code, 1) ,
6640 primary_uom_code ,
6641 NVL(inspection_required_flag, 'N') ,
6642 NVL(shelf_life_code, 1) ,
6643 NVL(shelf_life_days,0) ,
6644 NVL(allowed_units_lookup_code, 2) ,
6645 NVL(effectivity_control,1) ,
6646 0 ,
6647 0 ,
6648 NVL(default_serial_status_id,1) ,
6649 NVL(serial_status_enabled,'N') ,
6650 NVL(default_lot_status_id,0) ,
6651 NVL(lot_status_enabled,'N') ,
6652 '' ,
6653 'N' ,
6654 inventory_item_flag ,
6655 0 ,
6656 inventory_asset_flag ,
6657 outside_operation_flag ,
6658 --Bug 3952081
6659 --Select DUOM Attributes for every Item
6660 NVL(GRADE_CONTROL_FLAG,'N') ,
6661 NVL(DEFAULT_GRADE,'') ,
6662 NVL(EXPIRATION_ACTION_INTERVAL,0) ,
6663 NVL(EXPIRATION_ACTION_CODE,'') ,
6664 NVL(HOLD_DAYS,0) ,
6665 NVL(MATURITY_DAYS,0) ,
6666 NVL(RETEST_INTERVAL,0) ,
6667 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N') ,
6668 NVL(CHILD_LOT_FLAG,'N') ,
6669 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
6670 NVL(LOT_DIVISIBLE_FLAG,'Y') ,
6671 NVL(SECONDARY_UOM_CODE,'') ,
6672 NVL(SECONDARY_DEFAULT_IND,'') ,
6673 NVL(TRACKING_QUANTITY_IND,'P') ,
6674 NVL(DUAL_UOM_DEVIATION_HIGH,0) ,
6675 NVL(DUAL_UOM_DEVIATION_LOW,0) ,
6676 stock_enabled_flag
6677 FROM mtl_system_items_vl,
6678 /* Bug 5581528 */
6679 (
6680 SELECT DISTINCT rsl.Item_Id
6681 FROM po_Requisition_Lines_All prl,
6682 rcv_Shipment_Lines rsl ,
6683 po_req_Distributions_All prd
6684 WHERE prl.Requisition_Header_Id = p_reqHeadeRid
6685 AND l_From_lpn_Id IS NULL
6686 AND prl.Requisition_Line_Id = rsl.Requisition_Line_Id
6687 AND prl.Requisition_Line_Id = prd.Requisition_Line_Id
6688 AND prl.Destination_Organization_Id = p_Organization_Id--Bug 3972931- Added the condition to filter based on destination org
6689 AND (p_ProjectId IS NULL
6690 OR prd.Project_Id = p_ProjectId)
6691 AND (p_TaskId IS NULL
6692 OR prd.Task_Id = p_TaskId)
6693 ) rsl1
6694 WHERE organization_id = p_Organization_Id
6695 AND concatenated_segments LIKE p_concatenated_segments
6696 AND (purchasing_enabled_flag = 'Y'
6697 OR stock_enabled_flag = 'Y')
6698 AND Inventory_Item_Id = rsl1.Item_Id
6699
6700 UNION
6701
6702 -- Section for GTIN Cross Ref.
6703 -- Bug# 6747729
6704 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
6705 SELECT mcr.cross_reference ,
6706 msi.inventory_item_id ,
6707 msi.description ,
6708 NVL(msi.revision_qty_control_code,1) ,
6709 NVL(msi.lot_control_code, 1) ,
6710 NVL(msi.serial_number_control_code, 1) ,
6711 NVL(msi.restrict_subinventories_code, 2),
6712 NVL(msi.restrict_locators_code, 2) ,
6713 NVL(msi.location_control_code, 1) ,
6714 msi.primary_uom_code ,
6715 NVL(msi.inspection_required_flag, 'N') ,
6716 NVL(msi.shelf_life_code, 1) ,
6717 NVL(msi.shelf_life_days,0) ,
6718 NVL(msi.allowed_units_lookup_code, 2) ,
6719 NVL(msi.effectivity_control,1) ,
6720 0 ,
6721 0 ,
6722 NVL(msi.default_serial_status_id,1) ,
6723 NVL(msi.serial_status_enabled,'N') ,
6724 NVL(msi.default_lot_status_id,0) ,
6725 NVL(msi.lot_status_enabled,'N') ,
6726 msi.concatenated_segments ,
6727 'C' ,
6728 msi.inventory_item_flag ,
6729 0 ,
6730 msi.inventory_asset_flag ,
6731 msi.outside_operation_flag ,
6732 --Bug 3952081
6733 --Select DUOM Attributes for every Item
6734 NVL(MSI.GRADE_CONTROL_FLAG,'N') ,
6735 NVL(MSI.DEFAULT_GRADE,'') ,
6736 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0) ,
6737 NVL(MSI.EXPIRATION_ACTION_CODE,'') ,
6738 NVL(MSI.HOLD_DAYS,0) ,
6739 NVL(MSI.MATURITY_DAYS,0) ,
6740 NVL(MSI.RETEST_INTERVAL,0) ,
6741 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N') ,
6742 NVL(MSI.CHILD_LOT_FLAG,'N') ,
6743 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
6744 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y') ,
6745 NVL(MSI.SECONDARY_UOM_CODE,'') ,
6746 NVL(MSI.SECONDARY_DEFAULT_IND,'') ,
6747 NVL(MSI.TRACKING_QUANTITY_IND,'P') ,
6748 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0) ,
6749 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0) ,
6750 msi.stock_enabled_flag
6751 FROM mtl_system_items_vl msi
6752 /* Bug 5581528 */
6753 ,
6754 mtl_cross_references mcr
6755 WHERE msi.organization_id = p_Organization_Id
6756 AND ( mcr.cross_reference_type = g_gtin_cross_ref_type
6757 AND mcr.cross_reference LIKE g_crossref )
6758 AND ( (mcr.org_independent_flag = 'Y')
6759 OR (mcr.org_independent_flag = 'N'
6760 AND mcr.organization_id = p_organization_id ) )
6761 AND mcr.inventory_item_id = msi.inventory_item_id
6762 AND (purchasing_enabled_flag = 'Y'
6763 OR stock_enabled_flag = 'Y')
6764 AND EXISTS
6765 (SELECT 1
6766 FROM po_requisition_lines_all prl,
6767 rcv_shipment_lines rsl ,
6768 po_req_distributions_all prd
6769 WHERE prl.requisition_header_id = p_reqHeaderID
6770 AND rsl.item_id = msi.inventory_item_id
6771 AND ( (l_from_lpn_id IS NULL)
6772 OR (l_from_lpn_id IS NOT NULL
6773 AND EXISTS
6774 (SELECT '1'
6775 FROM wms_lpn_contents wlc
6776 WHERE wlc.parent_lpn_id = l_from_lpn_id
6777 AND wlc.inventory_item_id = rsl.item_id
6778 ) ) )
6779 AND prl.requisition_line_id = rsl.requisition_line_id
6780 AND prl.requisition_line_id = prd.requisition_line_id
6781 AND prl.destination_organization_id=p_Organization_Id--Bug 3972931- Added the condition to filter based on destination org
6782 AND (p_projectId IS NULL
6783 OR prd.project_id = p_projectId)
6784 AND (p_taskId IS NULL
6785 OR prd.task_id = p_taskId)
6786 ) ;
6787
6788 --End of Fix for Bug# 7216416
6789
6790 -- *****************************
6791 --- END OF REQ HEADER ID SECTION
6792 -- *****************************
6793
6794 end if; --- End of doc Entered transaction
6795
6796 else
6797
6798 -- *****************************
6799 ---- Case for Document Info is not entered in the session , i.e transaction starts with Item
6800 -- *****************************
6801
6802 OPEN x_items FOR
6803 --Items from Item Master
6804 -- Bug# 6747729
6805 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
6806 SELECT
6807 msi.concatenated_segments,
6808 msi.inventory_item_id,
6809 msi.description,
6810 Nvl(msi.revision_qty_control_code,1),
6811 Nvl(msi.lot_control_code, 1),
6812 Nvl(msi.serial_number_control_code, 1),
6813 Nvl(msi.restrict_subinventories_code, 2),
6814 Nvl(msi.restrict_locators_code, 2),
6815 Nvl(msi.location_control_code, 1),
6816 msi.primary_uom_code,
6817 Nvl(msi.inspection_required_flag, 'N'),
6818 Nvl(msi.shelf_life_code, 1),
6819 Nvl(msi.shelf_life_days,0),
6820 Nvl(msi.allowed_units_lookup_code, 2),
6821 Nvl(msi.effectivity_control,1),
6822 0,
6823 0,
6824 Nvl(msi.default_serial_status_id,1),
6825 Nvl(msi.serial_status_enabled,'N'),
6826 Nvl(msi.default_lot_status_id,0),
6827 Nvl(msi.lot_status_enabled,'N'),
6828 '',
6829 'N',
6830 msi.inventory_item_flag,
6831 0,
6832 msi.inventory_asset_flag,
6833 msi.outside_operation_flag,
6834 --Bug 3952081
6835 --Select DUOM Attributes for every Item
6836 NVL(msi.GRADE_CONTROL_FLAG,'N'),
6837 NVL(msi.DEFAULT_GRADE,''),
6838 NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
6839 NVL(msi.EXPIRATION_ACTION_CODE,''),
6840 NVL(msi.HOLD_DAYS,0),
6841 NVL(msi.MATURITY_DAYS,0),
6842 NVL(msi.RETEST_INTERVAL,0),
6843 NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
6844 NVL(msi.CHILD_LOT_FLAG,'N'),
6845 NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
6846 NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
6847 NVL(msi.SECONDARY_UOM_CODE,''),
6848 NVL(msi.SECONDARY_DEFAULT_IND,''),
6849 NVL(msi.TRACKING_QUANTITY_IND,'P'),
6850 NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
6851 NVL(msi.DUAL_UOM_DEVIATION_LOW,0),
6852 msi.stock_enabled_flag
6853 FROM
6854 mtl_system_items_vl msi /* Bug 5581528 */
6855 WHERE msi.organization_id = p_organization_Id
6856 AND msi.concatenated_segments LIKE p_concatenated_segments
6857 AND (msi.purchasing_enabled_flag = 'Y' OR msi.stock_enabled_flag = 'Y')
6858 UNION -- ALL
6859 --Bug 7608067 This should Union but not Union ALL which is causing of displaying duplicate items in the LOV
6860 --This is caused by the 5353920 who has changed this query in one version and reverted back but didnt reverted this.
6861 --- Substitute Item SQL
6862 -- Bug# 6747729
6863 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
6864 SELECT
6865 msi.concatenated_segments,
6866 msi.inventory_item_id,
6867 msi.description,
6868 Nvl(msi.revision_qty_control_code,1),
6869 Nvl(msi.lot_control_code, 1),
6870 Nvl(msi.serial_number_control_code, 1),
6871 Nvl(msi.restrict_subinventories_code, 2),
6872 Nvl(msi.restrict_locators_code,2),
6873 Nvl(msi.location_control_code,1),
6874 msi.primary_uom_code,
6875 Nvl(msi.inspection_required_flag,'N'),
6876 Nvl(msi.shelf_life_code, 1),
6877 Nvl(msi.shelf_life_days,0),
6878 Nvl(msi.allowed_units_lookup_code, 2),
6879 Nvl(msi.effectivity_control,1),
6880 0,
6881 0,
6882 Nvl(msi.default_serial_status_id,1),
6883 Nvl(msi.serial_status_enabled,'N'),
6884 Nvl(msi.default_lot_status_id,0),
6885 Nvl(msi.lot_status_enabled,'N'),
6886 '',
6887 'N',
6888 msi.inventory_item_flag,
6889 0,
6890 msi.inventory_asset_flag,
6891 msi.outside_operation_flag,
6892 --Bug 3952081
6893 --Select DUOM Attributes for every Item
6894 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
6895 NVL(MSI.DEFAULT_GRADE,''),
6896 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
6897 NVL(MSI.EXPIRATION_ACTION_CODE,''),
6898 NVL(MSI.HOLD_DAYS,0),
6899 NVL(MSI.MATURITY_DAYS,0),
6900 NVL(MSI.RETEST_INTERVAL,0),
6901 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
6902 NVL(MSI.CHILD_LOT_FLAG,'N'),
6903 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
6904 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
6905 NVL(MSI.SECONDARY_UOM_CODE,''),
6906 NVL(MSI.SECONDARY_DEFAULT_IND,''),
6907 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
6908 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
6909 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
6910 msi.stock_enabled_flag
6911 FROM
6912 mtl_system_items_vl msi /* Bug 5581528 */
6913 WHERE msi.organization_id = p_organization_Id
6914 AND msi.concatenated_segments LIKE p_concatenated_segments
6915 AND (msi.purchasing_enabled_flag = 'Y' OR msi.stock_enabled_flag = 'Y')
6916 AND EXISTS (SELECT '1'
6917 FROM po_lines_all pol,
6918 mtl_related_items mri,
6919 po_line_locations_all pll
6920 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
6921 , mtl_parameters mp,
6922 rcv_parameters rp
6923 -- End for Bug 7440217
6924 WHERE NVL(pll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED')
6925 AND NVL(pll.allow_substitute_receipts_flag, 'N') = 'Y'
6926 AND pll.po_line_id = pol.po_line_id
6927 AND pll.ship_to_organization_id = msi.organization_id
6928 AND (( mri.related_item_id = msi.inventory_item_id
6929 AND pol.item_id = mri.inventory_item_id)
6930 OR
6931 ( mri.inventory_item_id = msi.inventory_item_id
6932 AND pol.item_id = mri.related_item_id
6933 AND mri.reciprocal_flag = 'Y')
6934 )
6935 -- For Bug 7440217 Checking if it is LCM enabled
6936 AND mp.organization_id = p_organization_id
6937 AND rp.organization_id = p_organization_id
6938 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
6939 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
6940 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
6941 )
6942 -- End for Bug 7440217
6943 )
6944 UNION ALL
6945 ---- Vendor Item SQL
6946 -- Bug# 6747729
6947 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
6948 SELECT DISTINCT
6949 pol.vendor_product_num,
6950 msi.inventory_item_id,
6951 msi.description,
6952 Nvl(msi.revision_qty_control_code,1),
6953 Nvl(msi.lot_control_code, 1),
6954 Nvl(msi.serial_number_control_code, 1),
6955 Nvl(msi.restrict_subinventories_code, 2),
6956 Nvl(msi.restrict_locators_code,2),
6957 Nvl(msi.location_control_code,1),
6958 msi.primary_uom_code,
6959 Nvl(msi.inspection_required_flag,'N'),
6960 Nvl(msi.shelf_life_code, 1),
6961 Nvl(msi.shelf_life_days,0),
6962 Nvl(msi.allowed_units_lookup_code, 2),
6963 Nvl(msi.effectivity_control,1),
6964 0,
6965 0,
6966 Nvl(msi.default_serial_status_id,1),
6967 Nvl(msi.serial_status_enabled,'N'),
6968 Nvl(msi.default_lot_status_id,0),
6969 Nvl(msi.lot_status_enabled,'N'),
6970 msi.concatenated_segments,
6971 'Y',
6972 msi.inventory_item_flag,
6973 0,
6974 msi.inventory_asset_flag,
6975 msi.outside_operation_flag,
6976 --Bug 3952081
6977 --Select DUOM Attributes for every Item
6978 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
6979 NVL(MSI.DEFAULT_GRADE,''),
6980 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
6981 NVL(MSI.EXPIRATION_ACTION_CODE,''),
6982 NVL(MSI.HOLD_DAYS,0),
6983 NVL(MSI.MATURITY_DAYS,0),
6984 NVL(MSI.RETEST_INTERVAL,0),
6985 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
6986 NVL(MSI.CHILD_LOT_FLAG,'N'),
6987 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
6988 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
6989 NVL(MSI.SECONDARY_UOM_CODE,''),
6990 NVL(MSI.SECONDARY_DEFAULT_IND,''),
6991 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
6992 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
6993 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
6994 msi.stock_enabled_flag
6995 FROM
6996 po_lines_all pol,
6997 mtl_system_items_vl msi /* Bug 5581528 */
6998 WHERE msi.organization_id = p_organization_Id
6999 AND (msi.purchasing_enabled_flag = 'Y' OR msi.stock_enabled_flag = 'Y')
7000 AND pol.vendor_product_num like p_concatenated_segments
7001 AND pol.item_id = msi.inventory_item_id
7002 AND pol.vendor_product_num IS NOT NULL
7003 AND EXISTS (SELECT '1'
7004 FROM po_line_locations_all pll
7005 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
7006 , mtl_parameters mp,
7007 rcv_parameters rp
7008 -- End for Bug 7440217
7009 WHERE pll.po_line_id = pol.po_line_id
7010 AND pll.ship_to_organization_id = msi.organization_id
7011 AND NVL(pll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED')
7012 -- For Bug 7440217 Checking if it is LCM enabled
7013 AND mp.organization_id = p_organization_id
7014 AND rp.organization_id = p_organization_id
7015 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
7016 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
7017 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
7018 )
7019 -- End for Bug 7440217
7020 )
7021 UNION ALL
7022 --- Cross Ref Items
7023 -- Bug# 6747729
7024 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
7025 SELECT DISTINCT
7026 mcr.cross_reference,
7027 msi.inventory_item_id,
7028 msi.description,
7029 Nvl(msi.revision_qty_control_code,1),
7030 Nvl(msi.lot_control_code, 1),
7031 Nvl(msi.serial_number_control_code, 1),
7032 Nvl(msi.restrict_subinventories_code, 2),
7033 Nvl(msi.restrict_locators_code,2),
7034 Nvl(msi.location_control_code,1),
7035 msi.primary_uom_code,
7036 Nvl(msi.inspection_required_flag,'N'),
7037 Nvl(msi.shelf_life_code, 1),
7038 Nvl(msi.shelf_life_days,0),
7039 Nvl(msi.allowed_units_lookup_code, 2),
7040 Nvl(msi.effectivity_control,1),
7041 0,
7042 0,
7043 Nvl(msi.default_serial_status_id,1),
7044 Nvl(msi.serial_status_enabled,'N'),
7045 Nvl(msi.default_lot_status_id,0),
7046 Nvl(msi.lot_status_enabled,'N'),
7047 msi.concatenated_segments,
7048 'C',
7049 msi.inventory_item_flag,
7050 0,
7051 msi.inventory_asset_flag,
7052 msi.outside_operation_flag,
7053 --Bug 3952081
7054 --Select DUOM Attributes for every Item
7055 NVL(MSI.GRADE_CONTROL_FLAG,'N'),
7056 NVL(MSI.DEFAULT_GRADE,''),
7057 NVL(MSI.EXPIRATION_ACTION_INTERVAL,0),
7058 NVL(MSI.EXPIRATION_ACTION_CODE,''),
7059 NVL(MSI.HOLD_DAYS,0),
7060 NVL(MSI.MATURITY_DAYS,0),
7061 NVL(MSI.RETEST_INTERVAL,0),
7062 NVL(MSI.COPY_LOT_ATTRIBUTE_FLAG,'N'),
7063 NVL(MSI.CHILD_LOT_FLAG,'N'),
7064 NVL(MSI.CHILD_LOT_VALIDATION_FLAG,'N'),
7065 NVL(MSI.LOT_DIVISIBLE_FLAG,'Y'),
7066 NVL(MSI.SECONDARY_UOM_CODE,''),
7067 NVL(MSI.SECONDARY_DEFAULT_IND,''),
7068 NVL(MSI.TRACKING_QUANTITY_IND,'P'),
7069 NVL(MSI.DUAL_UOM_DEVIATION_HIGH,0),
7070 NVL(MSI.DUAL_UOM_DEVIATION_LOW,0),
7071 msi.stock_enabled_flag
7072 FROM
7073 mtl_system_items_vl msi, /* Bug 5581528 */
7074 mtl_cross_references mcr
7075 WHERE msi.organization_id = p_organization_Id
7076 AND ( (mcr.cross_reference_type = p_crossreftype
7077 AND mcr.cross_reference LIKE p_concatenated_segments
7078 ) OR
7079 ( mcr.cross_reference_type = g_gtin_cross_ref_type
7080 AND mcr.cross_reference LIKE g_crossref )
7081 )
7082 AND ( (mcr.org_independent_flag = 'Y') OR (mcr.org_independent_flag = 'N'
7083 AND mcr.organization_id = p_organization_Id
7084 ) )
7085 AND mcr.inventory_item_id = msi.inventory_item_id
7086 AND (msi.purchasing_enabled_flag = 'Y' OR msi.stock_enabled_flag = 'Y')
7087 UNION ALL
7088 -- Non Item Master
7089 -- Bug# 6747729
7090 -- Added code to also fetch stock_enabled_flag from mtl_system_items_v
7091 SELECT DISTINCT pol.item_description,
7092 to_number(''),
7093 pol.item_description,
7094 1,
7095 1,
7096 1,
7097 2,
7098 2,
7099 1,
7100 mum.uom_code,
7101 'N',
7102 1,
7103 0,
7104 2,
7105 1,
7106 0,
7107 0,
7108 1,
7109 'N',
7110 0,
7111 'N',
7112 '',
7113 'N',
7114 'N',
7115 0,
7116 to_char(NULL),
7117 'N',
7118 --Bug 3952081
7119 --Select DUOM Attributes for every Item
7120 'N',
7121 '',
7122 0,
7123 '',
7124 0,
7125 0,
7126 0,
7127 'N',
7128 'N',
7129 'N',
7130 'Y',
7131 '',
7132 '',
7133 'P',
7134 0,
7135 0,
7136 'N'
7137 FROM
7138 po_lines_all pol,
7139 mtl_units_of_measure mum
7140 -- Bug 2619063, 2614016
7141 -- Modified to select the base uom for the uom class defined on po.
7142 WHERE mum.uom_class = (SELECT mum2.uom_class
7143 FROM mtl_units_of_measure mum2
7144 WHERE mum2.unit_of_measure(+) = pol.unit_meas_lookup_code)
7145 AND mum.base_uom_flag = 'Y'
7146 AND pol.ITEM_ID is NULL
7147 AND pol.item_description IS NOT NULL
7148 AND pol.item_description LIKE p_concatenated_segments
7149 AND EXISTS (SELECT '1'
7150 FROM po_line_locations_all pll
7151 -- For Bug 7440217 Added MTL_PARAMETERS and RCV_PRAMETERS to find out if the organization is LCM enabled or not
7152 , mtl_parameters mp,
7153 rcv_parameters rp
7154 -- End for Bug 7440217
7155 WHERE pll.po_line_id = pol.po_line_id
7156 AND pll.ship_to_organization_id = p_organization_id
7157 -- For Bug 7440217 Checking if it is LCM enabled
7158 AND mp.organization_id = p_organization_id
7159 AND rp.organization_id = p_organization_id
7160 AND ((NVL(mp.lcm_enabled_flag,'N') = 'N') -- Org is non-lcm enabled
7161 OR (NVL(rp.pre_receive,'N') = 'N') -- Org is lcm enabled and it is post-receiving
7162 OR (NVL(pll.lcm_flag,'N') = 'N') -- Org is lcm enabled, pre-receiving and non-lcm enabled shipment
7163 )
7164 -- End for Bug 7440217
7165 AND NVL(pll.closed_code,'OPEN') NOT IN ('FINALLY CLOSED','CLOSED FOR RECEIVING', 'CLOSED'));
7166 end if;
7167
7168 END GET_ITEM_LOV_RECEIVING ;
7169 -- ************** End of Bug 2442518
7170
7171 PROCEDURE GET_ITEM_LOV_INVTXN (
7172 x_Items OUT NOCOPY t_genref,
7173 p_Organization_Id IN NUMBER default null ,
7174 p_Concatenated_Segments IN VARCHAR2 default null )
7175 IS
7176 g_gtin_cross_ref_type VARCHAR2(25) := fnd_profile.value('INV:GTIN_CROSS_REFERENCE_TYPE');
7177 g_gtin_code_length NUMBER := 14;
7178 g_crossref VARCHAR2(40) := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
7179 BEGIN
7180 open x_items for
7181
7182 select concatenated_segments,
7183 inventory_item_id,
7184 description,
7185 Nvl(revision_qty_control_code,1),
7186 Nvl(lot_control_code, 1),
7187 Nvl(serial_number_control_code, 1),
7188 Nvl(restrict_subinventories_code, 2),
7189 Nvl(restrict_locators_code, 2),
7190 Nvl(location_control_code, 1),
7191 primary_uom_code,
7192 Nvl(inspection_required_flag, 'N'),
7193 Nvl(shelf_life_code, 1),
7194 Nvl(shelf_life_days,0),
7195 Nvl(allowed_units_lookup_code, 2),
7196 Nvl(effectivity_control,1),
7197 0,
7198 0,
7199 Nvl(default_serial_status_id,1),
7200 Nvl(serial_status_enabled,'N'),
7201 Nvl(default_lot_status_id,0),
7202 Nvl(lot_status_enabled,'N'),
7203 '',
7204 'N',
7205 inventory_item_flag,
7206 0,
7207 inventory_asset_flag,
7208 outside_operation_flag,
7209 --Bug 3952081
7210 --Select DUOM Attributes for every Item
7211 NVL(GRADE_CONTROL_FLAG,'N'),
7212 NVL(DEFAULT_GRADE,''),
7213 NVL(EXPIRATION_ACTION_INTERVAL,0),
7214 NVL(EXPIRATION_ACTION_CODE,''),
7215 NVL(HOLD_DAYS,0),
7216 NVL(MATURITY_DAYS,0),
7217 NVL(RETEST_INTERVAL,0),
7218 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
7219 NVL(CHILD_LOT_FLAG,'N'),
7220 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
7221 NVL(LOT_DIVISIBLE_FLAG,'Y'),
7222 NVL(SECONDARY_UOM_CODE,''),
7223 NVL(SECONDARY_DEFAULT_IND,''),
7224 NVL(TRACKING_QUANTITY_IND,'P'),
7225 NVL(DUAL_UOM_DEVIATION_HIGH,0),
7226 NVL(DUAL_UOM_DEVIATION_LOW,0)
7227 from mtl_system_items_vl
7228 WHERE organization_id = p_Organization_Id
7229 and concatenated_segments like p_concatenated_segments
7230 and mtl_transactions_enabled_flag = 'Y'
7231 and bom_item_type=4
7232
7233 UNION
7234
7235 select msik.concatenated_segments,
7236 msik.inventory_item_id,
7237 msik.description,
7238 Nvl(revision_qty_control_code,1),
7239 Nvl(lot_control_code, 1),
7240 Nvl(serial_number_control_code, 1),
7241 Nvl(restrict_subinventories_code, 2),
7242 Nvl(restrict_locators_code, 2),
7243 Nvl(location_control_code, 1),
7244 primary_uom_code,
7245 Nvl(inspection_required_flag, 'N'),
7246 Nvl(shelf_life_code, 1),
7247 Nvl(shelf_life_days,0),
7248 Nvl(allowed_units_lookup_code, 2),
7249 Nvl(effectivity_control,1),
7250 0,
7251 0,
7252 Nvl(default_serial_status_id,1),
7253 Nvl(serial_status_enabled,'N'),
7254 Nvl(default_lot_status_id,0),
7255 Nvl(lot_status_enabled,'N'),
7256 mcr.cross_reference,
7257 'N',
7258 inventory_item_flag,
7259 0,
7260 inventory_asset_flag,
7261 outside_operation_flag,
7262 --Bug 3952081
7263 --Select DUOM Attributes for every Item
7264 NVL(GRADE_CONTROL_FLAG,'N'),
7265 NVL(DEFAULT_GRADE,''),
7266 NVL(EXPIRATION_ACTION_INTERVAL,0),
7267 NVL(EXPIRATION_ACTION_CODE,''),
7268 NVL(HOLD_DAYS,0),
7269 NVL(MATURITY_DAYS,0),
7270 NVL(RETEST_INTERVAL,0),
7271 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
7272 NVL(CHILD_LOT_FLAG,'N'),
7273 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
7274 NVL(LOT_DIVISIBLE_FLAG,'Y'),
7275 NVL(SECONDARY_UOM_CODE,''),
7276 NVL(SECONDARY_DEFAULT_IND,''),
7277 NVL(TRACKING_QUANTITY_IND,'P'),
7278 NVL(DUAL_UOM_DEVIATION_HIGH,0),
7279 NVL(DUAL_UOM_DEVIATION_LOW,0)
7280 from mtl_system_items_vl msik, /* Bug 5581528 */
7281 mtl_cross_references mcr
7282 WHERE msik.organization_id = p_Organization_Id
7283 AND msik.inventory_item_id = mcr.inventory_item_id
7284 AND mcr.cross_reference_type = g_gtin_cross_ref_type
7285 AND mcr.cross_reference LIKE g_crossref
7286 AND (mcr.organization_id = msik.organization_id
7287 OR
7288 mcr.org_independent_flag = 'Y')
7289 AND mtl_transactions_enabled_flag = 'Y' --Added for bug 5196506
7290 AND bom_item_type=4; --Added for bug 5196506
7291
7292
7293 END GET_ITEM_LOV_INVTXN;
7294
7295 -- Use of Bind Variables in Inspect Page
7296 -- 2442758
7297
7298 PROCEDURE GET_LPN_LOV_INSPECT
7299 (x_lpn_lov OUT NOCOPY t_genref,
7300 p_lpn IN VARCHAR2,
7301 p_orgid IN NUMBER ,
7302 p_projid IN NUMBER ,
7303 p_taskid IN NUMBER
7304 )
7305 IS
7306 BEGIN
7307 OPEN x_lpn_lov FOR
7308 SELECT DISTINCT wlpn.license_plate_number,
7309 wlpn.lpn_id,
7310 NVL(wlpn.inventory_item_id, 0),
7311 NVL(wlpn.organization_id, 0),
7312 wlpn.revision,
7313 wlpn.lot_number,
7314 wlpn.serial_number,
7315 wlpn.subinventory_code,
7316 NVL(wlpn.locator_id, 0),
7317 NVL(wlpn.parent_lpn_id, 0),
7318 NVL(wlpn.sealed_status, 2),
7319 wlpn.gross_weight_uom_code,
7320 NVL(wlpn.gross_weight, 0),
7321 wlpn.content_volume_uom_code,
7322 NVL(wlpn.content_volume, 0),
7323 milk.concatenated_segments,
7324 wlpn.lpn_context
7325 FROM wms_license_plate_numbers wlpn,
7326 mtl_item_locations_kfv milk,
7327 wms_lpn_contents wlc
7328 WHERE wlpn.organization_id = milk.organization_id (+)
7329 AND wlpn.locator_id = milk.inventory_location_id(+)
7330 AND wlc.parent_lpn_id (+) = wlpn.lpn_id
7331 AND wlpn.license_plate_number LIKE p_lpn
7332 AND wlpn.organization_id = p_orgid
7333 AND wlpn.lpn_context in (3,5)
7334 AND (wlpn.lpn_context = 3 and wlpn.lpn_id IN (Select mtrl.lpn_id from mtl_txn_request_lines mtrl
7335 where mtrl.lpn_id = wlpn.lpn_id AND NVL(mtrl.project_id, -99) = p_projid
7336 AND NVL(mtrl.task_id, -99) = p_taskid ) )
7337 ORDER BY wlpn.license_plate_number
7338 ;
7339 END GET_LPN_LOV_INSPECT;
7340
7341 PROCEDURE GET_LPN_LOV_INVTXN
7342 (x_lpn_lov OUT NOCOPY t_genref,
7343 p_lpn IN VARCHAR2,
7344 p_orgid IN NUMBER
7345 )
7346 IS
7347 BEGIN
7348 OPEN x_lpn_lov FOR
7349 SELECT DISTINCT wlpn.license_plate_number,
7350 wlpn.lpn_id,
7351 NVL(wlpn.inventory_item_id, 0),
7352 NVL(wlpn.organization_id, 0),
7353 wlpn.revision,
7354 wlpn.lot_number,
7355 wlpn.serial_number,
7356 wlpn.subinventory_code,
7357 NVL(wlpn.locator_id, 0),
7358 NVL(wlpn.parent_lpn_id, 0),
7359 NVL(wlpn.sealed_status, 2),
7360 wlpn.gross_weight_uom_code,
7361 NVL(wlpn.gross_weight, 0),
7362 wlpn.content_volume_uom_code,
7363 NVL(wlpn.content_volume, 0),
7364 milk.concatenated_segments,
7365 wlpn.lpn_context
7366 FROM wms_license_plate_numbers wlpn,
7367 mtl_item_locations_kfv milk,
7368 wms_lpn_contents wlc
7369 WHERE wlpn.organization_id = milk.organization_id (+)
7370 AND wlpn.locator_id = milk.inventory_location_id(+)
7371 AND wlc.parent_lpn_id (+) = wlpn.lpn_id
7372 AND wlpn.license_plate_number LIKE p_lpn
7373 AND wlpn.lpn_context in (1,5)
7374 AND wlpn.organization_id = p_orgid
7375 ;
7376 END GET_LPN_LOV_INVTXN;
7377
7378 PROCEDURE GET_LPN_LOV_PJM
7379 (x_lpn_lov OUT NOCOPY t_genref,
7380 p_lpn IN VARCHAR2,
7381 p_orgid IN NUMBER
7382 )
7383 IS
7384 BEGIN
7385 OPEN x_lpn_lov FOR
7386 SELECT DISTINCT wlpn.license_plate_number,
7387 wlpn.lpn_id,
7388 NVL(wlpn.inventory_item_id, 0),
7389 NVL(wlpn.organization_id, 0),
7390 wlpn.revision,
7391 wlpn.lot_number,
7392 wlpn.serial_number,
7393 wlpn.subinventory_code,
7394 NVL(wlpn.locator_id, 0),
7395 NVL(wlpn.parent_lpn_id, 0),
7396 NVL(wlpn.sealed_status, 2),
7397 wlpn.gross_weight_uom_code,
7398 NVL(wlpn.gross_weight, 0),
7399 wlpn.content_volume_uom_code,
7400 NVL(wlpn.content_volume, 0),
7401 INV_PROJECT.GET_LOCSEGS(milk.inventory_location_id,milk.organization_id),
7402 INV_PROJECT.GET_PROJECT_ID,
7403 INV_PROJECT.GET_PROJECT_NUMBER,
7404 INV_PROJECT.GET_TASK_ID,
7405 INV_PROJECT.GET_TASK_NUMBER,
7406 wlpn.lpn_context
7407 FROM wms_license_plate_numbers wlpn,
7408 mtl_item_locations_kfv milk,
7409 wms_lpn_contents wlc
7410 WHERE wlpn.organization_id = milk.organization_id (+)
7411 AND wlpn.locator_id = milk.inventory_location_id(+)
7412 AND wlc.parent_lpn_id (+) = wlpn.lpn_id
7413 AND wlpn.license_plate_number LIKE p_lpn
7414 AND wlpn.lpn_context in (1,5)
7415 AND wlpn.organization_id = p_orgid
7416 ;
7417 END GET_LPN_LOV_PJM;
7418
7419 PROCEDURE GET_COUNTRY_LOV
7420 (x_country_lov OUT NOCOPY t_genref,
7421 p_country IN VARCHAR2 )
7422 IS
7423 BEGIN
7424 OPEN x_country_lov FOR
7425 SELECT territory_code, territory_short_name
7426 FROM fnd_territories_vl
7427 WHERE territory_code LIKE p_country || '%'
7428 ORDER BY territory_code;
7429 END GET_COUNTRY_LOV;
7430
7431 PROCEDURE get_hr_hz_locations_lov(
7432 x_location_codes OUT NOCOPY t_genref,
7433 p_location_code IN VARCHAR2) IS
7434 -- This procedure will return all HR and HZ Active Locations.
7435 -- Added as part of eIB Build; Bug# 4348541
7436 BEGIN
7437 OPEN x_location_codes FOR
7438 SELECT location_code, location_id, description
7439 FROM( SELECT hr.location_code location_code,
7440 hr.location_id location_id,
7441 hr.description
7442 FROM hr_locations hr
7443 WHERE NVL(inactive_date, SYSDATE+1) > SYSDATE
7444 UNION
7445 SELECT DECODE (
7446 inv_check_product_install.check_cse_install,
7447 'Y', NVL(clli_code, SUBSTR(city, 1, 10) || SUBSTR(location_id, 1, 10)),
7448 SUBSTR (city, 1, 10)|| SUBSTR (location_id, 1, 10)) location_code,
7449 hz.location_id location_id,
7450 hz.short_description
7451 FROM hz_locations hz
7452 WHERE (SYSDATE BETWEEN NVL(hz.address_effective_date, SYSDATE-1) AND
7453 NVL(hz.address_expiration_date, SYSDATE+1)))
7454 WHERE UPPER(location_code) LIKE UPPER(NVL(p_location_code, location_code)||'%')
7455 ORDER BY location_code;
7456 END get_hr_hz_locations_lov;
7457
7458 --Added for BUG 4309432
7459 PROCEDURE GET_ACTRJTQTY_LOV
7460 (x_actrjtqty_lov OUT NOCOPY t_genref,
7461 p_deliver_type IN VARCHAR2)
7462 IS
7463 BEGIN
7464 OPEN x_actrjtqty_lov FOR
7465 SELECT lookup_code, meaning
7466 FROM mfg_lookups
7467 WHERE lookup_type = 'INV_RCV_DELIVER_TYPE'
7468 AND meaning LIKE p_deliver_type || '%' ;
7469 END GET_ACTRJTQTY_LOV;
7470
7471 --Added for Bug 4498173
7472 PROCEDURE GET_INV_ITEM_LOV_RECEIVING
7473 (
7474 x_Items OUT NOCOPY t_genref,
7475 p_Organization_Id IN NUMBER,
7476 p_Concatenated_Segments IN VARCHAR2,
7477 p_receiptNum IN VARCHAR2,
7478 p_poHeaderID IN VARCHAR2,
7479 p_poReleaseID IN VARCHAR2,
7480 p_poLineID IN VARCHAR2,
7481 p_shipmentHeaderID IN VARCHAR2,
7482 p_oeOrderHeaderID IN VARCHAR2,
7483 p_reqHeaderID IN VARCHAR2,
7484 p_shipmentHeaderReceipt IN VARCHAR2
7485 )
7486
7487 IS
7488
7489 g_gtin_cross_ref_type VARCHAR2(25) := fnd_profile.value('INV:GTIN_CROSS_REFERENCE_TYPE');
7490 g_gtin_code_length NUMBER := 14;
7491 g_crossref VARCHAR2(40) := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
7492
7493 BEGIN
7494
7495 IF (p_receiptNum IS NOT NULL ) THEN
7496
7497 open x_items for
7498 SELECT
7499 concatenated_segments,
7500 msik.inventory_item_id,
7501 msik.description,
7502 Nvl(revision_qty_control_code,1),
7503 Nvl(lot_control_code, 1),
7504 Nvl(serial_number_control_code, 1),
7505 Nvl(restrict_subinventories_code, 2),
7506 Nvl(restrict_locators_code, 2),
7507 Nvl(location_control_code, 1),
7508 primary_uom_code,
7509 Nvl(inspection_required_flag, 'N'),
7510 Nvl(shelf_life_code, 1),
7511 Nvl(shelf_life_days,0),
7512 Nvl(allowed_units_lookup_code, 2),
7513 Nvl(effectivity_control,1),
7514 0,
7515 0,
7516 Nvl(default_serial_status_id,1),
7517 Nvl(serial_status_enabled,'N'),
7518 Nvl(default_lot_status_id,0),
7519 Nvl(lot_status_enabled,'N'),
7520 null,
7521 'N',
7522 inventory_item_flag,
7523 0,
7524 inventory_asset_flag,
7525 outside_operation_flag,
7526 --Bug 3952081
7527 --Select DUOM Attributes for every Item
7528 NVL(GRADE_CONTROL_FLAG,'N'),
7529 NVL(DEFAULT_GRADE,''),
7530 NVL(EXPIRATION_ACTION_INTERVAL,0),
7531 NVL(EXPIRATION_ACTION_CODE,''),
7532 NVL(HOLD_DAYS,0),
7533 NVL(MATURITY_DAYS,0),
7534 NVL(RETEST_INTERVAL,0),
7535 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
7536 NVL(CHILD_LOT_FLAG,'N'),
7537 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
7538 NVL(LOT_DIVISIBLE_FLAG,'Y'),
7539 NVL(SECONDARY_UOM_CODE,''),
7540 NVL(SECONDARY_DEFAULT_IND,''),
7541 NVL(TRACKING_QUANTITY_IND,'P'),
7542 NVL(DUAL_UOM_DEVIATION_HIGH,0),
7543 NVL(DUAL_UOM_DEVIATION_LOW,0)
7544 FROM
7545 mtl_system_items_vl msik /* Bug 5581528 */
7546 WHERE
7547 organization_id = p_Organization_Id
7548 AND concatenated_segments like p_concatenated_segments
7549 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
7550 AND msik.inventory_item_id IN (
7551 SELECT item_id
7552 from rcv_supply
7553 WHERE shipment_header_id = p_shipmentHeaderReceipt
7554 )
7555 UNION
7556
7557 select
7558 concatenated_segments,
7559 msik.inventory_item_id,
7560 msik.description,
7561 Nvl(revision_qty_control_code,1),
7562 Nvl(lot_control_code, 1),
7563 Nvl(serial_number_control_code, 1),
7564 Nvl(restrict_subinventories_code, 2),
7565 Nvl(restrict_locators_code, 2),
7566 Nvl(location_control_code, 1),
7567 primary_uom_code,
7568 Nvl(inspection_required_flag, 'N'),
7569 Nvl(shelf_life_code, 1),
7570 Nvl(shelf_life_days,0),
7571 Nvl(allowed_units_lookup_code, 2),
7572 Nvl(effectivity_control,1),
7573 0,
7574 0,
7575 Nvl(default_serial_status_id,1),
7576 Nvl(serial_status_enabled,'N'),
7577 Nvl(default_lot_status_id,0),
7578 Nvl(lot_status_enabled,'N'),
7579 mcr.cross_reference,
7580 'N',
7581 inventory_item_flag,
7582 0,
7583 inventory_asset_flag,
7584 outside_operation_flag,
7585 --Bug No 3952081
7586 --Additional Fields for Process Convergence
7587 NVL(GRADE_CONTROL_FLAG,'N'),
7588 NVL(DEFAULT_GRADE,''),
7589 NVL(EXPIRATION_ACTION_INTERVAL,0),
7590 NVL(EXPIRATION_ACTION_CODE,''),
7591 NVL(HOLD_DAYS,0),
7592 NVL(MATURITY_DAYS,0),
7593 NVL(RETEST_INTERVAL,0),
7594 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
7595 NVL(CHILD_LOT_FLAG,'N'),
7596 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
7597 NVL(LOT_DIVISIBLE_FLAG,'Y'),
7598 NVL(SECONDARY_UOM_CODE,''),
7599 NVL(SECONDARY_DEFAULT_IND,''),
7600 NVL(TRACKING_QUANTITY_IND,'P'),
7601 NVL(DUAL_UOM_DEVIATION_HIGH,0),
7602 NVL(DUAL_UOM_DEVIATION_LOW,0)
7603 FROM
7604 mtl_system_items_vl msik, /* Bug 5581528 */
7605 mtl_cross_references mcr
7606 WHERE
7607 msik.organization_id = p_organization_id
7608 AND msik.inventory_item_id = mcr.inventory_item_id
7609 AND mcr.cross_reference_type = g_gtin_cross_ref_type
7610 AND mcr.cross_reference like g_crossref
7611 AND (mcr.organization_id = msik.organization_id
7612 OR mcr.org_independent_flag = 'Y' )
7613 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
7614 AND msik.inventory_item_id IN (
7615 SELECT item_id
7616 from rcv_supply
7617 WHERE shipment_header_id = p_shipmentHeaderReceipt
7618 );
7619
7620 ELSIF (p_poHeaderID IS NOT NULL ) THEN
7621
7622 IF (p_poReleaseID IS NOT NULL ) THEN
7623 open x_items for
7624 SELECT
7625 concatenated_segments,
7626 msik.inventory_item_id,
7627 msik.description,
7628 Nvl(revision_qty_control_code,1),
7629 Nvl(lot_control_code, 1),
7630 Nvl(serial_number_control_code, 1),
7631 Nvl(restrict_subinventories_code, 2),
7632 Nvl(restrict_locators_code, 2),
7633 Nvl(location_control_code, 1),
7634 primary_uom_code,
7635 Nvl(inspection_required_flag, 'N'),
7636 Nvl(shelf_life_code, 1),
7637 Nvl(shelf_life_days,0),
7638 Nvl(allowed_units_lookup_code, 2),
7639 Nvl(effectivity_control,1),
7640 0,
7641 0,
7642 Nvl(default_serial_status_id,1),
7643 Nvl(serial_status_enabled,'N'),
7644 Nvl(default_lot_status_id,0),
7645 Nvl(lot_status_enabled,'N'),
7646 null,
7647 'N',
7648 inventory_item_flag,
7649 0,
7650 inventory_asset_flag,
7651 outside_operation_flag,
7652 --Bug 3952081
7653 --Select DUOM Attributes for every Item
7654 NVL(GRADE_CONTROL_FLAG,'N'),
7655 NVL(DEFAULT_GRADE,''),
7656 NVL(EXPIRATION_ACTION_INTERVAL,0),
7657 NVL(EXPIRATION_ACTION_CODE,''),
7658 NVL(HOLD_DAYS,0),
7659 NVL(MATURITY_DAYS,0),
7660 NVL(RETEST_INTERVAL,0),
7661 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
7662 NVL(CHILD_LOT_FLAG,'N'),
7663 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
7664 NVL(LOT_DIVISIBLE_FLAG,'Y'),
7665 NVL(SECONDARY_UOM_CODE,''),
7666 NVL(SECONDARY_DEFAULT_IND,''),
7667 NVL(TRACKING_QUANTITY_IND,'P'),
7668 NVL(DUAL_UOM_DEVIATION_HIGH,0),
7669 NVL(DUAL_UOM_DEVIATION_LOW,0)
7670 FROM
7671 mtl_system_items_vl msik /* Bug 5581528 */
7672 WHERE
7673 organization_id = p_Organization_Id
7674 AND concatenated_segments like p_concatenated_segments
7675 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
7676 AND msik.inventory_item_id IN (SELECT item_id FROM rcv_supply WHERE po_header_id = p_poHeaderID and po_release_id = p_poReleaseID)
7677 UNION
7678 select
7679 concatenated_segments,
7680 msik.inventory_item_id,
7681 msik.description,
7682 Nvl(revision_qty_control_code,1),
7683 Nvl(lot_control_code, 1),
7684 Nvl(serial_number_control_code, 1),
7685 Nvl(restrict_subinventories_code, 2),
7686 Nvl(restrict_locators_code, 2),
7687 Nvl(location_control_code, 1),
7688 primary_uom_code,
7689 Nvl(inspection_required_flag, 'N'),
7690 Nvl(shelf_life_code, 1),
7691 Nvl(shelf_life_days,0),
7692 Nvl(allowed_units_lookup_code, 2),
7693 Nvl(effectivity_control,1),
7694 0,
7695 0,
7696 Nvl(default_serial_status_id,1),
7697 Nvl(serial_status_enabled,'N'),
7698 Nvl(default_lot_status_id,0),
7699 Nvl(lot_status_enabled,'N'),
7700 mcr.cross_reference,
7701 'N',
7702 inventory_item_flag,
7703 0,
7704 inventory_asset_flag,
7705 outside_operation_flag,
7706 --Bug No 3952081
7707 --Additional Fields for Process Convergence
7708 NVL(GRADE_CONTROL_FLAG,'N'),
7709 NVL(DEFAULT_GRADE,''),
7710 NVL(EXPIRATION_ACTION_INTERVAL,0),
7711 NVL(EXPIRATION_ACTION_CODE,''),
7712 NVL(HOLD_DAYS,0),
7713 NVL(MATURITY_DAYS,0),
7714 NVL(RETEST_INTERVAL,0),
7715 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
7716 NVL(CHILD_LOT_FLAG,'N'),
7717 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
7718 NVL(LOT_DIVISIBLE_FLAG,'Y'),
7719 NVL(SECONDARY_UOM_CODE,''),
7720 NVL(SECONDARY_DEFAULT_IND,''),
7721 NVL(TRACKING_QUANTITY_IND,'P'),
7722 NVL(DUAL_UOM_DEVIATION_HIGH,0),
7723 NVL(DUAL_UOM_DEVIATION_LOW,0)
7724 FROM
7725 mtl_system_items_vl msik, /* Bug 5581528 */
7726 mtl_cross_references mcr
7727 WHERE
7728 msik.organization_id = p_organization_id
7729 AND msik.inventory_item_id = mcr.inventory_item_id
7730 AND mcr.cross_reference_type = g_gtin_cross_ref_type
7731 AND mcr.cross_reference like g_crossref
7732 AND (mcr.organization_id = msik.organization_id
7733 OR mcr.org_independent_flag = 'Y' )
7734 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
7735 AND msik.inventory_item_id IN (SELECT item_id FROM rcv_supply WHERE po_header_id = p_poHeaderID and po_release_id = p_poReleaseID);
7736
7737 ELSIF (p_poLineID IS NOT null ) THEN
7738 open x_items for
7739 SELECT
7740 concatenated_segments,
7741 msik.inventory_item_id,
7742 msik.description,
7743 Nvl(revision_qty_control_code,1),
7744 Nvl(lot_control_code, 1),
7745 Nvl(serial_number_control_code, 1),
7746 Nvl(restrict_subinventories_code, 2),
7747 Nvl(restrict_locators_code, 2),
7748 Nvl(location_control_code, 1),
7749 primary_uom_code,
7750 Nvl(inspection_required_flag, 'N'),
7751 Nvl(shelf_life_code, 1),
7752 Nvl(shelf_life_days,0),
7753 Nvl(allowed_units_lookup_code, 2),
7754 Nvl(effectivity_control,1),
7755 0,
7756 0,
7757 Nvl(default_serial_status_id,1),
7758 Nvl(serial_status_enabled,'N'),
7759 Nvl(default_lot_status_id,0),
7760 Nvl(lot_status_enabled,'N'),
7761 null,
7762 'N',
7763 inventory_item_flag,
7764 0,
7765 inventory_asset_flag,
7766 outside_operation_flag,
7767 --Bug 3952081
7768 --Select DUOM Attributes for every Item
7769 NVL(GRADE_CONTROL_FLAG,'N'),
7770 NVL(DEFAULT_GRADE,''),
7771 NVL(EXPIRATION_ACTION_INTERVAL,0),
7772 NVL(EXPIRATION_ACTION_CODE,''),
7773 NVL(HOLD_DAYS,0),
7774 NVL(MATURITY_DAYS,0),
7775 NVL(RETEST_INTERVAL,0),
7776 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
7777 NVL(CHILD_LOT_FLAG,'N'),
7778 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
7779 NVL(LOT_DIVISIBLE_FLAG,'Y'),
7780 NVL(SECONDARY_UOM_CODE,''),
7781 NVL(SECONDARY_DEFAULT_IND,''),
7782 NVL(TRACKING_QUANTITY_IND,'P'),
7783 NVL(DUAL_UOM_DEVIATION_HIGH,0),
7784 NVL(DUAL_UOM_DEVIATION_LOW,0)
7785 FROM
7786 mtl_system_items_vl msik /* Bug 5581528 */
7787 WHERE
7788 organization_id = p_Organization_Id
7789 AND concatenated_segments like p_concatenated_segments
7790 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
7791 AND msik.inventory_item_id IN (SELECT item_id FROM rcv_supply WHERE po_header_id = p_poHeaderID and po_line_id = p_poLineID )
7792 UNION
7793 select
7794 concatenated_segments,
7795 msik.inventory_item_id,
7796 msik.description,
7797 Nvl(revision_qty_control_code,1),
7798 Nvl(lot_control_code, 1),
7799 Nvl(serial_number_control_code, 1),
7800 Nvl(restrict_subinventories_code, 2),
7801 Nvl(restrict_locators_code, 2),
7802 Nvl(location_control_code, 1),
7803 primary_uom_code,
7804 Nvl(inspection_required_flag, 'N'),
7805 Nvl(shelf_life_code, 1),
7806 Nvl(shelf_life_days,0),
7807 Nvl(allowed_units_lookup_code, 2),
7808 Nvl(effectivity_control,1),
7809 0,
7810 0,
7811 Nvl(default_serial_status_id,1),
7812 Nvl(serial_status_enabled,'N'),
7813 Nvl(default_lot_status_id,0),
7814 Nvl(lot_status_enabled,'N'),
7815 mcr.cross_reference,
7816 'N',
7817 inventory_item_flag,
7818 0,
7819 inventory_asset_flag,
7820 outside_operation_flag,
7821 --Bug No 3952081
7822 --Additional Fields for Process Convergence
7823 NVL(GRADE_CONTROL_FLAG,'N'),
7824 NVL(DEFAULT_GRADE,''),
7825 NVL(EXPIRATION_ACTION_INTERVAL,0),
7826 NVL(EXPIRATION_ACTION_CODE,''),
7827 NVL(HOLD_DAYS,0),
7828 NVL(MATURITY_DAYS,0),
7829 NVL(RETEST_INTERVAL,0),
7830 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
7831 NVL(CHILD_LOT_FLAG,'N'),
7832 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
7833 NVL(LOT_DIVISIBLE_FLAG,'Y'),
7834 NVL(SECONDARY_UOM_CODE,''),
7835 NVL(SECONDARY_DEFAULT_IND,''),
7836 NVL(TRACKING_QUANTITY_IND,'P'),
7837 NVL(DUAL_UOM_DEVIATION_HIGH,0),
7838 NVL(DUAL_UOM_DEVIATION_LOW,0)
7839 FROM
7840 mtl_system_items_vl msik, /* Bug 5581528 */
7841 mtl_cross_references mcr
7842 WHERE
7843 msik.organization_id = p_organization_id
7844 AND msik.inventory_item_id = mcr.inventory_item_id
7845 AND mcr.cross_reference_type = g_gtin_cross_ref_type
7846 AND mcr.cross_reference like g_crossref
7847 AND (mcr.organization_id = msik.organization_id
7848 OR mcr.org_independent_flag = 'Y' )
7849 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
7850 AND msik.inventory_item_id IN (SELECT item_id FROM rcv_supply WHERE po_header_id = p_poHeaderID and po_line_id = p_poLineID );
7851
7852 ELSE
7853 open x_items for
7854 SELECT
7855 concatenated_segments,
7856 msik.inventory_item_id,
7857 msik.description,
7858 Nvl(revision_qty_control_code,1),
7859 Nvl(lot_control_code, 1),
7860 Nvl(serial_number_control_code, 1),
7861 Nvl(restrict_subinventories_code, 2),
7862 Nvl(restrict_locators_code, 2),
7863 Nvl(location_control_code, 1),
7864 primary_uom_code,
7865 Nvl(inspection_required_flag, 'N'),
7866 Nvl(shelf_life_code, 1),
7867 Nvl(shelf_life_days,0),
7868 Nvl(allowed_units_lookup_code, 2),
7869 Nvl(effectivity_control,1),
7870 0,
7871 0,
7872 Nvl(default_serial_status_id,1),
7873 Nvl(serial_status_enabled,'N'),
7874 Nvl(default_lot_status_id,0),
7875 Nvl(lot_status_enabled,'N'),
7876 null,
7877 'N',
7878 inventory_item_flag,
7879 0,
7880 inventory_asset_flag,
7881 outside_operation_flag,
7882 --Bug 3952081
7883 --Select DUOM Attributes for every Item
7884 NVL(GRADE_CONTROL_FLAG,'N'),
7885 NVL(DEFAULT_GRADE,''),
7886 NVL(EXPIRATION_ACTION_INTERVAL,0),
7887 NVL(EXPIRATION_ACTION_CODE,''),
7888 NVL(HOLD_DAYS,0),
7889 NVL(MATURITY_DAYS,0),
7890 NVL(RETEST_INTERVAL,0),
7891 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
7892 NVL(CHILD_LOT_FLAG,'N'),
7893 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
7894 NVL(LOT_DIVISIBLE_FLAG,'Y'),
7895 NVL(SECONDARY_UOM_CODE,''),
7896 NVL(SECONDARY_DEFAULT_IND,''),
7897 NVL(TRACKING_QUANTITY_IND,'P'),
7898 NVL(DUAL_UOM_DEVIATION_HIGH,0),
7899 NVL(DUAL_UOM_DEVIATION_LOW,0)
7900 FROM
7901 mtl_system_items_vl msik /* Bug 5581528 */
7902 WHERE
7903 organization_id = p_Organization_Id
7904 AND concatenated_segments like p_concatenated_segments
7905 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
7906 AND msik.inventory_item_id IN (SELECT item_id FROM rcv_supply WHERE po_header_id = p_poHeaderID )
7907 UNION
7908 select
7909 concatenated_segments,
7910 msik.inventory_item_id,
7911 msik.description,
7912 Nvl(revision_qty_control_code,1),
7913 Nvl(lot_control_code, 1),
7914 Nvl(serial_number_control_code, 1),
7915 Nvl(restrict_subinventories_code, 2),
7916 Nvl(restrict_locators_code, 2),
7917 Nvl(location_control_code, 1),
7918 primary_uom_code,
7919 Nvl(inspection_required_flag, 'N'),
7920 Nvl(shelf_life_code, 1),
7921 Nvl(shelf_life_days,0),
7922 Nvl(allowed_units_lookup_code, 2),
7923 Nvl(effectivity_control,1),
7924 0,
7925 0,
7926 Nvl(default_serial_status_id,1),
7927 Nvl(serial_status_enabled,'N'),
7928 Nvl(default_lot_status_id,0),
7929 Nvl(lot_status_enabled,'N'),
7930 mcr.cross_reference,
7931 'N',
7932 inventory_item_flag,
7933 0,
7934 inventory_asset_flag,
7935 outside_operation_flag,
7936 --Bug No 3952081
7937 --Additional Fields for Process Convergence
7938 NVL(GRADE_CONTROL_FLAG,'N'),
7939 NVL(DEFAULT_GRADE,''),
7940 NVL(EXPIRATION_ACTION_INTERVAL,0),
7941 NVL(EXPIRATION_ACTION_CODE,''),
7942 NVL(HOLD_DAYS,0),
7943 NVL(MATURITY_DAYS,0),
7944 NVL(RETEST_INTERVAL,0),
7945 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
7946 NVL(CHILD_LOT_FLAG,'N'),
7947 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
7948 NVL(LOT_DIVISIBLE_FLAG,'Y'),
7949 NVL(SECONDARY_UOM_CODE,''),
7950 NVL(SECONDARY_DEFAULT_IND,''),
7951 NVL(TRACKING_QUANTITY_IND,'P'),
7952 NVL(DUAL_UOM_DEVIATION_HIGH,0),
7953 NVL(DUAL_UOM_DEVIATION_LOW,0)
7954 FROM
7955 mtl_system_items_vl msik, /* Bug 5581528 */
7956 mtl_cross_references mcr
7957 WHERE
7958 msik.organization_id = p_organization_id
7959 AND msik.inventory_item_id = mcr.inventory_item_id
7960 AND mcr.cross_reference_type = g_gtin_cross_ref_type
7961 AND mcr.cross_reference like g_crossref
7962 AND (mcr.organization_id = msik.organization_id
7963 OR mcr.org_independent_flag = 'Y' )
7964 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
7965 AND msik.inventory_item_id IN (SELECT item_id FROM rcv_supply WHERE po_header_id = p_poHeaderID );
7966 end if;
7967
7968 ELSIF (p_shipmentHeaderID IS NOT null ) THEN
7969 open x_items for
7970 SELECT
7971 concatenated_segments,
7972 msik.inventory_item_id,
7973 msik.description,
7974 Nvl(revision_qty_control_code,1),
7975 Nvl(lot_control_code, 1),
7976 Nvl(serial_number_control_code, 1),
7977 Nvl(restrict_subinventories_code, 2),
7978 Nvl(restrict_locators_code, 2),
7979 Nvl(location_control_code, 1),
7980 primary_uom_code,
7981 Nvl(inspection_required_flag, 'N'),
7982 Nvl(shelf_life_code, 1),
7983 Nvl(shelf_life_days,0),
7984 Nvl(allowed_units_lookup_code, 2),
7985 Nvl(effectivity_control,1),
7986 0,
7987 0,
7988 Nvl(default_serial_status_id,1),
7989 Nvl(serial_status_enabled,'N'),
7990 Nvl(default_lot_status_id,0),
7991 Nvl(lot_status_enabled,'N'),
7992 null,
7993 'N',
7994 inventory_item_flag,
7995 0,
7996 inventory_asset_flag,
7997 outside_operation_flag,
7998 --Bug 3952081
7999 --Select DUOM Attributes for every Item
8000 NVL(GRADE_CONTROL_FLAG,'N'),
8001 NVL(DEFAULT_GRADE,''),
8002 NVL(EXPIRATION_ACTION_INTERVAL,0),
8003 NVL(EXPIRATION_ACTION_CODE,''),
8004 NVL(HOLD_DAYS,0),
8005 NVL(MATURITY_DAYS,0),
8006 NVL(RETEST_INTERVAL,0),
8007 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
8008 NVL(CHILD_LOT_FLAG,'N'),
8009 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
8010 NVL(LOT_DIVISIBLE_FLAG,'Y'),
8011 NVL(SECONDARY_UOM_CODE,''),
8012 NVL(SECONDARY_DEFAULT_IND,''),
8013 NVL(TRACKING_QUANTITY_IND,'P'),
8014 NVL(DUAL_UOM_DEVIATION_HIGH,0),
8015 NVL(DUAL_UOM_DEVIATION_LOW,0)
8016 FROM
8017 mtl_system_items_vl msik /* Bug 5581528 */
8018 WHERE
8019 organization_id = p_Organization_Id
8020 AND concatenated_segments like p_concatenated_segments
8021 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
8022 AND msik.inventory_item_id IN (SELECT item_id FROM rcv_supply WHERE SHIPMENT_HEADER_ID = p_shipmentHeaderID )
8023 UNION
8024 select
8025 concatenated_segments,
8026 msik.inventory_item_id,
8027 msik.description,
8028 Nvl(revision_qty_control_code,1),
8029 Nvl(lot_control_code, 1),
8030 Nvl(serial_number_control_code, 1),
8031 Nvl(restrict_subinventories_code, 2),
8032 Nvl(restrict_locators_code, 2),
8033 Nvl(location_control_code, 1),
8034 primary_uom_code,
8035 Nvl(inspection_required_flag, 'N'),
8036 Nvl(shelf_life_code, 1),
8037 Nvl(shelf_life_days,0),
8038 Nvl(allowed_units_lookup_code, 2),
8039 Nvl(effectivity_control,1),
8040 0,
8041 0,
8042 Nvl(default_serial_status_id,1),
8043 Nvl(serial_status_enabled,'N'),
8044 Nvl(default_lot_status_id,0),
8045 Nvl(lot_status_enabled,'N'),
8046 mcr.cross_reference,
8047 'N',
8048 inventory_item_flag,
8049 0,
8050 inventory_asset_flag,
8051 outside_operation_flag,
8052 --Bug No 3952081
8053 --Additional Fields for Process Convergence
8054 NVL(GRADE_CONTROL_FLAG,'N'),
8055 NVL(DEFAULT_GRADE,''),
8056 NVL(EXPIRATION_ACTION_INTERVAL,0),
8057 NVL(EXPIRATION_ACTION_CODE,''),
8058 NVL(HOLD_DAYS,0),
8059 NVL(MATURITY_DAYS,0),
8060 NVL(RETEST_INTERVAL,0),
8061 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
8062 NVL(CHILD_LOT_FLAG,'N'),
8063 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
8064 NVL(LOT_DIVISIBLE_FLAG,'Y'),
8065 NVL(SECONDARY_UOM_CODE,''),
8066 NVL(SECONDARY_DEFAULT_IND,''),
8067 NVL(TRACKING_QUANTITY_IND,'P'),
8068 NVL(DUAL_UOM_DEVIATION_HIGH,0),
8069 NVL(DUAL_UOM_DEVIATION_LOW,0)
8070 FROM
8071 mtl_system_items_vl msik, /* Bug 5581528 */
8072 mtl_cross_references mcr
8073 WHERE
8074 msik.organization_id = p_organization_id
8075 AND msik.inventory_item_id = mcr.inventory_item_id
8076 AND mcr.cross_reference_type = g_gtin_cross_ref_type
8077 AND mcr.cross_reference like g_crossref
8078 AND (mcr.organization_id = msik.organization_id
8079 OR mcr.org_independent_flag = 'Y' )
8080 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
8081 AND msik.inventory_item_id IN (SELECT item_id FROM rcv_supply WHERE SHIPMENT_HEADER_ID = p_shipmentHeaderID );
8082
8083 ELSIF (p_reqHeaderID IS NOT NULL ) THEN
8084 open x_items for
8085 SELECT
8086 concatenated_segments,
8087 msik.inventory_item_id,
8088 msik.description,
8089 Nvl(revision_qty_control_code,1),
8090 Nvl(lot_control_code, 1),
8091 Nvl(serial_number_control_code, 1),
8092 Nvl(restrict_subinventories_code, 2),
8093 Nvl(restrict_locators_code, 2),
8094 Nvl(location_control_code, 1),
8095 primary_uom_code,
8096 Nvl(inspection_required_flag, 'N'),
8097 Nvl(shelf_life_code, 1),
8098 Nvl(shelf_life_days,0),
8099 Nvl(allowed_units_lookup_code, 2),
8100 Nvl(effectivity_control,1),
8101 0,
8102 0,
8103 Nvl(default_serial_status_id,1),
8104 Nvl(serial_status_enabled,'N'),
8105 Nvl(default_lot_status_id,0),
8106 Nvl(lot_status_enabled,'N'),
8107 null,
8108 'N',
8109 inventory_item_flag,
8110 0,
8111 inventory_asset_flag,
8112 outside_operation_flag,
8113 --Bug 3952081
8114 --Select DUOM Attributes for every Item
8115 NVL(GRADE_CONTROL_FLAG,'N'),
8116 NVL(DEFAULT_GRADE,''),
8117 NVL(EXPIRATION_ACTION_INTERVAL,0),
8118 NVL(EXPIRATION_ACTION_CODE,''),
8119 NVL(HOLD_DAYS,0),
8120 NVL(MATURITY_DAYS,0),
8121 NVL(RETEST_INTERVAL,0),
8122 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
8123 NVL(CHILD_LOT_FLAG,'N'),
8124 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
8125 NVL(LOT_DIVISIBLE_FLAG,'Y'),
8126 NVL(SECONDARY_UOM_CODE,''),
8127 NVL(SECONDARY_DEFAULT_IND,''),
8128 NVL(TRACKING_QUANTITY_IND,'P'),
8129 NVL(DUAL_UOM_DEVIATION_HIGH,0),
8130 NVL(DUAL_UOM_DEVIATION_LOW,0)
8131 FROM
8132 mtl_system_items_vl msik /* Bug 5581528 */
8133 WHERE
8134 organization_id = p_Organization_Id
8135 AND concatenated_segments like p_concatenated_segments
8136 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
8137 AND msik.inventory_item_id IN (SELECT item_id FROM po_requisition_lines WHERE requisition_header_id = p_reqHeaderID )
8138 UNION
8139 select
8140 concatenated_segments,
8141 msik.inventory_item_id,
8142 msik.description,
8143 Nvl(revision_qty_control_code,1),
8144 Nvl(lot_control_code, 1),
8145 Nvl(serial_number_control_code, 1),
8146 Nvl(restrict_subinventories_code, 2),
8147 Nvl(restrict_locators_code, 2),
8148 Nvl(location_control_code, 1),
8149 primary_uom_code,
8150 Nvl(inspection_required_flag, 'N'),
8151 Nvl(shelf_life_code, 1),
8152 Nvl(shelf_life_days,0),
8153 Nvl(allowed_units_lookup_code, 2),
8154 Nvl(effectivity_control,1),
8155 0,
8156 0,
8157 Nvl(default_serial_status_id,1),
8158 Nvl(serial_status_enabled,'N'),
8159 Nvl(default_lot_status_id,0),
8160 Nvl(lot_status_enabled,'N'),
8161 mcr.cross_reference,
8162 'N',
8163 inventory_item_flag,
8164 0,
8165 inventory_asset_flag,
8166 outside_operation_flag,
8167 --Bug No 3952081
8168 --Additional Fields for Process Convergence
8169 NVL(GRADE_CONTROL_FLAG,'N'),
8170 NVL(DEFAULT_GRADE,''),
8171 NVL(EXPIRATION_ACTION_INTERVAL,0),
8172 NVL(EXPIRATION_ACTION_CODE,''),
8173 NVL(HOLD_DAYS,0),
8174 NVL(MATURITY_DAYS,0),
8175 NVL(RETEST_INTERVAL,0),
8176 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
8177 NVL(CHILD_LOT_FLAG,'N'),
8178 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
8179 NVL(LOT_DIVISIBLE_FLAG,'Y'),
8180 NVL(SECONDARY_UOM_CODE,''),
8181 NVL(SECONDARY_DEFAULT_IND,''),
8182 NVL(TRACKING_QUANTITY_IND,'P'),
8183 NVL(DUAL_UOM_DEVIATION_HIGH,0),
8184 NVL(DUAL_UOM_DEVIATION_LOW,0)
8185 FROM
8186 mtl_system_items_vl msik, /* Bug 5581528 */
8187 mtl_cross_references mcr
8188 WHERE
8189 msik.organization_id = p_organization_id
8190 AND msik.inventory_item_id = mcr.inventory_item_id
8191 AND mcr.cross_reference_type = g_gtin_cross_ref_type
8192 AND mcr.cross_reference like g_crossref
8193 AND (mcr.organization_id = msik.organization_id
8194 OR mcr.org_independent_flag = 'Y' )
8195 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
8196 AND msik.inventory_item_id IN (SELECT item_id FROM po_requisition_lines WHERE requisition_header_id = p_reqHeaderID );
8197
8198 ELSIF (p_oeOrderHeaderID IS NOT NULL ) THEN
8199 open x_items for
8200 SELECT
8201 concatenated_segments,
8202 msik.inventory_item_id,
8203 msik.description,
8204 Nvl(revision_qty_control_code,1),
8205 Nvl(lot_control_code, 1),
8206 Nvl(serial_number_control_code, 1),
8207 Nvl(restrict_subinventories_code, 2),
8208 Nvl(restrict_locators_code, 2),
8209 Nvl(location_control_code, 1),
8210 primary_uom_code,
8211 Nvl(inspection_required_flag, 'N'),
8212 Nvl(shelf_life_code, 1),
8213 Nvl(shelf_life_days,0),
8214 Nvl(allowed_units_lookup_code, 2),
8215 Nvl(effectivity_control,1),
8216 0,
8217 0,
8218 Nvl(default_serial_status_id,1),
8219 Nvl(serial_status_enabled,'N'),
8220 Nvl(default_lot_status_id,0),
8221 Nvl(lot_status_enabled,'N'),
8222 null,
8223 'N',
8224 inventory_item_flag,
8225 0,
8226 inventory_asset_flag,
8227 outside_operation_flag,
8228 --Bug 3952081
8229 --Select DUOM Attributes for every Item
8230 NVL(GRADE_CONTROL_FLAG,'N'),
8231 NVL(DEFAULT_GRADE,''),
8232 NVL(EXPIRATION_ACTION_INTERVAL,0),
8233 NVL(EXPIRATION_ACTION_CODE,''),
8234 NVL(HOLD_DAYS,0),
8235 NVL(MATURITY_DAYS,0),
8236 NVL(RETEST_INTERVAL,0),
8237 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
8238 NVL(CHILD_LOT_FLAG,'N'),
8239 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
8240 NVL(LOT_DIVISIBLE_FLAG,'Y'),
8241 NVL(SECONDARY_UOM_CODE,''),
8242 NVL(SECONDARY_DEFAULT_IND,''),
8243 NVL(TRACKING_QUANTITY_IND,'P'),
8244 NVL(DUAL_UOM_DEVIATION_HIGH,0),
8245 NVL(DUAL_UOM_DEVIATION_LOW,0)
8246 FROM
8247 mtl_system_items_vl msik /* Bug 5581528 */
8248 WHERE
8249 organization_id = p_Organization_Id
8250 AND concatenated_segments like p_concatenated_segments
8251 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
8252 AND msik.inventory_item_id IN (SELECT item_id FROM rcv_supply WHERE OE_ORDER_HEADER_ID = p_oeOrderHeaderID )
8253 UNION
8254 select
8255 concatenated_segments,
8256 msik.inventory_item_id,
8257 msik.description,
8258 Nvl(revision_qty_control_code,1),
8259 Nvl(lot_control_code, 1),
8260 Nvl(serial_number_control_code, 1),
8261 Nvl(restrict_subinventories_code, 2),
8262 Nvl(restrict_locators_code, 2),
8263 Nvl(location_control_code, 1),
8264 primary_uom_code,
8265 Nvl(inspection_required_flag, 'N'),
8266 Nvl(shelf_life_code, 1),
8267 Nvl(shelf_life_days,0),
8268 Nvl(allowed_units_lookup_code, 2),
8269 Nvl(effectivity_control,1),
8270 0,
8271 0,
8272 Nvl(default_serial_status_id,1),
8273 Nvl(serial_status_enabled,'N'),
8274 Nvl(default_lot_status_id,0),
8275 Nvl(lot_status_enabled,'N'),
8276 mcr.cross_reference,
8277 'N',
8278 inventory_item_flag,
8279 0,
8280 inventory_asset_flag,
8281 outside_operation_flag,
8282 --Bug No 3952081
8283 --Additional Fields for Process Convergence
8284 NVL(GRADE_CONTROL_FLAG,'N'),
8285 NVL(DEFAULT_GRADE,''),
8286 NVL(EXPIRATION_ACTION_INTERVAL,0),
8287 NVL(EXPIRATION_ACTION_CODE,''),
8288 NVL(HOLD_DAYS,0),
8289 NVL(MATURITY_DAYS,0),
8290 NVL(RETEST_INTERVAL,0),
8291 NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
8292 NVL(CHILD_LOT_FLAG,'N'),
8293 NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
8294 NVL(LOT_DIVISIBLE_FLAG,'Y'),
8295 NVL(SECONDARY_UOM_CODE,''),
8296 NVL(SECONDARY_DEFAULT_IND,''),
8297 NVL(TRACKING_QUANTITY_IND,'P'),
8298 NVL(DUAL_UOM_DEVIATION_HIGH,0),
8299 NVL(DUAL_UOM_DEVIATION_LOW,0)
8300 FROM
8301 mtl_system_items_vl msik, /* Bug 5581528 */
8302 mtl_cross_references mcr
8303 WHERE
8304 msik.organization_id = p_organization_id
8305 AND msik.inventory_item_id = mcr.inventory_item_id
8306 AND mcr.cross_reference_type = g_gtin_cross_ref_type
8307 AND mcr.cross_reference like g_crossref
8308 AND (mcr.organization_id = msik.organization_id
8309 OR mcr.org_independent_flag = 'Y' )
8310 AND (purchasing_enabled_flag = 'Y' OR stock_enabled_flag = 'Y')
8311 AND msik.inventory_item_id IN (SELECT item_id FROM rcv_supply WHERE OE_ORDER_HEADER_ID = p_oeOrderHeaderID );
8312
8313 END IF;
8314
8315 END GET_INV_ITEM_LOV_RECEIVING;
8316
8317 --Bug No: 5246626:Added the procedures Print_debug and GET_RCV_SHP_FLEX_DETAILS
8318
8319 PROCEDURE print_debug(p_err_msg VARCHAR2, p_level NUMBER) IS
8320
8321 l_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
8322
8323 BEGIN
8324 IF (l_debug = 1) THEN
8325 inv_mobile_helper_functions.tracelog(p_err_msg => p_err_msg, p_module => 'inv_ui_rcv_lovs', p_level => p_level);
8326 END IF;
8327 END print_debug;
8328
8329 PROCEDURE GET_RCV_SHP_FLEX_DETAILS
8330 ( p_shipment_num IN VARCHAR2
8331 , p_orgid IN NUMBER
8332 , x_attribute1 OUT NOCOPY VARCHAR2
8333 , x_attribute2 OUT NOCOPY VARCHAR2
8334 , x_attribute3 OUT NOCOPY VARCHAR2
8335 , x_attribute4 OUT NOCOPY VARCHAR2
8336 , x_attribute5 OUT NOCOPY VARCHAR2
8337 , x_attribute6 OUT NOCOPY VARCHAR2
8338 , x_attribute7 OUT NOCOPY VARCHAR2
8339 , x_attribute8 OUT NOCOPY VARCHAR2
8340 , x_attribute9 OUT NOCOPY VARCHAR2
8341 , x_attribute10 OUT NOCOPY VARCHAR2
8342 , x_attribute11 OUT NOCOPY VARCHAR2
8343 , x_attribute12 OUT NOCOPY VARCHAR2
8344 , x_attribute13 OUT NOCOPY VARCHAR2
8345 , x_attribute14 OUT NOCOPY VARCHAR2
8346 , x_attribute15 OUT NOCOPY VARCHAR2
8347 , x_val_attribute1 OUT NOCOPY VARCHAR2
8348 , x_val_attribute2 OUT NOCOPY VARCHAR2
8349 , x_val_attribute3 OUT NOCOPY VARCHAR2
8350 , x_val_attribute4 OUT NOCOPY VARCHAR2
8351 , x_val_attribute5 OUT NOCOPY VARCHAR2
8352 , x_val_attribute6 OUT NOCOPY VARCHAR2
8353 , x_val_attribute7 OUT NOCOPY VARCHAR2
8354 , x_val_attribute8 OUT NOCOPY VARCHAR2
8355 , x_val_attribute9 OUT NOCOPY VARCHAR2
8356 , x_val_attribute10 OUT NOCOPY VARCHAR2
8357 , x_val_attribute11 OUT NOCOPY VARCHAR2
8358 , x_val_attribute12 OUT NOCOPY VARCHAR2
8359 , x_val_attribute13 OUT NOCOPY VARCHAR2
8360 , x_val_attribute14 OUT NOCOPY VARCHAR2
8361 , x_val_attribute15 OUT NOCOPY VARCHAR2
8362 , x_attribute_category OUT NOCOPY VARCHAR2
8363 , x_concatenated_val OUT NOCOPY VARCHAR2
8364 )
8365 IS
8366 TYPE seg_name IS TABLE OF VARCHAR2(1000)
8367 INDEX BY BINARY_INTEGER;
8368 l_context VARCHAR2(1000);
8369 l_context_r fnd_dflex.context_r;
8370 l_contexts_dr fnd_dflex.contexts_dr;
8371 l_dflex_r fnd_dflex.dflex_r;
8372 l_segments_dr fnd_dflex.segments_dr;
8373 l_enabled_seg_name seg_name;
8374 l_wms_all_segs_tbl seg_name;
8375 l_nsegments BINARY_INTEGER;
8376 l_global_context BINARY_INTEGER;
8377 v_index NUMBER := 1;
8378 l_chk_flag NUMBER := 0;
8379 l_char_count NUMBER;
8380 l_num_count NUMBER;
8381 l_date_count NUMBER;
8382 l_wms_attr_chk NUMBER := 1;
8383 l_return_status VARCHAR2(1);
8384 l_msg_count NUMBER;
8385 l_msg_data VARCHAR2(1000);
8386
8387 /* Variables used for Validate_desccols procedure */
8388 error_segment VARCHAR2(30);
8389 errors_received EXCEPTION;
8390 error_msg VARCHAR2(5000);
8391 s NUMBER;
8392 e NUMBER;
8393 l_null_char_val VARCHAR2(1000);
8394 l_null_num_val NUMBER;
8395 l_null_date_val DATE;
8396 l_global_nsegments NUMBER := 0;
8397
8398 col NUMBER;
8399
8400 l_date DATE;
8401
8402 TYPE char_tbl IS TABLE OF VARCHAR2(1500)
8403 INDEX BY BINARY_INTEGER;
8404
8405 l_attributes_tbl char_tbl;
8406 l_organization_id NUMBER;
8407 l_shipment_num varchar2(150);
8408 l_attrib_num NUMBER;
8409
8410 BEGIN
8411
8412 l_shipment_num := p_shipment_num;
8413 l_organization_id := p_orgid;
8414
8415 select
8416 attribute1,
8417 attribute2,
8418 attribute3,
8419 attribute4,
8420 attribute5,
8421 attribute6,
8422 attribute7,
8423 attribute8,
8424 attribute9,
8425 attribute10,
8426 attribute11,
8427 attribute12,
8428 attribute13,
8429 attribute14,
8430 attribute15,
8431 attribute_category
8432 into
8433 x_attribute1,
8434 x_attribute2,
8435 x_attribute3,
8436 x_attribute4,
8437 x_attribute5,
8438 x_attribute6,
8439 x_attribute7,
8440 x_attribute8,
8441 x_attribute9,
8442 x_attribute10,
8443 x_attribute11,
8444 x_attribute12,
8445 x_attribute13,
8446 x_attribute14,
8447 x_attribute15,
8448 x_attribute_category
8449 from rcv_shipment_headers rsh
8450 where rsh.shipment_num = l_shipment_num
8451 and rsh.ship_to_org_id = l_organization_id;
8452
8453
8454
8455 BEGIN
8456 l_attributes_tbl (1) := x_attribute1;
8457 l_attributes_tbl (2) := x_attribute2;
8458 l_attributes_tbl (3) := x_attribute3;
8459 l_attributes_tbl (4) := x_attribute4;
8460 l_attributes_tbl (5) := x_attribute5;
8461 l_attributes_tbl (6) := x_attribute6;
8462 l_attributes_tbl (7) := x_attribute7;
8463 l_attributes_tbl (8) := x_attribute8;
8464 l_attributes_tbl (9) := x_attribute9;
8465 l_attributes_tbl (10) := x_attribute10;
8466 l_attributes_tbl (11) := x_attribute11;
8467 l_attributes_tbl (12) := x_attribute12;
8468 l_attributes_tbl (13) := x_attribute13;
8469 l_attributes_tbl (14) := x_attribute14;
8470 l_attributes_tbl (15) := x_attribute15;
8471
8472 l_dflex_r.application_id := 201;
8473 l_dflex_r.flexfield_name := 'RCV_SHIPMENT_HEADERS';
8474
8475 print_debug('BEFORE SETTING THE ATTRIBUTES CONTEXT',4);
8476
8477 l_dflex_r.application_id := 201;
8478 l_dflex_r.flexfield_name := 'RCV_SHIPMENT_HEADERS';
8479
8480 print_debug('BEFORE SETTING THE ATTRIBUTES CONTEXT',4);
8481
8482 /* Get all contexts */
8483 fnd_dflex.get_contexts(flexfield => l_dflex_r, contexts => l_contexts_dr);
8484
8485 print_debug('Found contexts for the Flexfield MTL_LOT_NUMBERS',4);
8486
8487 /* From the l_contexts_dr, get the position of the global context */
8488 l_global_context := l_contexts_dr.global_context;
8489
8490 print_debug('Found the position of the global context ',4);
8491
8492 /* Using the position get the segments in the global context which are enabled */
8493 l_context := l_contexts_dr.context_code(l_global_context);
8494
8495 /* Prepare the context_r type for getting the segments associated with the global context */
8496
8497 l_context_r.flexfield := l_dflex_r;
8498 l_context_r.context_code := l_context;
8499
8500 fnd_dflex.get_segments(CONTEXT => l_context_r, segments => l_segments_dr, enabled_only => TRUE);
8501
8502 print_debug('After successfully getting all the enabled segmenst for the Global Context ',4);
8503
8504 /* read through the segments */
8505
8506 l_nsegments := l_segments_dr.nsegments;
8507 l_global_nsegments := l_segments_dr.nsegments;
8508
8509 print_debug('The number of enabled segments for the Global Context are ' || l_nsegments,4);
8510
8511 FOR i IN 1 .. l_nsegments LOOP
8512 l_enabled_seg_name(v_index) := l_segments_dr.application_column_name(i);
8513
8514 IF l_attributes_tbl.EXISTS(SUBSTR(l_segments_dr.application_column_name(i)
8515 , INSTR(l_segments_dr.application_column_name(i), 'ATTRIBUTE') + 9)) THEN
8516 print_debug('setting column values',4);
8517 print_debug('Actual Value is ' ||
8518 l_attributes_tbl(SUBSTR(l_segments_dr.application_column_name(i)
8519 , INSTR(l_segments_dr.application_column_name(i), 'ATTRIBUTE') + 9)), 4);
8520
8521 fnd_flex_descval.set_column_value(
8522 l_segments_dr.application_column_name(i)
8523 , l_attributes_tbl(SUBSTR(l_segments_dr.application_column_name(i)
8524 , INSTR(l_segments_dr.application_column_name(i), 'ATTRIBUTE') + 9))
8525 );
8526 ELSE
8527 fnd_flex_descval.set_column_value(l_segments_dr.application_column_name(i), l_null_char_val);
8528 END IF;
8529 v_index := v_index + 1;
8530 END LOOP;
8531
8532 IF l_enabled_seg_name.COUNT > 0 THEN
8533 FOR i IN l_enabled_seg_name.FIRST .. l_enabled_seg_name.LAST LOOP
8534 print_debug('The enabled segment : ' || l_enabled_seg_name(i), 4);
8535 END LOOP;
8536 END IF;
8537
8538 /* Initialise the l_context_value to null */
8539 l_context := NULL;
8540 l_nsegments := 0;
8541
8542 /*Get the context for the item passed */
8543 IF x_attribute_category IS NOT NULL THEN
8544 l_context := x_attribute_category;
8545 /* Set flex context for validation of the value set */
8546 fnd_flex_descval.set_context_value(l_context);
8547 print_debug('The value of INV context is ' || l_context, 4);
8548
8549 /* Prepare the context_r type */
8550 l_context_r.flexfield := l_dflex_r;
8551 l_context_r.context_code := l_context;
8552
8553 fnd_dflex.get_segments(CONTEXT => l_context_r, segments => l_segments_dr, enabled_only => TRUE);
8554
8555 /* read through the segments */
8556 l_nsegments := l_segments_dr.nsegments;
8557
8558 print_debug('No of segments enabled for context ' || l_context || ' are ' || l_nsegments, 4);
8559 print_debug('v_index is ' || v_index, 4);
8560
8561 FOR i IN 1 .. l_nsegments LOOP
8562
8563 l_enabled_seg_name(v_index) := l_segments_dr.application_column_name(i);
8564
8565 print_debug('The segment is ' || l_segments_dr.segment_name(i), 4);
8566
8567 IF l_attributes_tbl.EXISTS(SUBSTR(l_segments_dr.application_column_name(i)
8568 , INSTR(l_segments_dr.application_column_name(i), 'ATTRIBUTE') + 9)) THEN
8569
8570 fnd_flex_descval.set_column_value(
8571 l_segments_dr.application_column_name(i)
8572 , l_attributes_tbl(SUBSTR(l_segments_dr.application_column_name(i)
8573 , INSTR(l_segments_dr.application_column_name(i), 'ATTRIBUTE') + 9))
8574 );
8575 ELSE
8576 fnd_flex_descval.set_column_value(l_segments_dr.application_column_name(i), l_null_char_val);
8577 END IF;
8578 v_index := v_index + 1;
8579 END LOOP;
8580 END IF;
8581
8582 IF (l_global_nsegments > 0 AND x_attribute_Category IS NULL ) THEN
8583 print_debug('global segments > 0', 4);
8584 l_context := l_contexts_dr.context_code(l_global_context);
8585 fnd_flex_descval.set_context_value(l_context);
8586 End if;
8587
8588 IF fnd_flex_descval.validate_desccols(appl_short_name => 'PO',
8589 desc_flex_name => 'RCV_SHIPMENT_HEADERS', values_or_ids => 'I'
8590 , validation_date => SYSDATE) THEN
8591 print_debug('Value set validation successful', 4);
8592 ELSE
8593 error_segment := fnd_flex_descval.error_segment;
8594 print_debug('The error segment is : ' || fnd_flex_descval.error_segment, 4);
8595 RAISE errors_received;
8596 END IF;
8597
8598 x_concatenated_val := fnd_flex_descval.concatenated_values;
8599 print_debug('The concatenated values is : ' || x_concatenated_val , 4);
8600
8601 /** Retrun the VALUES to java */
8602 /** This Part of code is kept for future Use **********
8603 for i in 1..v_index
8604 Loop
8605 BEGIN
8606
8607 l_attrib_num := SUBSTR(l_enabled_seg_name(i)
8608 , INSTR(l_enabled_seg_name(i), 'ATTRIBUTE') + 9);
8609
8610 if l_attrib_num = 1 then
8611 x_val_attribute1 := fnd_flex_descval.Segment_Value(i);
8612 End if;
8613 if l_attrib_num = 2 then
8614 x_val_attribute2 := fnd_flex_descval.Segment_Value(i);
8615 End if;
8616 if l_attrib_num = 3 then
8617 x_val_attribute3 := fnd_flex_descval.Segment_Value(i);
8618 End if;
8619 if l_attrib_num = 4 then
8620 x_val_attribute4 := fnd_flex_descval.Segment_Value(i);
8621 End if;
8622 if l_attrib_num = 5 then
8623 x_val_attribute5 := fnd_flex_descval.Segment_Value(i);
8624 End if;
8625 if l_attrib_num =6 then
8626 x_val_attribute6 := fnd_flex_descval.Segment_Value(i);
8627 End if;
8628 if l_attrib_num = 7 then
8629 x_val_attribute7 := fnd_flex_descval.Segment_Value(i);
8630 End if;
8631 if l_attrib_num =8 then
8632 x_val_attribute8 := fnd_flex_descval.Segment_Value(i);
8633 End if;
8634 if l_attrib_num = 9 then
8635 x_val_attribute9 := fnd_flex_descval.Segment_Value(i);
8636 End if;
8637 if l_attrib_num = 10 then
8638 x_val_attribute10 := fnd_flex_descval.Segment_Value(i);
8639 End if;
8640 if l_attrib_num = 11 then
8641 x_val_attribute11 := fnd_flex_descval.Segment_Value(i);
8642 End if;
8643 if l_attrib_num = 12 then
8644 x_val_attribute12 := fnd_flex_descval.Segment_Value(i);
8645 End if;
8646 if l_attrib_num = 13 then
8647 x_val_attribute13 := fnd_flex_descval.Segment_Value(i);
8648 End if;
8649 if l_attrib_num = 14 then
8650 x_val_attribute14 := fnd_flex_descval.Segment_Value(i);
8651 End if;
8652 if l_attrib_num = 15 then
8653 x_val_attribute15 := fnd_flex_descval.Segment_Value(i);
8654 End if;
8655 EXCEPTION
8656 WHEN OTHERS THEN NULL;
8657 END;
8658 End Loop;
8659 *******************************************/
8660
8661 EXCEPTION
8662 WHEN OTHERS THEN
8663 print_debug('Can not get the concatenatd values due to problem in flexfield data ' , 4);
8664 print_debug('OTHER EXCEPTION OCCURED AT GET_RCV_SHIP_FLEX_DETAILS' , 4);
8665 END;
8666
8667 EXCEPTION
8668 WHEN OTHERS THEN
8669 print_debug('Can not Obtain the dff values for Shipment. Issue in shipment or org ' , 4);
8670 print_debug('Value of Shipment = ' || l_shipment_num , 4);
8671 print_debug('Value of Org = ' || l_organization_id , 4);
8672 END GET_RCV_SHP_FLEX_DETAILS;
8673
8674 END INV_UI_RCV_LOVS;