DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_GLOBALS

Source


1 PACKAGE BODY Oe_Globals AS
2 /* $Header: OEXSGLBB.pls 120.6.12010000.1 2008/07/25 07:54:20 appldev ship $ */
3 
4 --  Global constant holding the package name
5 
6 G_PKG_NAME                    CONSTANT VARCHAR2(30) := 'Oe_Globals';
7 
8 --  Procedure Get_Entities_Tbl.
9 --
10 --  Used by generator to avoid overriding or duplicating existing
11 --  entity constants.
12 --
13 --  DO NOT REMOVE
14 
15 PROCEDURE Get_Entities_Tbl
16 IS
17 I                             NUMBER:=0;
18 --
19 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
20 --
21 BEGIN
22 
23     FND_API.g_entity_tbl.DELETE;
24 
25 --  START GEN entities
26     I := I + 1;
27     FND_API.g_entity_tbl(I).name   := 'ALL';
28 
29 /* Order Object Entities: Begin */
30 
31     I := I + 1;
32     FND_API.g_entity_tbl(I).name   := 'HEADER';
33     I := I + 1;
34     FND_API.g_entity_tbl(I).name   := 'HEADER_ADJ';
35     I := I + 1;
36     FND_API.g_entity_tbl(I).name   := 'HEADER_SCREDIT';
37     I := I + 1;
38     FND_API.g_entity_tbl(I).name   := 'LINE';
39     I := I + 1;
40     FND_API.g_entity_tbl(I).name   := 'LINE_ADJ';
41     I := I + 1;
42     FND_API.g_entity_tbl(I).name   := 'LINE_SCREDIT';
43     I := I + 1;
44     FND_API.g_entity_tbl(I).name   := 'LOT_SERIAL';
45 
46 /* Order Object Entities: End */
47 
48 /* Pricing Contract Object Entities: Begin */
49 
50     I := I + 1;
51     FND_API.g_entity_tbl(I).name   := 'CONTRACT';
52     I := I + 1;
53     FND_API.g_entity_tbl(I).name   := 'AGREEMENT';
54     I := I + 1;
55     FND_API.g_entity_tbl(I).name   := 'PRICE_LHEADER';
56     I := I + 1;
57     FND_API.g_entity_tbl(I).name   := 'DISCOUNT_HEADER';
58     I := I + 1;
59     FND_API.g_entity_tbl(I).name   := 'PRICE_LLINE';
60     I := I + 1;
61     FND_API.g_entity_tbl(I).name   := 'DISCOUNT_CUST';
62     I := I + 1;
63     FND_API.g_entity_tbl(I).name   := 'DISCOUNT_LINE';
64     I := I + 1;
65     FND_API.g_entity_tbl(I).name   := 'PRICE_BREAK';
66 
67 /* Pricing Contract Object Entities: End */
68 
69 /* Charge Object Entities: Begin */
70     I := I + 1;
71     FND_API.g_entity_tbl(I).name := 'CHARGE_LINE';
72 /* Charge Object Entities: End */
73 
74 /* Customer and Item Settings Object Entities: Begin */
75     I := I + 1;
76     FND_API.g_entity_tbl(I).name := 'CUST_ITEM_SET';
77 /* Charge Object Entities: End */
78 
79 --  END GEN entities
80 
81 END Get_Entities_Tbl;
82 
83 --  Initialize control record.
84 
85 FUNCTION Init_Control_Rec
86 (   p_operation                     IN  VARCHAR2
87 ,   p_control_rec                   IN  Control_Rec_Type
88 )RETURN Control_Rec_Type
89 IS
90 l_control_rec                 Control_Rec_Type;
91 BEGIN
92 
93     IF p_control_rec.controlled_operation
94 	 AND p_control_rec.Private_Call THEN
95 
96 	l_control_rec := p_control_rec;
97 
98 	-- If there are mixed operations in a single call to process order
99 	-- e.g. updating a header and inserting a line for this same header,
100 	-- then the clear_dependents should be TRUE for header but
101 	-- clear_dependents should be FALSE for line. Since process order
102 	-- accepts one control record per call, the user cannot set it
103 	-- based on the operation.
104 	-- Therefore, even if the operation is controlled, set the
105 	-- clear_dependents flag based on the operation
106 	-- NEW(03/01/2000): BUT set it only if operation is CREATE as
107 	-- private callers may want to set clear_dependents to FALSE even
108 	-- if operation is UPDATE for performance reasons
109 	-- From the UI (sales order form), this setting is overridden
110 	-- as form calls with clear_dependents TRUE even for CREATE
111 	-- operation as the user changes attributes (e.g. enters an item
112 	-- , the attributes dependent on item should be cleared) and
113 	-- the record is not yet posted.
114 	IF (p_control_rec.default_attributes) THEN
115 
116 	   IF NOT (OE_GLOBALS.G_UI_FLAG) THEN
117 
118 	    IF p_operation = G_OPR_CREATE THEN
119 		 l_control_rec.clear_dependents := FALSE;
120 	    END IF;
121 
122 	   END IF;
123 
124 	-- If the clear_dependents flag is TRUE and default_attributes is
125 	-- FALSE, this could result in corrupted data; dependent fields would
126 	-- be cleared i.e. set to missing values but since there is no
127 	-- defaulting, these missing values might be saved to the DB.
128 	-- Therefore, always set default_attributes to TRUE if clear_dependents
129 	-- is TRUE.
130 	ELSIF (p_control_rec.clear_dependents) THEN
131 
132 		l_control_rec.default_attributes := TRUE;
133 
134 	END IF;
135 
136 	RETURN l_control_rec;
137 
138     ELSIF  p_operation = G_OPR_NONE OR p_operation IS NULL THEN
139 
140         l_control_rec.check_security:=  FALSE;
141         l_control_rec.clear_dependents:=  FALSE;
142         l_control_rec.default_attributes:=  FALSE;
143         l_control_rec.change_attributes :=  FALSE;
144         l_control_rec.validate_entity	:=  FALSE;
145         l_control_rec.write_to_DB	:=  FALSE;
146         l_control_rec.Process_Partial   := FALSE;
147         l_control_rec.process		:=  p_control_rec.process;
148         l_control_rec.process_entity	:=  p_control_rec.process_entity;
149         l_control_rec.request_category	:=  p_control_rec.request_category;
150         l_control_rec.request_name	:=  p_control_rec.request_name;
151         l_control_rec.clear_api_cache	:=  p_control_rec.clear_api_cache;
152         l_control_rec.clear_api_requests:=  p_control_rec.clear_api_requests;
153         l_control_rec.org_id := FND_API.G_MISS_NUM;
154 
155     ELSIF p_operation = G_OPR_CREATE THEN
156 
157         l_control_rec.check_security:=  TRUE;
158         l_control_rec.clear_dependents:=  FALSE;
159         l_control_rec.default_attributes:=   TRUE;
160         l_control_rec.change_attributes :=   TRUE;
161         l_control_rec.validate_entity  :=   TRUE;
162         l_control_rec.write_to_DB	:=   TRUE;
163         l_control_rec.Process_Partial   := FALSE;
164         l_control_rec.process		:=   TRUE;
165         l_control_rec.process_entity	:=   G_ENTITY_ALL;
166         l_control_rec.clear_api_cache	:=   TRUE;
167         l_control_rec.clear_api_requests:=   TRUE;
168         l_control_rec.org_id := FND_API.G_MISS_NUM;
169 
170     ELSIF p_operation = G_OPR_UPDATE THEN
171 
172         l_control_rec.check_security:=  TRUE;
173         l_control_rec.clear_dependents:=  TRUE;
174         l_control_rec.default_attributes:=   TRUE;
175         l_control_rec.change_attributes :=   TRUE;
176         l_control_rec.validate_entity	:=   TRUE;
177         l_control_rec.write_to_DB	:=   TRUE;
178         l_control_rec.Process_Partial   := FALSE;
179         l_control_rec.process		:=   TRUE;
180         l_control_rec.process_entity	:=   G_ENTITY_ALL;
181         l_control_rec.clear_api_cache	:=   TRUE;
182         l_control_rec.clear_api_requests:=   TRUE;
183         l_control_rec.org_id := FND_API.G_MISS_NUM;
184 
185     ELSIF p_operation = G_OPR_DELETE THEN
186 
187         l_control_rec.check_security:=  TRUE;
188         l_control_rec.clear_dependents:=  FALSE;
189         l_control_rec.default_attributes:=   FALSE;
190         l_control_rec.change_attributes :=   FALSE;
191         l_control_rec.validate_entity	  :=   TRUE;
192         l_control_rec.write_to_DB	  :=   TRUE;
193         l_control_rec.Process_Partial   := FALSE;
194         l_control_rec.process		  :=   TRUE;
195         l_control_rec.process_entity	  :=   G_ENTITY_ALL;
196         l_control_rec.clear_api_cache	  :=   TRUE;
197         l_control_rec.clear_api_requests:=   TRUE;
198         l_control_rec.org_id := FND_API.G_MISS_NUM;
199 
200     ELSE
201 
202         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
203         THEN
204             OE_MSG_PUB.Add_Exc_Msg
205             (   G_PKG_NAME
206             ,   'Init_Control_Rec'
207             ,   'Invalid operation'
208             );
209         END IF;
210 
211         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
212 
213     END IF;
214 
215     IF p_control_rec.controlled_operation AND
216 	NOT p_control_rec.Private_Call THEN
217 		l_control_rec.org_id := p_control_rec.org_id;
218 	     l_control_rec.process_partial := p_control_rec.process_partial;
219     END IF;
220 
221     RETURN l_control_rec;
222 
223 END Init_Control_Rec;
224 
225 
226 -- following constants are used to debug lock_order,
227 -- please do not use them for any other purpose.
228 -- G_LOCK_CONST and G_LOCK_TEST
229 
230 --  Function Equal
231 --  Number comparison.
232 
233 FUNCTION Equal
234 (   p_attribute1                    IN  NUMBER
235 ,   p_attribute2                    IN  NUMBER
236 )RETURN BOOLEAN
237 IS
238 BEGIN
239 
240     IF G_LOCK_TEST = 'Y' THEN
241       G_LOCK_CONST := G_LOCK_CONST + 1;
242 
243       IF NOT (( p_attribute1 IS NULL AND p_attribute2 IS NULL ) OR
244         ( p_attribute1 IS NOT NULL AND
245           p_attribute2 IS NOT NULL AND
246           p_attribute1 = p_attribute2 )) THEN
247         IF oe_debug_pub.g_debug_level  > 0 THEN
248             oe_debug_pub.add(  'LOCK COMPARISON FAILED: '|| G_LOCK_CONST , 1 ) ;
249         END IF;
250       END IF;
251       RETURN TRUE;
252 
253     ELSE
254       IF p_attribute1 IS NULL THEN
255          IF p_attribute2 IS NULL THEN
256             RETURN TRUE;
257          ELSE
258             RETURN FALSE;
259          END IF;
260       ELSE
261          IF p_attribute2 IS NULL THEN
262             RETURN FALSE;
263          ELSE
264             RETURN (p_attribute1 = p_attribute2);
265          END IF;
266       END IF;
267     END IF;
268 
269 END Equal;
270 
271 --  Varchar2 comparison.
272 
273 FUNCTION Equal
274 (   p_attribute1                    IN  VARCHAR2
275 ,   p_attribute2                    IN  VARCHAR2
276 )RETURN BOOLEAN
277 IS
278 BEGIN
279 
280     IF G_LOCK_TEST = 'Y' THEN
281       G_LOCK_CONST := G_LOCK_CONST + 1;
282 
283       IF NOT (( p_attribute1 IS NULL AND p_attribute2 IS NULL ) OR
284         ( p_attribute1 IS NOT NULL AND
285           p_attribute2 IS NOT NULL AND
286           p_attribute1 = p_attribute2 )) THEN
287         IF oe_debug_pub.g_debug_level  > 0 THEN
288             oe_debug_pub.add(  'LOCK COMPARISON FAILED: '|| G_LOCK_CONST , 1 ) ;
289         END IF;
290       END IF;
291       RETURN TRUE;
292 
293     ELSE
294       IF p_attribute1 IS NULL THEN
295          IF p_attribute2 IS NULL THEN
296             RETURN TRUE;
297          ELSE
298             RETURN FALSE;
299          END IF;
300       ELSE
301          IF p_attribute2 IS NULL THEN
302             RETURN FALSE;
303          ELSE
304             RETURN (p_attribute1 = p_attribute2);
305          END IF;
306       END IF;
307     END IF;
308 
309 END Equal;
310 
311 --  Date comparison.
312 
313 FUNCTION Equal
314 (   p_attribute1                    IN  DATE
315 ,   p_attribute2                    IN  DATE
316 )RETURN BOOLEAN
317 IS
318 BEGIN
319 
320     IF G_LOCK_TEST = 'Y' THEN
321       G_LOCK_CONST := G_LOCK_CONST + 1;
322 
323       IF NOT (( p_attribute1 IS NULL AND p_attribute2 IS NULL ) OR
324         ( p_attribute1 IS NOT NULL AND
325           p_attribute2 IS NOT NULL AND
326           p_attribute1 = p_attribute2 )) THEN
327         IF oe_debug_pub.g_debug_level  > 0 THEN
328             oe_debug_pub.add(  'LOCK COMPARISON FAILED: '|| G_LOCK_CONST , 1 ) ;
329         END IF;
330       END IF;
331       RETURN TRUE;
332 
333     ELSE
334       IF p_attribute1 IS NULL THEN
335          IF p_attribute2 IS NULL THEN
336             RETURN TRUE;
337          ELSE
338             RETURN FALSE;
339          END IF;
340       ELSE
341          IF p_attribute2 IS NULL THEN
342             RETURN FALSE;
343          ELSE
344             RETURN (p_attribute1 = p_attribute2);
345          END IF;
346       END IF;
347     END IF;
348 
349 END Equal;
350 
351 PROCEDURE Set_Context IS
352 l_org_id NUMBER;
353 
354 --
355 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
356 --
357 BEGIN
358 
359 /*SELECT NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1,1), ' ', NULL,
360  SUBSTRB(USERENV('CLIENT_INFO'),1,10))),-99) INTO
361   l_org_id FROM DUAL;*/
362 
363 -- MOAC changes
364 --   l_org_id := to_number(FND_PROFILE.VALUE('ORG_ID'));
365   l_org_id := MO_GLOBAL.Get_Current_Org_Id;
366 
367   IF l_org_id IS NOT NULL THEN
368      OE_GLOBALS.G_ORG_ID :=  l_org_id;
369   ELSE
370      IF l_debug_level > 0 THEN
371         OE_DEBUG_PUB.ADD('OEXSGLBB.pls- Org ID could not be fetched from MO API',5);
372      END IF;
373      fnd_message.set_name('FND', 'MO_ORG_REQUIRED');
374      OE_MSG_PUB.ADD;
375      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
376   END IF;
377 -- MOAC ends
378 
379 EXCEPTION
380 
381 	WHEN NO_DATA_FOUND THEN
382 			-- Not required since dual always returns - Rajeev
383 			OE_GLOBALS.G_ORG_ID := NULL;
384 
385 END Set_Context;
386 
387 FUNCTION CHECK_PRODUCT_INSTALLED
388 (   p_application_id                IN  NUMBER
389 )RETURN VARCHAR2
390 IS
391 l_status		VARCHAR2(1);
392 l_industry	VARCHAR2(1);
393 l_return_val	VARCHAR2(1);
394 
395 --
396 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
397 --
398 BEGIN
399 
400    IF (fnd_installation.get(p_application_id,p_application_id
401                          ,l_status,l_industry)) THEN
402 	 IF l_status IN ('I', 'S') THEN
403 	   l_return_val := 'Y';
404 
405            /* Fix 1857901: Return iPayment(673) Not Installed for a SHARED Install */
406            IF  (p_application_id = 673 and l_status = 'S' )
407            or  (p_application_id = 550 and l_status = 'S' )   -- OPM 2547940  Return OPM (550) Not Installed for a SHARED Install
408            or  (p_application_id = 603 and l_status = 'S' )   -- Return XDO (603) Not Installed for a SHARED Install
409            THEN
410              l_return_val := 'N';
411            END IF;
412       ELSE
413 	   l_return_val := 'N';
414       END IF;
415    ELSE
416 	   l_return_val := 'N';
417    END IF;
418    RETURN l_return_val;
419 
420 END CHECK_PRODUCT_INSTALLED;
421 
422 FUNCTION GET_APPLICATION_ID (p_resp_id IN NUMBER) RETURN NUMBER
423 IS
424 
425 l_default_appl_id NUMBER := 660;
426 l_appl_id NUMBER;
427 
428 --
429 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
430 --
431 BEGIN
432 
433    SELECT APPLICATION_ID
434    INTO   l_appl_id
435    FROM   FND_RESPONSIBILITY
436    WHERE  RESPONSIBILITY_ID = p_resp_id;
437 
438    RETURN l_appl_id;
439 
440 EXCEPTION
441 
442    WHEN OTHERS THEN
443         RETURN l_default_appl_id;
444 
445 END;
446 
447 FUNCTION GET_FORCE_CLEAR_UI_BLOCK RETURN VARCHAR2 IS
448 BEGIN
449    RETURN OE_GLOBALS.G_FORCE_CLEAR_UI_BLOCK;
450 END;
451 
452 PROCEDURE SET_FORCE_CLEAR_UI_BLOCK (ui_block IN VARCHAR2) IS
453 BEGIN
454    OE_GLOBALS.G_FORCE_CLEAR_UI_BLOCK:=ui_block;
455 END;
456 
457 FUNCTION Is_Same_Credit_Card
458 (   p_cc_num_old                    IN  VARCHAR2 DEFAULT NULL
459 ,   p_cc_num_new                    IN  VARCHAR2 DEFAULT NULL
460 ,   p_instrument_id_old              IN  NUMBER DEFAULT NULL
461 ,   p_instrument_id_new              IN  NUMBER DEFAULT NULL
462 ) RETURN BOOLEAN IS
463 
464 l_exists	VARCHAR2(1) := 'N';
465 l_hash1_old	VARCHAR2(30);
466 l_hash2_old	VARCHAR2(30);
467 l_hash1_new	VARCHAR2(30);
468 l_hash2_new	VARCHAR2(30);
469 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
470 
471 BEGIN
472 
473 	IF l_debug_level > 0 THEN
474 	    oe_debug_pub.add('Entering Is_Same_Credit_Card Function...');
475 	    oe_debug_pub.add('Old card number'||p_cc_num_old);
476 	    oe_debug_pub.add('New card number'||p_cc_num_new);
477 	    oe_debug_pub.add('Old instrument id'||p_instrument_id_old);
478 	    oe_debug_pub.add('New instrument id2'||p_instrument_id_new);
479 	END IF;
480 
481 	IF p_instrument_id_old IS NOT NULL AND p_instrument_id_new IS NOT NULL THEN
482 
483 	  BEGIN
484 	    SELECT 'Y'
485 	    INTO   l_exists
486             FROM   iby_creditcard ic1
487 	    WHERE  ic1.INSTRID = p_instrument_id_new
488  	    AND    ic1.cc_number_hash1 = (SELECT cc_number_hash1
489 				      FROM   iby_creditcard ic2
490  				      WHERE  ic2.INSTRID = p_instrument_id_old)
491             AND    ic1.cc_number_hash2 = (SELECT cc_number_hash2
492                                       FROM   iby_creditcard ic3
493                                       WHERE  ic3.INSTRID = p_instrument_id_old);
494 	    EXCEPTION WHEN NO_DATA_FOUND THEN
495 	      null;
496 	  END;
497 
498           IF l_exists = 'Y' THEN
499      	    RETURN TRUE;
500 	  ELSE
501 	    RETURN FALSE;
502 	  END IF;
503 
504 	ELSIF p_instrument_id_old IS NOT NULL AND p_instrument_id_new IS NULL THEN
505 	  IF p_cc_num_new IS NULL THEN
506 	    RETURN FALSE;
507 
508 	  ELSE
509 
510 	    BEGIN
511 	      SELECT cc_number_hash1, cc_number_hash2
512 	      INTO   l_hash1_old, l_hash2_old
513               FROM   iby_creditcard
514 	      WHERE  INSTRID = p_instrument_id_old;
515 	      EXCEPTION WHEN NO_DATA_FOUND THEN
516 	        null;
517 	      END;
518 
519 	      l_hash1_new := iby_security_pkg.get_hash(p_cc_num_new, 'F');
520 	      l_hash2_new := iby_security_pkg.get_hash(p_cc_num_new, 'T');
521 
522 	      IF l_hash1_old = l_hash1_new AND l_hash2_old = l_hash2_new THEN
523 		RETURN TRUE;
524 	      ELSE
525   		RETURN FALSE;
526  	      END IF;
527 	   END IF;
528 
529 	ELSIF p_instrument_id_old IS NULL AND p_instrument_id_new IS NOT NULL THEN
530 	  IF p_cc_num_old IS NULL THEN
531 	    RETURN FALSE;
532           ELSE
533             BEGIN
534             SELECT cc_number_hash1, cc_number_hash2
535             INTO   l_hash1_new, l_hash2_new
536             FROM   iby_creditcard
537             WHERE  INSTRID = p_instrument_id_new;
538             EXCEPTION WHEN NO_DATA_FOUND THEN
539               null;
540             END;
541 
542             l_hash1_old := iby_security_pkg.get_hash(p_cc_num_old, 'F');
543             l_hash2_old := iby_security_pkg.get_hash(p_cc_num_old, 'T');
544 
545             IF l_hash1_old = l_hash1_new AND l_hash2_old = l_hash2_new THEN
546               RETURN TRUE;
547             ELSE
548               RETURN FALSE;
549             END IF;
550           END IF;
551 
552 	ELSE
553           -- both old and new values are full numbers.
554           RETURN Equal(p_cc_num_old, p_cc_num_new);
555 
556 	END IF;
557 
558 
559 END Is_Same_Credit_Card;
560 
561 
562 END Oe_Globals;