DBA Data[Home] [Help]

PACKAGE BODY: APPS.CSTPPDOP

Source


1 PACKAGE BODY CSTPPDOP AS
2 /* $Header: CSTPDOPB.pls 120.1 2006/01/20 03:06:26 skayitha noship $ */
3 
4 FUNCTION validate_post_to_GL (
5 		p_org_id	IN	NUMBER,
6 		p_legal_entity	IN	NUMBER,
7 		p_cost_type_id	IN	NUMBER,
8 		p_options	IN	NUMBER
9 		)
10 /* ****************************************************************************	*/
11 /* Option = 1: IN Params Reqd: p_legal_entity, p_cost_type_id, options		*/
12 /* 	Description: a> If another Org having the same set of books posts to	*/
13 /*			Gl, then return FALSE 					*/
14 /*		     b> If another LE-CT combination having the same set of 	*/
15 /*			books has transfer to GL, then return FALSE		*/
16 /*		     C> If both the above conditions fail, then return TRUE	*/
17 /*										*/
18 /* Option = 2: IN Params Reqd: p_org_id, options				*/
19 /*	Description: a> If another LE-CT combination having the same set of 	*/
20 /*			books posts to GL, the return FALSE			*/
21 /*		     b> If above condition fails, the return TRUE		*/
22 /* **************************************************************************** */
23 
24 
25 RETURN	BOOLEAN		IS
26 	ret_num		NUMBER;
27 	dummy		NUMBER;
28 BEGIN
29 	ret_num		:= 0;
30 	dummy		:= 0;
31 
32     IF(p_options = 1) THEN
33 
34 	select	count(1)
35 	into 	dummy
36 	from
37         	CST_LE_COST_TYPES CLCT,
38         	CST_ACCT_INFO_V OOD,
39         	MTL_PARAMETERS MP
40 	where
41         	clct.set_of_books_id = ood.LEDGER_ID
42 	AND     ood.LEGAL_ENTITY = p_legal_entity
43 	AND     ood.organization_id IN (    SELECT  ccga.organization_id
44        		                            FROM    cst_cost_group_assignments ccga,
45                                          	    cst_cost_groups ccg
46                                     	    WHERE   ccg.legal_entity = p_legal_entity
47                                             AND     ccga.cost_group_id = ccg.cost_group_id )
48 	AND     clct.legal_entity  = p_legal_entity
49 	AND     clct.cost_type_id  = p_cost_type_id
50 	AND	clct.primary_cost_method > 2
51 	AND     mp.organization_id = ood.organization_id
52 	AND     mp.general_ledger_update_code <> 3
53 	AND     ROWNUM < 2 ;
54 
55 	IF(NVL(dummy,0) <> 0) THEN
56 		ret_num := 1;
57 	ELSE
58 		ret_num := 0;
59 	END IF;
60 
61 	IF(ret_num = 1) THEN
62 		return FALSE;
63 	END IF;
64 
65 	dummy	:= 0;
66 	ret_num	:= 0;
67 
68 	SELECT  count(*)
69 	INTO	dummy
70 	FROM    cst_le_cost_types clct
71 	WHERE   clct.legal_entity = p_legal_entity
72 	AND     clct.cost_type_id <> p_cost_type_id
73 	AND	clct.set_of_books_id = (SELECT	clct1.set_of_books_id
74 					FROM	cst_le_cost_types clct1
75 					WHERE	clct1.cost_type_id = p_cost_type_id
76 					AND	clct1.legal_entity = p_legal_entity
77 					AND	clct.primary_cost_method > 2)
78 	AND     clct.post_to_gl = 'Y';
79 
80         IF(NVL(dummy,0)<> 0) THEN
81                 ret_num := 1;
82         ELSE
83                 ret_num := 0;
84         END IF;
85 
86         IF(ret_num = 1) THEN
87                 return FALSE;
88         ELSE
89                 return TRUE;
90         END IF;
91 
92 
93    END IF; /* Option = 1 */
94 
95 
96   IF (p_options = 2) THEN
97 
98 	ret_num := 0;
99 	dummy	:= 0;
100 
101 	SELECT	count(1)
102 	INTO	dummy
103 	FROM
104         	cst_le_cost_types clct,
105         	 CST_ACCT_INFO_V ood,
106         	mtl_parameters mp
107 	WHERE
108         	clct.set_of_books_id = ood.LEDGER_ID
109 	AND     ood.organization_id  = p_org_id
110 	AND     ood.organization_id  = mp.organization_id
111 	AND     clct.legal_entity    = (     SELECT  distinct ccg.legal_entity
112        		                             FROM    cst_cost_group_assignments ccga,
113        		                                     cst_cost_groups ccg
114        		                             WHERE   ccga.organization_id = p_org_id
115        		                             AND     ccga.cost_group_id = ccg.cost_group_id )
116 	AND     clct.post_to_gl = 'Y'
117 	AND     clct.primary_cost_method > 2
118 	AND     ROWNUM < 2;
119 
120 
121         IF(NVL(dummy,0)<> 0) THEN
122                 ret_num := 1;
123 	ELSE
124 		ret_num := 0;
125 	END IF;
126 
127         IF(ret_num = 1) THEN
128                 return FALSE;
129         ELSE
130                 return TRUE;
131         END IF;
132 
133    ELSE
134 	return FALSE;
135    END IF; /* Option = 2 */
136 
137 EXCEPTION
138 	WHEN OTHERS THEN
139 		return FALSE;
140 
141 END validate_post_to_GL;
142 
143 
144 END CSTPPDOP;