1 PACKAGE BODY inv_reservation_util_pvt AS
2 /* $Header: INVRSV2B.pls 120.2 2005/09/28 18:24:44 vipartha 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 -- For increased efficiency if source_line_is is provided then that
254 -- is used as the index in which to store the demand info hence check that
255 -- position first. If it is null then use existing check
256 IF p_demand_source_line_id IS NOT NULL THEN
257 IF inv_reservation_global.g_demand_record_cache.EXISTS(p_demand_source_line_id) THEN
258 -- The orginal code allowed any value including demand_source_line_id to be null.
259 -- In the case where demand_source_line_id is null the demand record is place
260 -- in the first available slot in the table. Hence need to also check if record
261 -- returned is actual record required
262 IF inv_reservation_global.g_demand_record_cache(p_demand_source_line_id).demand_source_line_id IS NOT NULL THEN
263 l_index := p_demand_source_line_id;
264 END IF;
265 END IF;
266 ELSE -- loop through all
267 IF inv_reservation_global.g_demand_record_cache.count > 0 THEN
268 l_index := inv_reservation_global.g_demand_record_cache.first ;
269 LOOP
270 IF (inv_reservation_global.g_demand_record_cache
271 (l_index).demand_source_type_id IS NULL
272 AND p_demand_source_type_id IS NULL
273 OR inv_reservation_global.g_demand_record_cache
274 (l_index).demand_source_type_id = p_demand_source_type_id)
275 AND (inv_reservation_global.g_demand_record_cache
276 (l_index).demand_source_header_id IS NULL
277 AND p_demand_source_header_id IS NULL
278 OR inv_reservation_global.g_demand_record_cache
279 (l_index).demand_source_header_id
280 = p_demand_source_header_id)
281 AND (inv_reservation_global.g_demand_record_cache
282 (l_index).demand_source_line_id IS NULL
283 AND p_demand_source_line_id IS NULL
284 OR inv_reservation_global.g_demand_record_cache
285 (l_index).demand_source_line_id = p_demand_source_line_id)
286 AND (inv_reservation_global.g_demand_record_cache
287 (l_index).demand_source_name IS NULL
288 AND p_demand_source_name IS NULL
289 OR inv_reservation_global.g_demand_record_cache
290 (l_index).demand_source_name = p_demand_source_name)
291 THEN
292 EXIT;
293 ELSE
294 IF l_index =
295 inv_reservation_global.g_demand_record_cache.last THEN
296 l_index := NULL;
297 EXIT;
298 END IF;
299 l_index :=
300 inv_reservation_global.g_demand_record_cache.next(l_index) ;
301 END IF;
302 END LOOP;
303 END IF;
304 END IF;
305
306 x_index := l_index;
307 x_return_status := l_return_status;
308
309 EXCEPTION
310 WHEN OTHERS THEN
311 x_return_status := fnd_api.g_ret_sts_unexp_error ;
312
313 IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
314 THEN
315 fnd_msg_pub.add_exc_msg
316 ( g_pkg_name
317 , 'Search_Demand_Cache'
318 );
319 END IF;
320
321 END search_demand_cache;
322
323 PROCEDURE add_demand_cache
324 (
325 x_return_status OUT NOCOPY VARCHAR2
326 , p_demand_record IN inv_reservation_global.demand_record
327 , x_index OUT NOCOPY NUMBER
328 ) IS
329 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
330 l_index NUMBER;
331 BEGIN
332 IF p_demand_record.demand_source_line_id IS NOT NULL THEN
333 l_index := p_demand_record.demand_source_line_id;
334 ELSE
335 -- need to check whether there is a collision and increment accordingly
336 LOOP
337 IF inv_reservation_global.g_demand_record_cache.EXISTS(g_next_demand_entry)
338 THEN g_next_demand_entry := g_next_demand_entry + 1;
339 ELSE
340 exit; --loop
341 END IF;
342 END LOOP;
343 --l_index := inv_reservation_global.g_demand_record_cache.COUNT+1;
344 l_index := g_next_demand_entry;
345 g_next_demand_entry := g_next_demand_entry + 1;
346 END IF;
347 inv_reservation_global.g_demand_record_cache(l_index)
348 := p_demand_record;
349
350 x_index := l_index;
351 x_return_status := l_return_status;
352
353 EXCEPTION
354 WHEN OTHERS THEN
355 x_return_status := fnd_api.g_ret_sts_unexp_error ;
356
357 IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
358 THEN
359 fnd_msg_pub.add_exc_msg
360 ( g_pkg_name
361 , 'Add_Demand_Cache'
362 );
363 END IF;
364
365 END add_demand_cache;
366
367 PROCEDURE search_supply_cache
368 (
369 x_return_status OUT NOCOPY VARCHAR2
370 , p_supply_source_type_id IN NUMBER
371 , p_supply_source_header_id IN NUMBER
372 , p_supply_source_line_id IN NUMBER
373 , p_supply_source_name IN VARCHAR2
374 , x_index OUT NOCOPY NUMBER
375 ) IS
376 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
377 l_index NUMBER;
378 l_rec inv_reservation_global.supply_record;
379 BEGIN
380
381 IF inv_reservation_global.g_supply_record_cache.count > 0 THEN
382 l_index := inv_reservation_global.g_supply_record_cache.first ;
383 LOOP
384 IF (inv_reservation_global.g_supply_record_cache
385 (l_index).supply_source_type_id IS NULL
386 AND p_supply_source_type_id IS NULL
387 OR inv_reservation_global.g_supply_record_cache
388 (l_index).supply_source_type_id = p_supply_source_type_id)
389 AND (inv_reservation_global.g_supply_record_cache
390 (l_index).supply_source_header_id IS NULL
391 AND p_supply_source_header_id IS NULL
392 OR inv_reservation_global.g_supply_record_cache
393 (l_index).supply_source_header_id
394 = p_supply_source_header_id)
395 AND (inv_reservation_global.g_supply_record_cache
396 (l_index).supply_source_line_id IS NULL
397 AND p_supply_source_line_id IS NULL
398 OR inv_reservation_global.g_supply_record_cache
399 (l_index).supply_source_line_id = p_supply_source_line_id)
400 AND (inv_reservation_global.g_supply_record_cache
401 (l_index).supply_source_name IS NULL
402 AND p_supply_source_name IS NULL
403 OR inv_reservation_global.g_supply_record_cache
404 (l_index).supply_source_name = p_supply_source_name)
405 THEN
406 EXIT;
407 ELSE
408 IF l_index
409 = inv_reservation_global.g_supply_record_cache.last THEN
410 l_index := NULL;
411 EXIT;
412 END IF;
413 l_index :=
414 inv_reservation_global.g_supply_record_cache.next(l_index) ;
415 END IF;
416 END LOOP;
417 END IF;
418
419 x_index := l_index;
420 x_return_status := l_return_status;
421
422 EXCEPTION
423 WHEN OTHERS THEN
424 x_return_status := fnd_api.g_ret_sts_unexp_error ;
425
426 IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
427 THEN
428 fnd_msg_pub.add_exc_msg
429 ( g_pkg_name
430 , 'Search_Supply_Cache'
431 );
432 END IF;
433
434 END search_supply_cache;
435
436 PROCEDURE add_supply_cache
437 (
438 x_return_status OUT NOCOPY VARCHAR2
439 , p_supply_record IN inv_reservation_global.supply_record
440 , x_index OUT NOCOPY NUMBER
441 ) IS
442 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
443 l_index NUMBER;
444 BEGIN
445 l_index := inv_reservation_global.g_supply_record_cache.COUNT+1;
446 inv_reservation_global.g_supply_record_cache(l_index)
447 := p_supply_record;
448
449 x_index := l_index;
450 x_return_status := l_return_status;
451
452 EXCEPTION
453 WHEN OTHERS THEN
454 x_return_status := fnd_api.g_ret_sts_unexp_error ;
455
456 IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
457 THEN
458 fnd_msg_pub.add_exc_msg
459 ( g_pkg_name
460 , 'Add_Supply_Cache'
461 );
462 END IF;
463
464 END add_supply_cache;
465
466 PROCEDURE search_sub_cache
467 (
468 x_return_status OUT NOCOPY VARCHAR2
469 , p_subinventory_code IN VARCHAR2
470 , p_organization_id IN NUMBER
471 , x_index OUT NOCOPY NUMBER
472 ) IS
473 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
474 l_index NUMBER;
475 BEGIN
476 -- Modified for common API. Secondary_inventory_name replaces
477 -- subinventory_code
478
479 IF inv_reservation_global.g_sub_record_cache.count > 0 THEN
480 l_index := inv_reservation_global.g_sub_record_cache.first ;
481 LOOP
482 IF (inv_reservation_global.g_sub_record_cache
483 (l_index).secondary_inventory_name IS NULL
484 AND p_subinventory_code IS NULL
485 OR inv_reservation_global.g_sub_record_cache
486 (l_index).secondary_inventory_name= p_subinventory_code)
487 AND (inv_reservation_global.g_sub_record_cache
488 (l_index).organization_id IS NULL
489 AND p_organization_id IS NULL
490 OR inv_reservation_global.g_sub_record_cache
491 (l_index).organization_id = p_organization_id) THEN
492 EXIT;
493 ELSE
494 IF l_index = inv_reservation_global.g_sub_record_cache.last THEN
495 l_index := NULL;
496 EXIT;
497 END IF;
498 l_index :=
499 inv_reservation_global.g_sub_record_cache.next(l_index) ;
500 END IF;
501 END LOOP;
502 END IF;
503
504 x_index := l_index;
505 x_return_status := l_return_status;
506
507 EXCEPTION
508 WHEN OTHERS THEN
509 x_return_status := fnd_api.g_ret_sts_unexp_error ;
510
511 IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
512 THEN
513 fnd_msg_pub.add_exc_msg
514 ( g_pkg_name
515 , 'Search_Sub_Cache'
516 );
517 END IF;
518
519 END search_sub_cache;
520
521 PROCEDURE add_sub_cache
522 (
523 x_return_status OUT NOCOPY VARCHAR2
524 , p_sub_record IN inv_reservation_global.sub_record
525 , x_index OUT NOCOPY NUMBER
526 ) IS
527 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
528 l_index NUMBER;
529 BEGIN
530 l_index := inv_reservation_global.g_sub_record_cache.COUNT+1;
531 inv_reservation_global.g_sub_record_cache(l_index)
532 := p_sub_record;
533
534 x_index := l_index;
535 x_return_status := l_return_status;
536
537 EXCEPTION
538 WHEN OTHERS THEN
539 x_return_status := fnd_api.g_ret_sts_unexp_error ;
540
541 IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
542 THEN
543 fnd_msg_pub.add_exc_msg
544 ( g_pkg_name
545 , 'Add_Sub_Cache'
546 );
547 END IF;
548
549 END add_sub_cache;
550
551 -- Function
552 -- locator_control
553 -- Description
554 -- Determine whether locator control is on.
555 -- uses lookup code from mtl_location_controls.
556 -- see mtl_system_items in the TRM for more
557 -- information.
558 -- mtl_location_control lookup code
559 -- 1 no locator control
560 -- 2 prespecified locator control
561 -- 3 dynamic entry locator control
562 -- 4 locator control determined at subinventory level
563 -- 5 locator control determined at item level
564 -- Since this package is used by reservation only,
565 -- we will no have dynamic entry locator control at all
566 -- (if the input is 3, we treats it as 2);
567 -- also as create, update, delete, or transfer a reservation
568 -- has no impact on on hand quantity, we will not check
569 -- negative balance as we do in validation module for
570 -- cycle count transactions.
571 -- Return Value
572 -- a number in (1,2,4,5), as defined in mtl_location_control
573 -- lookup code
574 FUNCTION locator_control
575 (
576 p_org_control IN NUMBER
577 , p_sub_control IN NUMBER
578 , p_item_control IN NUMBER DEFAULT NULL
579 ) RETURN NUMBER IS
580 l_value NUMBER;
581 l_locator_control NUMBER;
582 BEGIN
583
584 IF p_org_control = inv_reservation_global.g_locator_control_no THEN
585 l_locator_control := inv_reservation_global.g_locator_control_no;
586 ELSIF p_org_control =
587 inv_reservation_global.g_locator_control_prespecified THEN
588 l_locator_control :=
589 inv_reservation_global.g_locator_control_prespecified;
590 ELSIF p_org_control =
591 inv_reservation_global.g_locator_control_dynamic THEN
592 l_locator_control :=
593 inv_reservation_global.g_locator_control_prespecified;
594 ELSIF p_org_control = inv_reservation_global.g_locator_control_by_sub THEN
595 IF p_sub_control = inv_reservation_global.g_locator_control_no THEN
596 l_locator_control := inv_reservation_global.g_locator_control_no;
597 ELSIF p_sub_control =
598 inv_reservation_global.g_locator_control_prespecified THEN
599 l_locator_control :=
600 inv_reservation_global.g_locator_control_prespecified ;
601 ELSIF p_sub_control =
602 inv_reservation_global.g_locator_control_dynamic THEN
603 l_locator_control :=
604 inv_reservation_global.g_locator_control_prespecified;
605 ELSIF p_sub_control =
606 inv_reservation_global.g_locator_control_by_item THEN
607 IF p_item_control = inv_reservation_global.g_locator_control_no THEN
608 l_locator_control := inv_reservation_global.g_locator_control_no;
609 ELSIF p_item_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_item_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_item_control IS NULL THEN
618 l_locator_control := p_sub_control;
619 ELSE
620 l_value := p_item_control;
621 app_exception.invalid_argument
622 ('LOCATOR.CONTROL','ITEM_LOCATOR_CONTROL',l_value);
623 END IF;
624 ELSE
625 l_value := p_sub_control;
626 app_exception.invalid_argument
627 ('LOCATOR.CONTROL','SUB_LOCATOR_CONTROL',l_value);
628 END IF;
629 ELSE
630 l_value := p_org_control;
631 app_exception.invalid_argument
632 ('LOCATOR.CONTROL','ORG_LOCATOR_CONTROL',l_value);
633 END IF;
634
635 RETURN l_locator_control;
636
637 END locator_control;
638
639 /*** {{ R12 Enhanced reservations code changes ***/
640 -- Get_wip_cache will first check if the cache for the wip_entity_id
641 -- already exists or not. If it's not exist, then call the API
642 -- inv_reservation_pvt.get_wip_entity to set the wip record cache.
643 PROCEDURE get_wip_cache
644 (
645 x_return_status OUT NOCOPY VARCHAR2
646 , p_wip_entity_id IN NUMBER
647 ) IS
648 l_return_status VARCHAR2(1) := fnd_api.g_ret_sts_success;
649 l_msg_count NUMBER;
650 l_msg_data VARCHAR2(1000);
651 l_wip_entity_type NUMBER;
652 l_wip_job_type VARCHAR2(15);
653 BEGIN
654
655 IF (NOT inv_reservation_global.g_wip_record_cache.EXISTS(p_wip_entity_id)) THEN
656 -- call get_wip_entity API
657 inv_reservation_pvt.get_wip_entity_type
658 ( p_api_version_number => 1.0
659 , p_init_msg_lst => fnd_api.g_false
660 , x_return_status => l_return_status
661 , x_msg_count => l_msg_count
662 , x_msg_data => l_msg_data
663 , p_organization_id => null
664 , p_item_id => null
665 , p_source_type_id => null
666 , p_source_header_id => p_wip_entity_id
667 , p_source_line_id => null
668 , p_source_line_detail => null
669 , x_wip_entity_type => l_wip_entity_type
670 , x_wip_job_type => l_wip_job_type
671 );
672
673 IF (l_return_status = fnd_api.g_ret_sts_error) THEN
674 RAISE fnd_api.g_exc_error;
675 ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
676 RAISE fnd_api.g_exc_unexpected_error;
677 END IF;
678
679 inv_reservation_global.g_wip_record_cache(p_wip_entity_id).wip_entity_id
680 := p_wip_entity_id;
681
682 inv_reservation_global.g_wip_record_cache(p_wip_entity_id).wip_entity_type
683 := l_wip_entity_type;
684
685 inv_reservation_global.g_wip_record_cache(p_wip_entity_id).wip_entity_job
686 := l_wip_job_type;
687 END IF;
688
689 x_return_status := l_return_status;
690 EXCEPTION
691 WHEN fnd_api.g_exc_error THEN
692 x_return_status := fnd_api.g_ret_sts_error;
693 --
694 WHEN fnd_api.g_exc_unexpected_error THEN
695 x_return_status := fnd_api.g_ret_sts_unexp_error ;
696 WHEN OTHERS THEN
697 x_return_status := fnd_api.g_ret_sts_unexp_error ;
698
699 IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
700 fnd_msg_pub.add_exc_msg
701 ( g_pkg_name
702 , 'Add_Wip_Cache'
703 );
704 END IF;
705
706 END get_wip_cache;
707 /*** End R12 }} ***/
708
709 END inv_reservation_util_pvt;