DBA Data[Home] [Help]

PACKAGE BODY: APPS.INV_UI_ITEM_LOVS

Source


1 PACKAGE BODY inv_ui_item_lovs AS
2   /* $Header: INVITMLB.pls 120.38.12020000.5 2013/03/01 08:32:44 raminoch ship $ */
3 
4 
5 g_gtin_cross_ref_type VARCHAR2(25) := fnd_profile.value('INV:GTIN_CROSS_REFERENCE_TYPE');
6 g_gtin_code_length NUMBER := 14;
7 g_debug NUMBER := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
8 g_pkg_name CONSTANT VARCHAR2(30) := 'INV_UI_ITEM_LOVS';
9 
10   --      Name: GET_ITEM_LOV
11   --      Input parameters:
12   --       p_Organization_Id   which restricts LOV SQL to current org
13   --       p_Concatenated_Segments   which restricts LOV SQL to the user input text
14   --                                e.g.  AS% for item LOV's contanenated_segment
15   --       p_where_clause    different LOV beans pass in different where clause string
16   --                         for their LOV SQL
17   --                         The String should start with AND and conform with dynamic
18   --                         SQL syntax  e.g. 'AND purchasing_enabled_flag = ''Y'''
19   --      Output parameters:
20   --       x_Items      returns LOV rows as reference cursor
21   --      Functions: This procedure uses dynamic SQL to handle different where clauses for
22   --                 LOV query. Because of the way the java file is structured, all the LOV's
23   --                 should select the same columns that is the columns finally
24   --                 selected should be the superset of the columns needed by all lovs.
25   --                 To addd more columns to LOV subfield, one should append the
26   --                 new columns to the end of the existing ones. Specifically, one should
27   --                 modify the following local variable, l_sql_stmt.
28   --
29 
30   PROCEDURE get_item_lov(x_items OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_concatenated_segments IN VARCHAR2, p_where_clause IN VARCHAR2) IS
31     posstring      NUMBER         := 0;
32     l_where_clause VARCHAR2(7500) := '';
33     l_sql_stmt      VARCHAR2(7500);
34     l_conc_seg varchar2(2000) := p_concatenated_segments;
35     l_append varchar2(2):='';
36     -- Bug# 6747729
37     -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
38     l_sql_stmt1     VARCHAR2(7500)
39   :=    'select concatenated_segments,'
40      || 'msik.inventory_item_id, msik.description,'
41      || 'Nvl(revision_qty_control_code,1),'
42      || 'Nvl(lot_control_code, 1),'
43      || 'Nvl(serial_number_control_code, 1),'
44      || 'Nvl(restrict_subinventories_code, 2),'
45      || 'Nvl(restrict_locators_code, 2),'
46      || 'Nvl(location_control_code, 1),'
47      || 'primary_uom_code,'
48      || 'Nvl(inspection_required_flag, ''N''),'
49      || 'Nvl(shelf_life_code, 1),'
50      || 'Nvl(shelf_life_days,0),'
51      || 'Nvl(allowed_units_lookup_code, 2),'
52      || 'Nvl(effectivity_control,1), '
53      || '0, 0,'
54      || 'Nvl(default_serial_status_id,1), '
55      || 'Nvl(serial_status_enabled,''N''), '
56      || 'Nvl(default_lot_status_id,0), '
57      || 'Nvl(lot_status_enabled,''N''), '
58      || 'null, '
59      || '''N'', '
60      || 'inventory_item_flag, '
61      || '0,'
62      || 'wms_deploy.get_item_client_name(msik.inventory_item_id),'
63      || 'inventory_asset_flag,'
64      || 'outside_operation_flag,'
65      --Bug No 3952081
66      --Additional Fields for Process Convergence
67      || 'NVL(GRADE_CONTROL_FLAG,''N''),'
68      || 'NVL(DEFAULT_GRADE,''''),'
69      || 'NVL(EXPIRATION_ACTION_INTERVAL,0),'
70      || 'NVL(EXPIRATION_ACTION_CODE,''''),'
71      || 'NVL(HOLD_DAYS,0),'
72      || 'NVL(MATURITY_DAYS,0),'
73      || 'NVL(RETEST_INTERVAL,0),'
74      || 'NVL(COPY_LOT_ATTRIBUTE_FLAG,''N''),'
75      || 'NVL(CHILD_LOT_FLAG,''N''),'
76      || 'NVL(CHILD_LOT_VALIDATION_FLAG,''N''),'
77      || 'NVL(LOT_DIVISIBLE_FLAG,''Y''),'
78      || 'NVL(SECONDARY_UOM_CODE,''''),'
79      || 'NVL(SECONDARY_DEFAULT_IND,''''),'
80      || 'NVL(TRACKING_QUANTITY_IND,''P''),'
81      || 'NVL(DUAL_UOM_DEVIATION_HIGH,0),'
82      || 'NVL(DUAL_UOM_DEVIATION_LOW,0),'
83      || 'stock_enabled_flag';
84     -- Bug# 6747729
85     -- Added code to also fetch stock_enabled_flag from mtl_system_items_vl
86     l_sql_stmt_xref     VARCHAR2(7500)
87   :=    'select concatenated_segments,'
88      || 'msik.inventory_item_id, msik.description,'
89      || 'Nvl(revision_qty_control_code,1),'
90      || 'Nvl(lot_control_code, 1),'
91      || 'Nvl(serial_number_control_code, 1),'
92      || 'Nvl(restrict_subinventories_code, 2),'
93      || 'Nvl(restrict_locators_code, 2),'
94      || 'Nvl(location_control_code, 1),'
95      || 'primary_uom_code,'
96      || 'Nvl(inspection_required_flag, ''N''),'
97      || 'Nvl(shelf_life_code, 1),'
98      || 'Nvl(shelf_life_days,0),'
99      || 'Nvl(allowed_units_lookup_code, 2),'
100      || 'Nvl(effectivity_control,1), '
101      || '0, 0,'
102      || 'Nvl(default_serial_status_id,1), '
103      || 'Nvl(serial_status_enabled,''N''), '
104      || 'Nvl(default_lot_status_id,0), '
105      || 'Nvl(lot_status_enabled,''N''), '
106      || 'mcr.cross_reference, '
107      || '''N'', '
108      || 'inventory_item_flag, '
109      || '0,'
110      || 'wms_deploy.get_item_client_name(msik.inventory_item_id),'
111      || 'inventory_asset_flag,'
112      || 'outside_operation_flag,'
113      --Bug No 3952081
114      --Additional Fields for Process Convergence
115      || 'NVL(GRADE_CONTROL_FLAG,''N''),'
116      || 'NVL(DEFAULT_GRADE,''''),'
117      || 'NVL(EXPIRATION_ACTION_INTERVAL,0),'
118      || 'NVL(EXPIRATION_ACTION_CODE,''''),'
119      || 'NVL(HOLD_DAYS,0),'
120      || 'NVL(MATURITY_DAYS,0),'
121      || 'NVL(RETEST_INTERVAL,0),'
122      || 'NVL(COPY_LOT_ATTRIBUTE_FLAG,''N''),'
123      || 'NVL(CHILD_LOT_FLAG,''N''),'
124      || 'NVL(CHILD_LOT_VALIDATION_FLAG,''N''),'
125      || 'NVL(LOT_DIVISIBLE_FLAG,''Y''),'
126      || 'NVL(SECONDARY_UOM_CODE,''''),'
127      || 'NVL(SECONDARY_DEFAULT_IND,''''),'
128      || 'NVL(TRACKING_QUANTITY_IND,''P''),'
129      || 'NVL(DUAL_UOM_DEVIATION_HIGH,0),'
130      || 'NVL(DUAL_UOM_DEVIATION_LOW,0),'
131      || 'stock_enabled_flag';
132 
133  -- Bug 4997004 sql Id 14813260 Start Added 3 variables to fix the literals issue in l_sql_stmt.
134   val VARCHAR2(10)  :='''';
135   pad VARCHAR2(20)  :='''00000000000000''';
136   flag VARCHAR2(10) :='''Y''';
137   -- Bug 4997004 sql Id 14813260 End
138   BEGIN
139     l_where_clause  := p_where_clause;
140 
141     l_append:=wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
142 
143      -- Modified for Bug # 5472330
144      -- Changed mtl_system_items_kfv to mtl_system_items_vl
145 
146     l_sql_stmt := l_sql_stmt1 || ' from mtl_system_items_vl msik WHERE organization_id = ' || p_organization_id || ' AND concatenated_segments like :l_conc_seg ' || l_where_clause;
147     -- 1 effectivity control implies that the item is NOT effectivity
148     -- controlled.
149 
150     l_sql_stmt := l_sql_stmt || ' UNION ' || l_sql_stmt_xref ||
151       ' FROM mtl_system_items_vl msik, mtl_cross_references mcr ' ||
152       ' WHERE msik.organization_id = ' || p_organization_id ||
153       ' AND msik.inventory_item_id = mcr.inventory_item_id ' ||
154       ' AND mcr.cross_reference_type = ''' || g_gtin_cross_ref_type || val ||
155       ' AND mcr.cross_reference      like lpad(rtrim(:l_conc_seg
156       , ''%'' ), ' || g_gtin_code_length || ' , ' || pad ||')' ||
157       ' AND (mcr.organization_id     = msik.organization_id OR mcr.org_independent_flag = ' || flag || ')' || l_where_clause;
158 
159     OPEN x_items FOR l_sql_stmt using l_conc_seg||l_append,l_conc_seg;
160   END get_item_lov;
161 
162 PROCEDURE mydebug(p_msg IN VARCHAR2) IS
163 BEGIN
164    IF (g_debug = 1) THEN
165       inv_mobile_helper_functions.tracelog(
166                              p_err_msg => p_msg,
167                              p_module  => g_pkg_name ,
168                              p_level   => 9);
169 
170    END IF;
171 END mydebug;
172 
173 
174   PROCEDURE get_item_lov_sub_loc_moqd(x_items OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_concatenated_segments IN VARCHAR2, p_subinventory_code IN VARCHAR2, p_locator_id IN NUMBER, p_where_clause IN VARCHAR2) IS
175     posstring      NUMBER         := 0;
176     l_where_clause VARCHAR2(7500) := '';
177     l_sql_stmt      VARCHAR2(7500);
178     l_conc_seg varchar2(2000) := p_concatenated_segments;
179     l_append varchar2(2):='';
180     l_sql_stmt1     VARCHAR2(7500)
181   :=    'select distinct msik.concatenated_segments,'
182      || 'msik.inventory_item_id, msik.description,'
183      || 'Nvl(msik.revision_qty_control_code,1),'
184      || 'Nvl(msik.lot_control_code, 1),'
185      || 'Nvl(msik.serial_number_control_code, 1),'
186      || 'Nvl(msik.restrict_subinventories_code, 2),'
187      || 'Nvl(msik.restrict_locators_code, 2),'
188      || 'Nvl(msik.location_control_code, 1),'
189      || ' msik.primary_uom_code,'
190      || 'Nvl(msik.inspection_required_flag, ''N''),'
191      || 'Nvl(msik.shelf_life_code, 1),'
192      || 'Nvl(msik.shelf_life_days,0),'
193      || 'Nvl(msik.allowed_units_lookup_code, 2),'
194      || 'Nvl(msik.effectivity_control,1), '
195      || '0, 0,'
196      || 'Nvl(msik.default_serial_status_id,1), '
197      || 'Nvl(msik.serial_status_enabled,''N''), '
198      || 'Nvl(msik.default_lot_status_id,0), '
199      || 'Nvl(msik.lot_status_enabled,''N''), '
200      || 'null, '
201      || '''N'', '
202      || ' msik.inventory_item_flag, '
203      || '0,'
204      || 'wms_deploy.get_item_client_name(msik.inventory_item_id),'
205      || ' msik.inventory_asset_flag,'
206      || ' msik.outside_operation_flag,'
207      --Bug No 3952081
208      --Additional Fields for Process Convergence
209      || 'NVL(msik.GRADE_CONTROL_FLAG,''N''),'
210      || 'NVL(msik.DEFAULT_GRADE,''''),'
211      || 'NVL(msik.EXPIRATION_ACTION_INTERVAL,0),'
212      || 'NVL(msik.EXPIRATION_ACTION_CODE,''''),'
213      || 'NVL(msik.HOLD_DAYS,0),'
214      || 'NVL(msik.MATURITY_DAYS,0),'
215      || 'NVL(msik.RETEST_INTERVAL,0),'
216      || 'NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,''N''),'
217      || 'NVL(msik.CHILD_LOT_FLAG,''N''),'
218      || 'NVL(msik.CHILD_LOT_VALIDATION_FLAG,''N''),'
219      || 'NVL(msik.LOT_DIVISIBLE_FLAG,''Y''),'
220      || 'NVL(msik.SECONDARY_UOM_CODE,''''),'
221      || 'NVL(msik.SECONDARY_DEFAULT_IND,''''),'
222      || 'NVL(msik.TRACKING_QUANTITY_IND,''P''),'
223      || 'NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),'
224      || 'NVL(msik.DUAL_UOM_DEVIATION_LOW,0)';
225 	l_sql_stmt_xref     VARCHAR2(7500)
226 	 :=    'select distinct msik.concatenated_segments,'
227 	|| 'msik.inventory_item_id, msik.description,'
228 	|| 'Nvl(msik.revision_qty_control_code,1),'
229 	|| 'Nvl(msik.lot_control_code, 1),'
230 	|| 'Nvl(msik.serial_number_control_code, 1),'
231 	|| 'Nvl(msik.restrict_subinventories_code, 2),'
232 	|| 'Nvl(msik.restrict_locators_code, 2),'
233 	|| 'Nvl(msik.location_control_code, 1),'
234 	|| ' msik.primary_uom_code,'
235 	|| 'Nvl(msik.inspection_required_flag, ''N''),'
236 	|| 'Nvl(msik.shelf_life_code, 1),'
237 	|| 'Nvl(msik.shelf_life_days,0),'
238 	|| 'Nvl(msik.allowed_units_lookup_code, 2),'
239 	|| 'Nvl(msik.effectivity_control,1), '
240 	|| '0, 0,'
241 	|| 'Nvl(msik.default_serial_status_id,1), '
242 	|| 'Nvl(msik.serial_status_enabled,''N''), '
243 	|| 'Nvl(msik.default_lot_status_id,0), '
244 	|| 'Nvl(msik.lot_status_enabled,''N''), '
245 	|| 'null, '
246 	|| '''N'', '
247 	|| ' msik.inventory_item_flag, '
248 	|| '0,'
249       || 'wms_deploy.get_item_client_name(msik.inventory_item_id),'
250 	|| ' msik.inventory_asset_flag,'
251 	|| ' msik.outside_operation_flag,'
252 	--Additional Fields for Process Convergence
253 	|| 'NVL(msik.GRADE_CONTROL_FLAG,''N''),'
254 	|| 'NVL(msik.DEFAULT_GRADE,''''),'
255 	|| 'NVL(msik.EXPIRATION_ACTION_INTERVAL,0),'
256 	|| 'NVL(msik.EXPIRATION_ACTION_CODE,''''),'
257 	|| 'NVL(msik.HOLD_DAYS,0),'
258 	|| 'NVL(msik.MATURITY_DAYS,0),'
259 	|| 'NVL(msik.RETEST_INTERVAL,0),'
260 	|| 'NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,''N''),'
261 	|| 'NVL(msik.CHILD_LOT_FLAG,''N''),'
262 	|| 'NVL(msik.CHILD_LOT_VALIDATION_FLAG,''N''),'
263 	|| 'NVL(msik.LOT_DIVISIBLE_FLAG,''Y''),'
264 	|| 'NVL(msik.SECONDARY_UOM_CODE,''''),'
265 	|| 'NVL(msik.SECONDARY_DEFAULT_IND,''''),'
266 	|| 'NVL(msik.TRACKING_QUANTITY_IND,''P''),'
267 	|| 'NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),'
268 	|| 'NVL(msik.DUAL_UOM_DEVIATION_LOW,0)';
269 
270   BEGIN
271    --Bug8791294 changed where clause added OR to check locatorid from MIL
272      --bug9758224 separated "moqd.locator id = ... OR locator_id in" into 2 separate selects union all'ed together
273     l_where_clause  := p_where_clause;
274     l_append:=wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
275 
276 IF (p_locator_id IS NOT NULL ) THEN
277     l_sql_stmt := l_sql_stmt1 || ' from mtl_system_items_vl msik, mtl_onhand_quantities_detail moqd  WHERE msik.organization_id = ' || p_organization_id || ' AND moqd.subinventory_code = ''' || p_subinventory_code /* Bug 5581528 */
278  || ''' AND  moqd.locator_id = ' || p_locator_id ||'
279 AND msik.concatenated_segments like :l_conc_seg ' || ' AND msik.organization_id = moqd.organization_id AND msik.inventory_item_id = moqd.inventory_item_id ' || l_where_clause;
280 
281     l_sql_stmt := l_sql_stmt||' union all '||l_sql_stmt1 || ' from mtl_system_items_kfv msik, mtl_onhand_quantities_detail moqd
282     WHERE msik.organization_id = ' || p_organization_id || ' AND moqd.subinventory_code = ''' || p_subinventory_code || '''
283     AND  moqd.locator_id in (select inventory_location_id from mtl_item_locations mil where mil.organization_id = ' || p_organization_id ||'
284        AND mil.physical_location_id = ' || p_locator_id || '
285        and mil.subinventory_code = ''' ||p_subinventory_code||''')
286 
287  AND msik.concatenated_segments like :l_conc_seg ' || ' AND msik.organization_id = moqd.organization_id AND msik.inventory_item_id = moqd.inventory_item_id ' || l_where_clause;
288 
289 	l_sql_stmt := l_sql_stmt || ' UNION ' || l_sql_stmt_xref ||
290 	 ' FROM mtl_system_items_vl msik, mtl_cross_references mcr ' || /* Bug 5581528 */
291 	 ' WHERE msik.organization_id = ' || p_organization_id ||
292 	 ' AND msik.inventory_item_id = mcr.inventory_item_id ' ||
293 	 ' AND mcr.cross_reference_type = ''' || g_gtin_cross_ref_type ||''''||
294 	 ' AND mcr.cross_reference      like lpad(rtrim(:l_conc_seg
295 	 , ''%'' ), ' || g_gtin_code_length || ' , ' || '''00000000000000'''||')' ||
296 	 ' AND (mcr.organization_id     = msik.organization_id OR mcr.org_independent_flag = ' || '''Y''' || ')' || l_where_clause;
297 
298 ELSE
299     l_sql_stmt := l_sql_stmt1 || ' from mtl_system_items_vl msik, mtl_onhand_quantities_detail moqd  WHERE msik.organization_id = ' || p_organization_id || ' AND moqd.subinventory_code = ''' || p_subinventory_code /* Bug 5581528 */
300  || ''' AND msik.concatenated_segments like :l_conc_seg ' || ' AND msik.organization_id = moqd.organization_id AND msik.inventory_item_id = moqd.inventory_item_id ' || l_where_clause;
301 
302 	   l_sql_stmt := l_sql_stmt || ' UNION ' || l_sql_stmt_xref ||
303 	 ' FROM mtl_system_items_vl msik, mtl_cross_references mcr ' || /* Bug 5581528 */
304 	 ' WHERE msik.organization_id = ' || p_organization_id ||
305 	 ' AND msik.inventory_item_id = mcr.inventory_item_id ' ||
306 	 ' AND mcr.cross_reference_type = ''' || g_gtin_cross_ref_type ||''''||
307 	 ' AND mcr.cross_reference      like lpad(rtrim(:l_conc_seg
308 	 , ''%'' ), ' || g_gtin_code_length || ' , ' || '''00000000000000'''||')' ||
309 	 ' AND (mcr.organization_id     = msik.organization_id OR mcr.org_independent_flag = ' || '''Y''' || ')' || l_where_clause;
310 	   l_sql_stmt := l_sql_stmt || ' UNION ' || l_sql_stmt_xref ||
311 	 ' FROM mtl_system_items_vl msik, mtl_cross_references mcr ' || /* Bug 5581528 */
312 	 ' WHERE msik.organization_id = ' || p_organization_id ||
313 	 ' AND msik.inventory_item_id = mcr.inventory_item_id ' ||
314 	 ' AND mcr.cross_reference_type = ''' || g_gtin_cross_ref_type ||''''||
315 	 ' AND mcr.cross_reference      like lpad(rtrim(:l_conc_seg
316 	 , ''%'' ), ' || g_gtin_code_length || ' , ' || '''00000000000000'''||')' ||
317 	 ' AND (mcr.organization_id     = msik.organization_id OR mcr.org_independent_flag = ' || '''Y''' || ')' || l_where_clause;
318 
319 END IF;
320 
321 	IF p_locator_id IS NOT NULL THEN
322 	    OPEN x_items FOR l_sql_stmt using l_conc_seg||l_append,l_conc_seg||l_append,l_conc_seg;
323 	ELSE
324 	   OPEN x_items FOR l_sql_stmt using l_conc_seg||l_append,l_conc_seg,l_conc_seg;
325 	END IF;
326   END get_item_lov_sub_loc_moqd;
327 
328 
329 
330 
331 
332 
333 
334  --Bug #5443966
335 --Removed inventory_asset_flag from the SELECT statements
336 --since it is not used in the Query MO Issue/Xfer pages
337 PROCEDURE get_mo_item_lov
338   (x_Items OUT NOCOPY t_genref,
339    p_Organization_Id IN NUMBER,
340    p_Concatenated_Segments IN VARCHAR2,
341    p_header_id IN VARCHAR2)
342   IS
343   l_cross_ref varchar2(204);
344   l_append varchar2(2):='';
345   l_Concatenated_Segments VARCHAR2(204):=p_Concatenated_Segments;
346 BEGIN
347 
348    l_cross_ref := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
349 
350    if l_Concatenated_Segments is not null then
351 	l_Concatenated_Segments:=l_Concatenated_Segments||wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
352    end if;
353 
354 
355    OPEN x_items FOR
356      SELECT concatenated_segments,
357             inventory_item_id,
358             description,
359             Nvl(revision_qty_control_code,1),
360             Nvl(lot_control_code, 1),
361             Nvl(serial_number_control_code, 1),
362             Nvl(restrict_subinventories_code, 2),
363             Nvl(restrict_locators_code, 2),
364             Nvl(location_control_code, 1),
365             primary_uom_code,
366             Nvl(inspection_required_flag, 'N'),
367             Nvl(shelf_life_code, 1),
368             Nvl(shelf_life_days,0),
369             Nvl(allowed_units_lookup_code, 2),
370             Nvl(effectivity_control,1),
371             0,
372             0,
373             Nvl(default_serial_status_id,1),
374             Nvl(serial_status_enabled,'N'),
375             Nvl(default_lot_status_id,0),
376             Nvl(lot_status_enabled,'N'),
377             '',
378             'N',
379             inventory_item_flag,
380             0,
381             wms_deploy.get_item_client_name(inventory_item_id),
382      --Bug No 3952081
383      --Additional Fields for Process Convergence
384             NVL(GRADE_CONTROL_FLAG,'N'),
385             NVL(DEFAULT_GRADE,''),
386             NVL(EXPIRATION_ACTION_INTERVAL,0),
387             NVL(EXPIRATION_ACTION_CODE,''),
388             NVL(HOLD_DAYS,0),
389             NVL(MATURITY_DAYS,0),
390             NVL(RETEST_INTERVAL,0),
391             NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
392             NVL(CHILD_LOT_FLAG,'N'),
393             NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
394             NVL(LOT_DIVISIBLE_FLAG,'Y'),
395             NVL(SECONDARY_UOM_CODE,''),
396             NVL(SECONDARY_DEFAULT_IND,''),
397             NVL(TRACKING_QUANTITY_IND,'P'),
398             NVL(DUAL_UOM_DEVIATION_HIGH,0),
399             NVL(DUAL_UOM_DEVIATION_LOW,0)
400      FROM   mtl_system_items_vl /* Bug 5581528 */
401      WHERE  organization_id = p_organization_id
402      AND    concatenated_segments LIKE nvl(l_concatenated_segments,concatenated_segments)
403      AND    inventory_item_id in (select inventory_item_id from mtl_txn_request_lines where header_id =to_number(p_header_id))
404 
405      --Changes for GTIN
406      UNION
407 
408      SELECT concatenated_segments,
409             msik.inventory_item_id,
410             msik.description,
411             Nvl(revision_qty_control_code,1),
412             Nvl(lot_control_code, 1),
413             Nvl(serial_number_control_code, 1),
414             Nvl(restrict_subinventories_code, 2),
415             Nvl(restrict_locators_code, 2),
416             Nvl(location_control_code, 1),
417             primary_uom_code,
418             Nvl(inspection_required_flag, 'N'),
419             Nvl(shelf_life_code, 1),
420             Nvl(shelf_life_days,0),
421             Nvl(allowed_units_lookup_code, 2),
422             Nvl(effectivity_control,1),
423             0,
424             0,
425             Nvl(default_serial_status_id,1),
426             Nvl(serial_status_enabled,'N'),
427             Nvl(default_lot_status_id,0),
428             Nvl(lot_status_enabled,'N'),
429             mcr.cross_reference,
430             'N',
431             inventory_item_flag,
432             0,
433             wms_deploy.get_item_client_name(msik.inventory_item_id),
434      --Bug No 3952081
435      --Additional Fields for Process Convergence
436             NVL(GRADE_CONTROL_FLAG,'N'),
437             NVL(DEFAULT_GRADE,''),
438             NVL(EXPIRATION_ACTION_INTERVAL,0),
439             NVL(EXPIRATION_ACTION_CODE,''),
440             NVL(HOLD_DAYS,0),
441             NVL(MATURITY_DAYS,0),
442             NVL(RETEST_INTERVAL,0),
443             NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
444             NVL(CHILD_LOT_FLAG,'N'),
445             NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
446             NVL(LOT_DIVISIBLE_FLAG,'Y'),
447             NVL(SECONDARY_UOM_CODE,''),
448             NVL(SECONDARY_DEFAULT_IND,''),
449             NVL(TRACKING_QUANTITY_IND,'P'),
450             NVL(DUAL_UOM_DEVIATION_HIGH,0),
451             NVL(DUAL_UOM_DEVIATION_LOW,0)
452      FROM   mtl_system_items_vl msik, mtl_cross_references mcr /* Bug 5581528 */
453      WHERE  msik.organization_id = p_organization_id
454      AND    msik.inventory_item_id   = mcr.inventory_item_id
455      AND    mcr.cross_reference_type = g_gtin_cross_ref_type
456      AND    mcr.cross_reference      LIKE l_cross_ref
457      AND    (mcr.organization_id     = msik.organization_id
458              OR
459              mcr.org_independent_flag = 'Y');
460 
461 END get_mo_item_lov;
462 
463 
464   PROCEDURE get_transactable_items(x_items OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_concatenated_segments IN VARCHAR2, p_transaction_action_id IN NUMBER, p_to_organization_id IN NUMBER) IS
465   l_cross_ref varchar2(204);
466   l_append varchar2(2):='';
467   BEGIN
468    --Bug 2769632 Modified the sub query so that invalid combinations of lot/serial and revision items are not visible in the LOV
469    l_cross_ref := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
470 
471    l_append:=wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
472 
473     OPEN x_items FOR
474       SELECT msik.concatenated_segments
475            , msik.inventory_item_id
476            , msik.description
477            , NVL(msik.revision_qty_control_code, 1)
478            , NVL(msik.lot_control_code, 1)
479            , NVL(msik.serial_number_control_code, 1)
480            , NVL(msik.restrict_subinventories_code, 2)
481            , NVL(msik.restrict_locators_code, 2)
482            , NVL(msik.location_control_code, 1)
483            , msik.primary_uom_code
484            , NVL(msik.inspection_required_flag, 2)
485            , NVL(msik.shelf_life_code, 1)
486            , NVL(msik.shelf_life_days, 0)
487            , NVL(msik.allowed_units_lookup_code, 2)
488            , NVL(msik.effectivity_control, 1)
489            , 0
490            , 0
491            , NVL(msik.default_serial_status_id, 0)
492            , NVL(msik.serial_status_enabled, 'N')
493            , NVL(msik.default_lot_status_id, 0)
494            , NVL(msik.lot_status_enabled, 'N')
495            , ''
496            , 'N'
497            , msik.inventory_item_flag
498            , 0
499 	     , wms_deploy.get_item_client_name(msik.inventory_item_id),
500      --Bug No 3952081
501      --Additional Fields for Process Convergence
502            NVL(msik.GRADE_CONTROL_FLAG,'N'),
503            NVL(msik.DEFAULT_GRADE,''),
504            NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
505            NVL(msik.EXPIRATION_ACTION_CODE,''),
506            NVL(msik.HOLD_DAYS,0),
507            NVL(msik.MATURITY_DAYS,0),
508            NVL(msik.RETEST_INTERVAL,0),
509            NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
510            NVL(msik.CHILD_LOT_FLAG,'N'),
511            NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
512            NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
513            NVL(msik.SECONDARY_UOM_CODE,''),
514            NVL(msik.SECONDARY_DEFAULT_IND,''),
515            NVL(msik.TRACKING_QUANTITY_IND,'P'),
516            NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
517            NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
518         FROM mtl_system_items_vl msik /* Bug 5581528 */
519        WHERE msik.organization_id = p_organization_id
520          AND msik.mtl_transactions_enabled_flag = 'Y'
521          AND ((p_transaction_action_id=3 AND EXISTS (SELECT 1
522                                                     FROM mtl_system_items_b msib
523                                                     WHERE msib.inventory_item_id=msik.inventory_item_id
524                                                     AND  msib.organization_id = p_to_organization_id
525                                                     AND msib.mtl_transactions_enabled_flag = 'Y'
526                                                     AND (NVL(msik.lot_control_code,1)=2 OR nvl(msib.lot_control_code,1)=1)
527                                                     AND (NVL(msik.serial_number_control_code,1) IN (2,5) OR nvl(msib.serial_number_control_code,1) IN (1,6))
528                                                    AND (NVL(msik.revision_qty_control_code,1)=2 OR NVL(msib.revision_qty_control_code,1)=1)))
529               OR (p_transaction_action_id<>3 AND EXISTS (SELECT 1
530                                                         FROM mtl_system_items_b msib1
531                                                         WHERE msib1.inventory_item_id=msik.inventory_item_id
532                                                         AND msib1.organization_id=p_to_organization_id
533                                                         AND msib1.mtl_transactions_enabled_flag='Y')))
534       AND msik.concatenated_segments LIKE (p_concatenated_segments||l_append)
535 
536       -- Changes for GTIN
537       UNION
538       SELECT concatenated_segments
539            , msik.inventory_item_id
540            , msik.description
541            , NVL(revision_qty_control_code, 1)
542            , NVL(lot_control_code, 1)
543            , NVL(serial_number_control_code, 1)
544            , NVL(restrict_subinventories_code, 2)
545            , NVL(restrict_locators_code, 2)
546            , NVL(location_control_code, 1)
547            , primary_uom_code
548            , NVL(inspection_required_flag, 2)
549            , NVL(shelf_life_code, 1)
550            , NVL(shelf_life_days, 0)
551            , NVL(allowed_units_lookup_code, 2)
552            , NVL(effectivity_control, 1)
553            , 0
554            , 0
555            , NVL(default_serial_status_id, 0)
556            , NVL(serial_status_enabled, 'N')
557            , NVL(default_lot_status_id, 0)
558            , NVL(lot_status_enabled, 'N')
559            , mcr.cross_reference
560            , 'N'
561            , inventory_item_flag
562            , 0
563 	     , wms_deploy.get_item_client_name(msik.inventory_item_id),
564      --Bug No 3952081
565      --Additional Fields for Process Convergence
566            NVL(GRADE_CONTROL_FLAG,'N'),
567            NVL(DEFAULT_GRADE,''),
568            NVL(EXPIRATION_ACTION_INTERVAL,0),
569            NVL(EXPIRATION_ACTION_CODE,''),
570            NVL(HOLD_DAYS,0),
571            NVL(MATURITY_DAYS,0),
572            NVL(RETEST_INTERVAL,0),
573            NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
574            NVL(CHILD_LOT_FLAG,'N'),
575            NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
576            NVL(LOT_DIVISIBLE_FLAG,'Y'),
577            NVL(SECONDARY_UOM_CODE,''),
578            NVL(SECONDARY_DEFAULT_IND,''),
579            NVL(TRACKING_QUANTITY_IND,'P'),
580            NVL(DUAL_UOM_DEVIATION_HIGH,0),
581            NVL(DUAL_UOM_DEVIATION_LOW,0)
582       FROM mtl_system_items_vl msik, mtl_cross_references mcr /* Bug 5581528 */
583       WHERE msik.organization_id = p_organization_id
584       AND msik.mtl_transactions_enabled_flag = 'Y'
585       AND ((p_transaction_action_id=3 AND EXISTS (SELECT 1
586                                                  FROM mtl_system_items_b msib
587                                                  WHERE msib.inventory_item_id=msik.inventory_item_id
588                                                  AND msib.organization_id = p_to_organization_id
589                                                  AND msib.mtl_transactions_enabled_flag ='Y'
590                                                  AND (NVL(msik.lot_control_code,1)=2 OR nvl(msib.lot_control_code,1)=1)
591                                                  AND (NVL(msik.serial_number_control_code,1) IN (2,5) OR nvl(msib.serial_number_control_code,1) IN (1,6))
592                                                  AND (NVL(msik.revision_qty_control_code,1)=2 OR NVL(msib.revision_qty_control_code,1)=1)))
593            OR ((p_transaction_action_id <>3 AND EXISTS(SELECT 1
594                                                    FROM mtl_system_items_b msib1
595                                                    WHERE  msib1.inventory_item_id=msik.inventory_item_id
596                                                      AND msib1.organization_id=p_to_organization_id
597                                                     AND msib1.mtl_transactions_enabled_flag='Y'))))
598       AND msik.inventory_item_id   = mcr.inventory_item_id
599       AND mcr.cross_reference_type = g_gtin_cross_ref_type
600       AND mcr.cross_reference      LIKE l_cross_ref
601       AND (mcr.organization_id     = msik.organization_id OR mcr.org_independent_flag = 'Y');
602   END get_transactable_items;
603 
604   --      Name: GET_REVISION_LOV
605   --
606   --      Input parameters:
607   --       p_organization_id     Organization ID
608   --       p_item_id             Inventory Item id
609   --       p_revision            Revision
610   --       p_planning_org_id     Planning Organization ID - Consignment and VMI Changes
611   --       p_planning_tp_type    Planning TP Type         - Consignment and VMI Changes
612   --       p_owning_org_id       Owning Organization ID   - Consignment and VMI Changes
613   --       p_owning_tp_type      Owning TP Type           - Consignment and VMI Changes
614   --
615   --      Output parameters:
616   --       x_revs                Returns LOV rows as Reference Cursor
617   --
618   --      Functions: This procedure returns valid Revisions after restricting it by
619   --                 Org, Item, Planning and Owning criterions.
620   --
621   --
622 
623   PROCEDURE get_revision_lov(
624     x_revs OUT NOCOPY t_genref
625   , p_organization_id IN NUMBER
626   , p_inventory_item_id IN NUMBER
627   , p_revision IN VARCHAR2
628   , p_planning_org_id IN NUMBER
629   , p_planning_tp_type IN NUMBER
630   , p_owning_org_id IN NUMBER
631   , p_owning_tp_type IN NUMBER
632   ) IS
633   BEGIN
634     OPEN x_revs FOR
635       SELECT a.revision, a.effectivity_date, NVL(a.description, '')
636         FROM mtl_item_revisions a
637        WHERE a.organization_id = p_organization_id
638          AND a.inventory_item_id = p_inventory_item_id
639           /* Bug# 8912324: Commented the code below so as to allow unimplemented item
640             revisions for other transactions except misc issue/ receipt */
641          -- AND a.implementation_date is not null                --BUG 7204523 Added to restrict the revisions that are not yet implemented.
642          AND a.revision LIKE (p_revision)
643          AND (p_planning_org_id IS NULL
644               OR EXISTS(SELECT 1 FROM mtl_onhand_quantities_detail moqd
645                          WHERE moqd.revision = a.revision
646                            AND moqd.organization_id = a.organization_id
647                            AND moqd.inventory_item_id = a.inventory_item_id
648                            AND moqd.planning_organization_id = p_planning_org_id
649                            AND moqd.planning_tp_type = p_planning_tp_type))
650          AND (p_owning_org_id IS NULL
651               OR EXISTS(SELECT 1 FROM mtl_onhand_quantities_detail moqd
652                          WHERE moqd.revision = a.revision
653                            AND moqd.organization_id = a.organization_id
654                            AND moqd.inventory_item_id = a.inventory_item_id
655                            AND moqd.owning_organization_id = p_owning_org_id
656                            AND moqd.owning_tp_type = p_owning_tp_type));
657   END get_revision_lov;
658 
659 
660   --      Name: GET_INV_TXN_REVISION_LOV
661   --
662   --      Input parameters:
663   --       p_organization_id     Organization ID
664   --       p_item_id             Inventory Item id
665   --       p_revision            Revision
666   --       p_planning_org_id     Planning Organization ID - Consignment and VMI Changes
667   --       p_planning_tp_type    Planning TP Type         - Consignment and VMI Changes
668   --       p_owning_org_id       Owning Organization ID   - Consignment and VMI Changes
669   --       p_owning_tp_type      Owning TP Type           - Consignment and VMI Changes
670   --
671   --      Output parameters:
672   --       x_revs                Returns LOV rows as Reference Cursor
673   --
674   --      Functions: This procedure returns valid Revisions after restricting it by
675   --                 Org, Item, Planning and Owning criterions.
676   --                 This lov is only applicable for inv transactions whicn restricts
677   --                 unimplemented item revisions
678 
679   /* Bug# 8912324 : Added new proc get_inv_txn_revision_lov */
680   PROCEDURE get_inv_txn_revision_lov(
681     x_revs OUT NOCOPY t_genref
682   , p_organization_id IN NUMBER
683   , p_inventory_item_id IN NUMBER
684   , p_revision IN VARCHAR2
685   , p_planning_org_id IN NUMBER
686   , p_planning_tp_type IN NUMBER
687   , p_owning_org_id IN NUMBER
688   , p_owning_tp_type IN NUMBER
689   ) IS
690   BEGIN
691     OPEN x_revs FOR
692       SELECT a.revision, a.effectivity_date, NVL(a.description, '')
693         FROM mtl_item_revisions a
694        WHERE a.organization_id = p_organization_id
695          AND a.inventory_item_id = p_inventory_item_id
696          AND a.implementation_date is not null                --BUG 7204523 Added to restrict the revisions that are not yet implemented.
697          AND a.revision LIKE (p_revision)
698          AND (p_planning_org_id IS NULL
699               OR EXISTS(SELECT 1 FROM mtl_onhand_quantities_detail moqd
700                          WHERE moqd.revision = a.revision
701                            AND moqd.organization_id = a.organization_id
702                            AND moqd.inventory_item_id = a.inventory_item_id
703                            AND moqd.planning_organization_id = p_planning_org_id
704                            AND moqd.planning_tp_type = p_planning_tp_type))
705          AND (p_owning_org_id IS NULL
706               OR EXISTS(SELECT 1 FROM mtl_onhand_quantities_detail moqd
707                          WHERE moqd.revision = a.revision
708                            AND moqd.organization_id = a.organization_id
709                            AND moqd.inventory_item_id = a.inventory_item_id
710                            AND moqd.owning_organization_id = p_owning_org_id
711                            AND moqd.owning_tp_type = p_owning_tp_type));
712   END get_inv_txn_revision_lov;
713 
714   --      Name: GET_UOM_LOV
715   --
716   --      Input parameters:
717   --       p_Organization_Id   which restricts LOV SQL to current org
718   --       p_Inventory_Item_Id restrict LOV for a given item
719   --       p_UOM_code   which restricts LOV SQL to the user input text
720   --                                e.g.  Ea%
721   --
722   --      Output parameters:
723   --       x_UOMS      returns LOV rows as reference cursor
724   --
725   --      Functions: This procedure returns LOV rows for a given org, item and
726   --                 user input text
727   --
728 
729   --Bug # 2647045
730   PROCEDURE get_uom_lov(x_UOMS OUT NOCOPY t_genref,
731 		      p_Organization_Id IN NUMBER,
732 		      p_Inventory_Item_Id IN NUMBER,
733 		      p_UOM_Code IN VARCHAR2) IS
734      l_code VARCHAR2(20):=p_UOM_Code;
735   BEGIN
736     IF (INSTR(l_code,'(') > 0) THEN
737       l_code := SUBSTR(p_UOM_Code,1,INSTR(p_UOM_Code,'(')-1);
738     END IF;
739 
740     OPEN x_uoms FOR
741       SELECT (inv_ui_item_lovs.get_conversion_rate(uom_code,
742 				   p_Organization_Id,
743 				   p_Inventory_Item_Id)) uom_code_comp
744            , unit_of_measure
745            , description
746            , uom_class
747         FROM mtl_item_uoms_view
748        WHERE organization_id = p_organization_id
749          AND inventory_item_id = p_inventory_item_id
750          AND uom_code LIKE (l_code)
751       ORDER BY inv_ui_item_lovs.conversion_order(inv_ui_item_lovs.get_conversion_rate(uom_code,
752 				   p_Organization_Id,
753 				   p_Inventory_Item_Id)) asc, Upper(uom_code);
754   END get_uom_lov;
755 
756   --      Name: GET_UOM_LOV_RCV
757   --
758   --      Input parameters:
759   --       p_Organization_Id   which restricts LOV SQL to current org
760   --       p_Inventory_Item_Id restrict LOV for a given item
761   --       p_uom_type  restrict LOV to certain UOM type
762   --       p_UOM_code   which restricts LOV SQL to the user input text
763   --                                e.g.  Ea%
764   --
765   --      Output parameters:
766   --       x_UOMS      returns LOV rows as reference cursor
767   --
768   --      Functions: This procedure returns UOM LOV rows for a given org, item and
769   --                 user input text.
770   --                 This API is for RECEIVING transaction only
771   --
772   -- Bug 2192815
773   -- The part for Expense Items is now moved over to INVRCVLB.pls, INVRCVLS.pls
774   -- The name of the procedure is get_uom_lov_expense
775   --
776 
777   --Bug # 2647045
778   PROCEDURE get_uom_lov_rcv(x_uoms OUT NOCOPY t_genref,
779 			  p_organization_id IN NUMBER,
780 			  p_item_id IN NUMBER,
781 			  p_uom_type IN NUMBER,
782 			  p_uom_code IN VARCHAR2) IS
783      l_code VARCHAR2(20):=p_uom_code;
784   BEGIN
785     IF (INSTR(l_code,'(') > 0) THEN
786       l_code := SUBSTR(p_uom_code,1,INSTR(p_uom_code,'(')-1);
787     END IF;
788 
789     IF (p_item_id IS NOT NULL
790         AND p_item_id > 0
791        ) THEN
792       OPEN x_uoms FOR
793         SELECT   (inv_ui_item_lovs.get_conversion_rate(uom_code,
794 				   p_organization_id,
795 				   Inventory_Item_Id)) uom_code_comp
796                , unit_of_measure
797                , description
798                , uom_class
799             FROM mtl_item_uoms_view
800            WHERE organization_id = p_organization_id
801              AND inventory_item_id(+) = p_item_id
802              AND NVL(uom_type, 3) = NVL(p_uom_type, 3)
803              AND uom_code LIKE (l_code)
804 	     ORDER BY inv_ui_item_lovs.conversion_order(inv_ui_item_lovs.get_conversion_rate(uom_code,
805 				   p_organization_id,
806 				   Inventory_Item_Id)) asc, Upper(uom_code);
807     -- Bug 2192815
808     -- The following is commented out as this is part of INVRCVLB.pls now
809     -- ELSE
810     -- OPEN x_uoms FOR
811     --SELECT uom_code
812     --, unit_of_measure
813     --, ''
814     --, uom_class
815     --FROM mtl_units_of_measure
816     --WHERE base_uom_flag = 'Y'
817     --AND uom_code LIKE (p_uom_code || '%')
818     --ORDER BY Upper(uom_code);
819 
820     END IF;
821   END get_uom_lov_rcv;
822 
823   PROCEDURE get_lot_items_lov(x_items OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_lot_number IN VARCHAR2, p_transaction_type_id IN VARCHAR2, p_concatenated_segments IN VARCHAR2) IS
824   l_cross_ref varchar2(204);
825   l_append varchar2(2):='';
826 BEGIN
827 
828    l_cross_ref := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
829    l_append:=wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
830 
831     IF p_transaction_type_id = inv_globals.g_type_inv_lot_split -- Lot Split (82)
832                                                                 THEN
833       OPEN x_items FOR
834         SELECT   msik.concatenated_segments concatenated_segments
835                , msik.inventory_item_id
836                , msik.description
837                , NVL(msik.revision_qty_control_code, 1)
838                , NVL(msik.lot_control_code, 1)
839                , NVL(msik.serial_number_control_code, 1)
840                , NVL(msik.restrict_subinventories_code, 2)
841                , NVL(msik.restrict_locators_code, 2)
842                , NVL(msik.location_control_code, 1)
843                , msik.primary_uom_code
844                , NVL(msik.inspection_required_flag, 2)
845                , NVL(msik.shelf_life_code, 1)
846                , NVL(msik.shelf_life_days, 0)
847                , NVL(msik.allowed_units_lookup_code, 2)
848                , NVL(msik.effectivity_control, 1)
849                , 0 parentlpnid
850                , 0 quantity
851                , NVL(msik.default_serial_status_id, 0)
852                , NVL(msik.serial_status_enabled, 'N')
853                , NVL(msik.default_lot_status_id, 0)
854                , NVL(msik.lot_status_enabled, 'N')
855                , ''
856                , 'N'
857                , msik.inventory_item_flag
858                , 0
859 		   , null,
860      --Bug No 3952081
861      --Additional Fields for Process Convergence
862                NVL(msik.GRADE_CONTROL_FLAG,'N'),
863                NVL(msik.DEFAULT_GRADE,''),
864                NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
865                NVL(msik.EXPIRATION_ACTION_CODE,''),
866                NVL(msik.HOLD_DAYS,0),
867                NVL(msik.MATURITY_DAYS,0),
868                NVL(msik.RETEST_INTERVAL,0),
869                NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
870                NVL(msik.CHILD_LOT_FLAG,'N'),
871                NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
872                NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
873                NVL(msik.SECONDARY_UOM_CODE,''),
874                NVL(msik.SECONDARY_DEFAULT_IND,''),
875                NVL(msik.TRACKING_QUANTITY_IND,'P'),
876                NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
877                NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
878             FROM mtl_system_items_vl msik, mtl_lot_numbers mln /* Bug 5581528 */
879            WHERE msik.lot_split_enabled = 'Y'
880              AND msik.concatenated_segments LIKE (p_concatenated_segments||l_append)
881              AND msik.organization_id = mln.organization_id
882              AND msik.inventory_item_id = mln.inventory_item_id
883              AND mln.lot_number = p_lot_number
884              AND mln.organization_id = p_organization_id
885              AND (NVL(msik.lot_status_enabled, 'N') = 'N'
886                  OR NOT EXISTS (SELECT 1 FROM  mtl_status_transaction_control
887                                  WHERE status_id = mln.status_id
888                                    AND transaction_type_id = p_transaction_type_id
889                                    AND is_allowed = 2))
890 
891 
892 	--Changes for GTIN
893 
894 	UNION
895 
896 	SELECT   msik.concatenated_segments concatenated_segments
897                , msik.inventory_item_id
898                , msik.description
899                , NVL(msik.revision_qty_control_code, 1)
900                , NVL(msik.lot_control_code, 1)
901                , NVL(msik.serial_number_control_code, 1)
902                , NVL(msik.restrict_subinventories_code, 2)
903                , NVL(msik.restrict_locators_code, 2)
904                , NVL(msik.location_control_code, 1)
905                , msik.primary_uom_code
906                , NVL(msik.inspection_required_flag, 2)
907                , NVL(msik.shelf_life_code, 1)
908                , NVL(msik.shelf_life_days, 0)
909                , NVL(msik.allowed_units_lookup_code, 2)
910                , NVL(msik.effectivity_control, 1)
911                , 0 parentlpnid
912                , 0 quantity
913                , NVL(msik.default_serial_status_id, 0)
914                , NVL(msik.serial_status_enabled, 'N')
915                , NVL(msik.default_lot_status_id, 0)
916                , NVL(msik.lot_status_enabled, 'N')
917                , mcr.cross_reference
918                , 'N'
919                , msik.inventory_item_flag
920                , 0
921 		   , null,
922      --Bug No 3952081
923      --Additional Fields for Process Convergence
924                NVL(msik.GRADE_CONTROL_FLAG,'N'),
925                NVL(msik.DEFAULT_GRADE,''),
926                NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
927                NVL(msik.EXPIRATION_ACTION_CODE,''),
928                NVL(msik.HOLD_DAYS,0),
929                NVL(msik.MATURITY_DAYS,0),
930                NVL(msik.RETEST_INTERVAL,0),
931                NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
932                NVL(msik.CHILD_LOT_FLAG,'N'),
933                NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
934                NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
935                NVL(msik.SECONDARY_UOM_CODE,''),
936                NVL(msik.SECONDARY_DEFAULT_IND,''),
937                NVL(msik.TRACKING_QUANTITY_IND,'P'),
938                NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
939                NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
940 	FROM mtl_system_items_vl msik, /* Bug 5581528 */
941 	mtl_lot_numbers mln,
942 	mtl_cross_references mcr
943 	WHERE msik.lot_split_enabled = 'Y'
944 	AND msik.organization_id = mln.organization_id
945 	AND msik.inventory_item_id = mln.inventory_item_id
946 	AND mln.lot_number = p_lot_number
947 	AND mln.organization_id = p_organization_id
948 	AND msik.inventory_item_id   = mcr.inventory_item_id
949 	AND mcr.cross_reference_type = g_gtin_cross_ref_type
950 	AND mcr.cross_reference      LIKE l_cross_ref
951 	AND (mcr.organization_id     = msik.organization_id
952 	     OR
953 	     mcr.org_independent_flag = 'Y')
954         AND (NVL(msik.lot_status_enabled, 'N') = 'N'
955              OR NOT EXISTS (SELECT 1 FROM  mtl_status_transaction_control
956                              WHERE status_id = mln.status_id
957                                AND transaction_type_id = p_transaction_type_id
958                                AND is_allowed = 2))
959 	ORDER BY concatenated_segments;
960 
961     ELSE
962       IF p_transaction_type_id = inv_globals.g_type_inv_lot_merge -- Lot Merge 83
963                                                                   THEN
964         OPEN x_items FOR
965           SELECT   msik.concatenated_segments concatenated_segments
966                  , msik.inventory_item_id
967                  , msik.description
968                  , NVL(msik.revision_qty_control_code, 1)
969                  , NVL(msik.lot_control_code, 1)
970                  , NVL(msik.serial_number_control_code, 1)
971                  , NVL(msik.restrict_subinventories_code, 2)
972                  , NVL(msik.restrict_locators_code, 2)
973                  , NVL(msik.location_control_code, 1)
974                  , msik.primary_uom_code
975                  , NVL(msik.inspection_required_flag, 2)
976                  , NVL(msik.shelf_life_code, 1)
977                  , NVL(msik.shelf_life_days, 0)
978                  , NVL(msik.allowed_units_lookup_code, 2)
979                  , NVL(msik.effectivity_control, 1)
980                  , 0 parentlpnid
981                  , 0 quantity
982                  , NVL(msik.default_serial_status_id, 0)
983                  , NVL(msik.serial_status_enabled, 'N')
984                  , NVL(msik.default_lot_status_id, 0)
985                  , NVL(msik.lot_status_enabled, 'N')
986                  , ''
987                  , 'N'
988                  , msik.inventory_item_flag
989                  , 0
990 		     , null,
991      --Bug No 3952081
992      --Additional Fields for Process Convergence
993                NVL(msik.GRADE_CONTROL_FLAG,'N'),
994                NVL(msik.DEFAULT_GRADE,''),
995                NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
996                NVL(msik.EXPIRATION_ACTION_CODE,''),
997                NVL(msik.HOLD_DAYS,0),
998                NVL(msik.MATURITY_DAYS,0),
999                NVL(msik.RETEST_INTERVAL,0),
1000                NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
1001                NVL(msik.CHILD_LOT_FLAG,'N'),
1002                NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
1003                NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
1004                NVL(msik.SECONDARY_UOM_CODE,''),
1005                NVL(msik.SECONDARY_DEFAULT_IND,''),
1006                NVL(msik.TRACKING_QUANTITY_IND,'P'),
1007                NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
1008                NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
1009               FROM mtl_system_items_vl msik, mtl_lot_numbers mln /* Bug 5581528 */
1010              WHERE msik.lot_merge_enabled = 'Y'
1011                AND msik.concatenated_segments LIKE (p_concatenated_segments||l_append)
1012                AND msik.organization_id = mln.organization_id
1013                AND msik.inventory_item_id = mln.inventory_item_id
1014                AND mln.lot_number = p_lot_number
1015   	       AND mln.organization_id = p_organization_id
1016                AND (NVL(msik.lot_status_enabled, 'N') = 'N'
1017                    OR NOT EXISTS (SELECT 1 FROM  mtl_status_transaction_control
1018                                    WHERE status_id = mln.status_id
1019                                      AND transaction_type_id = p_transaction_type_id
1020                                      AND is_allowed = 2))
1021 
1022 
1023 	  --Changes for GTIN
1024 
1025 	  UNION
1026 
1027           SELECT   msik.concatenated_segments concatenated_segments
1028                  , msik.inventory_item_id
1029                  , msik.description
1030                  , NVL(msik.revision_qty_control_code, 1)
1031                  , NVL(msik.lot_control_code, 1)
1032                  , NVL(msik.serial_number_control_code, 1)
1033                  , NVL(msik.restrict_subinventories_code, 2)
1034                  , NVL(msik.restrict_locators_code, 2)
1035                  , NVL(msik.location_control_code, 1)
1036                  , msik.primary_uom_code
1037                  , NVL(msik.inspection_required_flag, 2)
1038                  , NVL(msik.shelf_life_code, 1)
1039                  , NVL(msik.shelf_life_days, 0)
1040                  , NVL(msik.allowed_units_lookup_code, 2)
1041                  , NVL(msik.effectivity_control, 1)
1042                  , 0 parentlpnid
1043                  , 0 quantity
1044                  , NVL(msik.default_serial_status_id, 0)
1045                  , NVL(msik.serial_status_enabled, 'N')
1046                  , NVL(msik.default_lot_status_id, 0)
1047                  , NVL(msik.lot_status_enabled, 'N')
1048                  , mcr.cross_reference
1049                  , 'N'
1050                  , msik.inventory_item_flag
1051                  , 0
1052 		     , null,
1053      --Bug No 3952081
1054      --Additional Fields for Process Convergence
1055                NVL(msik.GRADE_CONTROL_FLAG,'N'),
1056                NVL(msik.DEFAULT_GRADE,''),
1057                NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
1058                NVL(msik.EXPIRATION_ACTION_CODE,''),
1059                NVL(msik.HOLD_DAYS,0),
1060                NVL(msik.MATURITY_DAYS,0),
1061                NVL(msik.RETEST_INTERVAL,0),
1062                NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
1063                NVL(msik.CHILD_LOT_FLAG,'N'),
1064                NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
1065                NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
1066                NVL(msik.SECONDARY_UOM_CODE,''),
1067                NVL(msik.SECONDARY_DEFAULT_IND,''),
1068                NVL(msik.TRACKING_QUANTITY_IND,'P'),
1069                NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
1070                NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
1071 	  FROM mtl_system_items_vl msik, /* Bug 5581528 */
1072 	  mtl_lot_numbers mln,
1073 	  mtl_cross_references mcr
1074 	  WHERE msik.lot_merge_enabled = 'Y'
1075 	  AND msik.organization_id = mln.organization_id
1076 	  AND msik.inventory_item_id = mln.inventory_item_id
1077 	  AND mln.lot_number = p_lot_number
1078 	  AND mln.organization_id = p_organization_id
1079 	  AND msik.inventory_item_id   = mcr.inventory_item_id
1080 	  AND mcr.cross_reference_type = g_gtin_cross_ref_type
1081 	  AND mcr.cross_reference      LIKE l_cross_ref
1082 	  AND (mcr.organization_id     = msik.organization_id
1083 	       OR
1084 	       mcr.org_independent_flag = 'Y')
1085           AND (NVL(msik.lot_status_enabled, 'N') = 'N'
1086                OR NOT EXISTS (SELECT 1 FROM  mtl_status_transaction_control
1087                                WHERE status_id = mln.status_id
1088                                  AND transaction_type_id = p_transaction_type_id
1089                                  AND is_allowed = 2))
1090 	  ORDER BY concatenated_segments;
1091 
1092       ELSE
1093         IF p_transaction_type_id = inv_globals.g_type_inv_lot_translate THEN
1094           IF (p_lot_number IS NOT NULL) THEN
1095             OPEN x_items FOR
1096               SELECT   msik.concatenated_segments concatenated_segments
1097                      , msik.inventory_item_id
1098                      , msik.description
1099                      , NVL(msik.revision_qty_control_code, 1)
1100                      , NVL(msik.lot_control_code, 1)
1101                      , NVL(msik.serial_number_control_code, 1)
1102                      , NVL(msik.restrict_subinventories_code, 2)
1103                      , NVL(msik.restrict_locators_code, 2)
1104                      , NVL(msik.location_control_code, 1)
1105                      , msik.primary_uom_code
1106                      , NVL(msik.inspection_required_flag, 2)
1107                      , NVL(msik.shelf_life_code, 1)
1108                      , NVL(msik.shelf_life_days, 0)
1109                      , NVL(msik.allowed_units_lookup_code, 2)
1110                      , NVL(msik.effectivity_control, 1)
1111                      , 0 parentlpnid
1112                      , 0 quantity
1113                      , NVL(msik.default_serial_status_id, 0)
1114                      , NVL(msik.serial_status_enabled, 'N')
1115                      , NVL(msik.default_lot_status_id, 0)
1116                      , NVL(msik.lot_status_enabled, 'N')
1117                      , ''
1118                      , 'N'
1119                      , msik.inventory_item_flag
1120                      , 0
1121 			   , null,
1122      --Bug No 3952081
1123      --Additional Fields for Process Convergence
1124                      NVL(msik.GRADE_CONTROL_FLAG,'N'),
1125                      NVL(msik.DEFAULT_GRADE,''),
1126                      NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
1127                      NVL(msik.EXPIRATION_ACTION_CODE,''),
1128                      NVL(msik.HOLD_DAYS,0),
1129                      NVL(msik.MATURITY_DAYS,0),
1130                      NVL(msik.RETEST_INTERVAL,0),
1131                      NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
1132                      NVL(msik.CHILD_LOT_FLAG,'N'),
1133                      NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
1134                      NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
1135                      NVL(msik.SECONDARY_UOM_CODE,''),
1136                      NVL(msik.SECONDARY_DEFAULT_IND,''),
1137                      NVL(msik.TRACKING_QUANTITY_IND,'P'),
1138                      NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
1139                      NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
1140                   FROM mtl_system_items_vl msik, mtl_lot_numbers mln /* Bug 5581528 */
1141                  WHERE msik.concatenated_segments LIKE (p_concatenated_segments||l_append)
1142                    AND msik.organization_id = mln.organization_id
1143                    AND msik.inventory_item_id = mln.inventory_item_id
1144                    AND mln.lot_number = p_lot_number
1145 	           AND mln.organization_id = p_organization_id
1146                    AND (NVL(msik.lot_status_enabled, 'N') = 'N'
1147                     OR NOT EXISTS (SELECT 1 FROM  mtl_status_transaction_control
1148                                     WHERE status_id = mln.status_id
1149                                       AND transaction_type_id = p_transaction_type_id
1150                                       AND is_allowed = 2))
1151 
1152 	      --Changes for GTIN
1153 
1154 	      UNION
1155 
1156 	      SELECT   msik.concatenated_segments concatenated_segments
1157                      , msik.inventory_item_id
1158                      , msik.description
1159                      , NVL(msik.revision_qty_control_code, 1)
1160                      , NVL(msik.lot_control_code, 1)
1161                      , NVL(msik.serial_number_control_code, 1)
1162                      , NVL(msik.restrict_subinventories_code, 2)
1163                      , NVL(msik.restrict_locators_code, 2)
1164                      , NVL(msik.location_control_code, 1)
1165                      , msik.primary_uom_code
1166                      , NVL(msik.inspection_required_flag, 2)
1167                      , NVL(msik.shelf_life_code, 1)
1168                      , NVL(msik.shelf_life_days, 0)
1169                      , NVL(msik.allowed_units_lookup_code, 2)
1170                      , NVL(msik.effectivity_control, 1)
1171                      , 0 parentlpnid
1172                      , 0 quantity
1173                      , NVL(msik.default_serial_status_id, 0)
1174                      , NVL(msik.serial_status_enabled, 'N')
1175                      , NVL(msik.default_lot_status_id, 0)
1176                      , NVL(msik.lot_status_enabled, 'N')
1177                      , mcr.cross_reference
1178                      , 'N'
1179                      , msik.inventory_item_flag
1180                      , 0
1181 			   , null,
1182      --Bug No 3952081
1183      --Additional Fields for Process Convergence
1184                      NVL(msik.GRADE_CONTROL_FLAG,'N'),
1185                      NVL(msik.DEFAULT_GRADE,''),
1186                      NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
1187                      NVL(msik.EXPIRATION_ACTION_CODE,''),
1188                      NVL(msik.HOLD_DAYS,0),
1189                      NVL(msik.MATURITY_DAYS,0),
1190                      NVL(msik.RETEST_INTERVAL,0),
1191                      NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
1192                      NVL(msik.CHILD_LOT_FLAG,'N'),
1193                      NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
1194                      NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
1195                      NVL(msik.SECONDARY_UOM_CODE,''),
1196                      NVL(msik.SECONDARY_DEFAULT_IND,''),
1197                      NVL(msik.TRACKING_QUANTITY_IND,'P'),
1198                      NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
1199                      NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
1200 	      FROM mtl_system_items_vl msik, /* Bug 5581528 */
1201 	      mtl_lot_numbers mln,
1202 	      mtl_cross_references mcr
1203 	      WHERE msik.organization_id = mln.organization_id
1204 	      AND msik.inventory_item_id = mln.inventory_item_id
1205 	      AND mln.lot_number = p_lot_number
1206 	      AND mln.organization_id = p_organization_id
1207 	      AND msik.inventory_item_id   = mcr.inventory_item_id
1208 	      AND mcr.cross_reference_type = g_gtin_cross_ref_type
1209 	      AND mcr.cross_reference      LIKE l_cross_ref
1210 	      AND (mcr.organization_id     = msik.organization_id
1211 		   OR
1212 		   mcr.org_independent_flag = 'Y')
1213               AND (NVL(msik.lot_status_enabled, 'N') = 'N'
1214                   OR NOT EXISTS (SELECT 1 FROM  mtl_status_transaction_control
1215                                   WHERE status_id = mln.status_id
1216                                     AND transaction_type_id = p_transaction_type_id
1217                                     AND is_allowed = 2))
1218 	      ORDER BY concatenated_segments;
1219           ELSE
1220             OPEN x_items FOR
1221               SELECT   msik.concatenated_segments concatenated_segments
1222                      , msik.inventory_item_id
1223                      , msik.description
1224                      , NVL(msik.revision_qty_control_code, 1)
1225                      , NVL(msik.lot_control_code, 1)
1226                      , NVL(msik.serial_number_control_code, 1)
1227                      , NVL(msik.restrict_subinventories_code, 2)
1228                      , NVL(msik.restrict_locators_code, 2)
1229                      , NVL(msik.location_control_code, 1)
1230                      , msik.primary_uom_code
1231                      , NVL(msik.inspection_required_flag, 2)
1232                      , NVL(msik.shelf_life_code, 1)
1233                      , NVL(msik.shelf_life_days, 0)
1234                      , NVL(msik.allowed_units_lookup_code, 2)
1235                      , NVL(msik.effectivity_control, 1)
1236                      , 0 parentlpnid
1237                      , 0 quantity
1238                      , NVL(msik.default_serial_status_id, 0)
1239                      , NVL(msik.serial_status_enabled, 'N')
1240                      , NVL(msik.default_lot_status_id, 0)
1241                      , NVL(msik.lot_status_enabled, 'N')
1242                      , ''
1243                      , 'N'
1244                      , msik.inventory_item_flag
1245                      , 0
1246 			   , null,
1247      --Bug No 3952081
1248      --Additional Fields for Process Convergence
1249                      NVL(msik.GRADE_CONTROL_FLAG,'N'),
1250                      NVL(msik.DEFAULT_GRADE,''),
1251                      NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
1252                      NVL(msik.EXPIRATION_ACTION_CODE,''),
1253                      NVL(msik.HOLD_DAYS,0),
1254                      NVL(msik.MATURITY_DAYS,0),
1255                      NVL(msik.RETEST_INTERVAL,0),
1256                      NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
1257                      NVL(msik.CHILD_LOT_FLAG,'N'),
1258                      NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
1259                      NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
1260                      NVL(msik.SECONDARY_UOM_CODE,''),
1261                      NVL(msik.SECONDARY_DEFAULT_IND,''),
1262                      NVL(msik.TRACKING_QUANTITY_IND,'P'),
1263                      NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
1264                      NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
1265                   FROM mtl_system_items_vl msik /* Bug 5581528 */
1266                  WHERE msik.concatenated_segments LIKE (p_concatenated_segments||l_append)
1267                    AND msik.lot_control_code = 2
1268 	      AND msik.organization_id = p_organization_id
1269 
1270 	      --Changes for GTIN
1271 
1272 	      UNION
1273 
1274 	                    SELECT   msik.concatenated_segments concatenated_segments
1275                      , msik.inventory_item_id
1276                      , msik.description
1277                      , NVL(msik.revision_qty_control_code, 1)
1278                      , NVL(msik.lot_control_code, 1)
1279                      , NVL(msik.serial_number_control_code, 1)
1280                      , NVL(msik.restrict_subinventories_code, 2)
1281                      , NVL(msik.restrict_locators_code, 2)
1282                      , NVL(msik.location_control_code, 1)
1283                      , msik.primary_uom_code
1284                      , NVL(msik.inspection_required_flag, 2)
1285                      , NVL(msik.shelf_life_code, 1)
1286                      , NVL(msik.shelf_life_days, 0)
1287                      , NVL(msik.allowed_units_lookup_code, 2)
1288                      , NVL(msik.effectivity_control, 1)
1289                      , 0 parentlpnid
1290                      , 0 quantity
1291                      , NVL(msik.default_serial_status_id, 0)
1292                      , NVL(msik.serial_status_enabled, 'N')
1293                      , NVL(msik.default_lot_status_id, 0)
1294                      , NVL(msik.lot_status_enabled, 'N')
1295                      , mcr.cross_reference
1296                      , 'N'
1297                      , msik.inventory_item_flag
1298                      , 0
1299 			   , null,
1300      --Bug No 3952081
1301      --Additional Fields for Process Convergence
1302                      NVL(msik.GRADE_CONTROL_FLAG,'N'),
1303                      NVL(msik.DEFAULT_GRADE,''),
1304                      NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
1305                      NVL(msik.EXPIRATION_ACTION_CODE,''),
1306                      NVL(msik.HOLD_DAYS,0),
1307                      NVL(msik.MATURITY_DAYS,0),
1308                      NVL(msik.RETEST_INTERVAL,0),
1309                      NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
1310                      NVL(msik.CHILD_LOT_FLAG,'N'),
1311                      NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
1312                      NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
1313                      NVL(msik.SECONDARY_UOM_CODE,''),
1314                      NVL(msik.SECONDARY_DEFAULT_IND,''),
1315                      NVL(msik.TRACKING_QUANTITY_IND,'P'),
1316                      NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
1317                      NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
1318 	      FROM mtl_system_items_vl msik, /* Bug 5581528 */
1319 	      mtl_cross_references mcr
1320 	      WHERE msik.lot_control_code = 2
1321 	      AND msik.organization_id = p_organization_id
1322 	      AND msik.inventory_item_id   = mcr.inventory_item_id
1323 	      AND mcr.cross_reference_type = g_gtin_cross_ref_type
1324 	      AND mcr.cross_reference      LIKE l_cross_ref
1325 	      AND (mcr.organization_id     = msik.organization_id
1326 		   OR
1327 		   mcr.org_independent_flag = 'Y')
1328               ORDER BY concatenated_segments;
1329           END IF;
1330         ELSE
1331           OPEN x_items FOR
1332             SELECT   msik.concatenated_segments concatenated_segments
1333                    , msik.inventory_item_id
1334                    , msik.description
1335                    , NVL(msik.revision_qty_control_code, 1)
1336                    , NVL(msik.lot_control_code, 1)
1337                    , NVL(msik.serial_number_control_code, 1)
1338                    , NVL(msik.restrict_subinventories_code, 2)
1339                    , NVL(msik.restrict_locators_code, 2)
1340                    , NVL(msik.location_control_code, 1)
1341                    , msik.primary_uom_code
1342                    , NVL(msik.inspection_required_flag, 2)
1343                    , NVL(msik.shelf_life_code, 1)
1344                    , NVL(msik.shelf_life_days, 0)
1345                    , NVL(msik.allowed_units_lookup_code, 2)
1346                    , NVL(msik.effectivity_control, 1)
1347                    , 0 parentlpnid
1348                    , 0 quantity
1349                    , NVL(msik.default_serial_status_id, 0)
1350                    , NVL(msik.serial_status_enabled, 'N')
1351                    , NVL(msik.default_lot_status_id, 0)
1352                    , NVL(msik.lot_status_enabled, 'N')
1353                    , ''
1354                    , 'N'
1355                    , msik.inventory_item_flag
1356                    , 0
1357 			 , null,
1358      --Bug No 3952081
1359      --Additional Fields for Process Convergence
1360                    NVL(msik.GRADE_CONTROL_FLAG,'N'),
1361                    NVL(msik.DEFAULT_GRADE,''),
1362                    NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
1363                    NVL(msik.EXPIRATION_ACTION_CODE,''),
1364                    NVL(msik.HOLD_DAYS,0),
1365                    NVL(msik.MATURITY_DAYS,0),
1366                    NVL(msik.RETEST_INTERVAL,0),
1367                    NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
1368                    NVL(msik.CHILD_LOT_FLAG,'N'),
1369                    NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
1370                    NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
1371                    NVL(msik.SECONDARY_UOM_CODE,''),
1372                    NVL(msik.SECONDARY_DEFAULT_IND,''),
1373                    NVL(msik.TRACKING_QUANTITY_IND,'P'),
1374                    NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
1375                    NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
1376                 FROM mtl_system_items_vl msik, mtl_lot_numbers mln /* Bug 5581528 */
1377                WHERE msik.concatenated_segments LIKE (p_concatenated_segments||l_append)
1378                  AND msik.organization_id = mln.organization_id
1379                  AND msik.inventory_item_id = mln.inventory_item_id
1380                  AND mln.lot_number = p_lot_number
1381                  AND mln.organization_id = p_organization_id
1382 
1383 	    --Changes for GTIN
1384 
1385 	    UNION
1386 
1387 	                SELECT   msik.concatenated_segments concatenated_segments
1388                    , msik.inventory_item_id
1389                    , msik.description
1390                    , NVL(msik.revision_qty_control_code, 1)
1391                    , NVL(msik.lot_control_code, 1)
1392                    , NVL(msik.serial_number_control_code, 1)
1393                    , NVL(msik.restrict_subinventories_code, 2)
1394                    , NVL(msik.restrict_locators_code, 2)
1395                    , NVL(msik.location_control_code, 1)
1396                    , msik.primary_uom_code
1397                    , NVL(msik.inspection_required_flag, 2)
1398                    , NVL(msik.shelf_life_code, 1)
1399                    , NVL(msik.shelf_life_days, 0)
1400                    , NVL(msik.allowed_units_lookup_code, 2)
1401                    , NVL(msik.effectivity_control, 1)
1402                    , 0 parentlpnid
1403                    , 0 quantity
1404                    , NVL(msik.default_serial_status_id, 0)
1405                    , NVL(msik.serial_status_enabled, 'N')
1406                    , NVL(msik.default_lot_status_id, 0)
1407                    , NVL(msik.lot_status_enabled, 'N')
1408                    , mcr.cross_reference
1409                    , 'N'
1410                    , msik.inventory_item_flag
1411                    , 0
1412 			 , null,
1413      --Bug No 3952081
1414      --Additional Fields for Process Convergence
1415                    NVL(msik.GRADE_CONTROL_FLAG,'N'),
1416                    NVL(msik.DEFAULT_GRADE,''),
1417                    NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
1418                    NVL(msik.EXPIRATION_ACTION_CODE,''),
1419                    NVL(msik.HOLD_DAYS,0),
1420                    NVL(msik.MATURITY_DAYS,0),
1421                    NVL(msik.RETEST_INTERVAL,0),
1422                    NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
1423                    NVL(msik.CHILD_LOT_FLAG,'N'),
1424                    NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
1425                    NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
1426                    NVL(msik.SECONDARY_UOM_CODE,''),
1427                    NVL(msik.SECONDARY_DEFAULT_IND,''),
1428                    NVL(msik.TRACKING_QUANTITY_IND,'P'),
1429                    NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
1430                    NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
1431 	    FROM mtl_system_items_vl msik, /* Bug 5581528 */
1432 	    mtl_lot_numbers mln,
1433 	    mtl_cross_references mcr
1434 	    WHERE msik.organization_id = mln.organization_id
1435 	    AND msik.inventory_item_id = mln.inventory_item_id
1436 	    AND mln.lot_number = p_lot_number
1437 	    AND mln.organization_id = p_organization_id
1438 	    AND msik.inventory_item_id   = mcr.inventory_item_id
1439 	    AND mcr.cross_reference_type = g_gtin_cross_ref_type
1440 	    AND mcr.cross_reference      LIKE l_cross_ref
1441 	    AND (mcr.organization_id     = msik.organization_id
1442 		 OR
1443 		 mcr.org_independent_flag = 'Y')
1444 	    ORDER BY concatenated_segments;
1445         END IF;
1446       END IF;
1447     END IF;
1448   END get_lot_items_lov;
1449 
1450   PROCEDURE get_lot_item_details(
1451     x_revision_qty_control_code    OUT    NOCOPY NUMBER
1452   , x_serial_number_control_code   OUT    NOCOPY NUMBER
1453   , x_restrict_subinventories_code OUT    NOCOPY NUMBER
1454   , x_restrict_locators_code       OUT    NOCOPY NUMBER
1455   , x_location_control_code        OUT    NOCOPY NUMBER
1456   , x_primary_uom_code             OUT    NOCOPY VARCHAR2
1457   , x_shelf_life_code              OUT    NOCOPY NUMBER
1458   , x_shelf_life_days              OUT    NOCOPY NUMBER
1459   , x_allowed_units_lookup_code    OUT    NOCOPY NUMBER
1460   , x_lot_status_enabled           OUT    NOCOPY VARCHAR2
1461   , x_default_lot_status_id        OUT    NOCOPY NUMBER
1462   , x_return_status                OUT    NOCOPY VARCHAR2
1463   , x_msg_count                    OUT    NOCOPY NUMBER
1464   , x_msg_data                     OUT    NOCOPY VARCHAR2
1465   , p_organization_id              IN     NUMBER
1466   , p_lot_number                   IN     VARCHAR2
1467   , p_transaction_type_id          IN     VARCHAR2
1468   , p_inventory_item_id            IN     NUMBER
1469   ) IS
1470   BEGIN
1471     x_return_status  := fnd_api.g_ret_sts_success;
1472     x_msg_data       := '';
1473 
1474     IF p_transaction_type_id = inv_globals.g_type_inv_lot_split -- Lot Split (82)
1475                                                                 THEN
1476       SELECT NVL(msik.revision_qty_control_code, 1)
1477            , NVL(msik.serial_number_control_code, 1)
1478            , NVL(msik.restrict_subinventories_code, 2)
1479            , NVL(msik.restrict_locators_code, 2)
1480            , NVL(msik.location_control_code, 1)
1481            , msik.primary_uom_code
1482            , NVL(msik.shelf_life_code, 1)
1483            , NVL(msik.shelf_life_days, 0)
1484            , NVL(msik.allowed_units_lookup_code, 2)
1485            , NVL(msik.lot_status_enabled, 'N')
1486            , NVL(msik.default_lot_status_id, 0)
1487         INTO x_revision_qty_control_code
1488            , x_serial_number_control_code
1489            , x_restrict_subinventories_code
1490            , x_restrict_locators_code
1491            , x_location_control_code
1492            , x_primary_uom_code
1493            , x_shelf_life_code
1494            , x_shelf_life_days
1495            , x_allowed_units_lookup_code
1496            , x_lot_status_enabled
1497            , x_default_lot_status_id
1498         FROM mtl_system_items_vl msik /* Bug 5581528 */
1499        WHERE msik.lot_split_enabled = 'Y'
1500          AND msik.organization_id = p_organization_id
1501          AND msik.inventory_item_id = p_inventory_item_id;
1502     ELSE
1503       IF p_transaction_type_id = inv_globals.g_type_inv_lot_merge -- Lot Merge 83
1504                                                                   THEN
1505         SELECT NVL(msik.revision_qty_control_code, 1)
1506              , NVL(msik.serial_number_control_code, 1)
1507              , NVL(msik.restrict_subinventories_code, 2)
1508              , NVL(msik.restrict_locators_code, 2)
1509              , NVL(msik.location_control_code, 1)
1510              , msik.primary_uom_code
1511              , NVL(msik.shelf_life_code, 1)
1512              , NVL(msik.shelf_life_days, 0)
1513              , NVL(msik.allowed_units_lookup_code, 2)
1514              , NVL(msik.lot_status_enabled, 'N') -- nsinghi bug#5475282
1515              , NVL(msik.default_lot_status_id, 0) -- nsinghi bug#5475282
1516           INTO x_revision_qty_control_code
1517              , x_serial_number_control_code
1518              , x_restrict_subinventories_code
1519              , x_restrict_locators_code
1520              , x_location_control_code
1521              , x_primary_uom_code
1522              , x_shelf_life_code
1523              , x_shelf_life_days
1524              , x_allowed_units_lookup_code
1525              , x_lot_status_enabled -- nsinghi bug#5475282
1526              , x_default_lot_status_id -- nsinghi bug#5475282
1527           FROM mtl_system_items_vl msik /* Bug 5581528 */
1528          WHERE msik.lot_merge_enabled = 'Y'
1529            AND msik.organization_id = p_organization_id
1530            AND msik.inventory_item_id = p_inventory_item_id;
1531       ELSIF p_transaction_type_id = inv_globals.g_type_inv_lot_translate -- Lot Translate 84 Added bug4096035
1532                                                                     THEN
1533           SELECT NVL(msik.revision_qty_control_code, 1)
1534              , NVL(msik.serial_number_control_code, 1)
1535              , NVL(msik.restrict_subinventories_code, 2)
1536              , NVL(msik.restrict_locators_code, 2)
1537              , NVL(msik.location_control_code, 1)
1538              , msik.primary_uom_code
1539              , NVL(msik.shelf_life_code, 1)
1540              , NVL(msik.shelf_life_days, 0)
1541              , NVL(msik.allowed_units_lookup_code, 2)
1542              , NVL(msik.lot_status_enabled, 'N')
1543              , NVL(msik.default_lot_status_id, 0)
1544           INTO x_revision_qty_control_code
1545              , x_serial_number_control_code
1546              , x_restrict_subinventories_code
1547              , x_restrict_locators_code
1548              , x_location_control_code
1549              , x_primary_uom_code
1550              , x_shelf_life_code
1551              , x_shelf_life_days
1552              , x_allowed_units_lookup_code
1553              , x_lot_status_enabled
1554              , x_default_lot_status_id
1555           FROM mtl_system_items_vl msik /* Bug 5581528 */
1556          WHERE msik.lot_translate_enabled = 'Y'
1557            AND msik.organization_id = p_organization_id
1558            AND msik.inventory_item_id = p_inventory_item_id; /*Added bug4096035*/
1559       ELSE
1560         SELECT NVL(msik.revision_qty_control_code, 1)
1561              , NVL(msik.serial_number_control_code, 1)
1562              , NVL(msik.restrict_subinventories_code, 2)
1563              , NVL(msik.restrict_locators_code, 2)
1564              , NVL(msik.location_control_code, 1)
1565              , msik.primary_uom_code
1566              , NVL(msik.shelf_life_code, 1)
1567              , NVL(msik.shelf_life_days, 0)
1568              , NVL(msik.allowed_units_lookup_code, 2)
1569           INTO x_revision_qty_control_code
1570              , x_serial_number_control_code
1571              , x_restrict_subinventories_code
1572              , x_restrict_locators_code
1573              , x_location_control_code
1574              , x_primary_uom_code
1575              , x_shelf_life_code
1576              , x_shelf_life_days
1577              , x_allowed_units_lookup_code
1578           FROM mtl_system_items_vl msik /* Bug 5581528 */
1579          WHERE msik.organization_id = p_organization_id
1580            AND msik.inventory_item_id = p_inventory_item_id;
1581       END IF;
1582     END IF;
1583   EXCEPTION
1584     WHEN NO_DATA_FOUND THEN
1585       x_return_status  := fnd_api.g_ret_sts_error;
1586       fnd_message.set_name('INV', 'INV_NO_ITEM');
1587       fnd_msg_pub.ADD;
1588       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
1589     WHEN OTHERS THEN
1590       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1591       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
1592   END get_lot_item_details;
1593 
1594   /* Overridden method to retreiveDUOM attributes for Convergence */
1595 
1596   PROCEDURE get_lot_item_details(
1597     x_revision_qty_control_code    OUT    NOCOPY NUMBER
1598   , x_serial_number_control_code   OUT    NOCOPY NUMBER
1599   , x_restrict_subinventories_code OUT    NOCOPY NUMBER
1600   , x_restrict_locators_code       OUT    NOCOPY NUMBER
1601   , x_location_control_code        OUT    NOCOPY NUMBER
1602   , x_primary_uom_code             OUT    NOCOPY VARCHAR2
1603   , x_shelf_life_code              OUT    NOCOPY NUMBER
1604   , x_shelf_life_days              OUT    NOCOPY NUMBER
1605   , x_allowed_units_lookup_code    OUT    NOCOPY NUMBER
1606   , x_lot_status_enabled           OUT    NOCOPY VARCHAR2
1607   , x_default_lot_status_id        OUT    NOCOPY NUMBER
1608   , x_GRADE_CONTROL_FLAG OUT    NOCOPY VARCHAR2
1609   , x_DEFAULT_GRADE OUT    NOCOPY VARCHAR2
1610   , x_EXPIRATION_ACTION_INTERVAL OUT    NOCOPY NUMBER
1611   , x_EXPIRATION_ACTION_CODE OUT    NOCOPY VARCHAR2
1612   , x_HOLD_DAYS OUT    NOCOPY NUMBER
1613   , x_MATURITY_DAYS OUT    NOCOPY NUMBER
1614   , x_RETEST_INTERVAL OUT    NOCOPY NUMBER
1615   , x_COPY_LOT_ATTRIBUTE_FLAG OUT    NOCOPY VARCHAR2
1616   , x_CHILD_LOT_FLAG OUT    NOCOPY VARCHAR2
1617   , x_CHILD_LOT_VALIDATION_FLAG OUT    NOCOPY VARCHAR2
1618   , x_LOT_DIVISIBLE_FLAG OUT    NOCOPY VARCHAR2
1619   , x_SECONDARY_UOM_CODE OUT    NOCOPY VARCHAR2
1620   , x_SECONDARY_DEFAULT_IND OUT    NOCOPY VARCHAR2
1621   , x_TRACKING_QUANTITY_IND OUT    NOCOPY VARCHAR2
1622   , x_DUAL_UOM_DEVIATION_HIGH OUT    NOCOPY NUMBER
1623   , x_DUAL_UOM_DEVIATION_LOW OUT    NOCOPY NUMBER
1624   , x_return_status                OUT    NOCOPY VARCHAR2
1625   , x_msg_count                    OUT    NOCOPY NUMBER
1626   , x_msg_data                     OUT    NOCOPY VARCHAR2
1627   , p_organization_id              IN     NUMBER
1628   , p_lot_number                   IN     VARCHAR2
1629   , p_transaction_type_id          IN     VARCHAR2
1630   , p_inventory_item_id            IN     NUMBER
1631   ) IS
1632   BEGIN
1633     x_return_status  := fnd_api.g_ret_sts_success;
1634     x_msg_data       := '';
1635 
1636     IF p_transaction_type_id = inv_globals.g_type_inv_lot_split -- Lot Split (82)
1637                                                                 THEN
1638       SELECT NVL(msik.revision_qty_control_code, 1)
1639            , NVL(msik.serial_number_control_code, 1)
1640            , NVL(msik.restrict_subinventories_code, 2)
1641            , NVL(msik.restrict_locators_code, 2)
1642            , NVL(msik.location_control_code, 1)
1643            , msik.primary_uom_code
1644            , NVL(msik.shelf_life_code, 1)
1645            , NVL(msik.shelf_life_days, 0)
1646            , NVL(msik.allowed_units_lookup_code, 2)
1647            , NVL(msik.lot_status_enabled, 'N')
1648            , NVL(msik.default_lot_status_id, 0),
1649      --Bug No 3952081
1650      --Additional Fields for Process Convergence
1651            NVL(msik.GRADE_CONTROL_FLAG,'N'),
1652            NVL(msik.DEFAULT_GRADE,''),
1653            NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
1654            NVL(msik.EXPIRATION_ACTION_CODE,''),
1655            NVL(msik.HOLD_DAYS,0),
1656            NVL(msik.MATURITY_DAYS,0),
1657            NVL(msik.RETEST_INTERVAL,0),
1658            NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
1659            NVL(msik.CHILD_LOT_FLAG,'N'),
1660            NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
1661            NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
1662            NVL(msik.SECONDARY_UOM_CODE,''),
1663            NVL(msik.SECONDARY_DEFAULT_IND,''),
1664            NVL(msik.TRACKING_QUANTITY_IND,'P'),
1665            NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
1666            NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
1667         INTO x_revision_qty_control_code
1668            , x_serial_number_control_code
1669            , x_restrict_subinventories_code
1670            , x_restrict_locators_code
1671            , x_location_control_code
1672            , x_primary_uom_code
1673            , x_shelf_life_code
1674            , x_shelf_life_days
1675            , x_allowed_units_lookup_code
1676            , x_lot_status_enabled
1677            , x_default_lot_status_id
1678            , x_GRADE_CONTROL_FLAG
1679            , x_DEFAULT_GRADE
1680            , x_EXPIRATION_ACTION_INTERVAL
1681            , x_EXPIRATION_ACTION_CODE
1682            , x_HOLD_DAYS
1683            , x_MATURITY_DAYS
1684            , x_RETEST_INTERVAL
1685            , x_COPY_LOT_ATTRIBUTE_FLAG
1686            , x_CHILD_LOT_FLAG
1687            , x_CHILD_LOT_VALIDATION_FLAG
1688            , x_LOT_DIVISIBLE_FLAG
1689            , x_SECONDARY_UOM_CODE
1690            , x_SECONDARY_DEFAULT_IND
1691            , x_TRACKING_QUANTITY_IND
1692            , x_DUAL_UOM_DEVIATION_HIGH
1693            , x_DUAL_UOM_DEVIATION_LOW
1694         FROM mtl_system_items_vl msik /* Bug 5581528 */
1695        WHERE msik.lot_split_enabled = 'Y'
1696          AND msik.organization_id = p_organization_id
1697          AND msik.inventory_item_id = p_inventory_item_id;
1698     ELSE
1699       IF p_transaction_type_id = inv_globals.g_type_inv_lot_merge -- Lot Merge 83
1700                                                                   THEN
1701         SELECT NVL(msik.revision_qty_control_code, 1)
1702              , NVL(msik.serial_number_control_code, 1)
1703              , NVL(msik.restrict_subinventories_code, 2)
1704              , NVL(msik.restrict_locators_code, 2)
1705              , NVL(msik.location_control_code, 1)
1706              , msik.primary_uom_code
1707              , NVL(msik.shelf_life_code, 1)
1708              , NVL(msik.shelf_life_days, 0)
1709              , NVL(msik.allowed_units_lookup_code, 2)
1710              , NVL(msik.lot_status_enabled, 'N') -- nsinghi bug#5475282
1711              , NVL(msik.default_lot_status_id, 0), -- nsinghi bug#5475282
1712      --Bug No 3952081
1713      --Additional Fields for Process Convergence
1714            NVL(msik.GRADE_CONTROL_FLAG,'N'),
1715            NVL(msik.DEFAULT_GRADE,''),
1716            NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
1717            NVL(msik.EXPIRATION_ACTION_CODE,''),
1718            NVL(msik.HOLD_DAYS,0),
1719            NVL(msik.MATURITY_DAYS,0),
1720            NVL(msik.RETEST_INTERVAL,0),
1721            NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
1722            NVL(msik.CHILD_LOT_FLAG,'N'),
1723            NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
1724            NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
1725            NVL(msik.SECONDARY_UOM_CODE,''),
1726            NVL(msik.SECONDARY_DEFAULT_IND,''),
1727            NVL(msik.TRACKING_QUANTITY_IND,'P'),
1728            NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
1729            NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
1730           INTO x_revision_qty_control_code
1731              , x_serial_number_control_code
1732              , x_restrict_subinventories_code
1733              , x_restrict_locators_code
1734              , x_location_control_code
1735              , x_primary_uom_code
1736              , x_shelf_life_code
1737              , x_shelf_life_days
1738              , x_allowed_units_lookup_code
1739              , x_lot_status_enabled -- nsinghi bug#5475282
1740              , x_default_lot_status_id -- nsinghi bug#5475282
1741            , x_GRADE_CONTROL_FLAG
1742            , x_DEFAULT_GRADE
1743            , x_EXPIRATION_ACTION_INTERVAL
1744            , x_EXPIRATION_ACTION_CODE
1745            , x_HOLD_DAYS
1746            , x_MATURITY_DAYS
1747            , x_RETEST_INTERVAL
1748            , x_COPY_LOT_ATTRIBUTE_FLAG
1749            , x_CHILD_LOT_FLAG
1750            , x_CHILD_LOT_VALIDATION_FLAG
1751            , x_LOT_DIVISIBLE_FLAG
1752            , x_SECONDARY_UOM_CODE
1753            , x_SECONDARY_DEFAULT_IND
1754            , x_TRACKING_QUANTITY_IND
1755            , x_DUAL_UOM_DEVIATION_HIGH
1756            , x_DUAL_UOM_DEVIATION_LOW
1757           FROM mtl_system_items_vl msik /* Bug 5581528 */
1758          WHERE msik.lot_merge_enabled = 'Y'
1759            AND msik.organization_id = p_organization_id
1760            AND msik.inventory_item_id = p_inventory_item_id;
1761       ELSIF p_transaction_type_id = inv_globals.g_type_inv_lot_translate -- Lot Translate 84 Added bug4096035
1762                                                                     THEN
1763           SELECT NVL(msik.revision_qty_control_code, 1)
1764              , NVL(msik.serial_number_control_code, 1)
1765              , NVL(msik.restrict_subinventories_code, 2)
1766              , NVL(msik.restrict_locators_code, 2)
1767              , NVL(msik.location_control_code, 1)
1768              , msik.primary_uom_code
1769              , NVL(msik.shelf_life_code, 1)
1770              , NVL(msik.shelf_life_days, 0)
1771              , NVL(msik.allowed_units_lookup_code, 2)
1772              , NVL(msik.lot_status_enabled, 'N')
1773              , NVL(msik.default_lot_status_id, 0),
1774              --Additional Fields for Process Convergence
1775               NVL(msik.GRADE_CONTROL_FLAG,'N'),
1776               NVL(msik.DEFAULT_GRADE,''),
1777               NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
1778               NVL(msik.EXPIRATION_ACTION_CODE,''),
1779               NVL(msik.HOLD_DAYS,0),
1780               NVL(msik.MATURITY_DAYS,0),
1781               NVL(msik.RETEST_INTERVAL,0),
1782               NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
1783               NVL(msik.CHILD_LOT_FLAG,'N'),
1784               NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
1785               NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
1786               NVL(msik.SECONDARY_UOM_CODE,''),
1787               NVL(msik.SECONDARY_DEFAULT_IND,''),
1788               NVL(msik.TRACKING_QUANTITY_IND,'P'),
1789               NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
1790               NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
1791           INTO x_revision_qty_control_code
1792              , x_serial_number_control_code
1793              , x_restrict_subinventories_code
1794              , x_restrict_locators_code
1795              , x_location_control_code
1796              , x_primary_uom_code
1797              , x_shelf_life_code
1798              , x_shelf_life_days
1799              , x_allowed_units_lookup_code
1800              , x_lot_status_enabled
1801              , x_default_lot_status_id
1802              , x_GRADE_CONTROL_FLAG
1803              , x_DEFAULT_GRADE
1804              , x_EXPIRATION_ACTION_INTERVAL
1805              , x_EXPIRATION_ACTION_CODE
1806              , x_HOLD_DAYS
1807              , x_MATURITY_DAYS
1808              , x_RETEST_INTERVAL
1809              , x_COPY_LOT_ATTRIBUTE_FLAG
1810              , x_CHILD_LOT_FLAG
1811              , x_CHILD_LOT_VALIDATION_FLAG
1812              , x_LOT_DIVISIBLE_FLAG
1813              , x_SECONDARY_UOM_CODE
1814              , x_SECONDARY_DEFAULT_IND
1815              , x_TRACKING_QUANTITY_IND
1816              , x_DUAL_UOM_DEVIATION_HIGH
1817              , x_DUAL_UOM_DEVIATION_LOW
1818           FROM mtl_system_items_vl msik /* Bug 5581528 */
1819          WHERE msik.lot_translate_enabled = 'Y'
1820            AND msik.organization_id = p_organization_id
1821            AND msik.inventory_item_id = p_inventory_item_id; /*Added bug4096035*/
1822 
1823 
1824       ELSE
1825         SELECT NVL(msik.revision_qty_control_code, 1)
1826              , NVL(msik.serial_number_control_code, 1)
1827              , NVL(msik.restrict_subinventories_code, 2)
1828              , NVL(msik.restrict_locators_code, 2)
1829              , NVL(msik.location_control_code, 1)
1830              , msik.primary_uom_code
1831              , NVL(msik.shelf_life_code, 1)
1832              , NVL(msik.shelf_life_days, 0)
1833              , NVL(msik.allowed_units_lookup_code, 2),
1834      --Bug No 3952081
1835      --Additional Fields for Process Convergence
1836            NVL(msik.GRADE_CONTROL_FLAG,'N'),
1837            NVL(msik.DEFAULT_GRADE,''),
1838            NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
1839            NVL(msik.EXPIRATION_ACTION_CODE,''),
1840            NVL(msik.HOLD_DAYS,0),
1841            NVL(msik.MATURITY_DAYS,0),
1842            NVL(msik.RETEST_INTERVAL,0),
1843            NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
1844            NVL(msik.CHILD_LOT_FLAG,'N'),
1845            NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
1846            NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
1847            NVL(msik.SECONDARY_UOM_CODE,''),
1848            NVL(msik.SECONDARY_DEFAULT_IND,''),
1849            NVL(msik.TRACKING_QUANTITY_IND,'P'),
1850            NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
1851            NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
1852           INTO x_revision_qty_control_code
1853              , x_serial_number_control_code
1854              , x_restrict_subinventories_code
1855              , x_restrict_locators_code
1856              , x_location_control_code
1857              , x_primary_uom_code
1858              , x_shelf_life_code
1859              , x_shelf_life_days
1860              , x_allowed_units_lookup_code
1861            , x_GRADE_CONTROL_FLAG
1862            , x_DEFAULT_GRADE
1863            , x_EXPIRATION_ACTION_INTERVAL
1864            , x_EXPIRATION_ACTION_CODE
1865            , x_HOLD_DAYS
1866            , x_MATURITY_DAYS
1867            , x_RETEST_INTERVAL
1868            , x_COPY_LOT_ATTRIBUTE_FLAG
1869            , x_CHILD_LOT_FLAG
1870            , x_CHILD_LOT_VALIDATION_FLAG
1871            , x_LOT_DIVISIBLE_FLAG
1872            , x_SECONDARY_UOM_CODE
1873            , x_SECONDARY_DEFAULT_IND
1874            , x_TRACKING_QUANTITY_IND
1875            , x_DUAL_UOM_DEVIATION_HIGH
1876            , x_DUAL_UOM_DEVIATION_LOW
1877           FROM mtl_system_items_vl msik /* Bug 5581528 */
1878          WHERE msik.organization_id = p_organization_id
1879            AND msik.inventory_item_id = p_inventory_item_id;
1880       END IF;
1881     END IF;
1882   EXCEPTION
1883     WHEN NO_DATA_FOUND THEN
1884       x_return_status  := fnd_api.g_ret_sts_error;
1885       fnd_message.set_name('INV', 'INV_NO_ITEM');
1886       fnd_msg_pub.ADD;
1887       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
1888     WHEN OTHERS THEN
1889       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1890       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
1891 END get_lot_item_details;
1892 
1893 -- Bug 5498323 - Procedure accepts two more parameters - Subinventory code and Locator Id
1894 -- If Subinventory code IS not NULL, then the Item list returned is filtered by this Subinventory
1895 -- If Subinventory is not NULL and Locator Id is not NULL and Locator Id <> -1, then the Item list returned is filtered by this Subinventory and Locator Id
1896 
1897 PROCEDURE get_status_items_lov(x_items OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_concatenated_segments IN VARCHAR2, p_subinventory_code IN VARCHAR2, p_locator_id IN NUMBER) IS
1898   l_cross_ref varchar2(204);
1899   l_append varchar2(2):='';
1900   l_sql_stmt1     VARCHAR2(7500)
1901   := 'SELECT msik.concatenated_segments concatenated_segments'
1902       ||            ', msik.inventory_item_id'
1903       ||            ', msik.description'
1904       ||            ', NVL(msik.revision_qty_control_code, 1)'
1905       ||            ', NVL(msik.lot_status_enabled, ''N'')'
1906       ||            ', NVL(msik.serial_status_enabled, ''N'')'
1907       ||            ', NVL(msik.restrict_subinventories_code, 2)'
1908       ||            ', NVL(msik.restrict_locators_code, 2)'
1909       ||            ', NVL(msik.location_control_code, 1)'
1910       ||            ', msik.primary_uom_code'
1911       ||            ', NVL(msik.inspection_required_flag, 2)'
1912       ||            ', NVL(msik.shelf_life_code, 1)'
1913       ||            ', NVL(msik.shelf_life_days, 0)'
1914       ||            ', NVL(msik.allowed_units_lookup_code, 2)'
1915       ||            ', NVL(msik.effectivity_control, 1)'
1916       ||            ', 0 parentlpnid'
1917       ||            ', 0 quantity'
1918       ||            ', NVL(msik.default_serial_status_id, 0)'
1919       ||            ', NVL(msik.serial_status_enabled, ''N'')'
1920       ||            ', NVL(msik.default_lot_status_id, 0)'
1921       ||            ', NVL(msik.lot_status_enabled, ''N'')'
1922       ||            ', '''''
1923       ||            ', ''N'''
1924       ||            ', msik.inventory_item_flag'
1925       ||            ', 0'
1926       ||            ', wms_deploy.get_item_client_name(msik.inventory_item_id),'
1927 --Bug No 3952081
1928 --Additional Fields for Process Convergence
1929       ||            'NVL(msik.GRADE_CONTROL_FLAG,''N''),'
1930       ||            'NVL(msik.DEFAULT_GRADE,''''),'
1931       ||            'NVL(msik.EXPIRATION_ACTION_INTERVAL,0),'
1932       ||            'NVL(msik.EXPIRATION_ACTION_CODE,''''),'
1933       ||            'NVL(msik.HOLD_DAYS,0),'
1934       ||            'NVL(msik.MATURITY_DAYS,0),'
1935       ||            'NVL(msik.RETEST_INTERVAL,0),'
1936       ||            'NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,''N''),'
1937       ||            'NVL(msik.CHILD_LOT_FLAG,''N''),'
1938       ||            'NVL(msik.CHILD_LOT_VALIDATION_FLAG,''N''),'
1939       ||            'NVL(msik.LOT_DIVISIBLE_FLAG,''Y''),'
1940       ||            'NVL(msik.SECONDARY_UOM_CODE,''''),'
1941       ||            'NVL(msik.SECONDARY_DEFAULT_IND,''''),'
1942       ||            'NVL(msik.TRACKING_QUANTITY_IND,''P''),'
1943       ||            'NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),'
1944       ||            'NVL(msik.DUAL_UOM_DEVIATION_LOW,0)';
1945 
1946 l_sql_stmt_xref     VARCHAR2(7500)
1947       :=       'SELECT msik.concatenated_segments concatenated_segments'
1948       ||            ', msik.inventory_item_id'
1949       ||            ', msik.description'
1950       ||            ', NVL(msik.revision_qty_control_code, 1)'
1951       ||            ', NVL(msik.lot_status_enabled, ''N'')'
1952       ||            ', NVL(msik.serial_status_enabled, ''N'')'
1953       ||            ', NVL(msik.restrict_subinventories_code, 2)'
1954       ||            ', NVL(msik.restrict_locators_code, 2)'
1955       ||            ', NVL(msik.location_control_code, 1)'
1956       ||            ', msik.primary_uom_code'
1957       ||            ', NVL(msik.inspection_required_flag, 2)'
1958       ||            ', NVL(msik.shelf_life_code, 1)'
1959       ||            ', NVL(msik.shelf_life_days, 0)'
1960       ||            ', NVL(msik.allowed_units_lookup_code, 2)'
1961       ||            ', NVL(msik.effectivity_control, 1)'
1962       ||            ', 0 parentlpnid'
1963       ||            ', 0 quantity'
1964       ||            ', NVL(msik.default_serial_status_id, 0)'
1965       ||            ', NVL(msik.serial_status_enabled, ''N'')'
1966       ||            ', NVL(msik.default_lot_status_id, 0)'
1967       ||            ', NVL(msik.lot_status_enabled, ''N'')'
1968       ||            ', mcr.cross_reference'
1969       ||            ', ''N'''
1970       ||            ', msik.inventory_item_flag'
1971       ||            ', 0'
1972       ||            ', wms_deploy.get_item_client_name(msik.inventory_item_id),'
1973      --Bug No 3952081
1974      --Additional Fields for Process Convergence
1975       ||            'NVL(msik.GRADE_CONTROL_FLAG,''N''),'
1976       ||            'NVL(msik.DEFAULT_GRADE,''''),'
1977       ||            'NVL(msik.EXPIRATION_ACTION_INTERVAL,0),'
1978       ||            'NVL(msik.EXPIRATION_ACTION_CODE,''''),'
1979       ||            'NVL(msik.HOLD_DAYS,0),'
1980       ||            'NVL(msik.MATURITY_DAYS,0),'
1981       ||            'NVL(msik.RETEST_INTERVAL,0),'
1982       ||            'NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,''N''),'
1983       ||            'NVL(msik.CHILD_LOT_FLAG,''N''),'
1984       ||            'NVL(msik.CHILD_LOT_VALIDATION_FLAG,''N''),'
1985       ||            'NVL(msik.LOT_DIVISIBLE_FLAG,''Y''),'
1986       ||            'NVL(msik.SECONDARY_UOM_CODE,''''),'
1987       ||            'NVL(msik.SECONDARY_DEFAULT_IND,''''),'
1988       ||            'NVL(msik.TRACKING_QUANTITY_IND,''P''),'
1989       ||            'NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),'
1990       ||            'NVL(msik.DUAL_UOM_DEVIATION_LOW,0)';
1991   BEGIN
1992 
1993    l_cross_ref := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
1994 
1995    l_append:=wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
1996 
1997    l_sql_stmt1 := l_sql_stmt1 || ' FROM mtl_system_items_vl msik, mtl_onhand_quantities_detail moqd'
1998                               || ' WHERE msik.concatenated_segments LIKE (''' || p_concatenated_segments ||l_append|| ''')'
1999          		      || ' AND msik.organization_id = ' || p_organization_id
2000 			      || ' AND (msik.lot_status_enabled = ''Y'' OR msik.serial_status_enabled = ''Y'')';
2001 
2002    l_sql_stmt_xref := l_sql_stmt_xref || ' FROM mtl_system_items_vl msik,'
2003 				|| 'mtl_cross_references mcr, mtl_onhand_quantities_detail moqd'
2004 				|| ' WHERE msik.organization_id = ' || p_organization_id
2005 				|| ' AND (msik.lot_status_enabled = ''Y'' OR msik.serial_status_enabled = ''Y'' )'
2006 				|| ' AND msik.inventory_item_id   = mcr.inventory_item_id'
2007 				|| ' AND mcr.cross_reference_type = ''' || g_gtin_cross_ref_type || ''''
2008 				|| ' AND mcr.cross_reference LIKE ''' || l_cross_ref || ''''
2009 				|| ' AND (mcr.organization_id = msik.organization_id OR mcr.org_independent_flag = ''Y'')';
2010 
2011 
2012    IF p_subinventory_code IS NOT NULL THEN
2013         l_sql_stmt1 := l_sql_stmt1 || ' AND moqd.organization_id = msik.organization_id'
2014 				   || ' AND moqd.inventory_item_id = msik.inventory_item_id'
2015 				   || ' AND moqd.subinventory_code = ''' || p_subinventory_code || '''';
2016 
2017         l_sql_stmt_xref := l_sql_stmt_xref || ' AND moqd.organization_id = msik.organization_id'
2018 				   || ' AND moqd.inventory_item_id = msik.inventory_item_id'
2019 				   || ' AND moqd.subinventory_code = ''' || p_subinventory_code || '''';
2020 
2021 	IF p_locator_id IS NOT NULL AND p_locator_id <> -1 THEN
2022 
2023 		l_sql_stmt1 := l_sql_stmt1 || ' AND moqd.locator_id = ' || p_locator_id;
2024 
2025 		l_sql_stmt_xref := l_sql_stmt_xref || ' AND moqd.locator_id = ' || p_locator_id;
2026 	END IF;
2027    END IF;
2028 
2029    l_sql_stmt1 := l_sql_stmt1 || ' UNION ' || l_sql_stmt_xref || ' ORDER BY concatenated_segments';
2030 
2031    --dbms_output.put_line(l_sql_stmt1);
2032    OPEN x_items FOR l_sql_stmt1;
2033 
2034 END get_status_items_lov;
2035 
2036   PROCEDURE get_ship_items_lov(x_items OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_delivery_id IN NUMBER, p_concatenated_segments IN VARCHAR2) IS
2037   l_cross_ref varchar2(204);
2038   l_append varchar2(2):='';
2039   BEGIN
2040 
2041    l_cross_ref := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
2042 
2043    l_append:=wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
2044 
2045     OPEN x_items FOR
2046       SELECT DISTINCT msik.concatenated_segments concatenated_segments
2047                     , msik.inventory_item_id
2048                     , msik.description
2049                     , NVL(msik.revision_qty_control_code, 1)
2050                     , NVL(msik.lot_control_code, 1)
2051                     , NVL(msik.serial_number_control_code, 1)
2052                     , NVL(msik.restrict_subinventories_code, 2)
2053                     , NVL(msik.restrict_locators_code, 2)
2054                     , NVL(msik.location_control_code, 1)
2055                     , msik.primary_uom_code
2056                     , NVL(msik.inspection_required_flag, 2)
2057                     , NVL(msik.shelf_life_code, 1)
2058                     , NVL(msik.shelf_life_days, 0)
2059                     , NVL(msik.allowed_units_lookup_code, 2)
2060                     , NVL(msik.effectivity_control, 1)
2061                     , 0 parentlpnid
2062                     , 0 quantity
2063                     , NVL(msik.default_serial_status_id, 0)
2064                     , NVL(msik.serial_status_enabled, 'N')
2065                     , NVL(msik.default_lot_status_id, 0)
2066                     , NVL(msik.lot_status_enabled, 'N')
2067                     , ''
2068                     , 'N'
2069                     , msik.inventory_item_flag
2070                     , 0
2071 			  , wms_deploy.get_item_client_name(msik.inventory_item_id),
2072      --Bug No 3952081
2073      --Additional Fields for Process Convergence
2074                     NVL(msik.GRADE_CONTROL_FLAG,'N'),
2075                     NVL(msik.DEFAULT_GRADE,''),
2076                     NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
2077                     NVL(msik.EXPIRATION_ACTION_CODE,''),
2078                     NVL(msik.HOLD_DAYS,0),
2079                     NVL(msik.MATURITY_DAYS,0),
2080                     NVL(msik.RETEST_INTERVAL,0),
2081                     NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
2082                     NVL(msik.CHILD_LOT_FLAG,'N'),
2083                     NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
2084                     NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
2085                     NVL(msik.SECONDARY_UOM_CODE,''),
2086                     NVL(msik.SECONDARY_DEFAULT_IND,''),
2087                     NVL(msik.TRACKING_QUANTITY_IND,'P'),
2088                     NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
2089                     NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
2090       FROM mtl_system_items_vl msik, wsh_delivery_details dd, wsh_delivery_assignments da, wsh_new_deliveries nd /* Bug 5581528 */
2091       WHERE msik.concatenated_segments LIKE (p_concatenated_segments||l_append)
2092       AND msik.organization_id = p_organization_id
2093       AND msik.inventory_item_id = dd.inventory_item_id
2094       AND nd.delivery_id = p_delivery_id
2095       AND nd.delivery_id = da.delivery_id
2096       AND da.delivery_detail_id = dd.delivery_detail_id
2097       AND (dd.inv_interfaced_flag = 'N' OR dd.inv_interfaced_flag IS NULL)
2098       AND dd.released_status = 'Y'
2099       AND nd.status_code NOT IN ('CO', 'CL', 'IT')
2100 
2101 	--Changes for GTIN
2102 	UNION
2103 
2104 	      SELECT DISTINCT msik.concatenated_segments concatenated_segments
2105                     , msik.inventory_item_id
2106                     , msik.description
2107                     , NVL(msik.revision_qty_control_code, 1)
2108                     , NVL(msik.lot_control_code, 1)
2109                     , NVL(msik.serial_number_control_code, 1)
2110                     , NVL(msik.restrict_subinventories_code, 2)
2111                     , NVL(msik.restrict_locators_code, 2)
2112                     , NVL(msik.location_control_code, 1)
2113                     , msik.primary_uom_code
2114                     , NVL(msik.inspection_required_flag, 2)
2115                     , NVL(msik.shelf_life_code, 1)
2116                     , NVL(msik.shelf_life_days, 0)
2117                     , NVL(msik.allowed_units_lookup_code, 2)
2118                     , NVL(msik.effectivity_control, 1)
2119                     , 0 parentlpnid
2120                     , 0 quantity
2121                     , NVL(msik.default_serial_status_id, 0)
2122                     , NVL(msik.serial_status_enabled, 'N')
2123                     , NVL(msik.default_lot_status_id, 0)
2124                     , NVL(msik.lot_status_enabled, 'N')
2125                     , mcr.cross_reference
2126                     , 'N'
2127                     , msik.inventory_item_flag
2128                     , 0
2129 			  , wms_deploy.get_item_client_name(msik.inventory_item_id),
2130      --Bug No 3952081
2131      --Additional Fields for Process Convergence
2132                     NVL(msik.GRADE_CONTROL_FLAG,'N'),
2133                     NVL(msik.DEFAULT_GRADE,''),
2134                     NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
2135                     NVL(msik.EXPIRATION_ACTION_CODE,''),
2136                     NVL(msik.HOLD_DAYS,0),
2137                     NVL(msik.MATURITY_DAYS,0),
2138                     NVL(msik.RETEST_INTERVAL,0),
2139                     NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
2140                     NVL(msik.CHILD_LOT_FLAG,'N'),
2141                     NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
2142                     NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
2143                     NVL(msik.SECONDARY_UOM_CODE,''),
2144                     NVL(msik.SECONDARY_DEFAULT_IND,''),
2145                     NVL(msik.TRACKING_QUANTITY_IND,'P'),
2146                     NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
2147                     NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
2148 	FROM mtl_system_items_vl msik, /* Bug 5581528 */
2149 	wsh_delivery_details dd,
2150 	wsh_delivery_assignments da,
2151 	wsh_new_deliveries nd,
2152 	mtl_cross_references mcr
2153 	WHERE msik.organization_id = p_organization_id
2154 	AND msik.inventory_item_id = dd.inventory_item_id
2155 	AND nd.delivery_id = p_delivery_id
2156 	AND nd.delivery_id = da.delivery_id
2157 	AND da.delivery_detail_id = dd.delivery_detail_id
2158 	AND (dd.inv_interfaced_flag = 'N' OR dd.inv_interfaced_flag IS NULL)
2159 	  AND dd.released_status = 'Y'
2160 	  AND nd.status_code NOT IN ('CO', 'CL', 'IT')
2161 	  AND msik.inventory_item_id   = mcr.inventory_item_id
2162 	  AND mcr.cross_reference_type = g_gtin_cross_ref_type
2163 	  AND mcr.cross_reference      LIKE l_cross_ref
2164 	  AND (mcr.organization_id     = msik.organization_id
2165 	       OR
2166 	       mcr.org_independent_flag = 'Y')
2167 	  ORDER BY concatenated_segments;
2168   END get_ship_items_lov;
2169 
2170   --      Name: GET_PHYINV_ITEM_LOV
2171   --
2172   --      Input parameters:
2173   --
2174   --        p_concatenated_segments - User inputted value
2175   --        p_organization_id     -  Organization ID
2176   --        p_subinventory_code   -  Subinventory
2177   --        p_locator_id          -  Locator ID
2178   --        p_dynamic_entry_flag  -  Indicates if dynamic entries are allowed
2179   --
2180   --      Output parameters:
2181   --       x_items    -  returns LOV rows as reference cursor
2182   --
2183   --      Functions: This procedure returns valid items that are associated
2184   --                 with the given physical inventory
2185   --
2186 
2187   PROCEDURE get_phyinv_item_lov(
2188     x_items                 OUT    NOCOPY t_genref
2189   , p_concatenated_segments IN     VARCHAR2
2190   , p_organization_id       IN     NUMBER
2191   , p_subinventory_code     IN     VARCHAR2
2192   , p_locator_id            IN     NUMBER
2193   , p_dynamic_entry_flag    IN     NUMBER
2194   , p_physical_inventory_id IN     NUMBER
2195   , p_parent_lpn_id         IN     NUMBER
2196   ) IS
2197   l_cross_ref varchar2(204);
2198   l_append varchar2(2):='';
2199   BEGIN
2200 
2201    l_cross_ref := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
2202 
2203    l_append:=wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
2204 
2205     IF (p_dynamic_entry_flag = 1) THEN -- Dynamic entries are allowed
2206       OPEN x_items FOR
2207         SELECT   concatenated_segments
2208                , inventory_item_id
2209                , description
2210                , NVL(revision_qty_control_code, 1)
2211                , NVL(lot_control_code, 1)
2212                , NVL(serial_number_control_code, 1)
2213                , NVL(restrict_subinventories_code, 2)
2214                , NVL(restrict_locators_code, 2)
2215                , NVL(location_control_code, 1)
2216                , primary_uom_code
2217                , NVL(inspection_required_flag, 2)
2218                , NVL(shelf_life_code, 1)
2219                , NVL(shelf_life_days, 0)
2220                , NVL(allowed_units_lookup_code, 2)
2221                , NVL(effectivity_control, 1)
2222                , 0 parentlpnid
2223                , 0 quantity
2224                , NVL(default_serial_status_id, 0)
2225                , NVL(serial_status_enabled, 'N')
2226                , NVL(default_lot_status_id, 0)
2227                , NVL(lot_status_enabled, 'N')
2228                , ''
2229                , 'N'
2230                , inventory_item_flag
2231                , 0
2232 		   , wms_deploy.get_item_client_name(inventory_item_id),
2233      --Bug No 3952081
2234      --Additional Fields for Process Convergence
2235                NVL(GRADE_CONTROL_FLAG,'N'),
2236                NVL(DEFAULT_GRADE,''),
2237                NVL(EXPIRATION_ACTION_INTERVAL,0),
2238                NVL(EXPIRATION_ACTION_CODE,''),
2239                NVL(HOLD_DAYS,0),
2240                NVL(MATURITY_DAYS,0),
2241                NVL(RETEST_INTERVAL,0),
2242                NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
2243                NVL(CHILD_LOT_FLAG,'N'),
2244                NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
2245                NVL(LOT_DIVISIBLE_FLAG,'Y'),
2246                NVL(SECONDARY_UOM_CODE,''),
2247                NVL(SECONDARY_DEFAULT_IND,''),
2248                NVL(TRACKING_QUANTITY_IND,'P'),
2249                NVL(DUAL_UOM_DEVIATION_HIGH,0),
2250                NVL(DUAL_UOM_DEVIATION_LOW,0)
2251             --FROM mtl_system_items_vl /* Bug 5581528 */
2252             from mtl_system_items_vl msik /*bug7626228*/
2253            WHERE organization_id = p_organization_id
2254 	AND concatenated_segments LIKE (p_concatenated_segments||l_append)
2255    /*AND INV_MATERIAL_STATUS_GRP.loc_valid_for_item(p_locator_id,
2256                                                   p_organization_id,
2257                                                   inventory_item_id,
2258                                                   p_subinventory_code)='Y' --Bug# 2879164
2259     AND INV_MATERIAL_STATUS_GRP.sub_valid_for_item (p_organization_id,
2260                                                     inventory_item_id,
2261                                                     p_subinventory_code)='Y' -- Bug 5500255*/
2262     AND INV_MATERIAL_STATUS_GRP.sub_loc_valid_for_item(p_organization_id,msik.inventory_item_id,p_subinventory_code,p_locator_id,
2263            msik.restrict_subinventories_code,msik.restrict_locators_code)='Y' -- bug7626228
2264     AND msik.stock_enabled_flag = 'Y'                             -- Added for Bug 6310345
2265 
2266 --Changes for GTIN
2267 	UNION
2268 
2269 	SELECT   concatenated_segments
2270                , msik.inventory_item_id
2271                , msik.description
2272                , NVL(revision_qty_control_code, 1)
2273                , NVL(lot_control_code, 1)
2274                , NVL(serial_number_control_code, 1)
2275                , NVL(restrict_subinventories_code, 2)
2276                , NVL(restrict_locators_code, 2)
2277                , NVL(location_control_code, 1)
2278                , primary_uom_code
2279                , NVL(inspection_required_flag, 2)
2280                , NVL(shelf_life_code, 1)
2281                , NVL(shelf_life_days, 0)
2282                , NVL(allowed_units_lookup_code, 2)
2283                , NVL(effectivity_control, 1)
2284                , 0 parentlpnid
2285                , 0 quantity
2286                , NVL(default_serial_status_id, 0)
2287                , NVL(serial_status_enabled, 'N')
2288                , NVL(default_lot_status_id, 0)
2289                , NVL(lot_status_enabled, 'N')
2290                , mcr.cross_reference
2291                , 'N'
2292                , inventory_item_flag
2293                , 0
2294 		   , wms_deploy.get_item_client_name(msik.inventory_item_id),
2295      --Bug No 3952081
2296      --Additional Fields for Process Convergence
2297                NVL(GRADE_CONTROL_FLAG,'N'),
2298                NVL(DEFAULT_GRADE,''),
2299                NVL(EXPIRATION_ACTION_INTERVAL,0),
2300                NVL(EXPIRATION_ACTION_CODE,''),
2301                NVL(HOLD_DAYS,0),
2302                NVL(MATURITY_DAYS,0),
2303                NVL(RETEST_INTERVAL,0),
2304                NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
2305                NVL(CHILD_LOT_FLAG,'N'),
2306                NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
2307                NVL(LOT_DIVISIBLE_FLAG,'Y'),
2308                NVL(SECONDARY_UOM_CODE,''),
2309                NVL(SECONDARY_DEFAULT_IND,''),
2310                NVL(TRACKING_QUANTITY_IND,'P'),
2311                NVL(DUAL_UOM_DEVIATION_HIGH,0),
2312                NVL(DUAL_UOM_DEVIATION_LOW,0)
2313 	FROM mtl_system_items_vl msik, mtl_cross_references mcr /* Bug 5581528 */
2314 	WHERE msik.organization_id = p_organization_id
2315 	AND msik.inventory_item_id   = mcr.inventory_item_id
2316 	AND mcr.cross_reference_type = g_gtin_cross_ref_type
2317 	AND mcr.cross_reference      LIKE l_cross_ref
2318 	AND (mcr.organization_id     = msik.organization_id
2319 	     OR
2320 	     mcr.org_independent_flag = 'Y')
2321        AND msik.stock_enabled_flag = 'Y'                             -- Added for Bug 6310345
2322         ORDER BY concatenated_segments;
2323 
2324     ELSE -- Dynamic entries are not allowed
2325       OPEN x_items FOR
2326         SELECT UNIQUE msik.concatenated_segments concatenated_segments
2327                     , msik.inventory_item_id
2328                     , msik.description
2329                     , NVL(msik.revision_qty_control_code, 1)
2330                     , NVL(msik.lot_control_code, 1)
2331                     , NVL(msik.serial_number_control_code, 1)
2332                     , NVL(msik.restrict_subinventories_code, 2)
2333                     , NVL(msik.restrict_locators_code, 2)
2334                     , NVL(msik.location_control_code, 1)
2335                     , msik.primary_uom_code
2336                     , NVL(msik.inspection_required_flag, 2)
2337                     , NVL(msik.shelf_life_code, 1)
2338                     , NVL(msik.shelf_life_days, 0)
2339                     , NVL(msik.allowed_units_lookup_code, 2)
2340                     , NVL(msik.effectivity_control, 1)
2341                     , 0 parentlpnid
2342                     , 0 quantity
2343                     , NVL(msik.default_serial_status_id, 0)
2344                     , NVL(msik.serial_status_enabled, 'N')
2345                     , NVL(msik.default_lot_status_id, 0)
2346                     , NVL(msik.lot_status_enabled, 'N')
2347                     , ''
2348                     , 'N'
2349                     , msik.inventory_item_flag
2350                     , 0
2351 		        , wms_deploy.get_item_client_name(msik.inventory_item_id),
2352      --Bug No 3952081
2353      --Additional Fields for Process Convergence
2354                     NVL(msik.GRADE_CONTROL_FLAG,'N'),
2355                     NVL(msik.DEFAULT_GRADE,''),
2356                     NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
2357                     NVL(msik.EXPIRATION_ACTION_CODE,''),
2358                     NVL(msik.HOLD_DAYS,0),
2359                     NVL(msik.MATURITY_DAYS,0),
2360                     NVL(msik.RETEST_INTERVAL,0),
2361                     NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
2362                     NVL(msik.CHILD_LOT_FLAG,'N'),
2363                     NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
2364                     NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
2365                     NVL(msik.SECONDARY_UOM_CODE,''),
2366                     NVL(msik.SECONDARY_DEFAULT_IND,''),
2367                     NVL(msik.TRACKING_QUANTITY_IND,'P'),
2368                     NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
2369                     NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
2370                  FROM mtl_system_items_vl msik, mtl_physical_inventory_tags mpit /* Bug 5581528 */
2371                 WHERE msik.organization_id = p_organization_id
2372                   AND msik.concatenated_segments LIKE (p_concatenated_segments||l_append)
2373                   AND msik.inventory_item_id = mpit.inventory_item_id
2374                   AND mpit.physical_inventory_id = p_physical_inventory_id
2375                   AND mpit.organization_id = p_organization_id
2376                   AND mpit.subinventory = p_subinventory_code
2377                   AND NVL(mpit.locator_id, -99999) = NVL(p_locator_id, -99999)
2378                   AND NVL(mpit.parent_lpn_id, -99999) = NVL(p_parent_lpn_id, -99999)
2379                   AND NVL(mpit.void_flag, 2) = 2
2380                   AND (mpit.adjustment_id IN (SELECT adjustment_id
2381                                                FROM mtl_physical_adjustments
2382                                               WHERE physical_inventory_id = p_physical_inventory_id
2383                                                 AND organization_id = p_organization_id
2384                                                 AND approval_status IS NULL) OR mpit.adjustment_id IS NULL)--Bug#9772069
2385                   /*AND INV_MATERIAL_STATUS_GRP.loc_valid_for_item(p_locator_id,
2386                                                                  p_organization_id,
2387                                                                  msik.inventory_item_id,
2388                                                                  p_subinventory_code)='Y' --Bug# 2879164
2389 						AND INV_MATERIAL_STATUS_GRP.sub_valid_for_item(p_organization_id,
2390                                                                  msik.inventory_item_id,
2391                                                                  p_subinventory_code)='Y' -- Bug 5500255*/
2392                   AND INV_MATERIAL_STATUS_GRP.sub_loc_valid_for_item(p_organization_id,msik.inventory_item_id,p_subinventory_code,p_locator_id,
2393                                                                      msik.restrict_subinventories_code,msik.restrict_locators_code)='Y' -- bug7626228
2394                  AND msik.stock_enabled_flag = 'Y'                             -- Added for Bug 6310345
2395 
2396                   --Changes for GTIN
2397 		  UNION
2398 		        SELECT UNIQUE msik.concatenated_segments concatenated_segments
2399                     , msik.inventory_item_id
2400                     , msik.description
2401                     , NVL(msik.revision_qty_control_code, 1)
2402                     , NVL(msik.lot_control_code, 1)
2403                     , NVL(msik.serial_number_control_code, 1)
2404                     , NVL(msik.restrict_subinventories_code, 2)
2405                     , NVL(msik.restrict_locators_code, 2)
2406                     , NVL(msik.location_control_code, 1)
2407                     , msik.primary_uom_code
2408                     , NVL(msik.inspection_required_flag, 2)
2409                     , NVL(msik.shelf_life_code, 1)
2410                     , NVL(msik.shelf_life_days, 0)
2411                     , NVL(msik.allowed_units_lookup_code, 2)
2412                     , NVL(msik.effectivity_control, 1)
2413                     , 0 parentlpnid
2414                     , 0 quantity
2415                     , NVL(msik.default_serial_status_id, 0)
2416                     , NVL(msik.serial_status_enabled, 'N')
2417                     , NVL(msik.default_lot_status_id, 0)
2418                     , NVL(msik.lot_status_enabled, 'N')
2419                     , mcr.cross_reference
2420                     , 'N'
2421                     , msik.inventory_item_flag
2422                     , 0
2423    		        , wms_deploy.get_item_client_name(msik.inventory_item_id),
2424      --Bug No 3952081
2425      --Additional Fields for Process Convergence
2426                     NVL(msik.GRADE_CONTROL_FLAG,'N'),
2427                     NVL(msik.DEFAULT_GRADE,''),
2428                     NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
2429                     NVL(msik.EXPIRATION_ACTION_CODE,''),
2430                     NVL(msik.HOLD_DAYS,0),
2431                     NVL(msik.MATURITY_DAYS,0),
2432                     NVL(msik.RETEST_INTERVAL,0),
2433                     NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
2434                     NVL(msik.CHILD_LOT_FLAG,'N'),
2435                     NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
2436                     NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
2437                     NVL(msik.SECONDARY_UOM_CODE,''),
2438                     NVL(msik.SECONDARY_DEFAULT_IND,''),
2439                     NVL(msik.TRACKING_QUANTITY_IND,'P'),
2440                     NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
2441                     NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
2442                  FROM mtl_system_items_vl msik, mtl_physical_inventory_tags mpit, mtl_cross_references mcr /* Bug 5581528 */
2443                 WHERE msik.organization_id = p_organization_id
2444                   AND msik.inventory_item_id = mpit.inventory_item_id
2445                   AND mpit.physical_inventory_id = p_physical_inventory_id
2446                   AND mpit.organization_id = p_organization_id
2447                   AND mpit.subinventory = p_subinventory_code
2448                   AND NVL(mpit.locator_id, -99999) = NVL(p_locator_id, -99999)
2449                   AND NVL(mpit.parent_lpn_id, -99999) = NVL(p_parent_lpn_id, -99999)
2450                   AND NVL(mpit.void_flag, 2) = 2
2451                   AND (mpit.adjustment_id IN (SELECT adjustment_id
2452                                                FROM mtl_physical_adjustments
2453                                               WHERE physical_inventory_id = p_physical_inventory_id
2454                                                 AND organization_id = p_organization_id
2455                                                 AND approval_status IS NULL) OR mpit.adjustment_id IS NULL)--Bug#9772069
2456 		AND msik.inventory_item_id   = mcr.inventory_item_id
2457       AND mcr.cross_reference_type = g_gtin_cross_ref_type
2458       AND mcr.cross_reference      LIKE l_cross_ref
2459       AND (mcr.organization_id     = msik.organization_id
2460 	   OR
2461 	   mcr.org_independent_flag = 'Y')
2462       AND msik.stock_enabled_flag = 'Y'                             -- Added for Bug 6310345
2463 	ORDER BY concatenated_segments;
2464     END IF;
2465   END get_phyinv_item_lov;
2466 
2467   --      Name: GET_PHYINV_REV_LOV
2468   --
2469   --      Input parameters:
2470   --       p_organization_id    - restricts LOV SQL to current org
2471   --       p_inventory_item_id  - restrict LOV for a given item
2472   --       p_revision           - restricts LOV SQL to the user input text
2473   --                                e.g.  A101%
2474   --       p_dynamic_entry_flag - Indicates if dynamic entries are allowed
2475   --       p_physical_inventory_id - restricts LOV SQL to current physical inventory
2476   --
2477   --      Output parameters:
2478   --       x_revs      returns LOV rows as reference cursor
2479   --
2480   --      Functions: This procedure returns LOV rows for a given org, item and
2481   --                 user input text for a given physical inventory
2482   --
2483 
2484   PROCEDURE get_phyinv_rev_lov(x_revs OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_inventory_item_id IN NUMBER, p_revision IN VARCHAR2, p_dynamic_entry_flag IN NUMBER, p_physical_inventory_id IN NUMBER, p_parent_lpn_id IN NUMBER) IS
2485   BEGIN
2486     IF (p_dynamic_entry_flag = 1) THEN -- Dynamic entries are allowed
2487       OPEN x_revs FOR
2488         SELECT   revision
2489                , effectivity_date
2490                , NVL(description, '')
2491             FROM mtl_item_revisions
2492            WHERE organization_id = p_organization_id
2493              AND inventory_item_id = p_inventory_item_id
2494              AND revision LIKE (p_revision)
2495         ORDER BY UPPER(revision);
2496     ELSE -- Dynamic entries are not allowed
2497       OPEN x_revs FOR
2498         SELECT UNIQUE mir.revision
2499                     , mir.effectivity_date
2500                     , NVL(mir.description, '')
2501                  FROM mtl_item_revisions mir, mtl_physical_inventory_tags mpit
2502                 WHERE mir.organization_id = p_organization_id
2503                   AND mir.inventory_item_id = p_inventory_item_id
2504                   AND mir.revision LIKE (p_revision)
2505                   AND mir.inventory_item_id = mpit.inventory_item_id
2506                   AND mpit.physical_inventory_id = p_physical_inventory_id
2507                   AND NVL(mpit.parent_lpn_id, -99999) = NVL(p_parent_lpn_id, -99999)
2508                   AND NVL(mpit.void_flag, 2) = 2
2509                   AND mpit.adjustment_id IN (SELECT adjustment_id
2510                                                FROM mtl_physical_adjustments
2511                                               WHERE physical_inventory_id = p_physical_inventory_id
2512                                                 AND organization_id = p_organization_id
2513                                                 AND approval_status IS NULL)
2514              ORDER BY UPPER(mir.revision);
2515     END IF;
2516   END get_phyinv_rev_lov;
2517 
2518   --      Name: GET_PHYINV_UOM_LOV
2519   --
2520   --      Input parameters:
2521   --       p_organization_id       - Restricts LOV SQL to current org
2522   --       p_inventory_item_id     - Restricts LOV for a given item
2523   --       p_uom_code              - Restricts LOV SQL to the user input text
2524   --                                   e.g.  Ea%
2525   --       p_dynamic_entry_flag    - Indicates if dynamic entries are allowed
2526   --       p_physical_inventory_id - Restricts LOV SQL to current physical inventory
2527   --
2528   --      Output parameters:
2529   --       x_uoms      returns LOV rows as reference cursor
2530   --
2531   --      Functions: This procedure returns LOV rows for a given org, item and
2532   --                 user inputted text for valid UOM's for a particular
2533   --                 physical inventory
2534   --
2535 
2536   PROCEDURE get_phyinv_uom_lov(x_uoms OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_inventory_item_id IN NUMBER, p_uom_code IN VARCHAR2) IS
2537      l_code VARCHAR2(20):=p_UOM_Code;
2538   BEGIN
2539     IF (INSTR(l_code,'(') > 0) THEN
2540       l_code := SUBSTR(p_UOM_Code,1,INSTR(p_UOM_Code,'(')-1);
2541     END IF;
2542 
2543     OPEN x_uoms FOR
2544       SELECT (inv_ui_item_lovs.get_conversion_rate(uom_code,
2545 				   p_Organization_Id,
2546 				   p_Inventory_Item_Id)) uom_code_comp
2547              , unit_of_measure
2548              , description
2549              , uom_class
2550           FROM mtl_item_uoms_view
2551          WHERE organization_id = p_organization_id
2552            AND inventory_item_id = p_inventory_item_id
2553            AND uom_code LIKE (l_code)
2554       ORDER BY inv_ui_item_lovs.conversion_order(inv_ui_item_lovs.get_conversion_rate(uom_code,
2555 				   p_Organization_Id,
2556 				   p_Inventory_Item_Id)) asc, Upper(uom_code);
2557   END get_phyinv_uom_lov;
2558 
2559   --      Name: GET_CONTAINER_ITEM_LOV
2560   --
2561   --      Input parameters:
2562   --
2563   --        p_concatenated_segments - Restricts output to user inputted value
2564   --        p_organization_id     -  Organization ID
2565   --
2566   --      Output parameters:
2567   --       x_items    -  returns LOV rows as reference cursor
2568   --
2569   --      Functions: This procedure returns valid container items
2570   --                 within the given org
2571   --
2572 
2573   PROCEDURE get_container_item_lov(x_items OUT NOCOPY t_genref, p_concatenated_segments IN VARCHAR2, p_organization_id IN NUMBER) IS
2574   l_cross_ref varchar2(204);
2575   l_append varchar2(2):='';
2576   BEGIN
2577 
2578    l_cross_ref := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
2579    l_append:=wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
2580     OPEN x_items FOR
2581       SELECT DISTINCT concatenated_segments
2582                     , inventory_item_id
2583                     , description
2584                     , NVL(revision_qty_control_code, 1)
2585                     , NVL(lot_control_code, 1)
2586                     , NVL(serial_number_control_code, 1)
2587                     , NVL(restrict_subinventories_code, 2)
2588                     , NVL(restrict_locators_code, 2)
2589                     , NVL(location_control_code, 1)
2590                     , primary_uom_code
2591                     , NVL(inspection_required_flag, 2)
2592                     , NVL(shelf_life_code, 1)
2593                     , NVL(shelf_life_days, 0)
2594                     , NVL(allowed_units_lookup_code, 2)
2595                     , NVL(effectivity_control, 1)
2596                     , 0 parentlpnid
2597                     , 0 quantity
2598                     , NVL(default_serial_status_id, 0)
2599                     , NVL(serial_status_enabled, 'N')
2600                     , NVL(default_lot_status_id, 0)
2601                     , NVL(lot_status_enabled, 'N')
2602                     , ''
2603                     , 'N'
2604                     , inventory_item_flag
2605                     , 0
2606 			  , wms_deploy.get_item_client_name(inventory_item_id),
2607 		    inventory_asset_flag, --5591433: Added inventory_asset_flag and outside_processing_flag.
2608                     outside_operation_flag,
2609                     --Bug No 3952081
2610                     --Additional Fields for Process Convergence
2611                     NVL(GRADE_CONTROL_FLAG,'N'),
2612                     NVL(DEFAULT_GRADE,''),
2613                     NVL(EXPIRATION_ACTION_INTERVAL,0),
2614                     NVL(EXPIRATION_ACTION_CODE,''),
2615                     NVL(HOLD_DAYS,0),
2616                     NVL(MATURITY_DAYS,0),
2617                     NVL(RETEST_INTERVAL,0),
2618                     NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
2619                     NVL(CHILD_LOT_FLAG,'N'),
2620                     NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
2621                     NVL(LOT_DIVISIBLE_FLAG,'Y'),
2622                     NVL(SECONDARY_UOM_CODE,''),
2623                     NVL(SECONDARY_DEFAULT_IND,''),
2624                     NVL(TRACKING_QUANTITY_IND,'P'),
2625                     NVL(DUAL_UOM_DEVIATION_HIGH,0),
2626                     NVL(DUAL_UOM_DEVIATION_LOW,0)
2627                  FROM mtl_system_items_vl /* Bug 5581528 */
2628                 WHERE organization_id = p_organization_id
2629                   AND container_item_flag = 'Y'
2630                   AND mtl_transactions_enabled_flag = 'Y'
2631       AND concatenated_segments LIKE (p_concatenated_segments||l_append)
2632 
2633       --Changes for GTIN
2634 
2635       UNION
2636 
2637            SELECT DISTINCT concatenated_segments
2638                     , msik.inventory_item_id
2639                     , msik.description
2640                     , NVL(revision_qty_control_code, 1)
2641                     , NVL(lot_control_code, 1)
2642                     , NVL(serial_number_control_code, 1)
2643                     , NVL(restrict_subinventories_code, 2)
2644                     , NVL(restrict_locators_code, 2)
2645                     , NVL(location_control_code, 1)
2646                     , primary_uom_code
2647                     , NVL(inspection_required_flag, 2)
2648                     , NVL(shelf_life_code, 1)
2649                     , NVL(shelf_life_days, 0)
2650                     , NVL(allowed_units_lookup_code, 2)
2651                     , NVL(effectivity_control, 1)
2652                     , 0 parentlpnid
2653                     , 0 quantity
2654                     , NVL(default_serial_status_id, 0)
2655                     , NVL(serial_status_enabled, 'N')
2656                     , NVL(default_lot_status_id, 0)
2657                     , NVL(lot_status_enabled, 'N')
2658                     , mcr.cross_reference
2659                     , 'N'
2660                     , inventory_item_flag
2661                     , 0
2662 			  , wms_deploy.get_item_client_name(msik.inventory_item_id),
2663 		    inventory_asset_flag, --5591433: Added inventory_asset_flag and outside_processing_flag.
2664                     outside_operation_flag,
2665                     --Bug No 3952081
2666                     --Additional Fields for Process Convergence
2667                     NVL(GRADE_CONTROL_FLAG,'N'),
2668                     NVL(DEFAULT_GRADE,''),
2669                     NVL(EXPIRATION_ACTION_INTERVAL,0),
2670                     NVL(EXPIRATION_ACTION_CODE,''),
2671                     NVL(HOLD_DAYS,0),
2672                     NVL(MATURITY_DAYS,0),
2673                     NVL(RETEST_INTERVAL,0),
2674                     NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
2675                     NVL(CHILD_LOT_FLAG,'N'),
2676                     NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
2677                     NVL(LOT_DIVISIBLE_FLAG,'Y'),
2678                     NVL(SECONDARY_UOM_CODE,''),
2679                     NVL(SECONDARY_DEFAULT_IND,''),
2680                     NVL(TRACKING_QUANTITY_IND,'P'),
2681                     NVL(DUAL_UOM_DEVIATION_HIGH,0),
2682                     NVL(DUAL_UOM_DEVIATION_LOW,0)
2683       FROM mtl_system_items_vl msik, /* Bug 5581528 */
2684       mtl_cross_references mcr
2685       WHERE msik.organization_id = p_organization_id
2686       AND msik.container_item_flag = 'Y'
2687       AND msik.mtl_transactions_enabled_flag = 'Y'
2688       AND msik.inventory_item_id   = mcr.inventory_item_id
2689       AND mcr.cross_reference_type = g_gtin_cross_ref_type
2690       AND mcr.cross_reference      LIKE l_cross_ref
2691       AND (mcr.organization_id     = msik.organization_id
2692 	   OR
2693 	   mcr.org_independent_flag = 'Y')
2694       ORDER BY concatenated_segments;
2695   END get_container_item_lov;
2696 
2697   --      Name: GET_CYC_ITEM_LOV
2698   --
2699   --      Input parameters:
2700   --
2701   --        p_concatenated_segments - User inputted value
2702   --        p_organization_id       -  Organization ID
2703   --        p_subinventory_code     -  Subinventory
2704   --        p_locator_id            -  Locator ID
2705   --        p_unscheduled_entry     -  Indicates if unscheduled entries are allowed
2706   --        p_cycle_count_header_id -  Restricts output to the given cycle count
2707   --        p_parent_lpn_id         -  Restricts output to only items with the
2708   --                                   given parent lpn ID
2709   --
2710   --      Output parameters:
2711   --       x_items    -  returns LOV rows as reference cursor
2712   --
2713   --      Functions: This procedure returns valid items that are associated
2714   --                 with the given cycle count
2715   --
2716 
2717   PROCEDURE get_cyc_item_lov(
2718     x_items                 OUT    NOCOPY t_genref
2719   , p_concatenated_segments IN     VARCHAR2
2720   , p_organization_id       IN     NUMBER
2721   , p_subinventory_code     IN     VARCHAR2
2722   , p_locator_id            IN     NUMBER
2723   , p_unscheduled_entry     IN     NUMBER
2724   , p_cycle_count_header_id IN     NUMBER
2725   , p_parent_lpn_id         IN     NUMBER
2726   ) IS
2727     l_serial_count_option          NUMBER;
2728     l_serial_discrepancy_option    NUMBER;
2729     l_container_discrepancy_option NUMBER;
2730     l_cross_ref varchar2(204);
2731     l_append varchar2(2):='';
2732   BEGIN
2733 
2734    l_cross_ref := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
2735 
2736    l_append:=wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
2737 
2738     -- Get the cycle count discrepancy option flags
2739     SELECT NVL(serial_discrepancy_option, 2)
2740          , NVL(container_discrepancy_option, 2)
2741       INTO l_serial_discrepancy_option
2742          , l_container_discrepancy_option
2743       FROM mtl_cycle_count_headers
2744      WHERE cycle_count_header_id = p_cycle_count_header_id;
2745 
2746     -- Get the serial count option for the cycle count header
2747     SELECT NVL(serial_count_option, 1)
2748       INTO l_serial_count_option
2749       FROM mtl_cycle_count_headers
2750      WHERE cycle_count_header_id = p_cycle_count_header_id
2751        AND organization_id = p_organization_id;
2752 
2753     IF (p_unscheduled_entry = 1) THEN -- Unscheduled entries are allowed
2754       OPEN x_items FOR
2755         SELECT   msik.concatenated_segments concatenated_segments
2756                , msik.inventory_item_id
2757                , msik.description
2758                , NVL(msik.revision_qty_control_code, 1)
2759                , NVL(msik.lot_control_code, 1)
2760                , NVL(msik.serial_number_control_code, 1)
2761                , NVL(msik.restrict_subinventories_code, 2)
2762                , NVL(msik.restrict_locators_code, 2)
2763                , NVL(msik.location_control_code, 1)
2764                , msik.primary_uom_code
2765                , NVL(msik.inspection_required_flag, 2)
2766                , NVL(msik.shelf_life_code, 1)
2767                , NVL(msik.shelf_life_days, 0)
2768                , NVL(msik.allowed_units_lookup_code, 2)
2769                , NVL(msik.effectivity_control, 1)
2770                , 0 parentlpnid
2771                , 0 quantity
2772                , NVL(msik.default_serial_status_id, 0)
2773                , NVL(msik.serial_status_enabled, 'N')
2774                , NVL(msik.default_lot_status_id, 0)
2775                , NVL(msik.lot_status_enabled, 'N')
2776                , ''
2777                , 'N'
2778                , msik.inventory_item_flag
2779                , 0
2780 	     	   , wms_deploy.get_item_client_name(msik.inventory_item_id),
2781      --Bug No 3952081
2782      --Additional Fields for Process Convergence
2783                NVL(msik.GRADE_CONTROL_FLAG,'N'),
2784                NVL(msik.DEFAULT_GRADE,''),
2785                NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
2786                NVL(msik.EXPIRATION_ACTION_CODE,''),
2787                NVL(msik.HOLD_DAYS,0),
2788                NVL(msik.MATURITY_DAYS,0),
2789                NVL(msik.RETEST_INTERVAL,0),
2790                NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
2791                NVL(msik.CHILD_LOT_FLAG,'N'),
2792                NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
2793                NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
2794                NVL(msik.SECONDARY_UOM_CODE,''),
2795                NVL(msik.SECONDARY_DEFAULT_IND,''),
2796                NVL(msik.TRACKING_QUANTITY_IND,'P'),
2797                NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
2798                NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
2799             FROM mtl_system_items_vl msik, /* Bug 5581528 */
2800 	         mtl_cycle_count_items mcci
2801            WHERE msik.organization_id = p_organization_id
2802              AND msik.inventory_item_id = mcci.inventory_item_id
2803              AND mcci.cycle_count_header_id = p_cycle_count_header_id
2804              AND (msik.serial_number_control_code IN (1, 6)
2805                   OR (l_serial_count_option <> 1
2806                       AND serial_number_control_code NOT IN (1, 6)
2807                      )
2808                  )
2809 	AND msik.concatenated_segments LIKE (p_concatenated_segments||l_append)
2810 	/*AND INV_MATERIAL_STATUS_GRP.loc_valid_for_item(p_locator_id,
2811                                                   p_organization_id,
2812                                                    msik.inventory_item_id,
2813                                                   p_subinventory_code)='Y' --Bug# 3188455 Added this for validating restricted Items to locator and subinventory
2814    AND INV_MATERIAL_STATUS_GRP.sub_valid_for_item(p_organization_id,
2815                                                   msik.inventory_item_id,
2816                                                   p_subinventory_code)='Y' -- Bug 5500255*/
2817    AND INV_MATERIAL_STATUS_GRP.sub_loc_valid_for_item(p_organization_id,msik.inventory_item_id,p_subinventory_code,p_locator_id,
2818                                                       msik.restrict_subinventories_code,msik.restrict_locators_code)='Y' -- Bug7626228
2819 	--Changes for GTIN
2820 	UNION
2821 
2822 	SELECT   msik.concatenated_segments concatenated_segments
2823                , msik.inventory_item_id
2824                , msik.description
2825                , NVL(msik.revision_qty_control_code, 1)
2826                , NVL(msik.lot_control_code, 1)
2827                , NVL(msik.serial_number_control_code, 1)
2828                , NVL(msik.restrict_subinventories_code, 2)
2829                , NVL(msik.restrict_locators_code, 2)
2830                , NVL(msik.location_control_code, 1)
2831                , msik.primary_uom_code
2832                , NVL(msik.inspection_required_flag, 2)
2833                , NVL(msik.shelf_life_code, 1)
2834                , NVL(msik.shelf_life_days, 0)
2835                , NVL(msik.allowed_units_lookup_code, 2)
2836                , NVL(msik.effectivity_control, 1)
2837                , 0 parentlpnid
2838                , 0 quantity
2839                , NVL(msik.default_serial_status_id, 0)
2840                , NVL(msik.serial_status_enabled, 'N')
2841                , NVL(msik.default_lot_status_id, 0)
2842                , NVL(msik.lot_status_enabled, 'N')
2843                , mcr.cross_reference
2844                , 'N'
2845                , msik.inventory_item_flag
2846                , 0
2847 	     	   , wms_deploy.get_item_client_name(msik.inventory_item_id),
2848      --Bug No 3952081
2849      --Additional Fields for Process Convergence
2850                NVL(msik.GRADE_CONTROL_FLAG,'N'),
2851                NVL(msik.DEFAULT_GRADE,''),
2852                NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
2853                NVL(msik.EXPIRATION_ACTION_CODE,''),
2854                NVL(msik.HOLD_DAYS,0),
2855                NVL(msik.MATURITY_DAYS,0),
2856                NVL(msik.RETEST_INTERVAL,0),
2857                NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
2858                NVL(msik.CHILD_LOT_FLAG,'N'),
2859                NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
2860                NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
2861                NVL(msik.SECONDARY_UOM_CODE,''),
2862                NVL(msik.SECONDARY_DEFAULT_IND,''),
2863                NVL(msik.TRACKING_QUANTITY_IND,'P'),
2864                NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
2865                NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
2866             FROM mtl_system_items_vl msik, /* Bug 5581528 */
2867 	         mtl_cycle_count_items mcci, mtl_cross_references mcr
2868            WHERE msik.organization_id = p_organization_id
2869              AND msik.inventory_item_id = mcci.inventory_item_id
2870              AND mcci.cycle_count_header_id = p_cycle_count_header_id
2871              AND (msik.serial_number_control_code IN (1, 6)
2872                   OR (l_serial_count_option <> 1
2873                       AND serial_number_control_code NOT IN (1, 6)
2874                      )
2875                  )
2876 	AND msik.inventory_item_id   = mcr.inventory_item_id
2877       AND mcr.cross_reference_type = g_gtin_cross_ref_type
2878       AND mcr.cross_reference      LIKE l_cross_ref
2879       AND (mcr.organization_id     = msik.organization_id
2880 	   OR
2881 	   mcr.org_independent_flag = 'Y')
2882         ORDER BY concatenated_segments;
2883     ELSE -- Unscheduled entries are not allowed
2884       OPEN x_items FOR
2885         SELECT UNIQUE msik.concatenated_segments concatenated_segments
2886                     , msik.inventory_item_id
2887                     , msik.description
2888                     , NVL(msik.revision_qty_control_code, 1)
2889                     , NVL(msik.lot_control_code, 1)
2890                     , NVL(msik.serial_number_control_code, 1)
2891                     , NVL(msik.restrict_subinventories_code, 2)
2892                     , NVL(msik.restrict_locators_code, 2)
2893                     , NVL(msik.location_control_code, 1)
2894                     , msik.primary_uom_code
2895                     , NVL(msik.inspection_required_flag, 2)
2896                     , NVL(msik.shelf_life_code, 1)
2897                     , NVL(msik.shelf_life_days, 0)
2898                     , NVL(msik.allowed_units_lookup_code, 2)
2899                     , NVL(msik.effectivity_control, 1)
2900                     , 0 parentlpnid
2901                     , 0 quantity
2902                     , NVL(msik.default_serial_status_id, 0)
2903                     , NVL(msik.serial_status_enabled, 'N')
2904                     , NVL(msik.default_lot_status_id, 0)
2905                     , NVL(msik.lot_status_enabled, 'N')
2906                     , ''
2907                     , 'N'
2908                     , msik.inventory_item_flag
2909                     , 0
2910 	     	        , wms_deploy.get_item_client_name(msik.inventory_item_id),
2911      --Bug No 3952081
2912      --Additional Fields for Process Convergence
2913                     NVL(msik.GRADE_CONTROL_FLAG,'N'),
2914                     NVL(msik.DEFAULT_GRADE,''),
2915                     NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
2916                     NVL(msik.EXPIRATION_ACTION_CODE,''),
2917                     NVL(msik.HOLD_DAYS,0),
2918                     NVL(msik.MATURITY_DAYS,0),
2919                     NVL(msik.RETEST_INTERVAL,0),
2920                     NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
2921                     NVL(msik.CHILD_LOT_FLAG,'N'),
2922                     NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
2923                     NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
2924                     NVL(msik.SECONDARY_UOM_CODE,''),
2925                     NVL(msik.SECONDARY_DEFAULT_IND,''),
2926                     NVL(msik.TRACKING_QUANTITY_IND,'P'),
2927                     NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
2928                     NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
2929                  FROM mtl_system_items_vl msik, /* Bug 5581528 */
2930 		      mtl_cycle_count_entries mcce
2931                 WHERE msik.organization_id = p_organization_id
2932                   AND msik.concatenated_segments LIKE (p_concatenated_segments||l_append)
2933                   AND msik.inventory_item_id = mcce.inventory_item_id
2934                   AND mcce.cycle_count_header_id = p_cycle_count_header_id
2935                   AND mcce.organization_id = p_organization_id
2936                   -- The sub and loc have to match an existing cycle count entry
2937                   -- OR the entry contains an LPN and
2938                   -- container discrepancies are allowed
2939                   -- OR the item is serial controlled, the cycle count header allows
2940                   -- serial items and serial discrepancies are allowed
2941                   AND ((mcce.subinventory = p_subinventory_code
2942                         AND NVL(mcce.locator_id, -99999) = NVL(p_locator_id, -99999)
2943                        )
2944                        OR (mcce.parent_lpn_id IS NOT NULL
2945                            AND l_container_discrepancy_option = 1
2946                           )
2947                        OR (l_serial_count_option <> 1
2948                            AND msik.serial_number_control_code NOT IN (1, 6)
2949                            AND l_serial_discrepancy_option = 1
2950                           )
2951                       )
2952                   AND NVL(mcce.parent_lpn_id, -99999) = NVL(p_parent_lpn_id, -99999)
2953 			 AND mcce.entry_status_code IN (1, 3)
2954 
2955 			 --Changes for GTIN
2956 			 UNION
2957 
2958 			         SELECT UNIQUE msik.concatenated_segments concatenated_segments
2959                     , msik.inventory_item_id
2960                     , msik.description
2961                     , NVL(msik.revision_qty_control_code, 1)
2962                     , NVL(msik.lot_control_code, 1)
2963                     , NVL(msik.serial_number_control_code, 1)
2964                     , NVL(msik.restrict_subinventories_code, 2)
2965                     , NVL(msik.restrict_locators_code, 2)
2966                     , NVL(msik.location_control_code, 1)
2967                     , msik.primary_uom_code
2968                     , NVL(msik.inspection_required_flag, 2)
2969                     , NVL(msik.shelf_life_code, 1)
2970                     , NVL(msik.shelf_life_days, 0)
2971                     , NVL(msik.allowed_units_lookup_code, 2)
2972                     , NVL(msik.effectivity_control, 1)
2973                     , 0 parentlpnid
2974                     , 0 quantity
2975                     , NVL(msik.default_serial_status_id, 0)
2976                     , NVL(msik.serial_status_enabled, 'N')
2977                     , NVL(msik.default_lot_status_id, 0)
2978                     , NVL(msik.lot_status_enabled, 'N')
2979                     , mcr.cross_reference
2980                     , 'N'
2981                     , msik.inventory_item_flag
2982                     , 0
2983 	     	        , wms_deploy.get_item_client_name(msik.inventory_item_id),
2984      --Bug No 3952081
2985      --Additional Fields for Process Convergence
2986                     NVL(msik.GRADE_CONTROL_FLAG,'N'),
2987                     NVL(msik.DEFAULT_GRADE,''),
2988                     NVL(msik.EXPIRATION_ACTION_INTERVAL,0),
2989                     NVL(msik.EXPIRATION_ACTION_CODE,''),
2990                     NVL(msik.HOLD_DAYS,0),
2991                     NVL(msik.MATURITY_DAYS,0),
2992                     NVL(msik.RETEST_INTERVAL,0),
2993                     NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,'N'),
2994                     NVL(msik.CHILD_LOT_FLAG,'N'),
2995                     NVL(msik.CHILD_LOT_VALIDATION_FLAG,'N'),
2996                     NVL(msik.LOT_DIVISIBLE_FLAG,'Y'),
2997                     NVL(msik.SECONDARY_UOM_CODE,''),
2998                     NVL(msik.SECONDARY_DEFAULT_IND,''),
2999                     NVL(msik.TRACKING_QUANTITY_IND,'P'),
3000                     NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),
3001                     NVL(msik.DUAL_UOM_DEVIATION_LOW,0)
3002                  FROM mtl_system_items_vl msik, /* Bug 5581528 */
3003 		      mtl_cycle_count_entries mcce, mtl_cross_references mcr
3004                 WHERE msik.organization_id = p_organization_id
3005                   AND msik.inventory_item_id = mcce.inventory_item_id
3006                   AND mcce.cycle_count_header_id = p_cycle_count_header_id
3007                   AND mcce.organization_id = p_organization_id
3008                   -- The sub and loc have to match an existing cycle count entry
3009                   -- OR the entry contains an LPN and
3010                   -- container discrepancies are allowed
3011                   -- OR the item is serial controlled, the cycle count header allows
3012                   -- serial items and serial discrepancies are allowed
3013                   AND ((mcce.subinventory = p_subinventory_code
3014                         AND NVL(mcce.locator_id, -99999) = NVL(p_locator_id, -99999)
3015                        )
3016                        OR (mcce.parent_lpn_id IS NOT NULL
3017                            AND l_container_discrepancy_option = 1
3018                           )
3019                        OR (l_serial_count_option <> 1
3020                            AND msik.serial_number_control_code NOT IN (1, 6)
3021                            AND l_serial_discrepancy_option = 1
3022                           )
3023                       )
3024                   AND NVL(mcce.parent_lpn_id, -99999) = NVL(p_parent_lpn_id, -99999)
3025 			 AND mcce.entry_status_code IN (1, 3)
3026 			       AND msik.inventory_item_id   = mcr.inventory_item_id
3027       AND mcr.cross_reference_type = g_gtin_cross_ref_type
3028       AND mcr.cross_reference      LIKE l_cross_ref
3029       AND (mcr.organization_id     = msik.organization_id
3030 	   OR
3031 	   mcr.org_independent_flag = 'Y')
3032              ORDER BY concatenated_segments;
3033     END IF;
3034   END get_cyc_item_lov;
3035 
3036   --      Name: GET_CYC_REV_LOV
3037   --
3038   --      Input parameters:
3039   --       p_organization_id    - restricts LOV SQL to current org
3040   --       p_inventory_item_id  - restrict LOV for a given item
3041   --       p_revision           - restricts LOV SQL to the user input text
3042   --                                e.g.  A101%
3043   --       p_unscheduled_entry  - Indicates if unscheduled entries are allowed
3044   --       p_cycle_count_header_id - restricts LOV SQL to current cycle count
3045   --       p_parent_lpn_id      -  Restricts output to only items with the
3046   --                               given parent lpn ID
3047   --
3048   --      Output parameters:
3049   --       x_revs      returns LOV rows as reference cursor
3050   --
3051   --      Functions: This procedure returns LOV rows for a given org, item and
3052   --                 user input text for a given cycle count
3053   --
3054 
3055   PROCEDURE get_cyc_rev_lov(x_revs OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_inventory_item_id IN NUMBER, p_revision IN VARCHAR2, p_unscheduled_entry IN NUMBER, p_cycle_count_header_id IN NUMBER, p_parent_lpn_id IN NUMBER) IS
3056   BEGIN
3057     IF (p_unscheduled_entry = 1) THEN -- Unscheduled entries are allowed
3058       OPEN x_revs FOR
3059         SELECT   revision
3060                , effectivity_date
3061                , NVL(description, '')
3062             FROM mtl_item_revisions
3063            WHERE organization_id = p_organization_id
3064              AND inventory_item_id = p_inventory_item_id
3065              AND revision LIKE (p_revision)
3066         ORDER BY UPPER(revision);
3067     ELSE -- Unscheduled entries are not allowed
3068       OPEN x_revs FOR
3069         SELECT UNIQUE mir.revision
3070                     , mir.effectivity_date
3071                     , NVL(mir.description, '')
3072                  FROM mtl_item_revisions mir, mtl_cycle_count_entries mcce
3073                 WHERE mir.organization_id = p_organization_id
3074                   AND mir.inventory_item_id = p_inventory_item_id
3075                   AND mir.revision LIKE (p_revision)
3076                   AND mir.inventory_item_id = mcce.inventory_item_id
3077                   AND mcce.cycle_count_header_id = p_cycle_count_header_id
3078                   AND NVL(mcce.parent_lpn_id, -99999) = NVL(p_parent_lpn_id, -99999)
3079                   AND mcce.entry_status_code IN (1, 3)
3080              ORDER BY UPPER(mir.revision);
3081     END IF;
3082   END get_cyc_rev_lov;
3083 
3084   --      Name: GET_CYC_UOM_LOV
3085   --
3086   --      Input parameters:
3087   --       p_organization_id       - Restricts LOV SQL to current org
3088   --       p_inventory_item_id     - Restricts LOV for a given item
3089   --       p_uom_code              - Restricts LOV SQL to the user input text
3090   --                                   e.g.  Ea%
3091   --       p_unscheduled_entry     - Indicates if unscheduled entries are allowed
3092   --       p_cycle_count_header_id - Restricts LOV SQL to current cycle count
3093   --
3094   --      Output parameters:
3095   --       x_uoms      returns LOV rows as reference cursor
3096   --
3097   --      Functions: This procedure returns LOV rows for a given org, item and
3098   --                 user inputted text for valid UOM's for a particular
3099   --                 cycle count
3100   --
3101 
3102   PROCEDURE get_cyc_uom_lov(x_uoms OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_inventory_item_id IN NUMBER, p_uom_code IN VARCHAR2) IS
3103   l_code VARCHAR2(20):=p_UOM_Code;
3104   BEGIN
3105    IF (INSTR(l_code,'(') > 0) THEN
3106       l_code := SUBSTR(p_UOM_Code,1,INSTR(p_UOM_Code,'(')-1);
3107    END IF;
3108 
3109     OPEN x_uoms FOR
3110 /* UOM LOV Enhancements */
3111 --      SELECT   uom_code
3112       SELECT (inv_ui_item_lovs.get_conversion_rate(uom_code,
3113                                    p_organization_id,
3114                                    p_inventory_item_id)) uom_code_comp
3115              , unit_of_measure
3116              , description
3117              , uom_class
3118           FROM mtl_item_uoms_view
3119          WHERE organization_id = p_organization_id
3120            AND inventory_item_id = p_inventory_item_id
3121            AND uom_code LIKE (l_code)
3122       ORDER BY inv_ui_item_lovs.conversion_order(inv_ui_item_lovs.get_conversion_rate(uom_code,
3123                                    p_Organization_Id,
3124                                    p_Inventory_Item_Id)) asc, Upper(uom_code);
3125 --      ORDER BY UPPER(uom_code);
3126   END get_cyc_uom_lov;
3127 
3128   --      Name: GET_INSPECT_ITEM_LOV
3129   --
3130   --      Input parameters:
3131   --       p_organization_id         organization where the inspection occurs
3132   --       p_concatenated_segments   restricts output to user entered search pattern for item
3133   --       p_lpn_id                  id of lpn that contains items to be inspected
3134   --
3135   --      Output parameters:
3136   --       x_items      returns LOV rows as reference cursor
3137   --
3138   --      Functions:
3139   --                      This procedure returns items that need inspection
3140   --
3141 
3142   PROCEDURE get_inspect_item_lov(x_items OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_concatenated_segments IN VARCHAR2, p_lpn_id IN NUMBER) IS
3143     l_inspection_qty NUMBER;
3144     l_return_status  VARCHAR2(10);
3145     l_msg_data       VARCHAR2(500);
3146     l_cross_ref varchar2(204);
3147     l_append varchar2(2):='';
3148    BEGIN
3149 
3150    l_cross_ref := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
3151    l_append:=wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
3152 
3153      IF (p_concatenated_segments IS NOT NULL
3154 	 AND p_concatenated_segments <> '%') THEN
3155 	OPEN x_items FOR
3156 	SELECT * FROM ( --BUG12820609 added to make function call only once
3157 		SELECT /*+ leading(b) */ DISTINCT a.concatenated_segments --BUG12820609 ordering of MTRL and MSI in from clause
3158 	            , a.inventory_item_id
3159                     , a.description
3160                     , NVL(a.revision_qty_control_code, 1)
3161                     , NVL(a.lot_control_code, 1)
3162                     , NVL(a.serial_number_control_code, 1)
3163                     , NVL(a.restrict_subinventories_code, 2)
3164                     , NVL(a.restrict_locators_code, 2)
3165                     , NVL(a.location_control_code, 1)
3166                     , a.primary_uom_code
3167                     , NVL(a.inspection_required_flag, 2)
3168                     , NVL(a.shelf_life_code, 1)
3169                     , NVL(a.shelf_life_days, 0)
3170                     , NVL(a.allowed_units_lookup_code, 2)
3171                     , NVL(a.effectivity_control, 1)
3172                     , 0 parent_lpn_id	--BUG12820609 added alias else outer select won't run
3173                     , 0 quantity		--BUG12820609 added alias else outer select won't run
3174                     , NVL(a.default_serial_status_id, 0)
3175                     , NVL(a.serial_status_enabled, 'N')
3176                     , NVL(a.default_lot_status_id, 0)
3177                     , NVL(a.lot_status_enabled, 'N')
3178                     , ''
3179                     , 'N'
3180                     , a.inventory_item_flag
3181                     , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('LPN', p_lpn_id, NULL, NULL, p_organization_id, b.inventory_item_id, a.primary_uom_code)) insp_qty	--BUG12820609
3182 			  , wms_deploy.get_item_client_name(a.inventory_item_id),
3183      --Bug No 3952081
3184      --Additional Fields for Process Convergence
3185                     NVL(a.GRADE_CONTROL_FLAG,'N'),
3186                     NVL(a.DEFAULT_GRADE,''),
3187                     NVL(a.EXPIRATION_ACTION_INTERVAL,0),
3188                     NVL(a.EXPIRATION_ACTION_CODE,''),
3189                     NVL(a.HOLD_DAYS,0),
3190                     NVL(a.MATURITY_DAYS,0),
3191                     NVL(a.RETEST_INTERVAL,0),
3192                     NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3193                     NVL(a.CHILD_LOT_FLAG,'N'),
3194                     NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
3195                     NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
3196                     NVL(a.SECONDARY_UOM_CODE,''),
3197                     NVL(a.SECONDARY_DEFAULT_IND,''),
3198                     NVL(a.TRACKING_QUANTITY_IND,'P'),
3199                     NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
3200                     NVL(a.DUAL_UOM_DEVIATION_LOW,0)
3201                  FROM mtl_txn_request_lines b , mtl_system_items_vl a /* Bug 5581528 */ --BUG12820609 changed order of MTRL and MSI
3202                 WHERE b.lpn_id = p_lpn_id
3203                   AND b.organization_id = p_organization_id
3204                   AND b.inspection_status is not null   -- 8405606
3205                   AND b.organization_id = a.organization_id
3206                   AND b.inventory_item_id = a.inventory_item_id
3207 				AND a.concatenated_segments LIKE (p_concatenated_segments||l_append)
3208 				AND Nvl(b.wms_process_flag,-1) <> 2
3209 				AND b.line_status <> 5 --BUG12820609 closed MTRL's do not matter in Inspect Item LOV
3210 	--  AND ((inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('LPN',p_lpn_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0) --BUG12820609 added outer select to reduce the call see where
3211 			)  WHERE insp_qty > 0 --BUG12820609 added as function call was reduced to one
3212 	  --Changes for GTIN
3213 	  UNION
3214 --BUG12820609 refer changes in above select, same done in below 2 select statements
3215 	SELECT * FROM (
3216 		SELECT /*+ leading(b) */ DISTINCT a.concatenated_segments
3217 	            , a.inventory_item_id
3218                     , a.description
3219                     , NVL(a.revision_qty_control_code, 1)
3220                     , NVL(a.lot_control_code, 1)
3221                     , NVL(a.serial_number_control_code, 1)
3222                     , NVL(a.restrict_subinventories_code, 2)
3223                     , NVL(a.restrict_locators_code, 2)
3224                     , NVL(a.location_control_code, 1)
3225                     , a.primary_uom_code
3226                     , NVL(a.inspection_required_flag, 2)
3227                     , NVL(a.shelf_life_code, 1)
3228                     , NVL(a.shelf_life_days, 0)
3229                     , NVL(a.allowed_units_lookup_code, 2)
3230                     , NVL(a.effectivity_control, 1)
3231                     , 0 parent_lpn_id
3232                     , 0 quantity
3233                     , NVL(a.default_serial_status_id, 0)
3234                     , NVL(a.serial_status_enabled, 'N')
3235                     , NVL(a.default_lot_status_id, 0)
3236                     , NVL(a.lot_status_enabled, 'N')
3237                     , mcr.cross_reference
3238                     , 'N'
3239                     , a.inventory_item_flag
3240                     , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('LPN', p_lpn_id, NULL, NULL, p_organization_id, b.inventory_item_id, a.primary_uom_code)) insp_qty
3241 			  , wms_deploy.get_item_client_name(a.inventory_item_id),
3242      --Bug No 3952081
3243      --Additional Fields for Process Convergence
3244                     NVL(a.GRADE_CONTROL_FLAG,'N'),
3245                     NVL(a.DEFAULT_GRADE,''),
3246                     NVL(a.EXPIRATION_ACTION_INTERVAL,0),
3247                     NVL(a.EXPIRATION_ACTION_CODE,''),
3248                     NVL(a.HOLD_DAYS,0),
3249                     NVL(a.MATURITY_DAYS,0),
3250                     NVL(a.RETEST_INTERVAL,0),
3251                     NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3252                     NVL(a.CHILD_LOT_FLAG,'N'),
3253                     NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
3254                     NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
3255                     NVL(a.SECONDARY_UOM_CODE,''),
3256                     NVL(a.SECONDARY_DEFAULT_IND,''),
3257                     NVL(a.TRACKING_QUANTITY_IND,'P'),
3258                     NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
3259                     NVL(a.DUAL_UOM_DEVIATION_LOW,0)
3260 	  FROM mtl_txn_request_lines b, mtl_system_items_vl a, /* Bug 5581528 */
3261 	    mtl_cross_references mcr
3262 	  WHERE b.lpn_id = p_lpn_id
3263 	  AND b.organization_id = p_organization_id
3264 	  AND b.inspection_status is not null   -- 8405606
3265 	  AND b.organization_id = a.organization_id
3266 	  AND b.inventory_item_id = a.inventory_item_id
3267 	  AND Nvl(b.wms_process_flag,-1) <> 2
3268 	--  AND ((inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('LPN',p_lpn_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0)
3269 	  AND a.inventory_item_id   = mcr.inventory_item_id
3270 	  AND mcr.cross_reference_type = g_gtin_cross_ref_type
3271 	  AND mcr.cross_reference      LIKE l_cross_ref
3272 	  AND (mcr.organization_id     = a.organization_id
3273 	       OR
3274 	       mcr.org_independent_flag = 'Y')
3275 	  AND b.line_status <> 5
3276 	) WHERE insp_qty > 0;
3277 
3278       ELSIF (p_concatenated_segments = '%' AND l_append='') THEN  -- bug#13092838
3279 
3280 	  OPEN x_items FOR
3281 	SELECT * FROM (
3282 	  SELECT /*+ leading(b) */ DISTINCT a.concatenated_segments
3283 	            , a.inventory_item_id
3284                     , a.description
3285                     , NVL(a.revision_qty_control_code, 1)
3286                     , NVL(a.lot_control_code, 1)
3287                     , NVL(a.serial_number_control_code, 1)
3288                     , NVL(a.restrict_subinventories_code, 2)
3289                     , NVL(a.restrict_locators_code, 2)
3290                     , NVL(a.location_control_code, 1)
3291                     , a.primary_uom_code
3292                     , NVL(a.inspection_required_flag, 2)
3293                     , NVL(a.shelf_life_code, 1)
3294                     , NVL(a.shelf_life_days, 0)
3295                     , NVL(a.allowed_units_lookup_code, 2)
3296                     , NVL(a.effectivity_control, 1)
3297                     , 0 parent_lpn_id
3298                     , 0 quantity
3299                     , NVL(a.default_serial_status_id, 0)
3300                     , NVL(a.serial_status_enabled, 'N')
3301                     , NVL(a.default_lot_status_id, 0)
3302                     , NVL(a.lot_status_enabled, 'N')
3303                     , ''
3304                     , 'N'
3305                     , a.inventory_item_flag
3306                     , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('LPN', p_lpn_id, NULL, NULL, p_organization_id, b.inventory_item_id, a.primary_uom_code)) insp_qty
3307 			  , wms_deploy.get_item_client_name(a.inventory_item_id),
3308      --Bug No 3952081
3309      --Additional Fields for Process Convergence
3310                     NVL(a.GRADE_CONTROL_FLAG,'N'),
3311                     NVL(a.DEFAULT_GRADE,''),
3312                     NVL(a.EXPIRATION_ACTION_INTERVAL,0),
3313                     NVL(a.EXPIRATION_ACTION_CODE,''),
3314                     NVL(a.HOLD_DAYS,0),
3315                     NVL(a.MATURITY_DAYS,0),
3316                     NVL(a.RETEST_INTERVAL,0),
3317                     NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3318                     NVL(a.CHILD_LOT_FLAG,'N'),
3319                     NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
3320                     NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
3321                     NVL(a.SECONDARY_UOM_CODE,''),
3322                     NVL(a.SECONDARY_DEFAULT_IND,''),
3323                     NVL(a.TRACKING_QUANTITY_IND,'P'),
3324                     NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
3325                     NVL(a.DUAL_UOM_DEVIATION_LOW,0)
3326                  FROM mtl_txn_request_lines b, mtl_system_items_vl a  /* Bug 5581528 */
3327                 WHERE b.lpn_id = p_lpn_id
3328                   AND b.organization_id = p_organization_id
3329                   AND b.inspection_status is not null   -- 8405606
3330                   AND b.organization_id = a.organization_id
3331                   AND b.inventory_item_id = a.inventory_item_id
3332 				-- bug#13092838  AND a.concatenated_segments LIKE (p_concatenated_segments||l_append)
3333 				AND Nvl(b.wms_process_flag,-1) <> 2
3334 	--  AND ((inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('LPN', p_lpn_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0)
3335 				AND b.line_status <> 5
3336 	 ) WHERE insp_qty > 0;
3337 
3338 	  ELSE
3339 
3340 	OPEN x_items FOR
3341 	SELECT * FROM (
3342 	  SELECT /*+ leading(b) */ DISTINCT a.concatenated_segments
3343 	            , a.inventory_item_id
3344                     , a.description
3345                     , NVL(a.revision_qty_control_code, 1)
3346                     , NVL(a.lot_control_code, 1)
3347                     , NVL(a.serial_number_control_code, 1)
3348                     , NVL(a.restrict_subinventories_code, 2)
3349                     , NVL(a.restrict_locators_code, 2)
3350                     , NVL(a.location_control_code, 1)
3351                     , a.primary_uom_code
3352                     , NVL(a.inspection_required_flag, 2)
3353                     , NVL(a.shelf_life_code, 1)
3354                     , NVL(a.shelf_life_days, 0)
3355                     , NVL(a.allowed_units_lookup_code, 2)
3356                     , NVL(a.effectivity_control, 1)
3357                     , 0 parent_lpn_id
3358                     , 0 quantity
3359                     , NVL(a.default_serial_status_id, 0)
3360                     , NVL(a.serial_status_enabled, 'N')
3361                     , NVL(a.default_lot_status_id, 0)
3362                     , NVL(a.lot_status_enabled, 'N')
3363                     , ''
3364                     , 'N'
3365                     , a.inventory_item_flag
3366                     , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('LPN', p_lpn_id, NULL, NULL, p_organization_id, b.inventory_item_id, a.primary_uom_code)) insp_qty
3367 			  , wms_deploy.get_item_client_name(a.inventory_item_id),
3368      --Bug No 3952081
3369      --Additional Fields for Process Convergence
3370                     NVL(a.GRADE_CONTROL_FLAG,'N'),
3371                     NVL(a.DEFAULT_GRADE,''),
3372                     NVL(a.EXPIRATION_ACTION_INTERVAL,0),
3373                     NVL(a.EXPIRATION_ACTION_CODE,''),
3374                     NVL(a.HOLD_DAYS,0),
3375                     NVL(a.MATURITY_DAYS,0),
3376                     NVL(a.RETEST_INTERVAL,0),
3377                     NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3378                     NVL(a.CHILD_LOT_FLAG,'N'),
3379                     NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
3380                     NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
3381                     NVL(a.SECONDARY_UOM_CODE,''),
3382                     NVL(a.SECONDARY_DEFAULT_IND,''),
3383                     NVL(a.TRACKING_QUANTITY_IND,'P'),
3384                     NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
3385                     NVL(a.DUAL_UOM_DEVIATION_LOW,0)
3386                  FROM mtl_txn_request_lines b, mtl_system_items_vl a  /* Bug 5581528 */
3387                 WHERE b.lpn_id = p_lpn_id
3388                   AND b.organization_id = p_organization_id
3389                   AND b.inspection_status is not null   -- 8405606
3390                   AND b.organization_id = a.organization_id
3391                   AND b.inventory_item_id = a.inventory_item_id
3392 				AND a.concatenated_segments LIKE (p_concatenated_segments||l_append)
3393 				AND Nvl(b.wms_process_flag,-1) <> 2
3394 	--  AND ((inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('LPN', p_lpn_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0)
3395 				AND b.line_status <> 5
3396 	 ) WHERE insp_qty > 0;
3397      END IF;
3398   END get_inspect_item_lov;
3399 
3400   --      Name: GET_INSPECT_REVISION_LOV
3401   --
3402   --      Input parameters:
3403   --       p_Organization_Id   which restricts LOV SQL to current org
3404   --       p_Inventory_Item_Id restrict LOV for a given item
3405   --       p_lpn_id            restricts items to lpn that is being inspected
3406   --       p_Revision          which restricts LOV SQL to the user input text
3407   --                                e.g.  A101%
3408   --
3409   --      Output parameters:
3410   --       x_Revs      returns LOV rows as reference cursor
3411   --
3412   --      Functions: This procedure returns LOV rows for a given org, item and
3413   --                 user input text
3414   --
3415   --
3416   --
3417   PROCEDURE get_inspect_revision_lov(x_revs OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_inventory_item_id IN NUMBER, p_lpn_id IN NUMBER, p_revision IN VARCHAR2) IS
3418   BEGIN
3419     OPEN x_revs FOR
3420       SELECT DISTINCT a.revision
3421                     , a.effectivity_date
3422                     , NVL(a.description, '')
3423                  FROM mtl_item_revisions a, mtl_txn_request_lines b
3424                 WHERE b.organization_id = p_organization_id
3425                   AND b.inventory_item_id = p_inventory_item_id
3426                   AND b.lpn_id = p_lpn_id
3427                   AND b.inspection_status is not null  --8405606
3428                   AND a.organization_id = b.organization_id
3429                   AND a.inventory_item_id = b.inventory_item_id
3430                   AND a.revision = b.revision
3431                   AND a.revision LIKE (p_revision);
3432   END get_inspect_revision_lov;
3433 
3434   PROCEDURE get_oh_item_lov(x_items OUT NOCOPY t_genref, p_org_id IN NUMBER, p_subinventory_code VARCHAR2, p_locator_id VARCHAR2, p_container_item_flag VARCHAR2, p_item IN VARCHAR2) IS
3435   l_cross_ref varchar2(204);
3436   l_append varchar2(2):='';
3437   BEGIN
3438 
3439    l_cross_ref := lpad(Rtrim(p_item, '%'), g_gtin_code_length, '00000000000000');
3440    l_append:=wms_deploy.get_item_suffix_for_lov(p_item);
3441 
3442     IF (p_container_item_flag IS NULL) THEN
3443       OPEN x_items FOR
3444         SELECT DISTINCT msi.concatenated_segments
3445                       , moq.inventory_item_id
3446                       , msi.description
3447                       , NVL(msi.revision_qty_control_code, 1)
3448                       , NVL(msi.lot_control_code, 1)
3449                       , NVL(msi.serial_number_control_code, 1)
3450                       , NVL(msi.restrict_subinventories_code, 2)
3451                       , NVL(msi.restrict_locators_code, 2)
3452                       , NVL(msi.location_control_code, 1)
3453                       , msi.primary_uom_code
3454                       , NVL(msi.inspection_required_flag, 2)
3455                       , NVL(msi.shelf_life_code, 1)
3456                       , NVL(msi.shelf_life_days, 0)
3457                       , NVL(msi.allowed_units_lookup_code, 2)
3458                       , NVL(msi.effectivity_control, 1)
3459                       , '0'
3460                       , '0'
3461                       , '0'
3462                       , '0'
3463                       , '0'
3464                       , '0'
3465                       , ''
3466                       , 'N'
3467                       , msi.inventory_item_flag
3468                       , 0
3469 			    , wms_deploy.get_item_client_name(moq.inventory_item_id),
3470      --Bug No 3952081
3471      --Additional Fields for Process Convergence
3472                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
3473                       NVL(msi.DEFAULT_GRADE,''),
3474                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
3475                       NVL(msi.EXPIRATION_ACTION_CODE,''),
3476                       NVL(msi.HOLD_DAYS,0),
3477                       NVL(msi.MATURITY_DAYS,0),
3478                       NVL(msi.RETEST_INTERVAL,0),
3479                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3480                       NVL(msi.CHILD_LOT_FLAG,'N'),
3481                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
3482                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
3483                       NVL(msi.SECONDARY_UOM_CODE,''),
3484                       NVL(msi.SECONDARY_DEFAULT_IND,''),
3485                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
3486                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
3487                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
3488                    FROM mtl_onhand_quantities_detail moq, mtl_system_items_vl msi  -- Bug 2687570, use MOQD instead of MOQ because consigned stock is not visible in MOQ
3489                   WHERE moq.organization_id = p_org_id
3490                     AND NVL(moq.subinventory_code, '@') = NVL(p_subinventory_code, NVL(moq.subinventory_code, '@'))
3491                     AND NVL(moq.locator_id, -1) = NVL(p_locator_id, NVL(moq.locator_id, -1))
3492                     AND moq.containerized_flag = 2
3493                     AND moq.inventory_item_id = msi.inventory_item_id
3494                     AND moq.organization_id = msi.organization_id
3495 	AND msi.concatenated_segments LIKE (p_item||l_append)
3496 
3497 	--Changes for GTIN
3498 	UNION
3499 
3500 	        SELECT DISTINCT msi.concatenated_segments
3501                       , moq.inventory_item_id
3502                       , msi.description
3503                       , NVL(msi.revision_qty_control_code, 1)
3504                       , NVL(msi.lot_control_code, 1)
3505                       , NVL(msi.serial_number_control_code, 1)
3506                       , NVL(msi.restrict_subinventories_code, 2)
3507                       , NVL(msi.restrict_locators_code, 2)
3508                       , NVL(msi.location_control_code, 1)
3509                       , msi.primary_uom_code
3510                       , NVL(msi.inspection_required_flag, 2)
3511                       , NVL(msi.shelf_life_code, 1)
3512                       , NVL(msi.shelf_life_days, 0)
3513                       , NVL(msi.allowed_units_lookup_code, 2)
3514                       , NVL(msi.effectivity_control, 1)
3515                       , '0'
3516                       , '0'
3517                       , '0'
3518                       , '0'
3519                       , '0'
3520                       , '0'
3521                       , mcr.cross_reference
3522                       , 'N'
3523                       , msi.inventory_item_flag
3524                       , 0
3525 			    , wms_deploy.get_item_client_name(moq.inventory_item_id),
3526      --Bug No 3952081
3527      --Additional Fields for Process Convergence
3528                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
3529                       NVL(msi.DEFAULT_GRADE,''),
3530                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
3531                       NVL(msi.EXPIRATION_ACTION_CODE,''),
3532                       NVL(msi.HOLD_DAYS,0),
3533                       NVL(msi.MATURITY_DAYS,0),
3534                       NVL(msi.RETEST_INTERVAL,0),
3535                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3536                       NVL(msi.CHILD_LOT_FLAG,'N'),
3537                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
3538                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
3539                       NVL(msi.SECONDARY_UOM_CODE,''),
3540                       NVL(msi.SECONDARY_DEFAULT_IND,''),
3541                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
3542                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
3543                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
3544 	FROM mtl_onhand_quantities_detail moq, -- Bug 2687570, use MOQD instead of MOQ because consigned stock is not visible in MOQ
3545 	mtl_system_items_vl msi, /* Bug 5581528 */
3546 	mtl_cross_references mcr
3547 	WHERE moq.organization_id = p_org_id
3548 	AND NVL(moq.subinventory_code, '@') = NVL(p_subinventory_code, NVL(moq.subinventory_code, '@'))
3549 	AND NVL(moq.locator_id, -1) = NVL(p_locator_id, NVL(moq.locator_id, -1))
3550 	AND moq.containerized_flag = 2
3551 	AND moq.inventory_item_id = msi.inventory_item_id
3552 	AND moq.organization_id = msi.organization_id
3553 	AND msi.inventory_item_id   = mcr.inventory_item_id
3554 	AND mcr.cross_reference_type = g_gtin_cross_ref_type
3555 	AND mcr.cross_reference      LIKE l_cross_ref
3556 	AND (mcr.organization_id     = msi.organization_id
3557 	     OR
3558 	     mcr.org_independent_flag = 'Y');
3559 
3560     ELSE
3561       OPEN x_items FOR
3562         SELECT DISTINCT msi.concatenated_segments
3563                       , moq.inventory_item_id
3564                       , msi.description
3565                       , NVL(msi.revision_qty_control_code, 1)
3566                       , NVL(msi.lot_control_code, 1)
3567                       , NVL(msi.serial_number_control_code, 1)
3568                       , NVL(msi.restrict_subinventories_code, 2)
3569                       , NVL(msi.restrict_locators_code, 2)
3570                       , NVL(msi.location_control_code, 1)
3571                       , msi.primary_uom_code
3572                       , NVL(msi.inspection_required_flag, 2)
3573                       , NVL(msi.shelf_life_code, 1)
3574                       , NVL(msi.shelf_life_days, 0)
3575                       , NVL(msi.allowed_units_lookup_code, 2)
3576                       , NVL(msi.effectivity_control, 1)
3577                       , '0'
3578                       , '0'
3579                       , '0'
3580                       , '0'
3581                       , '0'
3582                       , '0'
3583                       , ''
3584                       , 'N'
3585                       , msi.inventory_item_flag
3586                       , 0
3587 			    , wms_deploy.get_item_client_name(moq.inventory_item_id),
3588                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
3589      --Bug No 3952081
3590      --Additional Fields for Process Convergence
3591                       NVL(msi.DEFAULT_GRADE,''),
3592                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
3593                       NVL(msi.EXPIRATION_ACTION_CODE,''),
3594                       NVL(msi.HOLD_DAYS,0),
3595                       NVL(msi.MATURITY_DAYS,0),
3596                       NVL(msi.RETEST_INTERVAL,0),
3597                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3598                       NVL(msi.CHILD_LOT_FLAG,'N'),
3599                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
3600                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
3601                       NVL(msi.SECONDARY_UOM_CODE,''),
3602                       NVL(msi.SECONDARY_DEFAULT_IND,''),
3603                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
3604                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
3605                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
3606                    FROM mtl_onhand_quantities_detail moq, mtl_system_items_vl msi /* Bug 5581528 */
3607 					-- Bug 2687570, use MOQD instead of MOQ because consigned stock is not visible in MOQ
3608                   WHERE moq.organization_id = p_org_id
3609                     AND NVL(moq.subinventory_code, '@') = NVL(p_subinventory_code, NVL(moq.subinventory_code, '@'))
3610                     AND NVL(moq.locator_id, -1) = NVL(p_locator_id, NVL(moq.locator_id, -1))
3611                     AND NVL(msi.container_item_flag, '@') = NVL(p_container_item_flag, NVL(msi.container_item_flag, '@'))
3612                     AND moq.inventory_item_id = msi.inventory_item_id
3613                     AND moq.organization_id = msi.organization_id
3614 	AND concatenated_segments LIKE (p_item||l_append)
3615 
3616 	--Changes for GTIN
3617 	UNION
3618 
3619 	        SELECT DISTINCT msi.concatenated_segments
3620                       , moq.inventory_item_id
3621                       , msi.description
3622                       , NVL(msi.revision_qty_control_code, 1)
3623                       , NVL(msi.lot_control_code, 1)
3624                       , NVL(msi.serial_number_control_code, 1)
3625                       , NVL(msi.restrict_subinventories_code, 2)
3626                       , NVL(msi.restrict_locators_code, 2)
3627                       , NVL(msi.location_control_code, 1)
3628                       , msi.primary_uom_code
3629                       , NVL(msi.inspection_required_flag, 2)
3630                       , NVL(msi.shelf_life_code, 1)
3631                       , NVL(msi.shelf_life_days, 0)
3632                       , NVL(msi.allowed_units_lookup_code, 2)
3633                       , NVL(msi.effectivity_control, 1)
3634                       , '0'
3635                       , '0'
3636                       , '0'
3637                       , '0'
3638                       , '0'
3639                       , '0'
3640                       , mcr.cross_reference
3641                       , 'N'
3642                       , msi.inventory_item_flag
3643                       , 0
3644 			    , wms_deploy.get_item_client_name(moq.inventory_item_id),
3645      --Bug No 3952081
3646      --Additional Fields for Process Convergence
3647                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
3648                       NVL(msi.DEFAULT_GRADE,''),
3649                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
3650                       NVL(msi.EXPIRATION_ACTION_CODE,''),
3651                       NVL(msi.HOLD_DAYS,0),
3652                       NVL(msi.MATURITY_DAYS,0),
3653                       NVL(msi.RETEST_INTERVAL,0),
3654                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3655                       NVL(msi.CHILD_LOT_FLAG,'N'),
3656                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
3657                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
3658                       NVL(msi.SECONDARY_UOM_CODE,''),
3659                       NVL(msi.SECONDARY_DEFAULT_IND,''),
3660                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
3661                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
3662                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
3663 	FROM mtl_onhand_quantities_detail moq, -- Bug 2687570, use MOQD instead of MOQ because consigned stock is not visible in MOQ
3664 	mtl_system_items_vl msi, /* Bug 5581528 */
3665 	mtl_cross_references mcr
3666 	WHERE moq.organization_id = p_org_id
3667 	AND NVL(moq.subinventory_code, '@') = NVL(p_subinventory_code, NVL(moq.subinventory_code, '@'))
3668 	AND NVL(moq.locator_id, -1) = NVL(p_locator_id, NVL(moq.locator_id, -1))
3669 	AND NVL(msi.container_item_flag, '@') = NVL(p_container_item_flag, NVL(msi.container_item_flag, '@'))
3670 	AND moq.inventory_item_id = msi.inventory_item_id
3671 	AND moq.organization_id = msi.organization_id
3672 	AND msi.inventory_item_id   = mcr.inventory_item_id
3673 	AND mcr.cross_reference_type = g_gtin_cross_ref_type
3674 	AND mcr.cross_reference      LIKE l_cross_ref
3675 	AND (mcr.organization_id     = msi.organization_id
3676 	     OR
3677 	     mcr.org_independent_flag = 'Y');
3678     END IF;
3679   END get_oh_item_lov;
3680 
3681   PROCEDURE get_cont_item_lov(x_items OUT NOCOPY t_genref, p_org_id IN NUMBER, p_lpn_id IN VARCHAR2, p_item IN VARCHAR2) IS
3682   l_cross_ref varchar2(204);
3683   l_append varchar2(2):='';
3684   BEGIN
3685 
3686    l_cross_ref := lpad(Rtrim(p_item, '%'), g_gtin_code_length, '00000000000000');
3687    l_append:=wms_deploy.get_item_suffix_for_lov(p_item);
3688 
3689     OPEN x_items FOR
3690       SELECT DISTINCT msi.concatenated_segments
3691                     , wlc.inventory_item_id
3692                     , NVL(msi.description, '')
3693                     , NVL(msi.revision_qty_control_code, 1)
3694                     , NVL(msi.lot_control_code, 1)
3695                     , NVL(msi.serial_number_control_code, 1)
3696                     , NVL(msi.restrict_subinventories_code, 2)
3697                     , NVL(msi.restrict_locators_code, 2)
3698                     , NVL(msi.location_control_code, 1)
3699                     , NVL(msi.primary_uom_code, '')
3700                     , NVL(msi.inspection_required_flag, 2)
3701                     , NVL(msi.shelf_life_code, 1)
3702                     , NVL(msi.shelf_life_days, 0)
3703                     , NVL(msi.allowed_units_lookup_code, 2)
3704                     , NVL(msi.effectivity_control, 1)
3705                     , NVL(wlc.parent_lpn_id, 0)
3706                     , '0'
3707                     , '0'
3708                     , '0'
3709                     , '0'
3710                     , '0'
3711                     , ''
3712                     , 'N'
3713                     , msi.inventory_item_flag
3714                     , 0
3715 			  , wms_deploy.get_item_client_name(wlc.inventory_item_id),
3716      --Bug No 3952081
3717      --Additional Fields for Process Convergence
3718                     NVL(msi.GRADE_CONTROL_FLAG,'N'),
3719                     NVL(msi.DEFAULT_GRADE,''),
3720                     NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
3721                     NVL(msi.EXPIRATION_ACTION_CODE,''),
3722                     NVL(msi.HOLD_DAYS,0),
3723                     NVL(msi.MATURITY_DAYS,0),
3724                     NVL(msi.RETEST_INTERVAL,0),
3725                     NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3726                     NVL(msi.CHILD_LOT_FLAG,'N'),
3727                     NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
3728                     NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
3729                     NVL(msi.SECONDARY_UOM_CODE,''),
3730                     NVL(msi.SECONDARY_DEFAULT_IND,''),
3731                     NVL(msi.TRACKING_QUANTITY_IND,'P'),
3732                     NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
3733                     NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
3734                  FROM mtl_system_items_vl msi, wms_lpn_contents wlc /* Bug 5581528 */
3735                 WHERE wlc.organization_id = p_org_id
3736                   AND wlc.parent_lpn_id = TO_NUMBER(p_lpn_id)
3737                   AND msi.inventory_item_id = wlc.inventory_item_id
3738                   AND msi.organization_id = wlc.organization_id
3739       AND msi.concatenated_segments LIKE (p_item||l_append)
3740 
3741       --Changes for GTIN
3742       UNION
3743 
3744             SELECT DISTINCT msi.concatenated_segments
3745                     , wlc.inventory_item_id
3746                     , NVL(msi.description, '')
3747                     , NVL(msi.revision_qty_control_code, 1)
3748                     , NVL(msi.lot_control_code, 1)
3749                     , NVL(msi.serial_number_control_code, 1)
3750                     , NVL(msi.restrict_subinventories_code, 2)
3751                     , NVL(msi.restrict_locators_code, 2)
3752                     , NVL(msi.location_control_code, 1)
3753                     , NVL(msi.primary_uom_code, '')
3754                     , NVL(msi.inspection_required_flag, 2)
3755                     , NVL(msi.shelf_life_code, 1)
3756                     , NVL(msi.shelf_life_days, 0)
3757                     , NVL(msi.allowed_units_lookup_code, 2)
3758                     , NVL(msi.effectivity_control, 1)
3759                     , NVL(wlc.parent_lpn_id, 0)
3760                     , '0'
3761                     , '0'
3762                     , '0'
3763                     , '0'
3764                     , '0'
3765                     , mcr.cross_reference
3766                     , 'N'
3767                     , msi.inventory_item_flag
3768                     , 0
3769 			  , wms_deploy.get_item_client_name(wlc.inventory_item_id),
3770      --Bug No 3952081
3771      --Additional Fields for Process Convergence
3772                     NVL(msi.GRADE_CONTROL_FLAG,'N'),
3773                     NVL(msi.DEFAULT_GRADE,''),
3774                     NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
3775                     NVL(msi.EXPIRATION_ACTION_CODE,''),
3776                     NVL(msi.HOLD_DAYS,0),
3777                     NVL(msi.MATURITY_DAYS,0),
3778                     NVL(msi.RETEST_INTERVAL,0),
3779                     NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3780                     NVL(msi.CHILD_LOT_FLAG,'N'),
3781                     NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
3782                     NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
3783                     NVL(msi.SECONDARY_UOM_CODE,''),
3784                     NVL(msi.SECONDARY_DEFAULT_IND,''),
3785                     NVL(msi.TRACKING_QUANTITY_IND,'P'),
3786                     NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
3787                     NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
3788       FROM mtl_system_items_vl msi, /* Bug 5581528 */
3789       wms_lpn_contents wlc,
3790       mtl_cross_references mcr
3791       WHERE wlc.organization_id = p_org_id
3792       AND wlc.parent_lpn_id = TO_NUMBER(p_lpn_id)
3793       AND msi.inventory_item_id = wlc.inventory_item_id
3794       AND msi.organization_id = wlc.organization_id
3795       AND msi.inventory_item_id   = mcr.inventory_item_id
3796       AND mcr.cross_reference_type = g_gtin_cross_ref_type
3797       AND mcr.cross_reference      LIKE l_cross_ref
3798       AND (mcr.organization_id     = msi.organization_id
3799 	   OR
3800 	   mcr.org_independent_flag = 'Y');
3801 
3802   END get_cont_item_lov;
3803 
3804   PROCEDURE get_bp_item_lov(x_items OUT NOCOPY t_genref, p_org_id IN NUMBER, p_subinventory_code VARCHAR2, p_locator_id VARCHAR2, p_container_item_flag VARCHAR2, p_source VARCHAR2, p_item VARCHAR2) IS
3805   l_cross_ref varchar2(204);
3806   l_append varchar2(2):='';
3807   BEGIN
3808 
3809    l_cross_ref := lpad(Rtrim(p_item, '%'), g_gtin_code_length, '00000000000000');
3810    l_append:=wms_deploy.get_item_suffix_for_lov(p_item);
3811 
3812     IF (NVL(p_source, '1') = '1') THEN
3813       IF (p_container_item_flag = 'Y') THEN
3814         OPEN x_items FOR
3815           SELECT DISTINCT msi.concatenated_segments
3816                         , msi.inventory_item_id
3817                         , msi.description
3818                         , NVL(msi.revision_qty_control_code, 1)
3819                         , NVL(msi.lot_control_code, 1)
3820                         , NVL(msi.serial_number_control_code, 1)
3821                         , NVL(msi.restrict_subinventories_code, 2)
3822                         , NVL(msi.restrict_locators_code, 2)
3823                         , NVL(msi.location_control_code, 1)
3824                         , msi.primary_uom_code
3825                         , NVL(msi.inspection_required_flag, 2)
3826                         , NVL(msi.shelf_life_code, 1)
3827                         , NVL(msi.shelf_life_days, 0)
3828                         , NVL(msi.allowed_units_lookup_code, 2)
3829                         , NVL(msi.effectivity_control, 1)
3830                         , '0'
3831                         , '0'
3832                         , '0'
3833                         , '0'
3834                         , '0'
3835                         , '0'
3836                         , ''
3837                         , 'N'
3838                         , msi.inventory_item_flag
3839                         , 0
3840 				, wms_deploy.get_item_client_name(msi.inventory_item_id),
3841      --Bug No 3952081
3842      --Additional Fields for Process Convergence
3843                     NVL(msi.GRADE_CONTROL_FLAG,'N'),
3844                     NVL(msi.DEFAULT_GRADE,''),
3845                     NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
3846                     NVL(msi.EXPIRATION_ACTION_CODE,''),
3847                     NVL(msi.HOLD_DAYS,0),
3848                     NVL(msi.MATURITY_DAYS,0),
3849                     NVL(msi.RETEST_INTERVAL,0),
3850                     NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3851                     NVL(msi.CHILD_LOT_FLAG,'N'),
3852                     NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
3853                     NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
3854                     NVL(msi.SECONDARY_UOM_CODE,''),
3855                     NVL(msi.SECONDARY_DEFAULT_IND,''),
3856                     NVL(msi.TRACKING_QUANTITY_IND,'P'),
3857                     NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
3858                     NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
3859                      FROM mtl_system_items_vl msi /* Bug 5581528 */
3860                     WHERE msi.organization_id = p_org_id
3861                       AND NVL(serial_number_control_code, 1) IN (1, 2, 5, 6)
3862                       AND NVL(container_item_flag, 'N') = NVL(p_container_item_flag, NVL(container_item_flag, 'N'))
3863 	  AND msi.concatenated_segments LIKE (p_item||l_append)
3864 
3865 	  --Changes for GTIN
3866 	  UNION
3867 
3868 	            SELECT DISTINCT msi.concatenated_segments
3869                         , msi.inventory_item_id
3870                         , msi.description
3871                         , NVL(msi.revision_qty_control_code, 1)
3872                         , NVL(msi.lot_control_code, 1)
3873                         , NVL(msi.serial_number_control_code, 1)
3874                         , NVL(msi.restrict_subinventories_code, 2)
3875                         , NVL(msi.restrict_locators_code, 2)
3876                         , NVL(msi.location_control_code, 1)
3877                         , msi.primary_uom_code
3878                         , NVL(msi.inspection_required_flag, 2)
3879                         , NVL(msi.shelf_life_code, 1)
3880                         , NVL(msi.shelf_life_days, 0)
3881                         , NVL(msi.allowed_units_lookup_code, 2)
3882                         , NVL(msi.effectivity_control, 1)
3883                         , '0'
3884                         , '0'
3885                         , '0'
3886                         , '0'
3887                         , '0'
3888                         , '0'
3889                         , mcr.cross_reference
3890                         , 'N'
3891                         , msi.inventory_item_flag
3892                         , 0
3893 				, wms_deploy.get_item_client_name(msi.inventory_item_id),
3894      --Bug No 3952081
3895      --Additional Fields for Process Convergence
3896                     NVL(msi.GRADE_CONTROL_FLAG,'N'),
3897                     NVL(msi.DEFAULT_GRADE,''),
3898                     NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
3899                     NVL(msi.EXPIRATION_ACTION_CODE,''),
3900                     NVL(msi.HOLD_DAYS,0),
3901                     NVL(msi.MATURITY_DAYS,0),
3902                     NVL(msi.RETEST_INTERVAL,0),
3903                     NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3904                     NVL(msi.CHILD_LOT_FLAG,'N'),
3905                     NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
3906                     NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
3907                     NVL(msi.SECONDARY_UOM_CODE,''),
3908                     NVL(msi.SECONDARY_DEFAULT_IND,''),
3909                     NVL(msi.TRACKING_QUANTITY_IND,'P'),
3910                     NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
3911                     NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
3912 	  FROM mtl_system_items_vl msi, /* Bug 5581528 */
3913 	  mtl_cross_references mcr
3914 	  WHERE msi.organization_id = p_org_id
3915 	  AND NVL(serial_number_control_code, 1) IN (1, 2, 5, 6)
3916 	  AND NVL(container_item_flag, 'N') = NVL(p_container_item_flag, NVL(container_item_flag, 'N'))
3917 	  AND msi.inventory_item_id   = mcr.inventory_item_id
3918 	  AND mcr.cross_reference_type = g_gtin_cross_ref_type
3919 	  AND mcr.cross_reference      LIKE l_cross_ref
3920 	  AND (mcr.organization_id     = msi.organization_id
3921 	       OR
3922 	       mcr.org_independent_flag = 'Y');
3923 
3924       ELSE
3925         OPEN x_items FOR
3926           SELECT DISTINCT msi.concatenated_segments
3927                         , msi.inventory_item_id
3928                         , msi.description
3929                         , NVL(msi.revision_qty_control_code, 1)
3930                         , NVL(msi.lot_control_code, 1)
3931                         , NVL(msi.serial_number_control_code, 1)
3932                         , NVL(msi.restrict_subinventories_code, 2)
3933                         , NVL(msi.restrict_locators_code, 2)
3934                         , NVL(msi.location_control_code, 1)
3935                         , msi.primary_uom_code
3936                         , NVL(msi.inspection_required_flag, 2)
3937                         , NVL(msi.shelf_life_code, 1)
3938                         , NVL(msi.shelf_life_days, 0)
3939                         , NVL(msi.allowed_units_lookup_code, 2)
3940                         , NVL(msi.effectivity_control, 1)
3941                         , '0'
3942                         , '0'
3943                         , '0'
3944                         , '0'
3945                         , '0'
3946                         , '0'
3947                         , ''
3948                         , 'N'
3949                         , msi.inventory_item_flag
3950                         , 0
3951 				, wms_deploy.get_item_client_name(msi.inventory_item_id),
3952      --Bug No 3952081
3953      --Additional Fields for Process Convergence
3954                     NVL(msi.GRADE_CONTROL_FLAG,'N'),
3955                     NVL(msi.DEFAULT_GRADE,''),
3956                     NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
3957                     NVL(msi.EXPIRATION_ACTION_CODE,''),
3958                     NVL(msi.HOLD_DAYS,0),
3959                     NVL(msi.MATURITY_DAYS,0),
3960                     NVL(msi.RETEST_INTERVAL,0),
3961                     NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
3962                     NVL(msi.CHILD_LOT_FLAG,'N'),
3963                     NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
3964                     NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
3965                     NVL(msi.SECONDARY_UOM_CODE,''),
3966                     NVL(msi.SECONDARY_DEFAULT_IND,''),
3967                     NVL(msi.TRACKING_QUANTITY_IND,'P'),
3968                     NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
3969                     NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
3970                      FROM mtl_onhand_quantities_detail moq, mtl_system_items_vl msi -- Bug 2687570, use MOQD instead of MOQ because consigned stock is not visible in MOQ
3971                     WHERE msi.organization_id = p_org_id
3972                       AND NVL(serial_number_control_code, 1) IN (1, 2, 5, 6)
3973                       AND msi.concatenated_segments LIKE (p_item||l_append)
3974                       AND NVL(container_item_flag, 'N') = NVL(p_container_item_flag, NVL(container_item_flag, 'N'))
3975                       AND moq.subinventory_code = NVL(p_subinventory_code, moq.subinventory_code)
3976                       AND moq.locator_id = NVL(TO_NUMBER(p_locator_id), moq.locator_id)
3977                       AND moq.containerized_flag = 2
3978                       AND moq.inventory_item_id = msi.inventory_item_id
3979 	  AND moq.organization_id = msi.organization_id
3980 
3981 	  --Changes for GTIN
3982 	  UNION
3983 
3984 	            SELECT DISTINCT msi.concatenated_segments
3985                         , msi.inventory_item_id
3986                         , msi.description
3987                         , NVL(msi.revision_qty_control_code, 1)
3988                         , NVL(msi.lot_control_code, 1)
3989                         , NVL(msi.serial_number_control_code, 1)
3990                         , NVL(msi.restrict_subinventories_code, 2)
3991                         , NVL(msi.restrict_locators_code, 2)
3992                         , NVL(msi.location_control_code, 1)
3993                         , msi.primary_uom_code
3994                         , NVL(msi.inspection_required_flag, 2)
3995                         , NVL(msi.shelf_life_code, 1)
3996                         , NVL(msi.shelf_life_days, 0)
3997                         , NVL(msi.allowed_units_lookup_code, 2)
3998                         , NVL(msi.effectivity_control, 1)
3999                         , '0'
4000                         , '0'
4001                         , '0'
4002                         , '0'
4003                         , '0'
4004                         , '0'
4005                         , mcr.cross_reference
4006                         , 'N'
4007                         , msi.inventory_item_flag
4008                         , 0
4009 				, wms_deploy.get_item_client_name(msi.inventory_item_id),
4010      --Bug No 3952081
4011      --Additional Fields for Process Convergence
4012                     NVL(msi.GRADE_CONTROL_FLAG,'N'),
4013                     NVL(msi.DEFAULT_GRADE,''),
4014                     NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
4015                     NVL(msi.EXPIRATION_ACTION_CODE,''),
4016                     NVL(msi.HOLD_DAYS,0),
4017                     NVL(msi.MATURITY_DAYS,0),
4018                     NVL(msi.RETEST_INTERVAL,0),
4019                     NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4020                     NVL(msi.CHILD_LOT_FLAG,'N'),
4021                     NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
4022                     NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
4023                     NVL(msi.SECONDARY_UOM_CODE,''),
4024                     NVL(msi.SECONDARY_DEFAULT_IND,''),
4025                     NVL(msi.TRACKING_QUANTITY_IND,'P'),
4026                     NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
4027                     NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
4028 	  FROM mtl_onhand_quantities_detail moq, -- Bug 2687570, use MOQD instead of MOQ because consigned stock is not visible in MOQ
4029 	  mtl_system_items_vl msi, /* Bug 5581528 */
4030 	  mtl_cross_references mcr
4031 	  WHERE msi.organization_id = p_org_id
4032 	  AND NVL(serial_number_control_code, 1) IN (1, 2, 5, 6)
4033 	  AND NVL(container_item_flag, 'N') = NVL(p_container_item_flag, NVL(container_item_flag, 'N'))
4034 	  AND moq.subinventory_code = NVL(p_subinventory_code, moq.subinventory_code)
4035 	  AND moq.locator_id = NVL(TO_NUMBER(p_locator_id), moq.locator_id)
4036 	  AND moq.containerized_flag = 2
4037 	  AND moq.inventory_item_id = msi.inventory_item_id
4038 	  AND moq.organization_id = msi.organization_id
4039 	  AND msi.inventory_item_id   = mcr.inventory_item_id
4040 	  AND mcr.cross_reference_type = g_gtin_cross_ref_type
4041 	  AND mcr.cross_reference      LIKE l_cross_ref
4042 	  AND (mcr.organization_id     = msi.organization_id
4043 	       OR
4044 	       mcr.org_independent_flag = 'Y');
4045 
4046       END IF;
4047     ELSE
4048       OPEN x_items FOR
4049         SELECT DISTINCT concatenated_segments
4050                       , inventory_item_id
4051                       , description
4052                       , NVL(revision_qty_control_code, 1)
4053                       , NVL(lot_control_code, 1)
4054                       , NVL(serial_number_control_code, 1)
4055                       , NVL(restrict_subinventories_code, 2)
4056                       , NVL(restrict_locators_code, 2)
4057                       , NVL(location_control_code, 1)
4058                       , primary_uom_code
4059                       , NVL(inspection_required_flag, 2)
4060                       , NVL(shelf_life_code, 1)
4061                       , NVL(shelf_life_days, 0)
4062                       , NVL(allowed_units_lookup_code, 2)
4063                       , NVL(effectivity_control, 1)
4064                       , '0'
4065                       , '0'
4066                       , '0'
4067                       , '0'
4068                       , '0'
4069                       , '0'
4070                       , ''
4071                       , 'N'
4072                       , inventory_item_flag
4073                       , 0
4074 			    , wms_deploy.get_item_client_name(inventory_item_id),
4075      --Bug No 3952081
4076      --Additional Fields for Process Convergence
4077                     NVL(GRADE_CONTROL_FLAG,'N'),
4078                     NVL(DEFAULT_GRADE,''),
4079                     NVL(EXPIRATION_ACTION_INTERVAL,0),
4080                     NVL(EXPIRATION_ACTION_CODE,''),
4081                     NVL(HOLD_DAYS,0),
4082                     NVL(MATURITY_DAYS,0),
4083                     NVL(RETEST_INTERVAL,0),
4084                     NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
4085                     NVL(CHILD_LOT_FLAG,'N'),
4086                     NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
4087                     NVL(LOT_DIVISIBLE_FLAG,'Y'),
4088                     NVL(SECONDARY_UOM_CODE,''),
4089                     NVL(SECONDARY_DEFAULT_IND,''),
4090                     NVL(TRACKING_QUANTITY_IND,'P'),
4091                     NVL(DUAL_UOM_DEVIATION_HIGH,0),
4092                     NVL(DUAL_UOM_DEVIATION_LOW,0)
4093                    FROM mtl_system_items_vl /* Bug 5581528 */
4094                   WHERE organization_id = p_org_id
4095                     AND NVL(container_item_flag, 'N') = NVL(p_container_item_flag, NVL(container_item_flag, 'N'))
4096                     AND NVL(serial_number_control_code, 1) IN (1, 2, 5, 6)
4097 	AND concatenated_segments LIKE (p_item||l_append)
4098 
4099 	--Changes for GTIN
4100 	UNION
4101 
4102 	        SELECT DISTINCT msik.concatenated_segments
4103                       , msik.inventory_item_id
4104                       , msik.description
4105                       , NVL(revision_qty_control_code, 1)
4106                       , NVL(lot_control_code, 1)
4107                       , NVL(serial_number_control_code, 1)
4108                       , NVL(restrict_subinventories_code, 2)
4109                       , NVL(restrict_locators_code, 2)
4110                       , NVL(location_control_code, 1)
4111                       , primary_uom_code
4112                       , NVL(inspection_required_flag, 2)
4113                       , NVL(shelf_life_code, 1)
4114                       , NVL(shelf_life_days, 0)
4115                       , NVL(allowed_units_lookup_code, 2)
4116                       , NVL(effectivity_control, 1)
4117                       , '0'
4118                       , '0'
4119                       , '0'
4120                       , '0'
4121                       , '0'
4122                       , '0'
4123                       , mcr.cross_reference
4124                       , 'N'
4125                       , inventory_item_flag
4126                       , 0
4127 			    , wms_deploy.get_item_client_name(msik.inventory_item_id),
4128      --Bug No 3952081
4129      --Additional Fields for Process Convergence
4130                     NVL(GRADE_CONTROL_FLAG,'N'),
4131                     NVL(DEFAULT_GRADE,''),
4132                     NVL(EXPIRATION_ACTION_INTERVAL,0),
4133                     NVL(EXPIRATION_ACTION_CODE,''),
4134                     NVL(HOLD_DAYS,0),
4135                     NVL(MATURITY_DAYS,0),
4136                     NVL(RETEST_INTERVAL,0),
4137                     NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
4138                     NVL(CHILD_LOT_FLAG,'N'),
4139                     NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
4140                     NVL(LOT_DIVISIBLE_FLAG,'Y'),
4141                     NVL(SECONDARY_UOM_CODE,''),
4142                     NVL(SECONDARY_DEFAULT_IND,''),
4143                     NVL(TRACKING_QUANTITY_IND,'P'),
4144                     NVL(DUAL_UOM_DEVIATION_HIGH,0),
4145                     NVL(DUAL_UOM_DEVIATION_LOW,0)
4146 	FROM mtl_system_items_vl msik, /* Bug 5581528 */
4147 	mtl_cross_references mcr
4148 	WHERE msik.organization_id = p_org_id
4149 	AND NVL(msik.container_item_flag, 'N') = NVL(p_container_item_flag, NVL(msik.container_item_flag, 'N'))
4150 	AND NVL(msik.serial_number_control_code, 1) IN (1, 2, 5, 6)
4151 	AND msik.inventory_item_id   = mcr.inventory_item_id
4152 	AND mcr.cross_reference_type = g_gtin_cross_ref_type
4153 	AND mcr.cross_reference      LIKE l_cross_ref
4154 	AND (mcr.organization_id     = msik.organization_id
4155 	     OR
4156 	     mcr.org_independent_flag = 'Y');
4157 
4158     END IF;
4159   END get_bp_item_lov;
4160 
4161 
4162   --Bug # 2647045
4163   PROCEDURE get_cont_uom_lov(x_UOMS OUT NOCOPY t_genref,
4164 		      p_Organization_Id IN NUMBER,
4165 		      p_Inventory_Item_Id IN NUMBER,
4166 		      p_lpn_id IN NUMBER,
4167 		      p_UOM_Code IN VARCHAR2) IS
4168      l_code VARCHAR2(20):=p_UOM_Code;
4169   BEGIN
4170      IF (INSTR(l_code,'(') > 0) THEN
4171       l_code := SUBSTR(p_UOM_Code,1,INSTR(p_UOM_Code,'(')-1);
4172    END IF;
4173 
4174     OPEN x_uoms FOR
4175       SELECT DISTINCT (inv_ui_item_lovs.get_conversion_rate(wlc.uom_code,
4176 				   p_Organization_Id,
4177 				   p_Inventory_Item_Id)) uom_code_comp
4178                     , miuv.unit_of_measure
4179                     , miuv.description
4180                     , miuv.uom_class
4181                  FROM mtl_item_uoms_view miuv, wms_lpn_contents wlc
4182                 WHERE wlc.organization_id = p_organization_id
4183                   AND wlc.inventory_item_id = p_inventory_item_id
4184                   AND NVL(wlc.parent_lpn_id, 0) = NVL(p_lpn_id, NVL(wlc.parent_lpn_id, 0))
4185                   AND miuv.organization_id = wlc.organization_id
4186                   AND miuv.inventory_item_id = wlc.inventory_item_id
4187                   AND miuv.uom_code = wlc.uom_code
4188                   AND wlc.uom_code LIKE (l_code)
4189       ORDER BY inv_ui_item_lovs.conversion_order(inv_ui_item_lovs.get_conversion_rate(wlc.uom_code,
4190 				   p_Organization_Id,
4191 				   p_Inventory_Item_Id)) asc, Upper(wlc.uom_code);
4192   END get_cont_uom_lov;
4193 
4194 
4195 
4196   PROCEDURE get_all_uom_lov(x_uoms OUT NOCOPY t_genref, p_uom_code IN VARCHAR2) IS
4197   BEGIN
4198     OPEN x_uoms FOR
4199       SELECT DISTINCT uom_code
4200                     , unit_of_measure
4201                     , description
4202                     , uom_class
4203                  FROM mtl_units_of_measure
4204                 WHERE uom_code LIKE (p_uom_code);
4205   END get_all_uom_lov;
4206 
4207   --      Name: GET_INV_INSPECT_ITEM_LOV
4208   --
4209   --      Input parameters:
4210   --       p_organization_id         organization where the inspection occurs
4211   --       p_concatenated_segments   restricts output to user entered search pattern for item
4212   --       p_source                  document source type being inspected
4213   --                                 PO, INTSHIP, RMA, RECEIPT
4214   --       p_source_id               relevant document id based on p_source
4215   --                                 po_header_id, shipment_header_id, oe_order_header_id,
4216   --                                 receipt_num
4217   --
4218   --      Output parameters:
4219   --       x_items      returns LOV rows as reference cursor
4220   --
4221   --      Functions:
4222   --                      This procedure returns the items that need inspection
4223   --
4224 
4225   PROCEDURE get_inv_inspect_item_lov(x_items OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_concatenated_segments IN VARCHAR2, p_source IN VARCHAR2, p_source_id IN NUMBER) IS
4226   l_cross_ref varchar2(204);
4227   l_append varchar2(2):='';
4228   BEGIN
4229 
4230    l_cross_ref := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
4231 
4232    l_append:=wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
4233 
4234     IF (p_source IN ('PO', 'po')) THEN
4235       OPEN x_items FOR
4236         SELECT DISTINCT a.concatenated_segments
4237                       , a.inventory_item_id
4238                       , Nvl(b.item_description, a.description) -- Bug 14645109
4239                       , NVL(a.revision_qty_control_code, 1)
4240                       , NVL(a.lot_control_code, 1)
4241                       , NVL(a.serial_number_control_code, 1)
4242                       , NVL(a.restrict_subinventories_code, 2)
4243                       , NVL(a.restrict_locators_code, 2)
4244                       , NVL(a.location_control_code, 1)
4245                       , a.primary_uom_code
4246                       , NVL(a.inspection_required_flag, 2)
4247                       , NVL(a.shelf_life_code, 1)
4248                       , NVL(a.shelf_life_days, 0)
4249                       , NVL(a.allowed_units_lookup_code, 2)
4250                       , NVL(a.effectivity_control, 1)
4251                       , 0
4252                       , 0
4253                       , NVL(a.default_serial_status_id, 0)
4254                       , NVL(a.serial_status_enabled, 'N')
4255                       , NVL(a.default_lot_status_id, 0)
4256                       , NVL(a.lot_status_enabled, 'N')
4257                       , ''
4258                       , 'N'
4259                       , a.inventory_item_flag
4260                       , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('PO', p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code))
4261 		     	    , wms_deploy.get_item_client_name(a.inventory_item_id)
4262 		      , a.inventory_asset_flag --5405993: Added inventory_asset_flag and outside_processing_flag.
4263 		      , a.outside_operation_flag,
4264      --Bug No 3952081
4265      --Additional Fields for Process Convergence
4266                       NVL(a.GRADE_CONTROL_FLAG,'N'),
4267                       NVL(a.DEFAULT_GRADE,''),
4268                       NVL(a.EXPIRATION_ACTION_INTERVAL,0),
4269                       NVL(a.EXPIRATION_ACTION_CODE,''),
4270                       NVL(a.HOLD_DAYS,0),
4271                       NVL(a.MATURITY_DAYS,0),
4272                       NVL(a.RETEST_INTERVAL,0),
4273                       NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4274                       NVL(a.CHILD_LOT_FLAG,'N'),
4275                       NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
4276                       NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
4277                       NVL(a.SECONDARY_UOM_CODE,''),
4278                       NVL(a.SECONDARY_DEFAULT_IND,''),
4279                       NVL(a.TRACKING_QUANTITY_IND,'P'),
4280                       NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
4281                       NVL(a.DUAL_UOM_DEVIATION_LOW,0)
4282                    FROM mtl_system_items_vl a, rcv_transactions_v b /* Bug 5581528 */
4283                   WHERE b.to_organization_id = p_organization_id
4284                     AND b.po_header_id = p_source_id
4285                     AND b.inspection_status_code = 'NOT INSPECTED'
4286                     AND b.routing_id = 2  /* Inspection routing */
4287                     AND b.to_organization_id = a.organization_id
4288                     AND b.item_id = a.inventory_item_id
4289                     --bug5708184,in PO Source,add the condition to match with po supplier item.
4290                     AND (a.concatenated_segments LIKE (p_concatenated_segments||l_append)
4291                           or exists (select pla.vendor_product_num
4292                                     from po_lines_all pla
4293                                     where pla.po_header_id=b.po_header_id and
4294                                     pla.po_line_id=b.po_line_id and
4295                                     pla.vendor_product_num like (p_concatenated_segments)))
4296 	AND (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('PO',
4297 								 p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0
4298 
4299 	--Changes for GTIN
4300 
4301 	UNION
4302 	        SELECT DISTINCT a.concatenated_segments
4303                       , a.inventory_item_id
4304                       , nvl(b.item_description, a.description) -- Bug 14645109
4305                       , NVL(a.revision_qty_control_code, 1)
4306                       , NVL(a.lot_control_code, 1)
4307                       , NVL(a.serial_number_control_code, 1)
4308                       , NVL(a.restrict_subinventories_code, 2)
4309                       , NVL(a.restrict_locators_code, 2)
4310                       , NVL(a.location_control_code, 1)
4311                       , a.primary_uom_code
4312                       , NVL(a.inspection_required_flag, 2)
4313                       , NVL(a.shelf_life_code, 1)
4314                       , NVL(a.shelf_life_days, 0)
4315                       , NVL(a.allowed_units_lookup_code, 2)
4316                       , NVL(a.effectivity_control, 1)
4317                       , 0
4318                       , 0
4319                       , NVL(a.default_serial_status_id, 0)
4320                       , NVL(a.serial_status_enabled, 'N')
4321                       , NVL(a.default_lot_status_id, 0)
4322                       , NVL(a.lot_status_enabled, 'N')
4323                       , mcr.cross_reference
4324                       , 'N'
4325                       , a.inventory_item_flag
4326                       , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('PO', p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code))
4327 		     	    , wms_deploy.get_item_client_name(a.inventory_item_id)
4328 		      , a.inventory_asset_flag --5405993: Added inventory_asset_flag and outside_processing_flag.
4329 		      , a.outside_operation_flag,
4330      --Bug No 3952081
4331      --Additional Fields for Process Convergence
4332                       NVL(a.GRADE_CONTROL_FLAG,'N'),
4333                       NVL(a.DEFAULT_GRADE,''),
4334                       NVL(a.EXPIRATION_ACTION_INTERVAL,0),
4335                       NVL(a.EXPIRATION_ACTION_CODE,''),
4336                       NVL(a.HOLD_DAYS,0),
4337                       NVL(a.MATURITY_DAYS,0),
4338                       NVL(a.RETEST_INTERVAL,0),
4339                       NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4340                       NVL(a.CHILD_LOT_FLAG,'N'),
4341                       NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
4342                       NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
4343                       NVL(a.SECONDARY_UOM_CODE,''),
4344                       NVL(a.SECONDARY_DEFAULT_IND,''),
4345                       NVL(a.TRACKING_QUANTITY_IND,'P'),
4346                       NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
4347                       NVL(a.DUAL_UOM_DEVIATION_LOW,0)
4348 	FROM mtl_system_items_vl a, /* Bug 5581528 */
4349 	rcv_transactions_v b,
4350 	mtl_cross_references mcr
4351 	WHERE b.to_organization_id = p_organization_id
4352 	AND b.po_header_id = p_source_id
4353 	AND b.inspection_status_code = 'NOT INSPECTED'
4354 	AND b.routing_id = 2  /* Inspection routing */
4355 	AND b.to_organization_id = a.organization_id
4356 	AND b.item_id = a.inventory_item_id
4357 	AND (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('PO', p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0
4358 	AND a.inventory_item_id   = mcr.inventory_item_id
4359 	AND mcr.cross_reference_type = g_gtin_cross_ref_type
4360 	AND mcr.cross_reference      LIKE l_cross_ref
4361 	AND (mcr.organization_id     = a.organization_id
4362 	     OR
4363 	     mcr.org_independent_flag = 'Y');
4364 
4365      ELSIF (p_source IN ('INTSHIP', 'intship')) THEN
4366       OPEN x_items FOR
4367         SELECT DISTINCT a.concatenated_segments
4368                       , a.inventory_item_id
4369                       , a.description
4370                       , NVL(a.revision_qty_control_code, 1)
4371                       , NVL(a.lot_control_code, 1)
4372                       , NVL(a.serial_number_control_code, 1)
4373                       , NVL(a.restrict_subinventories_code, 2)
4374                       , NVL(a.restrict_locators_code, 2)
4375                       , NVL(a.location_control_code, 1)
4376                       , a.primary_uom_code
4377                       , NVL(a.inspection_required_flag, 2)
4378                       , NVL(a.shelf_life_code, 1)
4379                       , NVL(a.shelf_life_days, 0)
4380                       , NVL(a.allowed_units_lookup_code, 2)
4381                       , NVL(a.effectivity_control, 1)
4382                       , 0
4383                       , 0
4384                       , NVL(a.default_serial_status_id, 0)
4385                       , NVL(a.serial_status_enabled, 'N')
4386                       , NVL(a.default_lot_status_id, 0)
4387                       , NVL(a.lot_status_enabled, 'N')
4388                       , ''
4389                       , 'N'
4390                       , a.inventory_item_flag
4391                       , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('INTSHIP', p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code))
4392 		     	    , wms_deploy.get_item_client_name(a.inventory_item_id)
4393 		      , a.inventory_asset_flag --5405993: Added inventory_asset_flag and outside_processing_flag.
4394 		      , a.outside_operation_flag,
4395      --Bug No 3952081
4396      --Additional Fields for Process Convergence
4397                       NVL(a.GRADE_CONTROL_FLAG,'N'),
4398                       NVL(a.DEFAULT_GRADE,''),
4399                       NVL(a.EXPIRATION_ACTION_INTERVAL,0),
4400                       NVL(a.EXPIRATION_ACTION_CODE,''),
4401                       NVL(a.HOLD_DAYS,0),
4402                       NVL(a.MATURITY_DAYS,0),
4403                       NVL(a.RETEST_INTERVAL,0),
4404                       NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4405                       NVL(a.CHILD_LOT_FLAG,'N'),
4406                       NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
4407                       NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
4408                       NVL(a.SECONDARY_UOM_CODE,''),
4409                       NVL(a.SECONDARY_DEFAULT_IND,''),
4410                       NVL(a.TRACKING_QUANTITY_IND,'P'),
4411                       NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
4412                       NVL(a.DUAL_UOM_DEVIATION_LOW,0)
4413                    FROM mtl_system_items_vl a, rcv_transactions_v b /* Bug 5581528 */
4414                   WHERE b.to_organization_id = p_organization_id
4415                     AND b.shipment_header_id = p_source_id
4416                     AND b.receipt_source_code <> 'VENDOR'
4417                     AND b.inspection_status_code = 'NOT INSPECTED'
4418                     AND b.routing_id = 2  /* Inspection routing */
4419                     AND b.to_organization_id = a.organization_id
4420                     AND b.item_id = a.inventory_item_id
4421                     AND a.concatenated_segments LIKE (p_concatenated_segments||l_append)
4422 	AND (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('INTSHIP',
4423 								 p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0
4424 
4425 	--Changes for GTIN
4426 	UNION
4427 
4428 	        SELECT DISTINCT a.concatenated_segments
4429                       , a.inventory_item_id
4430                       , a.description
4431                       , NVL(a.revision_qty_control_code, 1)
4432                       , NVL(a.lot_control_code, 1)
4433                       , NVL(a.serial_number_control_code, 1)
4434                       , NVL(a.restrict_subinventories_code, 2)
4435                       , NVL(a.restrict_locators_code, 2)
4436                       , NVL(a.location_control_code, 1)
4437                       , a.primary_uom_code
4438                       , NVL(a.inspection_required_flag, 2)
4439                       , NVL(a.shelf_life_code, 1)
4440                       , NVL(a.shelf_life_days, 0)
4441                       , NVL(a.allowed_units_lookup_code, 2)
4442                       , NVL(a.effectivity_control, 1)
4443                       , 0
4444                       , 0
4445                       , NVL(a.default_serial_status_id, 0)
4446                       , NVL(a.serial_status_enabled, 'N')
4447                       , NVL(a.default_lot_status_id, 0)
4448                       , NVL(a.lot_status_enabled, 'N')
4449                       , mcr.cross_reference
4450                       , 'N'
4451                       , a.inventory_item_flag
4452                       , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('INTSHIP', p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code))
4453 		     	    , wms_deploy.get_item_client_name(a.inventory_item_id)
4454 		      , a.inventory_asset_flag --5405993: Added inventory_asset_flag and outside_processing_flag.
4455 		      , a.outside_operation_flag,
4456      --Bug No 3952081
4457      --Additional Fields for Process Convergence
4458                       NVL(a.GRADE_CONTROL_FLAG,'N'),
4459                       NVL(a.DEFAULT_GRADE,''),
4460                       NVL(a.EXPIRATION_ACTION_INTERVAL,0),
4461                       NVL(a.EXPIRATION_ACTION_CODE,''),
4462                       NVL(a.HOLD_DAYS,0),
4463                       NVL(a.MATURITY_DAYS,0),
4464                       NVL(a.RETEST_INTERVAL,0),
4465                       NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4466                       NVL(a.CHILD_LOT_FLAG,'N'),
4467                       NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
4468                       NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
4469                       NVL(a.SECONDARY_UOM_CODE,''),
4470                       NVL(a.SECONDARY_DEFAULT_IND,''),
4471                       NVL(a.TRACKING_QUANTITY_IND,'P'),
4472                       NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
4473                       NVL(a.DUAL_UOM_DEVIATION_LOW,0)
4474 	FROM mtl_system_items_vl a, /* Bug 5581528 */
4475 	rcv_transactions_v b,
4476 	mtl_cross_references mcr
4477 	WHERE b.to_organization_id = p_organization_id
4478 	AND b.shipment_header_id = p_source_id
4479 	AND b.receipt_source_code <> 'VENDOR'
4480 	AND b.inspection_status_code = 'NOT INSPECTED'
4481 	AND b.routing_id = 2  /* Inspection routing */
4482 	AND b.to_organization_id = a.organization_id
4483 	AND b.item_id = a.inventory_item_id
4484 	AND (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('INTSHIP',
4485 								 p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0
4486 	AND a.inventory_item_id   = mcr.inventory_item_id
4487 	AND mcr.cross_reference_type = g_gtin_cross_ref_type
4488 	AND mcr.cross_reference      LIKE l_cross_ref
4489 	AND (mcr.organization_id     = a.organization_id
4490 	     OR
4491 	     mcr.org_independent_flag = 'Y');
4492 
4493     ELSIF (p_source IN ('RMA', 'rma')) THEN
4494       OPEN x_items FOR
4495         SELECT DISTINCT a.concatenated_segments
4496                       , a.inventory_item_id
4497                       , a.description
4498                       , NVL(a.revision_qty_control_code, 1)
4499                       , NVL(a.lot_control_code, 1)
4500                       , NVL(a.serial_number_control_code, 1)
4501                       , NVL(a.restrict_subinventories_code, 2)
4502                       , NVL(a.restrict_locators_code, 2)
4503                       , NVL(a.location_control_code, 1)
4504                       , a.primary_uom_code
4505                       , NVL(a.inspection_required_flag, 2)
4506                       , NVL(a.shelf_life_code, 1)
4507                       , NVL(a.shelf_life_days, 0)
4508                       , NVL(a.allowed_units_lookup_code, 2)
4509                       , NVL(a.effectivity_control, 1)
4510                       , 0
4511                       , 0
4512                       , NVL(a.default_serial_status_id, 0)
4513                       , NVL(a.serial_status_enabled, 'N')
4514                       , NVL(a.default_lot_status_id, 0)
4515                       , NVL(a.lot_status_enabled, 'N')
4516                       , ''
4517                       , 'N'
4518                       , a.inventory_item_flag
4519                       , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('RMA', p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code))
4520 		     	    , wms_deploy.get_item_client_name(a.inventory_item_id)
4521 		      , a.inventory_asset_flag --5405993: Added inventory_asset_flag and outside_processing_flag.
4522 		      , a.outside_operation_flag,
4523      --Bug No 3952081
4524      --Additional Fields for Process Convergence
4525                       NVL(a.GRADE_CONTROL_FLAG,'N'),
4526                       NVL(a.DEFAULT_GRADE,''),
4527                       NVL(a.EXPIRATION_ACTION_INTERVAL,0),
4528                       NVL(a.EXPIRATION_ACTION_CODE,''),
4529                       NVL(a.HOLD_DAYS,0),
4530                       NVL(a.MATURITY_DAYS,0),
4531                       NVL(a.RETEST_INTERVAL,0),
4532                       NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4533                       NVL(a.CHILD_LOT_FLAG,'N'),
4534                       NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
4535                       NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
4536                       NVL(a.SECONDARY_UOM_CODE,''),
4537                       NVL(a.SECONDARY_DEFAULT_IND,''),
4538                       NVL(a.TRACKING_QUANTITY_IND,'P'),
4539                       NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
4540                       NVL(a.DUAL_UOM_DEVIATION_LOW,0)
4541                    FROM mtl_system_items_vl a, rcv_transactions_v b /* Bug 5581528 */
4542                   WHERE b.to_organization_id = p_organization_id
4543                     AND b.oe_order_header_id = p_source_id
4544                     AND b.receipt_source_code <> 'VENDOR'
4545                     AND b.inspection_status_code = 'NOT INSPECTED'
4546                     AND b.routing_id = 2  /* Inspection routing */
4547                     AND b.to_organization_id = a.organization_id
4548                     AND b.item_id = a.inventory_item_id
4549                     AND a.concatenated_segments LIKE (p_concatenated_segments||l_append)
4550 	AND (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('RMA',
4551 								 p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0
4552 
4553 	--Changes for GTIN
4554 	UNION
4555 
4556 	        SELECT DISTINCT a.concatenated_segments
4557                       , a.inventory_item_id
4558                       , a.description
4559                       , NVL(a.revision_qty_control_code, 1)
4560                       , NVL(a.lot_control_code, 1)
4561                       , NVL(a.serial_number_control_code, 1)
4562                       , NVL(a.restrict_subinventories_code, 2)
4563                       , NVL(a.restrict_locators_code, 2)
4564                       , NVL(a.location_control_code, 1)
4565                       , a.primary_uom_code
4566                       , NVL(a.inspection_required_flag, 2)
4567                       , NVL(a.shelf_life_code, 1)
4568                       , NVL(a.shelf_life_days, 0)
4569                       , NVL(a.allowed_units_lookup_code, 2)
4570                       , NVL(a.effectivity_control, 1)
4571                       , 0
4572                       , 0
4573                       , NVL(a.default_serial_status_id, 0)
4574                       , NVL(a.serial_status_enabled, 'N')
4575                       , NVL(a.default_lot_status_id, 0)
4576                       , NVL(a.lot_status_enabled, 'N')
4577                       , mcr.cross_reference
4578                       , 'N'
4579                       , a.inventory_item_flag
4580                       , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('RMA', p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code))
4581 		     	    , wms_deploy.get_item_client_name(a.inventory_item_id)
4582 		      , a.inventory_asset_flag --5405993: Added inventory_asset_flag and outside_processing_flag.
4583 		      , a.outside_operation_flag,
4584      --Bug No 3952081
4585      --Additional Fields for Process Convergence
4586                       NVL(a.GRADE_CONTROL_FLAG,'N'),
4587                       NVL(a.DEFAULT_GRADE,''),
4588                       NVL(a.EXPIRATION_ACTION_INTERVAL,0),
4589                       NVL(a.EXPIRATION_ACTION_CODE,''),
4590                       NVL(a.HOLD_DAYS,0),
4591                       NVL(a.MATURITY_DAYS,0),
4592                       NVL(a.RETEST_INTERVAL,0),
4593                       NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4594                       NVL(a.CHILD_LOT_FLAG,'N'),
4595                       NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
4596                       NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
4597                       NVL(a.SECONDARY_UOM_CODE,''),
4598                       NVL(a.SECONDARY_DEFAULT_IND,''),
4599                       NVL(a.TRACKING_QUANTITY_IND,'P'),
4600                       NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
4601                       NVL(a.DUAL_UOM_DEVIATION_LOW,0)
4602 	FROM mtl_system_items_vl a, /* Bug 5581528 */
4603 	rcv_transactions_v b,
4604 	mtl_cross_references mcr
4605 	WHERE b.to_organization_id = p_organization_id
4606 	AND b.oe_order_header_id = p_source_id
4607 	AND b.receipt_source_code <> 'VENDOR'
4608 	AND b.inspection_status_code = 'NOT INSPECTED'
4609 	AND b.routing_id = 2  /* Inspection routing */
4610 	AND b.to_organization_id = a.organization_id
4611 	AND b.item_id = a.inventory_item_id
4612 	AND (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('RMA',
4613 								 p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0
4614 	AND a.inventory_item_id   = mcr.inventory_item_id
4615 	AND mcr.cross_reference_type = g_gtin_cross_ref_type
4616 	AND mcr.cross_reference      LIKE l_cross_ref
4617 	AND (mcr.organization_id     = a.organization_id
4618 	     OR
4619 	     mcr.org_independent_flag = 'Y');
4620 
4621     ELSIF (p_source IN ('RECEIPT', 'receipt')) THEN
4622       OPEN x_items FOR
4623         SELECT DISTINCT a.concatenated_segments
4624                       , a.inventory_item_id
4625                       , Nvl(b.item_description, a.description) -- Bug 14645109
4626                       , NVL(a.revision_qty_control_code, 1)
4627                       , NVL(a.lot_control_code, 1)
4628                       , NVL(a.serial_number_control_code, 1)
4629                       , NVL(a.restrict_subinventories_code, 2)
4630                       , NVL(a.restrict_locators_code, 2)
4631                       , NVL(a.location_control_code, 1)
4632                       , a.primary_uom_code
4633                       , NVL(a.inspection_required_flag, 2)
4634                       , NVL(a.shelf_life_code, 1)
4635                       , NVL(a.shelf_life_days, 0)
4636                       , NVL(a.allowed_units_lookup_code, 2)
4637                       , NVL(a.effectivity_control, 1)
4638                       , 0
4639                       , 0
4640                       , NVL(a.default_serial_status_id, 0)
4641                       , NVL(a.serial_status_enabled, 'N')
4642                       , NVL(a.default_lot_status_id, 0)
4643                       , NVL(a.lot_status_enabled, 'N')
4644                       , ''
4645                       , 'N'
4646                       , a.inventory_item_flag
4647                       , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('RECEIPT', p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code))
4648 		     	    , wms_deploy.get_item_client_name(a.inventory_item_id)
4649 		      , a.inventory_asset_flag --5405993: Added inventory_asset_flag and outside_processing_flag.
4650 		      , a.outside_operation_flag,
4651      --Bug No 3952081
4652      --Additional Fields for Process Convergence
4653                       NVL(a.GRADE_CONTROL_FLAG,'N'),
4654                       NVL(a.DEFAULT_GRADE,''),
4655                       NVL(a.EXPIRATION_ACTION_INTERVAL,0),
4656                       NVL(a.EXPIRATION_ACTION_CODE,''),
4657                       NVL(a.HOLD_DAYS,0),
4658                       NVL(a.MATURITY_DAYS,0),
4659                       NVL(a.RETEST_INTERVAL,0),
4660                       NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4661                       NVL(a.CHILD_LOT_FLAG,'N'),
4662                       NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
4663                       NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
4664                       NVL(a.SECONDARY_UOM_CODE,''),
4665                       NVL(a.SECONDARY_DEFAULT_IND,''),
4666                       NVL(a.TRACKING_QUANTITY_IND,'P'),
4667                       NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
4668                       NVL(a.DUAL_UOM_DEVIATION_LOW,0)
4669                    FROM mtl_system_items_vl a, rcv_transactions_v b /* Bug 5581528 */
4670                   WHERE b.to_organization_id = p_organization_id
4671                     AND b.shipment_header_id = TO_CHAR(p_source_id)
4672                     AND b.inspection_status_code = 'NOT INSPECTED'
4673                     AND b.routing_id = 2  /* Inspection routing */
4674                     AND b.to_organization_id = a.organization_id
4675                     AND b.item_id = a.inventory_item_id
4676                     --bug5708184,in Receitp source,add the condition to match with po supplier item
4677                     AND (a.concatenated_segments LIKE (p_concatenated_segments||l_append)
4678                           or exists (select pla.vendor_product_num
4679                                     from po_lines_all pla
4680                                     where pla.po_header_id=b.po_header_id and
4681                                     pla.po_line_id=b.po_line_id and
4682                                     pla.vendor_product_num like (p_concatenated_segments)))
4683 	AND (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('RECEIPT',
4684 								 p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0
4685 
4686 	--Changes for GTIN
4687 	UNION
4688 
4689 	        SELECT DISTINCT a.concatenated_segments
4690                       , a.inventory_item_id
4691                       , Nvl(b.item_description, a.description) -- Bug 	14645109
4692                       , NVL(a.revision_qty_control_code, 1)
4693                       , NVL(a.lot_control_code, 1)
4694                       , NVL(a.serial_number_control_code, 1)
4695                       , NVL(a.restrict_subinventories_code, 2)
4696                       , NVL(a.restrict_locators_code, 2)
4697                       , NVL(a.location_control_code, 1)
4698                       , a.primary_uom_code
4699                       , NVL(a.inspection_required_flag, 2)
4700                       , NVL(a.shelf_life_code, 1)
4701                       , NVL(a.shelf_life_days, 0)
4702                       , NVL(a.allowed_units_lookup_code, 2)
4703                       , NVL(a.effectivity_control, 1)
4704                       , 0
4705                       , 0
4706                       , NVL(a.default_serial_status_id, 0)
4707                       , NVL(a.serial_status_enabled, 'N')
4708                       , NVL(a.default_lot_status_id, 0)
4709                       , NVL(a.lot_status_enabled, 'N')
4710                       , mcr.cross_reference
4711                       , 'N'
4712                       , a.inventory_item_flag
4713                       , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('RECEIPT', p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code))
4714 		     	    , wms_deploy.get_item_client_name(a.inventory_item_id)
4715 		      , a.inventory_asset_flag --5405993: Added inventory_asset_flag and outside_processing_flag.
4716 		      , a.outside_operation_flag,
4717      --Bug No 3952081
4718      --Additional Fields for Process Convergence
4719                       NVL(a.GRADE_CONTROL_FLAG,'N'),
4720                       NVL(a.DEFAULT_GRADE,''),
4721                       NVL(a.EXPIRATION_ACTION_INTERVAL,0),
4722                       NVL(a.EXPIRATION_ACTION_CODE,''),
4723                       NVL(a.HOLD_DAYS,0),
4724                       NVL(a.MATURITY_DAYS,0),
4725                       NVL(a.RETEST_INTERVAL,0),
4726                       NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4727                       NVL(a.CHILD_LOT_FLAG,'N'),
4728                       NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
4729                       NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
4730                       NVL(a.SECONDARY_UOM_CODE,''),
4731                       NVL(a.SECONDARY_DEFAULT_IND,''),
4732                       NVL(a.TRACKING_QUANTITY_IND,'P'),
4733                       NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
4734                       NVL(a.DUAL_UOM_DEVIATION_LOW,0)
4735 	FROM mtl_system_items_vl a, /* Bug 5581528 */
4736 	rcv_transactions_v b,
4737 	mtl_cross_references mcr
4738 	WHERE b.to_organization_id = p_organization_id
4739 	AND b.shipment_header_id = TO_CHAR(p_source_id)
4740 	AND b.inspection_status_code = 'NOT INSPECTED'
4741 	AND b.routing_id = 2  /* Inspection routing */
4742 	AND b.to_organization_id = a.organization_id
4743 	AND b.item_id = a.inventory_item_id
4744 	AND (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('RECEIPT',
4745 								 p_source_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0
4746 	AND a.inventory_item_id   = mcr.inventory_item_id
4747 	AND mcr.cross_reference_type = g_gtin_cross_ref_type
4748 	AND mcr.cross_reference      LIKE l_cross_ref
4749 	AND (mcr.organization_id     = a.organization_id
4750 	     OR
4751 	     mcr.org_independent_flag = 'Y');
4752      ELSIF (p_source IN ('REQ', 'req')) THEN
4753        --BUG 3421219: First get the shipment_num for this IR, then query
4754        --exactly the same way as for IntShip
4755        OPEN x_items FOR
4756         SELECT DISTINCT a.concatenated_segments
4757                       , a.inventory_item_id
4758                       , a.description
4759                       , NVL(a.revision_qty_control_code, 1)
4760                       , NVL(a.lot_control_code, 1)
4761                       , NVL(a.serial_number_control_code, 1)
4762                       , NVL(a.restrict_subinventories_code, 2)
4763                       , NVL(a.restrict_locators_code, 2)
4764                       , NVL(a.location_control_code, 1)
4765                       , a.primary_uom_code
4766                       , NVL(a.inspection_required_flag, 2)
4767                       , NVL(a.shelf_life_code, 1)
4768                       , NVL(a.shelf_life_days, 0)
4769                       , NVL(a.allowed_units_lookup_code, 2)
4770                       , NVL(a.effectivity_control, 1)
4771                       , 0
4772                       , 0
4773                       , NVL(a.default_serial_status_id, 0)
4774                       , NVL(a.serial_status_enabled, 'N')
4775                       , NVL(a.default_lot_status_id, 0)
4776                       , NVL(a.lot_status_enabled, 'N')
4777                       , ''
4778                       , 'N'
4779                       , a.inventory_item_flag
4780                       , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('INTSHIP', shipment.shipment_header_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code))
4781 		     	    , wms_deploy.get_item_client_name(a.inventory_item_id)
4782 		      , a.inventory_asset_flag --5405993: Added inventory_asset_flag and outside_processing_flag.
4783 		      , a.outside_operation_flag,
4784      --Bug No 3952081
4785      --Additional Fields for Process Convergence
4786                       NVL(a.GRADE_CONTROL_FLAG,'N'),
4787                       NVL(a.DEFAULT_GRADE,''),
4788                       NVL(a.EXPIRATION_ACTION_INTERVAL,0),
4789                       NVL(a.EXPIRATION_ACTION_CODE,''),
4790                       NVL(a.HOLD_DAYS,0),
4791                       NVL(a.MATURITY_DAYS,0),
4792                       NVL(a.RETEST_INTERVAL,0),
4793                       NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4794                       NVL(a.CHILD_LOT_FLAG,'N'),
4795                       NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
4796                       NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
4797                       NVL(a.SECONDARY_UOM_CODE,''),
4798                       NVL(a.SECONDARY_DEFAULT_IND,''),
4799                       NVL(a.TRACKING_QUANTITY_IND,'P'),
4800                       NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
4801                       NVL(a.DUAL_UOM_DEVIATION_LOW,0)
4802 	             FROM mtl_system_items_vl a, /* Bug 5581528 */
4803 	                  rcv_transactions_v b,
4804 	                  (SELECT DISTINCT rsl.shipment_header_id
4805 			   FROM   po_requisition_lines pol,
4806 			          rcv_shipment_lines rsl
4807 			   WHERE  pol.requisition_header_id = p_source_id
4808 			   AND    pol.requisition_line_id = rsl.requisition_line_id
4809 			   ) shipment
4810 	           WHERE b.to_organization_id = p_organization_id
4811 	            AND b.shipment_header_id = shipment.shipment_header_id
4812                     AND b.receipt_source_code <> 'VENDOR'
4813                     AND b.inspection_status_code = 'NOT INSPECTED'
4814                     AND b.routing_id = 2  /* Inspection routing */
4815                     AND b.to_organization_id = a.organization_id
4816                     AND b.item_id = a.inventory_item_id
4817                     AND a.concatenated_segments LIKE (p_concatenated_segments||l_append)
4818 	AND (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('INTSHIP',
4819 								 shipment.shipment_header_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0
4820 
4821 	--Changes for GTIN
4822 	UNION
4823 
4824 	        SELECT DISTINCT a.concatenated_segments
4825                       , a.inventory_item_id
4826                       , a.description
4827                       , NVL(a.revision_qty_control_code, 1)
4828                       , NVL(a.lot_control_code, 1)
4829                       , NVL(a.serial_number_control_code, 1)
4830                       , NVL(a.restrict_subinventories_code, 2)
4831                       , NVL(a.restrict_locators_code, 2)
4832                       , NVL(a.location_control_code, 1)
4833                       , a.primary_uom_code
4834                       , NVL(a.inspection_required_flag, 2)
4835                       , NVL(a.shelf_life_code, 1)
4836                       , NVL(a.shelf_life_days, 0)
4837                       , NVL(a.allowed_units_lookup_code, 2)
4838                       , NVL(a.effectivity_control, 1)
4839                       , 0
4840                       , 0
4841                       , NVL(a.default_serial_status_id, 0)
4842                       , NVL(a.serial_status_enabled, 'N')
4843                       , NVL(a.default_lot_status_id, 0)
4844                       , NVL(a.lot_status_enabled, 'N')
4845                       , mcr.cross_reference
4846                       , 'N'
4847                       , a.inventory_item_flag
4848                       , (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('INTSHIP', shipment.shipment_header_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code))
4849 		     	    , wms_deploy.get_item_client_name(a.inventory_item_id)
4850 		      , a.inventory_asset_flag --5405993: Added inventory_asset_flag and outside_processing_flag.
4851 		      , a.outside_operation_flag,
4852      --Bug No 3952081
4853      --Additional Fields for Process Convergence
4854                       NVL(a.GRADE_CONTROL_FLAG,'N'),
4855                       NVL(a.DEFAULT_GRADE,''),
4856                       NVL(a.EXPIRATION_ACTION_INTERVAL,0),
4857                       NVL(a.EXPIRATION_ACTION_CODE,''),
4858                       NVL(a.HOLD_DAYS,0),
4859                       NVL(a.MATURITY_DAYS,0),
4860                       NVL(a.RETEST_INTERVAL,0),
4861                       NVL(a.COPY_LOT_ATTRIBUTE_FLAG,'N'),
4862                       NVL(a.CHILD_LOT_FLAG,'N'),
4863                       NVL(a.CHILD_LOT_VALIDATION_FLAG,'N'),
4864                       NVL(a.LOT_DIVISIBLE_FLAG,'Y'),
4865                       NVL(a.SECONDARY_UOM_CODE,''),
4866                       NVL(a.SECONDARY_DEFAULT_IND,''),
4867                       NVL(a.TRACKING_QUANTITY_IND,'P'),
4868                       NVL(a.DUAL_UOM_DEVIATION_HIGH,0),
4869                       NVL(a.DUAL_UOM_DEVIATION_LOW,0)
4870 	FROM mtl_system_items_vl a, /* Bug 5581528 */
4871 	rcv_transactions_v b,
4872 	mtl_cross_references mcr,
4873 	(SELECT DISTINCT rsl.shipment_header_id
4874 	 FROM   po_requisition_lines pol,
4875 	 rcv_shipment_lines rsl
4876 	 WHERE  pol.requisition_header_id = p_source_id
4877 	 AND    pol.requisition_line_id = rsl.requisition_line_id
4878 	 ) shipment
4879 	WHERE b.to_organization_id = p_organization_id
4880 	AND b.shipment_header_id = shipment.shipment_header_id
4881 	AND b.receipt_source_code <> 'VENDOR'
4882 	AND b.inspection_status_code = 'NOT INSPECTED'
4883 	AND b.routing_id = 2  /* Inspection routing */
4884 	AND b.to_organization_id = a.organization_id
4885 	AND b.item_id = a.inventory_item_id
4886 	AND (inv_rcv_std_inspect_apis.get_inspection_qty_wrapper('INTSHIP',
4887 								 shipment.shipment_header_id, NULL, NULL, p_organization_id, a.inventory_item_id, a.primary_uom_code)) > 0
4888 	AND a.inventory_item_id   = mcr.inventory_item_id
4889 	AND mcr.cross_reference_type = g_gtin_cross_ref_type
4890 	AND mcr.cross_reference      LIKE l_cross_ref
4891 	AND (mcr.organization_id     = a.organization_id
4892 	     OR
4893 	     mcr.org_independent_flag = 'Y');
4894     END IF;
4895   END get_inv_inspect_item_lov;
4896 
4897   --      Name: GET_INV_INSPECT_REVISION_LOV
4898   --
4899   --      Input parameters:
4900   --       p_Organization_Id   which restricts LOV SQL to current org
4901   --       p_Inventory_Item_Id restrict LOV for a given item
4902   --       p_source                  document source type being inspected
4903   --                                 PO, INTSHIP, RMA, RECEIPT
4904   --       p_source_id               relevant document id based on p_source
4905   --                                 po_header_id, shipment_header_id, oe_order_header_id,
4906   --                                 receipt_num
4907   --       p_Revision          which restricts LOV SQL to the user input text
4908   --                                e.g.  A101%
4909   --
4910   --      Output parameters:
4911   --       x_Revs      returns LOV rows as reference cursor
4912   --
4913   --      Functions: This procedure returns LOV rows for a given org, item and
4914   --                 user input text
4915   --
4916   --
4917   --
4918 
4919   PROCEDURE get_inv_inspect_revision_lov(x_revs OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_inventory_item_id IN NUMBER, p_source IN VARCHAR2, p_source_id IN NUMBER, p_revision IN VARCHAR2) IS
4920   BEGIN
4921     IF (p_source IN ('PO', 'po')) THEN
4922       OPEN x_revs FOR
4923         SELECT DISTINCT a.revision
4924                       , a.effectivity_date
4925                       , NVL(a.description, '')
4926                    FROM mtl_item_revisions a, rcv_transactions_v b
4927                   WHERE b.to_organization_id = p_organization_id
4928                     AND b.item_id = p_inventory_item_id
4929                     AND b.po_header_id = p_source_id
4930                     AND b.inspection_status_code = 'NOT INSPECTED'
4931                     AND b.routing_id = 2  /* Inspection routing */
4932                     AND a.organization_id = b.to_organization_id
4933                     AND a.inventory_item_id = b.item_id
4934                     AND a.revision = b.item_revision
4935                     AND a.revision LIKE (p_revision);
4936     ELSIF (p_source IN ('INTSHIP', 'intship', 'REQ', 'req')) THEN
4937       OPEN x_revs FOR
4938         SELECT DISTINCT a.revision
4939                       , a.effectivity_date
4940                       , NVL(a.description, '')
4941                    FROM mtl_item_revisions a, rcv_transactions_v b
4942                   WHERE b.to_organization_id = p_organization_id
4943                     AND b.item_id = p_inventory_item_id
4944                     AND b.receipt_source_code <> 'VENDOR'
4945                     AND b.shipment_header_id = p_source_id
4946                     AND b.inspection_status_code = 'NOT INSPECTED'
4947                     AND b.routing_id = 2  /* Inspection routing */
4948                     AND a.organization_id = b.to_organization_id
4949                     AND a.inventory_item_id = b.item_id
4950                     AND a.revision = b.item_revision
4951                     AND a.revision LIKE (p_revision);
4952     ELSIF (p_source IN ('RMA', 'rma')) THEN
4953       OPEN x_revs FOR
4954         SELECT DISTINCT a.revision
4955                       , a.effectivity_date
4956                       , NVL(a.description, '')
4957                    FROM mtl_item_revisions a, rcv_transactions_v b
4958                   WHERE b.to_organization_id = p_organization_id
4959                     AND b.item_id = p_inventory_item_id
4960                     AND b.receipt_source_code <> 'VENDOR'
4961                     AND b.oe_order_header_id = p_source_id
4962                     AND b.inspection_status_code = 'NOT INSPECTED'
4963                     AND b.routing_id = 2  /* Inspection routing */
4964                     AND a.organization_id = b.to_organization_id
4965                     AND a.inventory_item_id = b.item_id
4966                     AND a.revision = b.item_revision
4967                     AND a.revision LIKE (p_revision);
4968     ELSIF (p_source IN ('RECEIPT', 'receipt')) THEN
4969       OPEN x_revs FOR
4970         SELECT DISTINCT a.revision
4971                       , a.effectivity_date
4972                       , NVL(a.description, '')
4973                    FROM mtl_item_revisions a, rcv_transactions_v b
4974                   WHERE b.to_organization_id = p_organization_id
4975                     AND b.item_id = p_inventory_item_id
4976                     AND b.shipment_header_id = TO_CHAR(p_source_id)
4977                     AND b.inspection_status_code = 'NOT INSPECTED'
4978                     AND b.routing_id = 2  /* Inspection routing */
4979                     AND a.organization_id = b.to_organization_id
4980                     AND a.inventory_item_id = b.item_id
4981                     AND a.revision = b.item_revision
4982                     AND a.revision LIKE (p_revision);
4983     END IF;
4984   END get_inv_inspect_revision_lov;
4985 
4986   PROCEDURE get_cgupdate_item_lov(x_items OUT NOCOPY t_genref, p_org_id IN NUMBER, p_lpn_id IN NUMBER, p_item IN VARCHAR2) IS
4987   l_cross_ref varchar2(204);
4988   l_append varchar2(2):='';
4989   BEGIN
4990 
4991    l_cross_ref := lpad(Rtrim(p_item, '%'), g_gtin_code_length, '00000000000000');
4992 
4993    l_append:=wms_deploy.get_item_suffix_for_lov(p_item);
4994 
4995     IF p_lpn_id IS NULL THEN
4996       OPEN x_items FOR
4997         SELECT DISTINCT msi.concatenated_segments concatenated_segments
4998                       , moq.inventory_item_id
4999                       , msi.description
5000                       , NVL(msi.revision_qty_control_code, 1)
5001                       , NVL(msi.lot_control_code, 1)
5002                       , NVL(msi.serial_number_control_code, 1)
5003                       , '0'
5004                       , '0'
5005                       , '0'
5006                       , msi.primary_uom_code
5007                       , '0'
5008                       , NVL(shelf_life_code, 1)
5009                       , '0'
5010                       , '0'
5011                       , '0'
5012                       , '0'
5013                       , '0'
5014                       , NVL(msi.default_serial_status_id, 0)
5015                       , NVL(msi.serial_status_enabled, 'N')
5016                       , NVL(msi.default_lot_status_id, 0)
5017                       , NVL(msi.lot_status_enabled, 'N')
5018                       , ''
5019                       , 'N'
5020                       , msi.inventory_item_flag
5021                       , 0
5022 			    , wms_deploy.get_item_client_name(moq.inventory_item_id),
5023      --Bug No 3952081
5024      --Additional Fields for Process Convergence
5025                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
5026                       NVL(msi.DEFAULT_GRADE,''),
5027                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
5028                       NVL(msi.EXPIRATION_ACTION_CODE,''),
5029                       NVL(msi.HOLD_DAYS,0),
5030                       NVL(msi.MATURITY_DAYS,0),
5031                       NVL(msi.RETEST_INTERVAL,0),
5032                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5033                       NVL(msi.CHILD_LOT_FLAG,'N'),
5034                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
5035                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
5036                       NVL(msi.SECONDARY_UOM_CODE,''),
5037                       NVL(msi.SECONDARY_DEFAULT_IND,''),
5038                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
5039                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
5040                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
5041                   FROM mtl_onhand_quantities_detail moq, mtl_system_items_vl msi -- Bug 2687570, use MOQD instead of MOQ because consigned stock is not visible in MOQ
5042                   WHERE moq.containerized_flag = 2
5043                     AND moq.organization_id = p_org_id
5044                     AND moq.inventory_item_id = msi.inventory_item_id
5045                     AND msi.concatenated_segments LIKE (p_item||l_append)
5046 	AND msi.organization_id = p_org_id
5047 
5048 	--Changes for GTIN
5049 	UNION
5050 	        SELECT DISTINCT msi.concatenated_segments concatenated_segments
5051                       , moq.inventory_item_id
5052                       , msi.description
5053                       , NVL(msi.revision_qty_control_code, 1)
5054                       , NVL(msi.lot_control_code, 1)
5055                       , NVL(msi.serial_number_control_code, 1)
5056                       , '0'
5057                       , '0'
5058                       , '0'
5059                       , msi.primary_uom_code
5060                       , '0'
5061                       , NVL(shelf_life_code, 1)
5062                       , '0'
5063                       , '0'
5064                       , '0'
5065                       , '0'
5066                       , '0'
5067                       , NVL(msi.default_serial_status_id, 0)
5068                       , NVL(msi.serial_status_enabled, 'N')
5069                       , NVL(msi.default_lot_status_id, 0)
5070                       , NVL(msi.lot_status_enabled, 'N')
5071                       , mcr.cross_reference
5072                       , 'N'
5073                       , msi.inventory_item_flag
5074                       , 0
5075 			    , wms_deploy.get_item_client_name(moq.inventory_item_id),
5076      --Bug No 3952081
5077      --Additional Fields for Process Convergence
5078                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
5079                       NVL(msi.DEFAULT_GRADE,''),
5080                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
5081                       NVL(msi.EXPIRATION_ACTION_CODE,''),
5082                       NVL(msi.HOLD_DAYS,0),
5083                       NVL(msi.MATURITY_DAYS,0),
5084                       NVL(msi.RETEST_INTERVAL,0),
5085                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5086                       NVL(msi.CHILD_LOT_FLAG,'N'),
5087                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
5088                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
5089                       NVL(msi.SECONDARY_UOM_CODE,''),
5090                       NVL(msi.SECONDARY_DEFAULT_IND,''),
5091                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
5092                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
5093                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
5094 	FROM mtl_onhand_quantities_detail moq, -- Bug 2687570, use MOQD instead of MOQ because consigned stock is not visible in MOQ
5095 	mtl_system_items_vl msi, /* Bug 5581528 */
5096 	mtl_cross_references mcr
5097 	WHERE moq.containerized_flag = 2
5098 	AND moq.organization_id = p_org_id
5099 	AND moq.inventory_item_id = msi.inventory_item_id
5100 	AND msi.organization_id = p_org_id
5101 	AND msi.inventory_item_id   = mcr.inventory_item_id
5102 	AND mcr.cross_reference_type = g_gtin_cross_ref_type
5103 	AND mcr.cross_reference      LIKE l_cross_ref
5104 	AND (mcr.organization_id     = msi.organization_id
5105 	     OR
5106 	     mcr.org_independent_flag = 'Y')
5107 
5108 	ORDER BY concatenated_segments;
5109      ELSE
5110       OPEN x_items FOR
5111         SELECT DISTINCT msi.concatenated_segments concatenated_segments
5112                       , wlc.inventory_item_id
5113                       , msi.description
5114                       , NVL(msi.revision_qty_control_code, 1)
5115                       , NVL(msi.lot_control_code, 1)
5116                       , NVL(msi.serial_number_control_code, 1)
5117                       , '0'
5118                       , '0'
5119                       , '0'
5120                       , msi.primary_uom_code
5121                       , '0'
5122                       , NVL(shelf_life_code, 1)
5123                       , '0'
5124                       , '0'
5125                       , '0'
5126                       , '0'
5127                       , '0'
5128                       , NVL(msi.default_serial_status_id, 0)
5129                       , NVL(msi.serial_status_enabled, 'N')
5130                       , NVL(msi.default_lot_status_id, 0)
5131                       , NVL(msi.lot_status_enabled, 'N')
5132                       , ''
5133                       , 'N'
5134                       , msi.inventory_item_flag
5135                       , 0
5136 			    , wms_deploy.get_item_client_name(wlc.inventory_item_id),
5137      --Bug No 3952081
5138      --Additional Fields for Process Convergence
5139                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
5140                       NVL(msi.DEFAULT_GRADE,''),
5141                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
5142                       NVL(msi.EXPIRATION_ACTION_CODE,''),
5143                       NVL(msi.HOLD_DAYS,0),
5144                       NVL(msi.MATURITY_DAYS,0),
5145                       NVL(msi.RETEST_INTERVAL,0),
5146                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5147                       NVL(msi.CHILD_LOT_FLAG,'N'),
5148                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
5149                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
5150                       NVL(msi.SECONDARY_UOM_CODE,''),
5151                       NVL(msi.SECONDARY_DEFAULT_IND,''),
5152                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
5153                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
5154                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
5155                    -- bug 5172851, wms_lpn_contents_v is replaced with
5156                    --              wms_lpn_contents for performance reason
5157                    FROM mtl_system_items_vl msi, wms_lpn_contents wlc /* Bug 5581528 */
5158                   WHERE msi.concatenated_segments LIKE (p_item||l_append)
5159                     AND msi.inventory_item_id = wlc.inventory_item_id
5160                     AND msi.organization_id = p_org_id
5161 	AND wlc.parent_lpn_id = p_lpn_id
5162 
5163 	--Changes for GTIN
5164 	UNION
5165 
5166 	        SELECT DISTINCT msi.concatenated_segments concatenated_segments
5167                       , wlc.inventory_item_id
5168                       , msi.description
5169                       , NVL(msi.revision_qty_control_code, 1)
5170                       , NVL(msi.lot_control_code, 1)
5171                       , NVL(msi.serial_number_control_code, 1)
5172                       , '0'
5173                       , '0'
5174                       , '0'
5175                       , msi.primary_uom_code
5176                       , '0'
5177                       , NVL(shelf_life_code, 1)
5178                       , '0'
5179                       , '0'
5180                       , '0'
5181                       , '0'
5182                       , '0'
5183                       , NVL(msi.default_serial_status_id, 0)
5184                       , NVL(msi.serial_status_enabled, 'N')
5185                       , NVL(msi.default_lot_status_id, 0)
5186                       , NVL(msi.lot_status_enabled, 'N')
5187                       , mcr.cross_reference
5188                       , 'N'
5189                       , msi.inventory_item_flag
5190                       , 0
5191 			    , wms_deploy.get_item_client_name(wlc.inventory_item_id),
5192      --Bug No 3952081
5193      --Additional Fields for Process Convergence
5194                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
5195                       NVL(msi.DEFAULT_GRADE,''),
5196                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
5197                       NVL(msi.EXPIRATION_ACTION_CODE,''),
5198                       NVL(msi.HOLD_DAYS,0),
5199                       NVL(msi.MATURITY_DAYS,0),
5200                       NVL(msi.RETEST_INTERVAL,0),
5201                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5202                       NVL(msi.CHILD_LOT_FLAG,'N'),
5203                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
5204                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
5205                       NVL(msi.SECONDARY_UOM_CODE,''),
5206                       NVL(msi.SECONDARY_DEFAULT_IND,''),
5207                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
5208                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
5209                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
5210 	FROM mtl_system_items_vl msi, /* Bug 5581528 */
5211         -- bug 5172851, wms_lpn_contents_v is replaced with
5212         --              wms_lpn_contents for performance reason
5213 	wms_lpn_contents wlc,
5214 	mtl_cross_references mcr
5215 	WHERE msi.inventory_item_id = wlc.inventory_item_id
5216 	AND msi.organization_id = p_org_id
5217 	AND wlc.parent_lpn_id = p_lpn_id
5218 	AND msi.inventory_item_id   = mcr.inventory_item_id
5219 	AND mcr.cross_reference_type = g_gtin_cross_ref_type
5220 	AND mcr.cross_reference      LIKE l_cross_ref
5221 	AND (mcr.organization_id     = msi.organization_id
5222 	     OR
5223 	     mcr.org_independent_flag = 'Y')
5224 	ORDER BY concatenated_segments;
5225     END IF;
5226   END get_cgupdate_item_lov;
5227 
5228   PROCEDURE get_content_revision_lov(x_revs OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_inventory_item_id IN VARCHAR2, p_lpn_id IN VARCHAR2, p_revision IN VARCHAR2) IS
5229   BEGIN
5230     OPEN x_revs FOR
5231       SELECT DISTINCT wlc.revision
5232                     , mir.effectivity_date
5233                     , NVL(mir.description, '')
5234                  FROM mtl_item_revisions mir, wms_lpn_contents_v wlc
5235                 WHERE wlc.organization_id = p_organization_id
5236                   AND wlc.inventory_item_id = TO_NUMBER(p_inventory_item_id)
5237                   AND NVL(wlc.parent_lpn_id, '0') = NVL(TO_NUMBER(p_lpn_id), NVL(wlc.parent_lpn_id, '0'))
5238                   AND mir.organization_id = wlc.organization_id
5239                   AND mir.inventory_item_id = wlc.inventory_item_id
5240                   AND mir.revision = wlc.revision
5241                   AND wlc.revision LIKE (p_revision);
5242   END get_content_revision_lov;
5243 
5244   PROCEDURE get_system_item_lov(x_items OUT NOCOPY t_genref, p_org_id IN NUMBER, p_item IN VARCHAR2) IS
5245   l_cross_ref varchar2(204);
5246   l_append varchar2(2):='';
5247   BEGIN
5248 
5249    l_cross_ref := lpad(Rtrim(p_item, '%'), g_gtin_code_length, '00000000000000');
5250 
5251    l_append:=wms_deploy.get_item_suffix_for_lov(p_item);
5252 
5253     OPEN x_items FOR
5254       SELECT DISTINCT concatenated_segments
5255                     , inventory_item_id
5256                     , description
5257                     , NVL(revision_qty_control_code, 1)
5258                     , NVL(lot_control_code, 1)
5259                     , NVL(serial_number_control_code, 1)
5260                     , NVL(restrict_subinventories_code, 2)
5261                     , NVL(restrict_locators_code, 2)
5262                     , NVL(location_control_code, 1)
5263                     , primary_uom_code
5264                     , NVL(inspection_required_flag, 2)
5265                     , NVL(shelf_life_code, 1)
5266                     , NVL(shelf_life_days, 0)
5267                     , NVL(allowed_units_lookup_code, 2)
5268                     , NVL(effectivity_control, 1)
5269                     , '0'
5270                     , '0'
5271                     , '0'
5272                     , '0'
5273                     , '0'
5274                     , '0'
5275                     , ''
5276                     , 'N'
5277                     , inventory_item_flag
5278                     , 0
5279 			  , wms_deploy.get_item_client_name(inventory_item_id),
5280      --Bug No 3952081
5281      --Additional Fields for Process Convergence
5282                       NVL(GRADE_CONTROL_FLAG,'N'),
5283                       NVL(DEFAULT_GRADE,''),
5284                       NVL(EXPIRATION_ACTION_INTERVAL,0),
5285                       NVL(EXPIRATION_ACTION_CODE,''),
5286                       NVL(HOLD_DAYS,0),
5287                       NVL(MATURITY_DAYS,0),
5288                       NVL(RETEST_INTERVAL,0),
5289                       NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
5290                       NVL(CHILD_LOT_FLAG,'N'),
5291                       NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
5292                       NVL(LOT_DIVISIBLE_FLAG,'Y'),
5293                       NVL(SECONDARY_UOM_CODE,''),
5294                       NVL(SECONDARY_DEFAULT_IND,''),
5295                       NVL(TRACKING_QUANTITY_IND,'P'),
5296                       NVL(DUAL_UOM_DEVIATION_HIGH,0),
5297                       NVL(DUAL_UOM_DEVIATION_LOW,0)
5298                  FROM mtl_system_items_vl /* Bug 5581528 */
5299                 WHERE organization_id = p_org_id
5300       AND concatenated_segments LIKE (p_item||l_append)
5301 
5302       --Changes for GTIN
5303       UNION
5304 
5305             SELECT DISTINCT msik.concatenated_segments
5306                     , msik.inventory_item_id
5307                     , msik.description
5308                     , NVL(revision_qty_control_code, 1)
5309                     , NVL(lot_control_code, 1)
5310                     , NVL(serial_number_control_code, 1)
5311                     , NVL(restrict_subinventories_code, 2)
5312                     , NVL(restrict_locators_code, 2)
5313                     , NVL(location_control_code, 1)
5314                     , primary_uom_code
5315                     , NVL(inspection_required_flag, 2)
5316                     , NVL(shelf_life_code, 1)
5317                     , NVL(shelf_life_days, 0)
5318                     , NVL(allowed_units_lookup_code, 2)
5319                     , NVL(effectivity_control, 1)
5320                     , '0'
5321                     , '0'
5322                     , '0'
5323                     , '0'
5324                     , '0'
5325                     , '0'
5326                     , mcr.cross_reference
5327                     , 'N'
5328                     , inventory_item_flag
5329                     , 0
5330 			  , wms_deploy.get_item_client_name(msik.inventory_item_id),
5331      --Bug No 3952081
5332      --Additional Fields for Process Convergence
5333                       NVL(GRADE_CONTROL_FLAG,'N'),
5334                       NVL(DEFAULT_GRADE,''),
5335                       NVL(EXPIRATION_ACTION_INTERVAL,0),
5336                       NVL(EXPIRATION_ACTION_CODE,''),
5337                       NVL(HOLD_DAYS,0),
5338                       NVL(MATURITY_DAYS,0),
5339                       NVL(RETEST_INTERVAL,0),
5340                       NVL(COPY_LOT_ATTRIBUTE_FLAG,'N'),
5341                       NVL(CHILD_LOT_FLAG,'N'),
5342                       NVL(CHILD_LOT_VALIDATION_FLAG,'N'),
5343                       NVL(LOT_DIVISIBLE_FLAG,'Y'),
5344                       NVL(SECONDARY_UOM_CODE,''),
5345                       NVL(SECONDARY_DEFAULT_IND,''),
5346                       NVL(TRACKING_QUANTITY_IND,'P'),
5347                       NVL(DUAL_UOM_DEVIATION_HIGH,0),
5348                       NVL(DUAL_UOM_DEVIATION_LOW,0)
5349       FROM mtl_system_items_vl msik, /* Bug 5581528 */
5350       mtl_cross_references mcr
5351       WHERE msik.organization_id = p_org_id
5352       AND msik.inventory_item_id   = mcr.inventory_item_id
5353       AND mcr.cross_reference_type = g_gtin_cross_ref_type
5354       AND mcr.cross_reference      LIKE l_cross_ref
5355       AND (mcr.organization_id     = msik.organization_id
5356 	   OR
5357 	   mcr.org_independent_flag = 'Y');
5358   END get_system_item_lov;
5359 
5360   PROCEDURE get_serial_item_lov(x_items OUT NOCOPY t_genref, p_org_id IN NUMBER, p_serial IN VARCHAR2, p_item IN VARCHAR2) IS
5361   l_cross_ref varchar2(204);
5362   l_append varchar2(2):='';
5363   BEGIN
5364 
5365    l_cross_ref := lpad(Rtrim(p_item, '%'), g_gtin_code_length, '00000000000000');
5366 
5367    l_append:=wms_deploy.get_item_suffix_for_lov(p_item);
5368 
5369     OPEN x_items FOR
5370       SELECT DISTINCT msi.concatenated_segments
5371                     , msi.inventory_item_id
5372                     , msi.description
5373                     , NVL(msi.revision_qty_control_code, 1)
5374                     , NVL(msi.lot_control_code, 1)
5375                     , NVL(msi.serial_number_control_code, 1)
5376                     , NVL(msi.restrict_subinventories_code, 2)
5377                     , NVL(msi.restrict_locators_code, 2)
5378                     , NVL(msi.location_control_code, 1)
5379                     , msi.primary_uom_code
5380                     , NVL(msi.inspection_required_flag, 2)
5381                     , NVL(msi.shelf_life_code, 1)
5382                     , NVL(msi.shelf_life_days, 0)
5383                     , NVL(msi.allowed_units_lookup_code, 2)
5384                     , NVL(msi.effectivity_control, 1)
5385                     , '0'
5386                     , '0'
5387                     , '0'
5388                     , '0'
5389                     , '0'
5390                     , '0'
5391                     , ''
5392                     , 'N'
5393                     , msi.inventory_item_flag
5394                     , 0
5395 			  , wms_deploy.get_item_client_name(msi.inventory_item_id),
5396      --Bug No 3952081
5397      --Additional Fields for Process Convergence
5398                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
5399                       NVL(msi.DEFAULT_GRADE,''),
5400                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
5401                       NVL(msi.EXPIRATION_ACTION_CODE,''),
5402                       NVL(msi.HOLD_DAYS,0),
5403                       NVL(msi.MATURITY_DAYS,0),
5404                       NVL(msi.RETEST_INTERVAL,0),
5405                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5406                       NVL(msi.CHILD_LOT_FLAG,'N'),
5407                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
5408                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
5409                       NVL(msi.SECONDARY_UOM_CODE,''),
5410                       NVL(msi.SECONDARY_DEFAULT_IND,''),
5411                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
5412                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
5413                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
5414                  FROM mtl_serial_numbers msn, mtl_system_items_vl msi /* Bug 5581528 */
5415                 WHERE msn.current_organization_id = p_org_id
5416                   AND msn.serial_number = p_serial
5417                   AND msn.inventory_item_id = msi.inventory_item_id
5418                   AND msi.organization_id = msn.current_organization_id
5419       AND msi.concatenated_segments LIKE (p_item||l_append)
5420 
5421       --Changes for GTIN
5422       UNION
5423 
5424             SELECT DISTINCT msi.concatenated_segments
5425                     , msi.inventory_item_id
5426                     , msi.description
5427                     , NVL(msi.revision_qty_control_code, 1)
5428                     , NVL(msi.lot_control_code, 1)
5429                     , NVL(msi.serial_number_control_code, 1)
5430                     , NVL(msi.restrict_subinventories_code, 2)
5431                     , NVL(msi.restrict_locators_code, 2)
5432                     , NVL(msi.location_control_code, 1)
5433                     , msi.primary_uom_code
5434                     , NVL(msi.inspection_required_flag, 2)
5435                     , NVL(msi.shelf_life_code, 1)
5436                     , NVL(msi.shelf_life_days, 0)
5437                     , NVL(msi.allowed_units_lookup_code, 2)
5438                     , NVL(msi.effectivity_control, 1)
5439                     , '0'
5440                     , '0'
5441                     , '0'
5442                     , '0'
5443                     , '0'
5444                     , '0'
5445                     , mcr.cross_reference
5446                     , 'N'
5447                     , msi.inventory_item_flag
5448                     , 0
5449 			  , wms_deploy.get_item_client_name(msi.inventory_item_id),
5450      --Bug No 3952081
5451      --Additional Fields for Process Convergence
5452                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
5453                       NVL(msi.DEFAULT_GRADE,''),
5454                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
5455                       NVL(msi.EXPIRATION_ACTION_CODE,''),
5456                       NVL(msi.HOLD_DAYS,0),
5457                       NVL(msi.MATURITY_DAYS,0),
5458                       NVL(msi.RETEST_INTERVAL,0),
5459                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5460                       NVL(msi.CHILD_LOT_FLAG,'N'),
5461                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
5462                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
5463                       NVL(msi.SECONDARY_UOM_CODE,''),
5464                       NVL(msi.SECONDARY_DEFAULT_IND,''),
5465                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
5466                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
5467                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
5468       FROM mtl_serial_numbers msn,
5469       mtl_system_items_vl msi, /* Bug 5581528 */
5470       mtl_cross_references mcr
5471       WHERE msn.current_organization_id = p_org_id
5472       AND msn.serial_number = p_serial
5473       AND msn.inventory_item_id = msi.inventory_item_id
5474       AND msi.organization_id = msn.current_organization_id
5475       AND msi.inventory_item_id   = mcr.inventory_item_id
5476       AND mcr.cross_reference_type = g_gtin_cross_ref_type
5477       AND mcr.cross_reference      LIKE l_cross_ref
5478       AND (mcr.organization_id     = msi.organization_id
5479 	   OR
5480 	   mcr.org_independent_flag = 'Y');
5481 
5482   END get_serial_item_lov;
5483 
5484   --"Returns"
5485   PROCEDURE get_return_items_lov(x_items OUT NOCOPY t_genref, p_org_id IN NUMBER, p_lpn_id IN NUMBER, p_item IN VARCHAR2) IS
5486   l_cross_ref varchar2(204);
5487   l_append varchar2(2):='';
5488   BEGIN
5489 
5490    l_cross_ref := lpad(Rtrim(p_item, '%'), g_gtin_code_length, '00000000000000');
5491 
5492    l_append:=wms_deploy.get_item_suffix_for_lov(p_item);
5493 
5494     OPEN x_items FOR
5495       SELECT DISTINCT msi.concatenated_segments
5496                     , msi.inventory_item_id
5497                     , msi.description
5498                     , NVL(msi.revision_qty_control_code, 1)
5499                     , NVL(msi.lot_control_code, 1)
5500                     , NVL(msi.serial_number_control_code, 1)
5501                     , NVL(msi.restrict_subinventories_code, 2)
5502                     , NVL(msi.restrict_locators_code, 2)
5503                     , NVL(msi.location_control_code, 1)
5504                     , msi.primary_uom_code
5505                     , NVL(msi.inspection_required_flag, 2)
5506                     , NVL(msi.shelf_life_code, 1)
5507                     , NVL(msi.shelf_life_days, 0)
5508                     , NVL(msi.allowed_units_lookup_code, 2)
5509                     , NVL(msi.effectivity_control, 1)
5510                     , '0'
5511                     , '0'
5512                     , '0'
5513                     , '0'
5514                     , '0'
5515                     , '0'
5516                     , ''
5517                     , 'N'
5518                     , msi.inventory_item_flag
5519                     , 0
5520 			  , wms_deploy.get_item_client_name(msi.inventory_item_id),
5521      --Bug No 3952081
5522      --Additional Fields for Process Convergence
5523                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
5524                       NVL(msi.DEFAULT_GRADE,''),
5525                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
5526                       NVL(msi.EXPIRATION_ACTION_CODE,''),
5527                       NVL(msi.HOLD_DAYS,0),
5528                       NVL(msi.MATURITY_DAYS,0),
5529                       NVL(msi.RETEST_INTERVAL,0),
5530                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5531                       NVL(msi.CHILD_LOT_FLAG,'N'),
5532                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
5533                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
5534                       NVL(msi.SECONDARY_UOM_CODE,''),
5535                       NVL(msi.SECONDARY_DEFAULT_IND,''),
5536                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
5537                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
5538                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
5539                  FROM mtl_system_items_vl msi, wms_lpn_contents wlpnc /* Bug 5581528 */
5540                 WHERE wlpnc.parent_lpn_id = p_lpn_id
5541                   AND wlpnc.source_name IN ('RETURN TO VENDOR', 'RETURN TO CUSTOMER', 'RETURN TO RECEIVING')
5542                   AND wlpnc.organization_id = p_org_id
5543                   AND msi.organization_id = wlpnc.organization_id
5544                   AND msi.inventory_item_id = wlpnc.inventory_item_id
5545                   AND msi.concatenated_segments LIKE (p_item||l_append)
5546       UNION
5547       SELECT DISTINCT msi.concatenated_segments
5548                     , msi.inventory_item_id
5549                     , msi.description
5550                     , NVL(msi.revision_qty_control_code, 1)
5551                     , NVL(msi.lot_control_code, 1)
5552                     , NVL(msi.serial_number_control_code, 1)
5553                     , NVL(msi.restrict_subinventories_code, 2)
5554                     , NVL(msi.restrict_locators_code, 2)
5555                     , NVL(msi.location_control_code, 1)
5556                     , msi.primary_uom_code
5557                     , NVL(msi.inspection_required_flag, 2)
5558                     , NVL(msi.shelf_life_code, 1)
5559                     , NVL(msi.shelf_life_days, 0)
5560                     , NVL(msi.allowed_units_lookup_code, 2)
5561                     , NVL(msi.effectivity_control, 1)
5562                     , '0'
5563                     , '0'
5564                     , '0'
5565                     , '0'
5566                     , '0'
5567                     , '0'
5568                     , ''
5569                     , 'N'
5570                     , msi.inventory_item_flag
5571                     , 0
5572 			  , wms_deploy.get_item_client_name(msi.inventory_item_id),
5573      --Bug No 3952081
5574      --Additional Fields for Process Convergence
5575                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
5576                       NVL(msi.DEFAULT_GRADE,''),
5577                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
5578                       NVL(msi.EXPIRATION_ACTION_CODE,''),
5579                       NVL(msi.HOLD_DAYS,0),
5580                       NVL(msi.MATURITY_DAYS,0),
5581                       NVL(msi.RETEST_INTERVAL,0),
5582                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5583                       NVL(msi.CHILD_LOT_FLAG,'N'),
5584                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
5585                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
5586                       NVL(msi.SECONDARY_UOM_CODE,''),
5587                       NVL(msi.SECONDARY_DEFAULT_IND,''),
5588                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
5589                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
5590                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
5591                  FROM mtl_system_items_vl msi, mtl_serial_numbers msn /* Bug 5581528 */
5592                 WHERE msn.lpn_id = p_lpn_id
5593                   AND msn.last_txn_source_name IN ('RETURN TO VENDOR', 'RETURN TO CUSTOMER', 'RETURN TO RECEIVING')
5594                   AND msn.current_organization_id = p_org_id
5595                   AND msi.organization_id = msn.current_organization_id
5596                   AND msi.inventory_item_id = msn.inventory_item_id
5597       AND msi.concatenated_segments LIKE (p_item||l_append)
5598 
5599       -- Changes for GTIN
5600       UNION
5601 
5602       SELECT DISTINCT msi.concatenated_segments
5603                     , msi.inventory_item_id
5604                     , msi.description
5605                     , NVL(msi.revision_qty_control_code, 1)
5606                     , NVL(msi.lot_control_code, 1)
5607                     , NVL(msi.serial_number_control_code, 1)
5608                     , NVL(msi.restrict_subinventories_code, 2)
5609                     , NVL(msi.restrict_locators_code, 2)
5610                     , NVL(msi.location_control_code, 1)
5611                     , msi.primary_uom_code
5612                     , NVL(msi.inspection_required_flag, 2)
5613                     , NVL(msi.shelf_life_code, 1)
5614                     , NVL(msi.shelf_life_days, 0)
5615                     , NVL(msi.allowed_units_lookup_code, 2)
5616                     , NVL(msi.effectivity_control, 1)
5617                     , '0'
5618                     , '0'
5619                     , '0'
5620                     , '0'
5621                     , '0'
5622                     , '0'
5623                     , mcr.cross_reference
5624                     , 'N'
5625                     , msi.inventory_item_flag
5626                     , 0
5627 			  , wms_deploy.get_item_client_name(msi.inventory_item_id),
5628      --Bug No 3952081
5629      --Additional Fields for Process Convergence
5630                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
5631                       NVL(msi.DEFAULT_GRADE,''),
5632                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
5633                       NVL(msi.EXPIRATION_ACTION_CODE,''),
5634                       NVL(msi.HOLD_DAYS,0),
5635                       NVL(msi.MATURITY_DAYS,0),
5636                       NVL(msi.RETEST_INTERVAL,0),
5637                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5638                       NVL(msi.CHILD_LOT_FLAG,'N'),
5639                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
5640                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
5641                       NVL(msi.SECONDARY_UOM_CODE,''),
5642                       NVL(msi.SECONDARY_DEFAULT_IND,''),
5643                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
5644                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
5645                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
5646       FROM mtl_system_items_vl msi, /* Bug 5581528 */
5647       wms_lpn_contents wlpnc,
5648       mtl_cross_references mcr
5649       WHERE wlpnc.parent_lpn_id = p_lpn_id
5650       AND wlpnc.source_name IN ('RETURN TO VENDOR', 'RETURN TO CUSTOMER', 'RETURN TO RECEIVING')
5651       AND wlpnc.organization_id = p_org_id
5652       AND msi.organization_id = wlpnc.organization_id
5653       AND msi.inventory_item_id = wlpnc.inventory_item_id
5654       AND msi.inventory_item_id   = mcr.inventory_item_id
5655       AND mcr.cross_reference_type = g_gtin_cross_ref_type
5656       AND mcr.cross_reference      LIKE l_cross_ref
5657       AND (mcr.organization_id     = msi.organization_id
5658 	   OR
5659 	   mcr.org_independent_flag = 'Y')
5660       UNION
5661       SELECT DISTINCT msi.concatenated_segments
5662                     , msi.inventory_item_id
5663                     , msi.description
5664                     , NVL(msi.revision_qty_control_code, 1)
5665                     , NVL(msi.lot_control_code, 1)
5666                     , NVL(msi.serial_number_control_code, 1)
5667                     , NVL(msi.restrict_subinventories_code, 2)
5668                     , NVL(msi.restrict_locators_code, 2)
5669                     , NVL(msi.location_control_code, 1)
5670                     , msi.primary_uom_code
5671                     , NVL(msi.inspection_required_flag, 2)
5672                     , NVL(msi.shelf_life_code, 1)
5673                     , NVL(msi.shelf_life_days, 0)
5674                     , NVL(msi.allowed_units_lookup_code, 2)
5675                     , NVL(msi.effectivity_control, 1)
5676                     , '0'
5677                     , '0'
5678                     , '0'
5679                     , '0'
5680                     , '0'
5681                     , '0'
5682                     , mcr.cross_reference
5683                     , 'N'
5684                     , msi.inventory_item_flag
5685                     , 0
5686 			  , wms_deploy.get_item_client_name(msi.inventory_item_id),
5687      --Bug No 3952081
5688      --Additional Fields for Process Convergence
5689                       NVL(msi.GRADE_CONTROL_FLAG,'N'),
5690                       NVL(msi.DEFAULT_GRADE,''),
5691                       NVL(msi.EXPIRATION_ACTION_INTERVAL,0),
5692                       NVL(msi.EXPIRATION_ACTION_CODE,''),
5693                       NVL(msi.HOLD_DAYS,0),
5694                       NVL(msi.MATURITY_DAYS,0),
5695                       NVL(msi.RETEST_INTERVAL,0),
5696                       NVL(msi.COPY_LOT_ATTRIBUTE_FLAG,'N'),
5697                       NVL(msi.CHILD_LOT_FLAG,'N'),
5698                       NVL(msi.CHILD_LOT_VALIDATION_FLAG,'N'),
5699                       NVL(msi.LOT_DIVISIBLE_FLAG,'Y'),
5700                       NVL(msi.SECONDARY_UOM_CODE,''),
5701                       NVL(msi.SECONDARY_DEFAULT_IND,''),
5702                       NVL(msi.TRACKING_QUANTITY_IND,'P'),
5703                       NVL(msi.DUAL_UOM_DEVIATION_HIGH,0),
5704                       NVL(msi.DUAL_UOM_DEVIATION_LOW,0)
5705       FROM mtl_system_items_vl msi, /* Bug 5581528 */
5706       mtl_serial_numbers msn,
5707       mtl_cross_references mcr
5708       WHERE msn.lpn_id = p_lpn_id
5709       AND msn.last_txn_source_name IN ('RETURN TO VENDOR', 'RETURN TO CUSTOMER', 'RETURN TO RECEIVING')
5710       AND msn.current_organization_id = p_org_id
5711       AND msi.organization_id = msn.current_organization_id
5712       AND msi.inventory_item_id = msn.inventory_item_id
5713       AND msi.inventory_item_id   = mcr.inventory_item_id
5714       AND mcr.cross_reference_type = g_gtin_cross_ref_type
5715       AND mcr.cross_reference      LIKE l_cross_ref
5716       AND (mcr.organization_id     = msi.organization_id
5717 	   OR
5718 	   mcr.org_independent_flag = 'Y');
5719   END get_return_items_lov;
5720 
5721   PROCEDURE get_return_revision_lov(x_revs OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_inventory_item_id IN VARCHAR2, p_lpn_id IN VARCHAR2, p_revision IN VARCHAR2) IS
5722   BEGIN
5723     OPEN x_revs FOR
5724       SELECT DISTINCT wlc.revision
5725                     , mir.effectivity_date
5726                     , NVL(mir.description, '')
5727                  FROM mtl_item_revisions mir, wms_lpn_contents_v wlc
5728                 WHERE wlc.organization_id = p_organization_id
5729                   AND wlc.inventory_item_id = TO_NUMBER(p_inventory_item_id)
5730                   AND NVL(wlc.parent_lpn_id, '0') = NVL(TO_NUMBER(p_lpn_id), NVL(wlc.parent_lpn_id, '0'))
5731                   AND wlc.source_name IN ('RETURN TO VENDOR', 'RETURN TO CUSTOMER', 'RETURN TO RECEIVING')
5732                   AND mir.organization_id = wlc.organization_id
5733                   AND mir.inventory_item_id = wlc.inventory_item_id
5734                   AND mir.revision = wlc.revision
5735                   AND wlc.revision LIKE (p_revision);
5736   END get_return_revision_lov;
5737 
5738   --"Returns"
5739 
5740 
5741   /* Direct Shipping */
5742 
5743   PROCEDURE get_vehicle_lov(x_vehicle OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_concatenated_segments IN VARCHAR2) IS
5744   BEGIN
5745     OPEN x_vehicle FOR
5746       SELECT   msi.concatenated_segments
5747              , msi.description
5748              , msi.inventory_item_id
5749           FROM mtl_system_items_vl msi /* Bug 5581528 */
5750          WHERE msi.organization_id = p_organization_id
5751            AND msi.concatenated_segments LIKE (p_concatenated_segments)
5752            AND msi.vehicle_item_flag = 'Y'
5753       ORDER BY UPPER(msi.concatenated_segments);
5754   END get_vehicle_lov;
5755 
5756   --Bug#2310308
5757   PROCEDURE get_direct_ship_uom_lov(x_uom OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_lpn_id IN NUMBER, p_uom_text IN VARCHAR2) IS
5758   BEGIN
5759     OPEN x_uom FOR
5760       SELECT DISTINCT muom.uom_code
5761                     , muom.unit_of_measure
5762                     , muom.description
5763                     , muom.uom_class
5764                  FROM mtl_units_of_measure muom, wms_license_plate_numbers wlpn
5765                 WHERE muom.uom_code LIKE (p_uom_text)
5766                   AND wlpn.lpn_id = p_lpn_id
5767                   AND muom.uom_code = wlpn.gross_weight_uom_code
5768       UNION
5769       SELECT DISTINCT muom.uom_code
5770                     , muom.unit_of_measure
5771                     , muom.description
5772                     , muom.uom_class
5773                  FROM mtl_units_of_measure muom, wsh_shipping_parameters wsp
5774                 WHERE wsp.organization_id = p_organization_id
5775                   AND wsp.weight_uom_class = muom.uom_class
5776                   AND muom.uom_code LIKE (p_uom_text);
5777   END get_direct_ship_uom_lov;
5778 
5779   --Bug#2310308
5780 
5781   --Bug #2252193
5782   PROCEDURE get_deliver_revision_lov(x_revs OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_inventory_item_id IN NUMBER, p_po_header_id IN NUMBER, p_shipment_header_id IN NUMBER, p_revision IN VARCHAR2) IS
5783   BEGIN
5784   /* Bug 13598673 modified to get revision based on both shipement header id and po headerid*/
5785     IF (p_shipment_header_id <> 0 and p_po_header_id <> 0) THEN
5786       OPEN x_revs FOR
5787         SELECT DISTINCT miv.revision
5788                       , miv.effectivity_date
5789                       , NVL(miv.description, '')
5790                    FROM mtl_item_revisions miv, rcv_supply rs
5791                   WHERE miv.organization_id = p_organization_id
5792                     AND miv.inventory_item_id = p_inventory_item_id
5793                     AND rs.shipment_header_id(+) = p_shipment_header_id
5794                     AND (rs.shipment_header_id IS NULL
5795                          OR rs.shipment_header_id = p_shipment_header_id
5796                         )
5797 					AND rs.po_header_id(+) = p_po_header_id
5798                     AND (rs.po_header_id IS NULL
5799                          OR rs.po_header_id = p_po_header_id
5800                         )
5801                     AND rs.to_organization_id(+) = miv.organization_id
5802                     AND (rs.to_organization_id IS NULL
5803                          OR rs.to_organization_id = p_organization_id
5804                         )
5805                     AND rs.item_id(+) = miv.inventory_item_id
5806                     AND (rs.item_id IS NULL
5807                          OR rs.item_id = p_inventory_item_id
5808                         )
5809                     AND NVL(rs.item_revision, miv.revision) = miv.revision
5810                     AND miv.revision LIKE (p_revision);
5811 	/* End of Bug 13598673 */
5812 	ELSIF (p_shipment_header_id <> 0) THEN
5813       OPEN x_revs FOR
5814         SELECT DISTINCT miv.revision
5815                       , miv.effectivity_date
5816                       , NVL(miv.description, '')
5817                    FROM mtl_item_revisions miv, rcv_supply rs
5818                   WHERE miv.organization_id = p_organization_id
5819                     AND miv.inventory_item_id = p_inventory_item_id
5820                     AND rs.shipment_header_id(+) = p_shipment_header_id
5821                     AND (rs.shipment_header_id IS NULL
5822                          OR rs.shipment_header_id = p_shipment_header_id
5823                         )
5824                     AND rs.to_organization_id(+) = miv.organization_id
5825                     AND (rs.to_organization_id IS NULL
5826                          OR rs.to_organization_id = p_organization_id
5827                         )
5828                     AND rs.item_id(+) = miv.inventory_item_id
5829                     AND (rs.item_id IS NULL
5830                          OR rs.item_id = p_inventory_item_id
5831                         )
5832                     AND NVL(rs.item_revision, miv.revision) = miv.revision
5833                     AND miv.revision LIKE (p_revision);
5834     ELSIF (p_po_header_id <> 0) THEN
5835       OPEN x_revs FOR
5836         SELECT DISTINCT miv.revision
5837                       , miv.effectivity_date
5838                       , NVL(miv.description, '')
5839                    FROM mtl_item_revisions miv, rcv_supply rs
5840                   WHERE miv.organization_id = p_organization_id
5841                     AND miv.inventory_item_id = p_inventory_item_id
5842                     AND rs.po_header_id(+) = p_po_header_id
5843                     AND (rs.po_header_id IS NULL
5844                          OR rs.po_header_id = p_po_header_id
5845                         )
5846                     AND rs.to_organization_id(+) = miv.organization_id
5847                     AND (rs.to_organization_id IS NULL
5848                          OR rs.to_organization_id = p_organization_id
5849                         )
5850                     AND rs.item_id(+) = miv.inventory_item_id
5851                     AND (rs.item_id IS NULL
5852                          OR rs.item_id = p_inventory_item_id
5853                         )
5854                     AND NVL(rs.item_revision, miv.revision) = miv.revision
5855                     AND miv.revision LIKE (p_revision);
5856     ELSE
5857       get_revision_lov(x_revs, p_organization_id, p_inventory_item_id, p_revision);
5858     END IF;
5859   END get_deliver_revision_lov;
5860 
5861   --Bug# 2647045
5862 FUNCTION conversion_order(p_uom_string IN VARCHAR2) RETURN NUMBER IS
5863    l_uom_string VARCHAR2(50);
5864    l_bracket_loc NUMBER;
5865 BEGIN
5866    l_uom_string := p_uom_string;
5867    l_bracket_loc := Instr(l_uom_string,'(');
5868    IF l_bracket_loc IS NULL OR l_bracket_loc = 0 THEN
5869       RETURN 0;
5870    END IF;
5871    l_uom_string :=  Substr(l_uom_string,l_bracket_loc+1);
5872    l_bracket_loc := Instr(l_uom_string,' ');
5873    IF l_bracket_loc IS NULL OR l_bracket_loc = 0 THEN
5874       RETURN 0;
5875    END IF;
5876    l_uom_string := Substr(l_uom_string,1,l_bracket_loc-1);
5877    RETURN To_number(l_uom_string);
5878 END;
5879 
5880 --Bug# 2647045
5881 FUNCTION get_conversion_rate(p_from_uom_code   varchar2,
5882 			     p_organization_id NUMBER,
5883 			     p_item_id         NUMBER)
5884   RETURN VARCHAR2 IS
5885      l_primary_uom_code VARCHAR2(3);
5886      l_conversion_rate NUMBER;
5887      l_return_string VARCHAR2(50);
5888 BEGIN
5889    IF p_item_id IS NULL THEN
5890       RETURN p_from_uom_code;
5891     ELSE
5892       BEGIN
5893 	 SELECT primary_uom_code
5894 	   INTO l_primary_uom_code
5895 	   FROM mtl_system_items
5896 	  WHERE organization_id = p_organization_id
5897 	    AND inventory_item_id = p_item_id;
5898       EXCEPTION
5899 	 WHEN OTHERS THEN
5900 	    NULL;
5901       END;
5902 
5903       IF (p_from_uom_code <> l_primary_uom_code) THEN
5904 	      inv_convert.inv_um_conversion(p_from_uom_code,
5905 				    l_primary_uom_code,
5906 				    p_item_id,
5907 				    l_conversion_rate);
5908       ELSE
5909       	      l_conversion_rate := 1;
5910       END IF;
5911 
5912       IF l_conversion_rate IS NOT NULL AND l_conversion_rate > 0 THEN
5913 	 l_return_string :=
5914 	   p_from_uom_code||'('||To_char(TRUNC(l_conversion_rate,4))||' '||l_primary_uom_code||')';
5915 	 RETURN l_return_string;
5916       END IF;
5917       RETURN p_from_uom_code;
5918    END IF;
5919 END;
5920 
5921 --added the procedure for handling lpn and loose in update status page for LPN status project
5922 PROCEDURE get_ostatus_items_lov(x_items OUT NOCOPY t_genref,
5923                                p_organization_id IN NUMBER,
5924                                p_lpn IN VARCHAR2,
5925                                p_concatenated_segments IN VARCHAR2,
5926                                p_subinventory_code IN VARCHAR2,
5927                                p_locator_id IN NUMBER) is
5928 l_cross_ref varchar2(204);
5929 l_append varchar2(2):=''; -- Bug 9369327
5930 
5931   l_sql_stmt1     VARCHAR2(7500)
5932   := 'SELECT msik.concatenated_segments concatenated_segments'
5933       ||            ', msik.inventory_item_id'
5934       ||            ', msik.description'
5935       ||            ', NVL(msik.revision_qty_control_code, 1)'
5936       ||            ', NVL(msik.lot_status_enabled, ''N'')'
5937       ||            ', NVL(msik.serial_status_enabled, ''N'')'
5938       ||            ', NVL(msik.restrict_subinventories_code, 2)'
5939       ||            ', NVL(msik.restrict_locators_code, 2)'
5940       ||            ', NVL(msik.location_control_code, 1)'
5941       ||            ', msik.primary_uom_code'
5942       ||            ', NVL(msik.inspection_required_flag, 2)'
5943       ||            ', NVL(msik.shelf_life_code, 1)'
5944       ||            ', NVL(msik.shelf_life_days, 0)'
5945       ||            ', NVL(msik.allowed_units_lookup_code, 2)'
5946       ||            ', NVL(msik.effectivity_control, 1)'
5947       ||            ', 0 parentlpnid'
5948       ||            ', 0 quantity'
5949       ||            ', NVL(msik.default_serial_status_id, 0)'
5950       ||            ', NVL(msik.serial_status_enabled, ''N'')'
5951       ||            ', NVL(msik.default_lot_status_id, 0)'
5952       ||            ', NVL(msik.lot_status_enabled, ''N'')'
5953       ||            ', '''''
5954       ||            ', ''N'''
5955       ||            ', msik.inventory_item_flag'
5956       ||            ', 0'
5957       ||            ', wms_deploy.get_item_client_name(msik.inventory_item_id),' -- Bug9369327
5958 --Bug No 3952081
5959 --Additional Fields for Process Convergence
5960       ||            'NVL(msik.GRADE_CONTROL_FLAG,''N''),'
5961       ||            'NVL(msik.DEFAULT_GRADE,''''),'
5962       ||            'NVL(msik.EXPIRATION_ACTION_INTERVAL,0),'
5963       ||            'NVL(msik.EXPIRATION_ACTION_CODE,''''),'
5964       ||            'NVL(msik.HOLD_DAYS,0),'
5965       ||            'NVL(msik.MATURITY_DAYS,0),'
5966       ||            'NVL(msik.RETEST_INTERVAL,0),'
5967       ||            'NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,''N''),'
5968       ||            'NVL(msik.CHILD_LOT_FLAG,''N''),'
5969       ||            'NVL(msik.CHILD_LOT_VALIDATION_FLAG,''N''),'
5970       ||            'NVL(msik.LOT_DIVISIBLE_FLAG,''Y''),'
5971       ||            'NVL(msik.SECONDARY_UOM_CODE,''''),'
5972       ||            'NVL(msik.SECONDARY_DEFAULT_IND,''''),'
5973       ||            'NVL(msik.TRACKING_QUANTITY_IND,''P''),'
5974       ||            'NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),'
5975       ||            'NVL(msik.DUAL_UOM_DEVIATION_LOW,0)';
5976 
5977 l_sql_stmt_xref     VARCHAR2(7500)
5978       :=       'SELECT msik.concatenated_segments concatenated_segments'
5979       ||            ', msik.inventory_item_id'
5980       ||            ', msik.description'
5981       ||            ', NVL(msik.revision_qty_control_code, 1)'
5982       ||            ', NVL(msik.lot_status_enabled, ''N'')'
5983       ||            ', NVL(msik.serial_status_enabled, ''N'')'
5984       ||            ', NVL(msik.restrict_subinventories_code, 2)'
5985       ||            ', NVL(msik.restrict_locators_code, 2)'
5986       ||            ', NVL(msik.location_control_code, 1)'
5987       ||            ', msik.primary_uom_code'
5988       ||            ', NVL(msik.inspection_required_flag, 2)'
5989       ||            ', NVL(msik.shelf_life_code, 1)'
5990       ||            ', NVL(msik.shelf_life_days, 0)'
5991       ||            ', NVL(msik.allowed_units_lookup_code, 2)'
5992       ||            ', NVL(msik.effectivity_control, 1)'
5993       ||            ', 0 parentlpnid'
5994       ||            ', 0 quantity'
5995       ||            ', NVL(msik.default_serial_status_id, 0)'
5996       ||            ', NVL(msik.serial_status_enabled, ''N'')'
5997       ||            ', NVL(msik.default_lot_status_id, 0)'
5998       ||            ', NVL(msik.lot_status_enabled, ''N'')'
5999       ||            ', mcr.cross_reference'
6000       ||            ', ''N'''
6001       ||            ', msik.inventory_item_flag'
6002       ||            ', 0'
6003       ||            ', wms_deploy.get_item_client_name(msik.inventory_item_id),' -- Bug9369327
6004      --Bug No 3952081
6005      --Additional Fields for Process Convergence
6006       ||            'NVL(msik.GRADE_CONTROL_FLAG,''N''),'
6007       ||            'NVL(msik.DEFAULT_GRADE,''''),'
6008       ||            'NVL(msik.EXPIRATION_ACTION_INTERVAL,0),'
6009       ||            'NVL(msik.EXPIRATION_ACTION_CODE,''''),'
6010       ||            'NVL(msik.HOLD_DAYS,0),'
6011       ||            'NVL(msik.MATURITY_DAYS,0),'
6012       ||            'NVL(msik.RETEST_INTERVAL,0),'
6013       ||            'NVL(msik.COPY_LOT_ATTRIBUTE_FLAG,''N''),'
6014       ||            'NVL(msik.CHILD_LOT_FLAG,''N''),'
6015       ||            'NVL(msik.CHILD_LOT_VALIDATION_FLAG,''N''),'
6016       ||            'NVL(msik.LOT_DIVISIBLE_FLAG,''Y''),'
6017       ||            'NVL(msik.SECONDARY_UOM_CODE,''''),'
6018       ||            'NVL(msik.SECONDARY_DEFAULT_IND,''''),'
6019       ||            'NVL(msik.TRACKING_QUANTITY_IND,''P''),'
6020       ||            'NVL(msik.DUAL_UOM_DEVIATION_HIGH,0),'
6021       ||            'NVL(msik.DUAL_UOM_DEVIATION_LOW,0)';
6022   BEGIN
6023 
6024    l_cross_ref := lpad(Rtrim(p_concatenated_segments, '%'), g_gtin_code_length, '00000000000000');
6025 
6026    l_append := wms_deploy.get_item_suffix_for_lov(p_concatenated_segments);
6027 
6028 
6029 IF P_LPN IS NULL THEN
6030 
6031    l_sql_stmt1 := l_sql_stmt1 || ' FROM mtl_system_items_vl msik, mtl_onhand_quantities_detail moqd'
6032                               || ' WHERE msik.concatenated_segments LIKE (''' || p_concatenated_segments ||l_append|| ''')' -- Bug 9369327
6033 
6034          		      || ' AND msik.organization_id = ' || p_organization_id
6035 			            || ' AND (msik.serial_number_control_code in (1,6) OR msik.serial_status_enabled = ''Y'' )'
6036                      || ' AND moqd.inventory_item_id = msik.inventory_item_id '
6037                      || ' AND moqd.organization_id = msik.organization_id '
6038                      || ' AND moqd.lpn_id is NULL ' ;
6039 
6040    l_sql_stmt_xref := l_sql_stmt_xref || ' FROM mtl_system_items_vl msik,'
6041 				|| 'mtl_cross_references mcr, mtl_onhand_quantities_detail moqd'
6042 				|| ' WHERE msik.organization_id = ' || p_organization_id
6043 				|| ' AND (msik.serial_number_control_code in (1,6) OR msik.serial_status_enabled = ''Y'' )'
6044 				|| ' AND msik.inventory_item_id   = mcr.inventory_item_id'
6045 				|| ' AND mcr.cross_reference_type = ''' || g_gtin_cross_ref_type || ''''
6046 				|| ' AND mcr.cross_reference LIKE ''' || l_cross_ref || ''''
6047 				|| ' AND (mcr.organization_id = msik.organization_id OR mcr.org_independent_flag = ''Y'')'
6048             || ' AND moqd.organization_id = msik.organization_id '
6049             || ' AND moqd.inventory_item_id = msik.inventory_item_id '
6050             || ' AND moqd.lpn_id is NULL ' ;
6051 
6052 
6053    IF p_subinventory_code IS NOT NULL THEN
6054         l_sql_stmt1 := l_sql_stmt1
6055 				   || ' AND moqd.subinventory_code = ''' || p_subinventory_code || '''';
6056 
6057         l_sql_stmt_xref := l_sql_stmt_xref
6058 				  				   || ' AND moqd.subinventory_code = ''' || p_subinventory_code || '''';
6059 
6060 	IF p_locator_id IS NOT NULL AND p_locator_id <> -1 THEN
6061 
6062 		l_sql_stmt1 := l_sql_stmt1 || ' AND moqd.locator_id = ' || p_locator_id;
6063 
6064 		l_sql_stmt_xref := l_sql_stmt_xref || ' AND moqd.locator_id = ' || p_locator_id;
6065 	END IF;
6066    END IF;
6067 ELSE
6068    l_sql_stmt1 := l_sql_stmt1 || ' FROM mtl_system_items_vl msik, mtl_onhand_quantities_detail moqd ,WMS_LICENSE_PLATE_NUMBERS WLPN ,WMS_LPN_CONTENTS WLC'
6069                               || ' WHERE WLPN.LICENSE_PLATE_NUMBER = ''' || p_lpn || ''''
6070                               || ' AND WLC.PARENT_LPN_ID =  WLPN.LPN_ID '
6071                               || ' AND MSIK.INVENTORY_ITEM_ID = WLC.INVENTORY_ITEM_ID '
6072                               || ' AND msik.concatenated_segments LIKE (''' || p_concatenated_segments ||l_append|| ''')' -- Bug 9369327
6073                   		      || ' AND msik.organization_id = ' || p_organization_id
6074 			                     || ' AND (msik.serial_number_control_code in (1,6) OR msik.serial_status_enabled = ''Y'' )'
6075                               || ' AND moqd.organization_id = msik.organization_id'
6076                               || ' AND moqd.inventory_item_id = msik.inventory_item_id';
6077 
6078    l_sql_stmt_xref := l_sql_stmt_xref || ' FROM mtl_system_items_vl msik,'
6079 				|| 'mtl_cross_references mcr, mtl_onhand_quantities_detail moqd ,WMS_LICENSE_PLATE_NUMBERS WLPN ,WMS_LPN_CONTENTS WLC'
6080 				|| ' WHERE WLPN.LICENSE_PLATE_NUMBER = ''' || p_lpn || ''''
6081             || ' AND WLC.PARENT_LPN_ID =  WLPN.LPN_ID '
6082             || ' AND MSIK.INVENTORY_ITEM_ID = WLC.INVENTORY_ITEM_ID '
6083             || ' AND msik.organization_id = ' || p_organization_id
6084 				|| ' AND (msik.serial_number_control_code in (1,6) OR msik.serial_status_enabled = ''Y'' )'
6085 				|| ' AND msik.inventory_item_id   = mcr.inventory_item_id'
6086 				|| ' AND mcr.cross_reference_type = ''' || g_gtin_cross_ref_type || ''''
6087 				|| ' AND mcr.cross_reference LIKE ''' || l_cross_ref || ''''
6088 				|| ' AND (mcr.organization_id = msik.organization_id OR mcr.org_independent_flag = ''Y'')'
6089             || ' AND moqd.organization_id = msik.organization_id'
6090             || ' AND moqd.inventory_item_id = msik.inventory_item_id';
6091 
6092 
6093        l_sql_stmt1 := l_sql_stmt1
6094 
6095 				   || ' AND moqd.subinventory_code = ''' || p_subinventory_code || '''';
6096 
6097         l_sql_stmt_xref := l_sql_stmt_xref
6098 				  	   || ' AND moqd.subinventory_code = ''' || p_subinventory_code || '''';
6099 
6100 		l_sql_stmt1 := l_sql_stmt1 || ' AND moqd.locator_id = ' || p_locator_id;
6101 
6102 		l_sql_stmt_xref := l_sql_stmt_xref || ' AND moqd.locator_id = ' || p_locator_id;
6103 
6104 
6105 END IF;
6106    l_sql_stmt1 := l_sql_stmt1 || ' UNION ' || l_sql_stmt_xref || ' ORDER BY concatenated_segments';
6107 
6108    --dbms_output.put_line(l_sql_stmt1);
6109  OPEN x_items FOR l_sql_stmt1;
6110 END get_ostatus_items_lov;
6111 
6112 -- MUOM:SK start
6113 FUNCTION get_conversion_rate(
6114     p_from_uom_code    VARCHAR2,
6115     p_organization_id  NUMBER,
6116     p_item_id          NUMBER,
6117     p_fulfillment_base VARCHAR2) -- MUOM:SK
6118   RETURN VARCHAR2
6119 IS
6120   l_primary_uom_code VARCHAR2(3);
6121   l_sec_uom_code     VARCHAR2(3); -- MUOM:SK
6122   l_conversion_rate  NUMBER;
6123   l_return_string    VARCHAR2(50);
6124 BEGIN
6125   IF p_item_id IS NULL THEN
6126     RETURN p_from_uom_code;
6127   ELSE
6128     BEGIN
6129       SELECT primary_uom_code,
6130         SECONDARY_UOM_CODE
6131       INTO l_primary_uom_code,
6132         l_sec_uom_code
6133       FROM mtl_system_items
6134       WHERE organization_id = p_organization_id
6135       AND inventory_item_id = p_item_id;
6136     EXCEPTION
6137     WHEN OTHERS THEN
6138       NULL;
6139     END;
6140     mydebug('get_converson_rate function value of p_fulfillment_base is :'|| p_fulfillment_base);
6141     mydebug('get_converson_rate function value of l_primary_uom_code is :'|| l_primary_uom_code);
6142     mydebug('get_converson_rate function value of l_sec_uom_code     is :'|| l_sec_uom_code);
6143     mydebug('get_converson_rate function value of p_from_uom_code    is :'|| p_from_uom_code);
6144     IF p_fulfillment_base  = 'S' THEN -- MUOM:SK
6145       IF (p_from_uom_code <> l_sec_uom_code) THEN
6146         inv_convert.inv_um_conversion(p_from_uom_code,
6147 		                              l_sec_uom_code,
6148 									  p_item_id,
6149 									  l_conversion_rate);
6150       ELSE
6151         l_conversion_rate := 1;
6152       END IF;
6153     ELSE -- MUOM:SK
6154       IF (p_from_uom_code <> l_primary_uom_code) THEN
6155         inv_convert.inv_um_conversion(p_from_uom_code,
6156                                       l_primary_uom_code,
6157 									  p_item_id,
6158 									  l_conversion_rate);
6159       ELSE
6160         l_conversion_rate := 1;
6161       END IF;
6162     END IF; -- MUOM:SK
6163 	IF p_fulfillment_base  = 'S' THEN
6164 		IF l_conversion_rate IS NOT NULL AND l_conversion_rate > 0 THEN
6165 		  l_return_string    := p_from_uom_code||'('||TO_CHAR(TRUNC(l_conversion_rate,4))||' '||l_sec_uom_code||')';
6166           mydebug('get_converson_rate l_return_string is :'|| l_return_string);
6167 		  RETURN l_return_string;
6168 		END IF;
6169 	ELSE
6170 		IF l_conversion_rate IS NOT NULL AND l_conversion_rate > 0 THEN
6171 		  l_return_string    := p_from_uom_code||'('||TO_CHAR(TRUNC(l_conversion_rate,4))||' '||l_primary_uom_code||')';
6172           mydebug('get_converson_rate l_return_string is :'|| l_return_string);
6173 		  RETURN l_return_string;
6174 		END IF;
6175 	END IF;
6176     RETURN p_from_uom_code;
6177   END IF;
6178 END;
6179 
6180   -- this is a new lov for the UOM after MUOM project
6181   PROCEDURE get_uom_lov_pick(
6182 			x_uoms OUT NOCOPY t_genref
6183 		  , p_organization_id IN NUMBER
6184 		  , p_item_id IN NUMBER
6185 		  , p_uom_type IN NUMBER
6186 		  , p_uom_code IN VARCHAR2
6187 		  , p_fulfillment_base in VARCHAR2) IS
6188 
6189       l_code VARCHAR2(20):=p_uom_code;
6190   BEGIN
6191 
6192     IF (INSTR(l_code,'(') > 0) THEN
6193       l_code := SUBSTR(p_uom_code,1,INSTR(p_uom_code,'(')-1);
6194     END IF;
6195 
6196     IF (p_item_id IS NOT NULL
6197         AND p_item_id > 0
6198        ) THEN
6199        OPEN x_uoms FOR
6200         SELECT uom_code_comp,
6201                unit_of_measure,
6202                description,
6203                uom_class
6204           FROM (SELECT ( inv_ui_item_lovs.Get_conversion_rate(uom_code, p_organization_id,
6205                                                inventory_item_id,
6206                                                Nvl( p_fulfillment_base,'P'))) uom_code_comp,
6207                unit_of_measure,
6208                description,
6209                uom_class
6210           FROM mtl_item_uoms_view
6211          WHERE organization_id = p_organization_id
6212            AND inventory_item_id = p_item_id
6213            AND Nvl(uom_type, 3) = Nvl(p_uom_type, 3)
6214            AND uom_code LIKE ( l_code ))
6215          WHERE ((Nvl(p_fulfillment_base,'P') = 'S'
6216            AND inv_convert.is_uom_in_same_class( Substr(uom_code_comp, 1, Instr(uom_code_comp, '(') - 1), p_organization_id , p_item_id , Nvl(p_fulfillment_base,'P')) = 'Y')
6217             OR (Nvl(p_fulfillment_base,'P') = 'P'))
6218          ORDER BY inv_ui_item_lovs.conversion_order(inv_ui_item_lovs.Get_conversion_rate(Substr(uom_code_comp, 1,
6219                                                         Instr(uom_code_comp, '(') - 1),
6220                                                          p_organization_id,
6221                                                          p_item_id,
6222                                                          Nvl( p_fulfillment_base,'P'))) ASC, Upper(Substr(uom_code_comp, 1, Instr(uom_code_comp, '(') - 1));
6223 
6224     END IF;
6225   END;
6226 
6227 END inv_ui_item_lovs;