DBA Data[Home] [Help]

PACKAGE BODY: APPS.INV_RESERVATION_UTIL_PVT

Source


1 PACKAGE BODY inv_reservation_util_pvt AS
2 /* $Header: INVRSV2B.pls 120.2.12020000.2 2012/07/09 08:16:29 asugandh ship $ */
3 g_pkg_name CONSTANT VARCHAR2(30) := 'Rsv_Service';
4 g_next_demand_entry    NUMBER := 1;
5 
6 PROCEDURE set_file_info
7   (
8    p_file_name IN VARCHAR2
9    ) IS
10 BEGIN
11   /* set file name and directory path */
12    -- file location should be changed before released
13    fnd_file.put_names
14      (
15         p_file_name
16       , 'RSV_OUTPUT'
17       , '/nfs/net/ap111sun/d3/log/dev115'
18       );
19 
20 END set_file_info;
21 
22 PROCEDURE close_file IS
23 BEGIN
24   fnd_file.close;
25 END;
26 
27 PROCEDURE write_to_logfile
28   (
29      x_return_status    OUT NOCOPY VARCHAR2
30    , p_msg_to_append    IN  VARCHAR2
31    , p_appl_short_name  IN  VARCHAR2
32    , p_file_name        IN  VARCHAR2
33    , p_program_name     IN  VARCHAR2
34    , p_new_or_append    IN  NUMBER
35    ) IS
36       l_return_status   VARCHAR2(1) := fnd_api.g_ret_sts_success;
37       l_buff            VARCHAR2(2000);   -- translated message
38 BEGIN
39   /* get translation for mesage code into l_buff */
40   FND_MESSAGE.SET_NAME(p_appl_short_name, p_msg_to_append);
41   l_buff := FND_MESSAGE.GET;
42 
43   /* write to log file the local buffer */
44   fnd_file.put(fnd_file.Log, l_buff);
45   /* put in 1 (one) carriage return for next write to file */
46   fnd_file.new_line(fnd_file.Log, 1);
47 
48   x_return_status := l_return_status;
49 
50 EXCEPTION
51    WHEN OTHERS THEN
52       -- possible error
53       -- utl_file.invalid_path       - file location or name was invalid
54       -- utl_file.invalid_mode       - the open_mode string was invalid
55       -- utl_file.invalid_filehandle - file handle is invalid
56       -- utl_file.invalid_operation  - file is not open for writing/appending
57       -- utl_file.write_error        - OS error occured during write operation
58       x_return_status := fnd_api.g_ret_sts_unexp_error ;
59 
60       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
61 	THEN
62 	 fnd_msg_pub.add_exc_msg
63 	   (  g_pkg_name
64               , 'Write_To_Logfile'
65               );
66       END IF;
67 
68 END write_to_logfile;
69 
70 PROCEDURE search_item_cache
71   (
72      x_return_status           OUT NOCOPY VARCHAR2
73    , p_inventory_item_id       IN  NUMBER
74    , p_organization_id         IN  NUMBER
75    , x_index                   OUT NOCOPY NUMBER
76    ) IS
77       l_return_status   VARCHAR2(1) := fnd_api.g_ret_sts_success;
78       l_index           NUMBER;
79       l_rec             inv_reservation_global.item_record;
80 BEGIN
81    IF inv_reservation_global.g_item_record_cache.EXISTS(p_inventory_item_id) THEN
82       IF inv_reservation_global.g_item_record_cache(p_inventory_item_id).organization_id = p_organization_id THEN
83          l_index := p_inventory_item_id;
84       END IF;
85    END IF;
86 
87 /*
88    IF inv_reservation_global.g_item_record_cache.count > 0 THEN
89       l_index := inv_reservation_global.g_item_record_cache.first ;
90       LOOP
91 	 IF inv_reservation_global.g_item_record_cache
92 	   (l_index).inventory_item_id = p_inventory_item_id
93 	   AND inv_reservation_global.g_item_record_cache
94 	   (l_index).organization_id = p_organization_id THEN
95 	    EXIT;
96 	  ELSE
97 	    IF l_index = inv_reservation_global.g_item_record_cache.last THEN
98 	       l_index := NULL;
99 	       EXIT;
100 	    END IF;
101 	    l_index :=
102 	      inv_reservation_global.g_item_record_cache.next(l_index) ;
103 	 END IF;
104       END LOOP;
105    END IF;
106 */
107 
108    x_index := l_index;
109    x_return_status := l_return_status;
110 
111 EXCEPTION
112    WHEN OTHERS THEN
113       x_return_status := fnd_api.g_ret_sts_unexp_error ;
114 
115       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
116 	THEN
117 	 fnd_msg_pub.add_exc_msg
118 	   (  g_pkg_name
119               , 'Search_Item_Cache'
120               );
121       END IF;
122 
123 END search_item_cache;
124 
125 PROCEDURE add_item_cache
126   (
127      x_return_status   OUT NOCOPY VARCHAR2
128    , p_item_record     IN  inv_reservation_global.item_record
129    , x_index           OUT NOCOPY NUMBER
130    ) IS
131       l_return_status  VARCHAR2(1) := fnd_api.g_ret_sts_success;
132       l_index          NUMBER;
133 BEGIN
134    --l_index := inv_reservation_global.g_item_record_cache.COUNT+1;
135    l_index := p_item_record.inventory_item_id;
136    inv_reservation_global.g_item_record_cache(l_index)
137      := p_item_record;
138 
139    x_index := l_index;
140    x_return_status := l_return_status;
141 
142 EXCEPTION
143    WHEN OTHERS THEN
144       x_return_status := fnd_api.g_ret_sts_unexp_error ;
145 
146       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
147 	THEN
148 	 fnd_msg_pub.add_exc_msg
149 	   (  g_pkg_name
150               , 'Add_Item_Cache'
151               );
152       END IF;
153 
154 END add_item_cache;
155 
156 PROCEDURE search_organization_cache
157   (
158      x_return_status           OUT NOCOPY VARCHAR2
159    , p_organization_id         IN  NUMBER
160    , x_index                   OUT NOCOPY NUMBER
161    ) IS
162       l_return_status   VARCHAR2(1) := fnd_api.g_ret_sts_success;
163       l_index           NUMBER;
164       l_rec             inv_reservation_global.organization_record;
165 BEGIN
166    IF inv_reservation_global.g_organization_record_cache.EXISTS(p_organization_id) THEN
167       l_index := p_organization_id;
168    END IF;
169 
170 /*
171    IF inv_reservation_global.g_organization_record_cache.count > 0 THEN
172       l_index := inv_reservation_global.g_organization_record_cache.first ;
173       LOOP
174 	 IF inv_reservation_global.g_organization_record_cache
175 	   (l_index).organization_id = p_organization_id THEN
176 	    EXIT;
177 	  ELSE
178 	    IF l_index =
179 	      inv_reservation_global.g_organization_record_cache.last
180 	      THEN
181 	       l_index := NULL;
182 	       EXIT;
183 	    END IF;
184 	    l_index :=
185 	    inv_reservation_global.g_organization_record_cache.next(l_index) ;
186 	 END IF;
187       END LOOP;
188    END IF;
189 */
190 
191    x_index := l_index;
192    x_return_status := l_return_status;
193 
194 EXCEPTION
195    WHEN OTHERS THEN
196       x_return_status := fnd_api.g_ret_sts_unexp_error ;
197 
198       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
199 	THEN
200 	 fnd_msg_pub.add_exc_msg
201 	   (  g_pkg_name
202               , 'Search_Organization_Cache'
203               );
204       END IF;
205 
206 END search_organization_cache;
207 
208 PROCEDURE add_organization_cache
209   (
210      x_return_status           OUT NOCOPY VARCHAR2
211    , p_organization_record     IN  inv_reservation_global.organization_record
212    , x_index                   OUT NOCOPY NUMBER
213    ) IS
214       l_return_status   VARCHAR2(1) := fnd_api.g_ret_sts_success;
215       l_index           NUMBER;
216 BEGIN
217    --l_index := inv_reservation_global.g_organization_record_cache.COUNT+1;
218    l_index := p_organization_record.organization_id;
219    inv_reservation_global.g_organization_record_cache(l_index)
220      := p_organization_record;
221 
222    x_index := l_index;
223    x_return_status := l_return_status;
224 
225 EXCEPTION
226    WHEN OTHERS THEN
227       x_return_status := fnd_api.g_ret_sts_unexp_error ;
228 
229       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
230 	THEN
231 	 fnd_msg_pub.add_exc_msg
232 	   (  g_pkg_name
233               , 'Add_Organization_Cache'
234               );
235       END IF;
236 
237 END add_organization_cache;
238 
239 PROCEDURE search_demand_cache
240   (
241      x_return_status           OUT NOCOPY VARCHAR2
242    , p_demand_source_type_id   IN  NUMBER
243    , p_demand_source_header_id IN  NUMBER
244    , p_demand_source_line_id   IN  NUMBER
245    , p_demand_source_name      IN  VARCHAR2
246    , x_index                   OUT NOCOPY NUMBER
247    ) IS
248       l_return_status   VARCHAR2(1) := fnd_api.g_ret_sts_success;
249       l_index           NUMBER;
250       l_rec             inv_reservation_global.demand_record;
251 BEGIN
252 
253 	 -- Bug 7717612, demand_source_line_id can exceed 2^31 if the max value of the sequence
254  	       --    is modified. In such case EXISTS on a plsql table throws NO_DATA_FOUND
255  	       --    exception as it is indexed by binary interger.
256  	       --    Using MOD(line_id,2^31) to ensure that index always falls
257  	       --    in the correct range.
258 
259  	 --#BUG 7717612#
260 
261 -- For increased efficiency if source_line_is is provided then that
262 -- is used as the index in which to store the demand info hence check that
263 -- position first. If it is null then use existing check
264 
265    IF p_demand_source_line_id IS NOT NULL THEN
266       IF inv_reservation_global.g_demand_record_cache.EXISTS(MOD(p_demand_source_line_id,2147483648))THEN
267        -- The orginal code allowed any value including demand_source_line_id to be null.
268        -- In the case where demand_source_line_id is null the demand record is place
269        -- in the first available slot in the table. Hence need to also check if record
270        -- returned is actual record required
271          IF inv_reservation_global.g_demand_record_cache(MOD(p_demand_source_line_id,2147483648)).demand_source_line_id IS NOT NULL THEN
272             l_index := MOD(p_demand_source_line_id,2147483648);
273          END IF;
274       END IF;
275    ELSE -- loop through all
276    IF inv_reservation_global.g_demand_record_cache.count > 0 THEN
277       l_index := inv_reservation_global.g_demand_record_cache.first ;
278       LOOP
279 	 IF (inv_reservation_global.g_demand_record_cache
280 	       (l_index).demand_source_type_id IS NULL
281 		 AND p_demand_source_type_id IS NULL
282 		   OR inv_reservation_global.g_demand_record_cache
283 		   (l_index).demand_source_type_id = p_demand_source_type_id)
284 	   AND (inv_reservation_global.g_demand_record_cache
285 	       (l_index).demand_source_header_id IS NULL
286 		 AND p_demand_source_header_id IS NULL
287 		   OR inv_reservation_global.g_demand_record_cache
288 		   (l_index).demand_source_header_id
289 		   = p_demand_source_header_id)
290            AND (inv_reservation_global.g_demand_record_cache
291 	       (l_index).demand_source_line_id IS NULL
292 		 AND p_demand_source_line_id IS NULL
293 		   OR inv_reservation_global.g_demand_record_cache
294 		   (l_index).demand_source_line_id = p_demand_source_line_id)
295 	   AND (inv_reservation_global.g_demand_record_cache
296 	       (l_index).demand_source_name IS NULL
297 		 AND p_demand_source_name IS NULL
298 		   OR inv_reservation_global.g_demand_record_cache
299 		   (l_index).demand_source_name = p_demand_source_name)
300 	   THEN
301 	    EXIT;
302 	  ELSE
303 	    IF l_index =
304 	      inv_reservation_global.g_demand_record_cache.last THEN
305 	       l_index := NULL;
306 	       EXIT;
307 	    END IF;
308 	    l_index :=
309 	      inv_reservation_global.g_demand_record_cache.next(l_index) ;
310 	 END IF;
311       END LOOP;
312    END IF;
313    END IF;
314 
315    x_index := l_index;
316    x_return_status := l_return_status;
317 
318 EXCEPTION
319    WHEN OTHERS THEN
320       x_return_status := fnd_api.g_ret_sts_unexp_error ;
321 
322       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
323 	THEN
324 	 fnd_msg_pub.add_exc_msg
325 	   (  g_pkg_name
326               , 'Search_Demand_Cache'
327               );
328       END IF;
329 
330 END search_demand_cache;
331 
332 PROCEDURE add_demand_cache
333   (
334      x_return_status   OUT NOCOPY VARCHAR2
335    , p_demand_record   IN  inv_reservation_global.demand_record
336    , x_index           OUT NOCOPY NUMBER
337    ) IS
338       l_return_status  VARCHAR2(1) := fnd_api.g_ret_sts_success;
339       l_index          NUMBER;
340 BEGIN
341    IF p_demand_record.demand_source_line_id IS NOT NULL THEN
342     --#BUG7717612#
343     --  l_index := p_demand_record.demand_source_line_id;
344         l_index := MOD(p_demand_record.demand_source_line_id,2147483648);
345     --#BUG7717612#
346    ELSE
347       -- need to check whether there is a collision and increment accordingly
348       LOOP
349         IF inv_reservation_global.g_demand_record_cache.EXISTS(g_next_demand_entry)
350            THEN g_next_demand_entry := g_next_demand_entry + 1;
351         ELSE
352            exit; --loop
353         END IF;
354       END LOOP;
355       --l_index := inv_reservation_global.g_demand_record_cache.COUNT+1;
356       l_index := g_next_demand_entry;
357       g_next_demand_entry := g_next_demand_entry + 1;
358    END IF;
359    inv_reservation_global.g_demand_record_cache(l_index)
360      := p_demand_record;
361 
362    x_index := l_index;
363    x_return_status := l_return_status;
364 
365 EXCEPTION
366    WHEN OTHERS THEN
367       x_return_status := fnd_api.g_ret_sts_unexp_error ;
368 
369       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
370 	THEN
371 	 fnd_msg_pub.add_exc_msg
372 	   (  g_pkg_name
373               , 'Add_Demand_Cache'
374               );
375       END IF;
376 
377 END add_demand_cache;
378 
379 PROCEDURE search_supply_cache
380   (
381      x_return_status           OUT NOCOPY VARCHAR2
382    , p_supply_source_type_id   IN  NUMBER
383    , p_supply_source_header_id IN  NUMBER
384    , p_supply_source_line_id   IN  NUMBER
385    , p_supply_source_name      IN  VARCHAR2
386    , x_index                   OUT NOCOPY NUMBER
387    ) IS
388       l_return_status   VARCHAR2(1) := fnd_api.g_ret_sts_success;
389       l_index           NUMBER;
390       l_rec             inv_reservation_global.supply_record;
391 BEGIN
392 
393    IF inv_reservation_global.g_supply_record_cache.count > 0 THEN
394       l_index := inv_reservation_global.g_supply_record_cache.first ;
395       LOOP
396 	 IF    (inv_reservation_global.g_supply_record_cache
397 	        (l_index).supply_source_type_id IS NULL
398 	        AND p_supply_source_type_id IS NULL
399 		OR inv_reservation_global.g_supply_record_cache
400 		(l_index).supply_source_type_id = p_supply_source_type_id)
401 	   AND (inv_reservation_global.g_supply_record_cache
402 	        (l_index).supply_source_header_id IS NULL
403 		AND p_supply_source_header_id IS NULL
404 		OR inv_reservation_global.g_supply_record_cache
405 		(l_index).supply_source_header_id
406 		= p_supply_source_header_id)
407 	   AND (inv_reservation_global.g_supply_record_cache
408 	        (l_index).supply_source_line_id IS NULL
409 		AND p_supply_source_line_id IS NULL
410 		OR inv_reservation_global.g_supply_record_cache
411 		(l_index).supply_source_line_id = p_supply_source_line_id)
412 	   AND (inv_reservation_global.g_supply_record_cache
413 	        (l_index).supply_source_name IS NULL
414 		AND p_supply_source_name IS NULL
415 		OR inv_reservation_global.g_supply_record_cache
416 		(l_index).supply_source_name = p_supply_source_name)
417 	   THEN
418 	    EXIT;
419 	  ELSE
420 	    IF l_index
421 	      = inv_reservation_global.g_supply_record_cache.last THEN
422 	       l_index := NULL;
423 	       EXIT;
424 	    END IF;
425 	    l_index :=
426 	      inv_reservation_global.g_supply_record_cache.next(l_index) ;
427 	 END IF;
428       END LOOP;
429    END IF;
430 
431    x_index := l_index;
432    x_return_status := l_return_status;
433 
434 EXCEPTION
435    WHEN OTHERS THEN
436       x_return_status := fnd_api.g_ret_sts_unexp_error ;
437 
438       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
439 	THEN
440 	 fnd_msg_pub.add_exc_msg
441 	   (  g_pkg_name
442               , 'Search_Supply_Cache'
443               );
444       END IF;
445 
446 END search_supply_cache;
447 
448 PROCEDURE add_supply_cache
449   (
450      x_return_status   OUT NOCOPY VARCHAR2
451    , p_supply_record   IN  inv_reservation_global.supply_record
452    , x_index           OUT NOCOPY NUMBER
453    ) IS
454       l_return_status  VARCHAR2(1) := fnd_api.g_ret_sts_success;
455       l_index          NUMBER;
456 BEGIN
457    l_index := inv_reservation_global.g_supply_record_cache.COUNT+1;
458    inv_reservation_global.g_supply_record_cache(l_index)
459      := p_supply_record;
460 
461    x_index := l_index;
462    x_return_status := l_return_status;
463 
464 EXCEPTION
465    WHEN OTHERS THEN
466       x_return_status := fnd_api.g_ret_sts_unexp_error ;
467 
468       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
469 	THEN
470 	 fnd_msg_pub.add_exc_msg
471 	   (  g_pkg_name
472               , 'Add_Supply_Cache'
473               );
474       END IF;
475 
476 END add_supply_cache;
477 
478 PROCEDURE search_sub_cache
479   (
480      x_return_status         OUT NOCOPY VARCHAR2
481    , p_subinventory_code     IN  VARCHAR2
482    , p_organization_id       IN  NUMBER
483    , x_index                 OUT NOCOPY NUMBER
484    ) IS
485       l_return_status   VARCHAR2(1) := fnd_api.g_ret_sts_success;
486       l_index           NUMBER;
487 BEGIN
488   -- Modified for common API. Secondary_inventory_name replaces
489 -- subinventory_code
490 
491    IF inv_reservation_global.g_sub_record_cache.count > 0 THEN
492       l_index := inv_reservation_global.g_sub_record_cache.first ;
493       LOOP
494 	 IF (inv_reservation_global.g_sub_record_cache
495 	       (l_index).secondary_inventory_name IS NULL
496 	       AND p_subinventory_code IS NULL
497 	       OR inv_reservation_global.g_sub_record_cache
498 	       (l_index).secondary_inventory_name= p_subinventory_code)
499 	   AND (inv_reservation_global.g_sub_record_cache
500 	        (l_index).organization_id IS NULL
501 		AND p_organization_id IS NULL
502 		OR inv_reservation_global.g_sub_record_cache
503 		(l_index).organization_id = p_organization_id) THEN
504 	    EXIT;
505 	  ELSE
506 	    IF l_index = inv_reservation_global.g_sub_record_cache.last THEN
507 	       l_index := NULL;
508 	       EXIT;
509 	    END IF;
510 	    l_index :=
511 	      inv_reservation_global.g_sub_record_cache.next(l_index) ;
512 	 END IF;
513       END LOOP;
514    END IF;
515 
516    x_index := l_index;
517    x_return_status := l_return_status;
518 
519 EXCEPTION
520    WHEN OTHERS THEN
521       x_return_status := fnd_api.g_ret_sts_unexp_error ;
522 
523       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
524 	THEN
525 	 fnd_msg_pub.add_exc_msg
526 	   (  g_pkg_name
527               , 'Search_Sub_Cache'
528               );
529       END IF;
530 
531 END search_sub_cache;
532 
533 PROCEDURE add_sub_cache
534   (
535      x_return_status   OUT NOCOPY VARCHAR2
536    , p_sub_record      IN  inv_reservation_global.sub_record
537    , x_index           OUT NOCOPY NUMBER
538    ) IS
539       l_return_status  VARCHAR2(1) := fnd_api.g_ret_sts_success;
540       l_index          NUMBER;
541 BEGIN
542    l_index := inv_reservation_global.g_sub_record_cache.COUNT+1;
543    inv_reservation_global.g_sub_record_cache(l_index)
544      := p_sub_record;
545 
546    x_index := l_index;
547    x_return_status := l_return_status;
548 
549 EXCEPTION
550    WHEN OTHERS THEN
551       x_return_status := fnd_api.g_ret_sts_unexp_error ;
552 
553       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
554 	THEN
555 	 fnd_msg_pub.add_exc_msg
556 	   (  g_pkg_name
557               , 'Add_Sub_Cache'
558               );
559       END IF;
560 
561 END add_sub_cache;
562 
563 -- Function
564 --   locator_control
565 -- Description
566 --   Determine whether locator control is on.
567 --   uses lookup code from mtl_location_controls.
568 --   see mtl_system_items in the TRM for more
569 --   information.
570 --   mtl_location_control lookup code
571 --      1      no locator control
572 --      2      prespecified locator control
573 --      3      dynamic entry locator control
574 --      4      locator control determined at subinventory level
575 --      5      locator control determined at item level
576 --   Since this package is used by reservation only,
577 --   we will no have dynamic entry locator control at all
578 --   (if the input is 3, we treats it as 2);
579 --   also as create, update, delete, or transfer a reservation
580 --   has no impact on on hand quantity, we will not check
581 --   negative balance as we do in validation module for
582 --   cycle count transactions.
583 -- Return Value
584 --      a number in (1,2,4,5), as defined in mtl_location_control
585 --      lookup code
586 FUNCTION locator_control
587   (
588      p_org_control  IN    NUMBER
589    , p_sub_control  IN    NUMBER
590    , p_item_control IN    NUMBER DEFAULT NULL
591    ) RETURN NUMBER IS
592       l_value           NUMBER;
593       l_locator_control NUMBER;
594 BEGIN
595 
596     IF p_org_control = inv_reservation_global.g_locator_control_no THEN
597        l_locator_control := inv_reservation_global.g_locator_control_no;
598      ELSIF p_org_control =
599        inv_reservation_global.g_locator_control_prespecified THEN
600        l_locator_control :=
601 	 inv_reservation_global.g_locator_control_prespecified;
602      ELSIF p_org_control =
603        inv_reservation_global.g_locator_control_dynamic THEN
604        l_locator_control :=
605 	 inv_reservation_global.g_locator_control_prespecified;
606      ELSIF p_org_control = inv_reservation_global.g_locator_control_by_sub THEN
607        IF p_sub_control = inv_reservation_global.g_locator_control_no THEN
608 	  l_locator_control := inv_reservation_global.g_locator_control_no;
609 	ELSIF p_sub_control =
610 	  inv_reservation_global.g_locator_control_prespecified THEN
611 	  l_locator_control :=
612 	    inv_reservation_global.g_locator_control_prespecified ;
613 	ELSIF p_sub_control =
614 	  inv_reservation_global.g_locator_control_dynamic THEN
615 	  l_locator_control :=
616 	    inv_reservation_global.g_locator_control_prespecified;
617 	ELSIF p_sub_control =
618 	  inv_reservation_global.g_locator_control_by_item THEN
619 	  IF p_item_control = inv_reservation_global.g_locator_control_no THEN
620 	     l_locator_control := inv_reservation_global.g_locator_control_no;
621 	   ELSIF p_item_control =
622 	     inv_reservation_global.g_locator_control_prespecified THEN
623 	     l_locator_control :=
624 	       inv_reservation_global.g_locator_control_prespecified;
625 	   ELSIF p_item_control =
626 	     inv_reservation_global.g_locator_control_dynamic THEN
627              l_locator_control :=
628 	       inv_reservation_global.g_locator_control_prespecified;
629 	   ELSIF p_item_control IS NULL THEN
630 	     l_locator_control := p_sub_control;
631 	   ELSE
632 	     l_value := p_item_control;
633 	     app_exception.invalid_argument
634 	       ('LOCATOR.CONTROL','ITEM_LOCATOR_CONTROL',l_value);
635 	  END IF;
636 	ELSE
637 	  l_value := p_sub_control;
638 	  app_exception.invalid_argument
639 	    ('LOCATOR.CONTROL','SUB_LOCATOR_CONTROL',l_value);
640        END IF;
641      ELSE
642        l_value := p_org_control;
643        app_exception.invalid_argument
644 	 ('LOCATOR.CONTROL','ORG_LOCATOR_CONTROL',l_value);
645     END IF;
646 
647     RETURN l_locator_control;
648 
649 END locator_control;
650 
651 /*** {{ R12 Enhanced reservations code changes ***/
652 -- Get_wip_cache will first check if the cache for the wip_entity_id
653 -- already exists or not. If it's not exist, then call the API
654 -- inv_reservation_pvt.get_wip_entity to set the wip record cache.
655 PROCEDURE get_wip_cache
656   (
657      x_return_status     OUT NOCOPY VARCHAR2
658    , p_wip_entity_id     IN  NUMBER
659   ) IS
660   l_return_status     VARCHAR2(1) := fnd_api.g_ret_sts_success;
661   l_msg_count         NUMBER;
662   l_msg_data          VARCHAR2(1000);
663   l_wip_entity_type   NUMBER;
664   l_wip_job_type      VARCHAR2(15);
665 BEGIN
666 
667   IF (NOT inv_reservation_global.g_wip_record_cache.EXISTS(p_wip_entity_id)) THEN
668       -- call get_wip_entity API
669       inv_reservation_pvt.get_wip_entity_type
670          (  p_api_version_number           => 1.0
671           , p_init_msg_lst                 => fnd_api.g_false
672           , x_return_status                => l_return_status
673           , x_msg_count                    => l_msg_count
674           , x_msg_data                     => l_msg_data
675           , p_organization_id              => null
676           , p_item_id                      => null
677           , p_source_type_id               => null
678           , p_source_header_id             => p_wip_entity_id
679           , p_source_line_id               => null
680           , p_source_line_detail           => null
681           , x_wip_entity_type              => l_wip_entity_type
682           , x_wip_job_type                 => l_wip_job_type
683          );
684 
685       IF (l_return_status = fnd_api.g_ret_sts_error) THEN
686           RAISE fnd_api.g_exc_error;
687       ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
688           RAISE fnd_api.g_exc_unexpected_error;
689       END IF;
690 
691       inv_reservation_global.g_wip_record_cache(p_wip_entity_id).wip_entity_id
692          := p_wip_entity_id;
693 
694       inv_reservation_global.g_wip_record_cache(p_wip_entity_id).wip_entity_type
695          := l_wip_entity_type;
696 
697       inv_reservation_global.g_wip_record_cache(p_wip_entity_id).wip_entity_job
698          := l_wip_job_type;
699   END IF;
700 
701   x_return_status := l_return_status;
702 EXCEPTION
703   WHEN fnd_api.g_exc_error THEN
704      x_return_status := fnd_api.g_ret_sts_error;
705      --
706   WHEN fnd_api.g_exc_unexpected_error THEN
707       x_return_status := fnd_api.g_ret_sts_unexp_error ;
708   WHEN OTHERS THEN
709       x_return_status := fnd_api.g_ret_sts_unexp_error ;
710 
711       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
712          fnd_msg_pub.add_exc_msg
713            (  g_pkg_name
714               , 'Add_Wip_Cache'
715            );
716       END IF;
717 
718 END get_wip_cache;
719 /*** End R12 }} ***/
720 
721 END inv_reservation_util_pvt;