DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_FAS423_XMLP_PKG

Source


1 PACKAGE BODY FA_FAS423_XMLP_PKG AS
2 /* $Header: FAS423B.pls 120.0.12010000.1 2008/07/28 13:14:24 appldev ship $ */
3 function BookFormula return VARCHAR2 is
4 begin
5 DECLARE
6   l_book       VARCHAR2(15);
7   l_book_class VARCHAR2(15);
8   l_accounting_flex_structure NUMBER(15);
9   l_currency_code VARCHAR2(15);
10   l_distribution_source_book VARCHAR2(15);
11   l_precision NUMBER(15);
12 BEGIN
13   SELECT bc.book_type_code,
14          bc.book_class,
15          bc.accounting_flex_structure,
16          bc.distribution_source_book,
17          sob.currency_code,
18          cur.precision
19   INTO   l_book,
20          l_book_class,
21          l_accounting_flex_Structure,
22          l_distribution_source_book,
23          l_currency_code,
24          l_precision
25   FROM   FA_BOOK_CONTROLS bc,
26          GL_SETS_OF_BOOKS sob,
27          FND_CURRENCIES cur
28   WHERE  bc.book_type_code = P_BOOK
29   AND    sob.set_of_books_id = bc.set_of_books_id
30   AND    sob.currency_code    = cur.currency_code;
31   Book_Class := l_book_class;
32   Accounting_Flex_Structure:=l_accounting_flex_structure;
33   Distribution_SOurce_Book :=l_distribution_source_book;
34   Currency_Code := l_currency_code;
35   P_Min_Precision := l_precision;
36   return(l_book);
37 END;
38 RETURN NULL; end;
39 function Period1Formula return VARCHAR2 is
40 begin
41 DECLARE
42   l_period_name VARCHAR2(15);
43   l_period_POD  DATE;
44   l_period_PCD  DATE;
45   l_period_PC   NUMBER(15);
46   l_period_FY   NUMBER(15);
47 BEGIN
48   SELECT period_name,
49          period_counter,
50          period_open_date,
51          nvl(period_close_date, sysdate),
52          fiscal_year
53   INTO   l_period_name,
54          l_period_PC,
55          l_period_POD,
56          l_period_PCD,
57          l_period_FY
58   FROM   FA_DEPRN_PERIODS
59   WHERE  book_type_code = P_BOOK
60   AND    period_name    = P_PERIOD1;
61   Period1_PC := l_period_PC;
62   Period1_POD := l_period_POD;
63   Period1_PCD := l_period_PCD;
64   Period1_FY  := l_period_FY;
65   RP_PERIOD_RANGE := P_Period1;
66   return(l_period_name);
67 END;
68 RETURN NULL; end;
69 function report_nameformula(Company_Name in varchar2) return varchar2 is
70 begin
71 DECLARE
72   l_report_name VARCHAR2(80);
73   l_conc_program_id NUMBER;
74 BEGIN
75 --Added during DT Fix
76 P_CONC_REQUEST_ID := fnd_global.CONC_REQUEST_ID;
77 --End of DT Fix
78   RP_Company_Name := Company_Name;
79   SELECT cr.concurrent_program_id
80   INTO l_conc_program_id
81   FROM FND_CONCURRENT_REQUESTS cr
82   WHERE cr.program_application_id = 140
83   AND   cr.request_id = P_CONC_REQUEST_ID;
84   SELECT cp.user_concurrent_program_name
85   INTO   l_report_name
86   FROM    FND_CONCURRENT_PROGRAMS_VL cp
87   WHERE
88       cp.concurrent_program_id= l_conc_program_id
89   and cp.application_id = 140;
90   l_report_name := substr(l_report_name,1,instr(l_report_name,' (XML)'));
91   RP_Report_Name := l_report_name;
92   RETURN(l_report_name);
93 EXCEPTION
94   WHEN OTHERS THEN
95     RP_Report_Name := 'REPORT TITLE';
96     RETURN('REPORT TITLE');
97 END;
98 RETURN NULL; end;
99 function Period2Formula return VARCHAR2 is
100 begin
101 DECLARE
102   l_period_name VARCHAR2(15);
103   l_period_POD  DATE;
104   l_period_PCD  DATE;
105   l_period_PC   NUMBER(15);
106   l_period_FY   NUMBER(15);
107 BEGIN
108   SELECT period_name,
109          period_counter,
110          period_open_date,
111          nvl(period_close_date, sysdate),
112          fiscal_year
113   INTO   l_period_name,
114          l_period_PC,
115          l_period_POD,
116          l_period_PCD,
117          l_period_FY
118   FROM   FA_DEPRN_PERIODS
119   WHERE  book_type_code = P_BOOK
120   AND    period_name    = P_PERIOD2;
121   Period2_PC := l_period_PC;
122   Period2_POD := l_period_POD;
123   Period2_PCD := l_period_PCD;
124   Period2_FY  := l_period_FY;
125   RP_PERIOD_RANGE := P_Period1|| ' - '||P_Period2;
126   return(l_period_name);
127 EXCEPTION
128     WHEN NO_DATA_FOUND
129     THEN
130          Period2_PC := Period1_PC;
131          Period2_POD := Period1_POD;
132          Period2_PCD := Period1_PCD;
133          Period2_FY := Period1_FY;
134     return(P_PERIOD1);
135 END;
136 RETURN NULL; end;
137 function BeforeReport return boolean is
138 begin
139 /*SRW.USER_EXIT('FND SRWINIT');*/null;
140   return (TRUE);
141 end;
142 function AfterReport return boolean is
143 begin
144 /*SRW.USER_EXIT('FND SRWEXIT');*/null;
145   return (TRUE);
146 end;
147 function d_lifeformula(life in number, adj_rate in number, bonus_rate in number, prod in number) return varchar2 is
148 begin
149 begin
150 	return(fadolif(life, adj_rate, bonus_rate,
151 			prod));
152 end;
153 RETURN NULL; end;
154 FUNCTION do_life77(life NUMBER,
155 		adj_rate NUMBER,
156 		bonus_rate NUMBER,
157 		prod NUMBER)
158 RETURN VARCHAR2 IS
159    temp_retval 	VARCHAR2(7);
160    retval NUMBER;
161 BEGIN
162    IF life IS NOT NULL
163    THEN
164       temp_retval := (LPAD(TO_CHAR(TRUNC(life/12, 0), '90'),3,' ') || '.' ||
165 		SUBSTR(TO_CHAR(MOD(life, 12), '00'), 2, 2)) || ' ';
166       retval := fnd_number.canonical_to_number(temp_retval);
167    ELSIF adj_rate IS NOT NULL
168    THEN
169       retval := TO_CHAR(ROUND((adj_rate + NVL(bonus_rate, 0))*100, 2), '90D99') || '%';
170    ELSIF prod IS NOT NULL
171    THEN
172       retval := TO_CHAR(prod);
173    ELSE
174 	      retval := 'None';
175    END IF;
176    return(retval);
177 END;
178 --Functions to refer Oracle report placeholders--
179  Function Accounting_Flex_Structure_p return number is
180 	Begin
181 	 return Accounting_Flex_Structure;
182 	 END;
183  Function ACCT_BAL_APROMPT_p return varchar2 is
184 	Begin
185 	 return ACCT_BAL_APROMPT;
186 	 END;
187  Function ACCT_CC_APROMPT_p return varchar2 is
188 	Begin
189 	 return ACCT_CC_APROMPT;
190 	 END;
191  Function CAT_MAJ_APROMPT_p return varchar2 is
192 	Begin
193 	 return CAT_MAJ_APROMPT;
194 	 END;
195  Function Currency_Code_p return varchar2 is
196 	Begin
197 	 return Currency_Code;
198 	 END;
199  Function Book_Class_p return varchar2 is
200 	Begin
201 	 return Book_Class;
202 	 END;
203  Function Distribution_Source_Book_p return varchar2 is
204 	Begin
205 	 return Distribution_Source_Book;
206 	 END;
207  Function Period1_PC_p return number is
208 	Begin
209 	 return Period1_PC;
210 	 END;
211  Function Period1_PCD_p return date is
212 	Begin
213 	 return Period1_PCD;
214 	 END;
215  Function Period1_POD_p return date is
216 	Begin
217 	 return Period1_POD;
218 	 END;
219  Function Period1_FY_p return number is
220 	Begin
221 	 return Period1_FY;
222 	 END;
223  Function Period2_FY_p return number is
224 	Begin
225 	 return Period2_FY;
226 	 END;
227  Function Period2_PCD_p return date is
228 	Begin
229 	 return Period2_PCD;
230 	 END;
231  Function Period2_POD_p return date is
232 	Begin
233 	 return Period2_POD;
234 	 END;
235  Function Period2_PC_p return number is
236 	Begin
237 	 return Period2_PC;
238 	 END;
239  Function RP_COMPANY_NAME_p return varchar2 is
240 	Begin
241 	 return RP_COMPANY_NAME;
242 	 END;
243  Function RP_REPORT_NAME_p return varchar2 is
244 	Begin
245 	 return RP_REPORT_NAME;
246 	 END;
247  Function RP_PERIOD_RANGE_p return varchar2 is
248 	Begin
249 	 return RP_PERIOD_RANGE;
250 	 END;
251 FUNCTION fadolif(life NUMBER,
252 		adj_rate NUMBER,
253 		bonus_rate NUMBER,
254 		prod NUMBER)
255 RETURN CHAR IS
256    retval CHAR(7);
257    num_chars NUMBER;
258    temp_retval number;
259 BEGIN
260    IF life IS NOT NULL
261    THEN
262       -- Fix for bug 601202 -- added substrb after lpad.  changed '90' to '999'
263       temp_retval := fnd_number.canonical_to_number((LPAD(SUBSTR(TO_CHAR(TRUNC(life/12, 0), '999'), 2, 3),3,' ') || '.' ||
264 		SUBSTR(TO_CHAR(MOD(life, 12), '00'), 2, 2)) );
265       retval := to_char(temp_retval,'999D99');
266    ELSIF adj_rate IS NOT NULL
267    THEN
268       /* Bug 1744591
269          Changed 90D99 to 990D99 */
270            retval := SUBSTR(TO_CHAR(ROUND((adj_rate + NVL(bonus_rate, 0))*100, 2), '990.99'),2,6) || '%';
271    ELSIF prod IS NOT NULL
272    THEN
273 	--test for length of production_capacity; if it's longer
274 	--than 7 characters, then display in exponential notation
275       --IF prod <= 9999999
276       --THEN
277       --   retval := TO_CHAR(prod);
278       --ELSE
279       --   retval := SUBSTR(LTRIM(TO_CHAR(prod, '9.9EEEE')), 1, 7);
280       --END IF;
281 	--display nothing for UOP assets
282 	retval := '';
283    ELSE
284 	--should not occur
285       retval := ' ';
286    END IF;
287    return(retval);
288 END;
289 END FA_FAS423_XMLP_PKG ;
290