DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_UTILS_PKG

Source


1 PACKAGE BODY FA_UTILS_PKG as
2 /* $Header: FAXUTILB.pls 120.4 2005/07/25 10:04:30 yyoon ship $ */
3 
4 --  Function  faxrnd
5 --
6 FUNCTION faxrnd(X_amount   IN OUT NOCOPY NUMBER,
7                 X_book     IN VARCHAR2,
8                 p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
9                 return BOOLEAN is
10 
11    h_set_of_books_id  number;
12    l_found            boolean := FALSE;
13    l_array_count      number  := faxcurr_table.count;
14    l_count            number  := 0;
15 
16    BEGIN
17 
18      h_set_of_books_id := nvl(FA_CACHE_PKG.fazcbcs_record.set_of_books_id,
19                               FA_CACHE_PKG.fazcbc_record.set_of_books_id);
20 
21      /* look at the record and then the array and if no hit, then select */
22      IF (h_set_of_books_id = faxcurr_record.set_of_books_id) then
23         null;
24      ELSE
25         for i in 1..l_array_count loop
26 
27             l_count := i;
28 
29             if (faxcurr_table(i).set_of_books_id = h_set_of_books_id) then
30                l_found := TRUE;
31                exit;
32             else
33                l_found := FALSE;
34             end if;
35 
36         end loop;
37 
38         if l_found = TRUE then
39            faxcurr_record       := faxcurr_table(l_count);
40         else
41            SELECT h_set_of_books_id,
42                   curr.currency_code,
43                   curr.precision
44            INTO   faxcurr_record.set_of_books_id,
45                   faxcurr_record.currency_code,
46                   faxcurr_record.precision
47            FROM   fnd_currencies curr, gl_sets_of_books sob
48            WHERE  sob.set_of_books_id = h_set_of_books_id AND
49                   curr.currency_code = sob.currency_code;
50 
51            faxcurr_table(l_array_count + 1):= faxcurr_record;
52 
53         end if;
54      END IF;
55 
56      X_amount := ROUND(X_amount, faxcurr_record.precision);
57 
58      return(TRUE);
59 
60    EXCEPTION
61      WHEN OTHERS THEN
62         FA_SRVR_MSG.ADD_SQL_ERROR(CALLING_FN => 'FA_UTILS_PKG.faxrnd'
63                 ,p_log_level_rec => p_log_level_rec);
64         return(FALSE);
65 
66    END faxrnd;
67 
68 
69 FUNCTION faxtru
70 	(
71 	X_num		IN OUT NOCOPY number,
72 	X_book_type_code 	IN VARCHAR2,
73         p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
74 	return boolean is
75 
76    h_set_of_books_id	fa_book_controls.set_of_books_id%type;
77    l_found            boolean := FALSE;
78    l_array_count      number  := faxcurr_table.count;
79    l_count            number  := 0;
80 
81 begin <<FAXTRU>>
82 
83      h_set_of_books_id := nvl(FA_CACHE_PKG.fazcbcs_record.set_of_books_id,
84                               FA_CACHE_PKG.fazcbc_record.set_of_books_id);
85 
86      /* look at the record and then the array and if no hit, then select */
87 
88      IF (h_set_of_books_id = faxcurr_record.set_of_books_id) then
89         null;
90      ELSE
91         for i in 1..l_array_count loop
92 
93             l_count := i;
94 
95             if (faxcurr_table(i).set_of_books_id = h_set_of_books_id) then
96                l_found := TRUE;
97                exit;
98             else
99                l_found := FALSE;
100             end if;
101 
102         end loop;
103 
104         if l_found = TRUE then
105            faxcurr_record       := faxcurr_table(l_count);
106         else
107 
108            SELECT h_set_of_books_id,
109                   curr.precision
110            INTO   faxcurr_record.set_of_books_id,
111                   faxcurr_record.precision
112            FROM   fnd_currencies curr, gl_sets_of_books sob
113            WHERE  sob.set_of_books_id = h_set_of_books_id AND
114                   curr.currency_code = sob.currency_code;
115 
116            faxcurr_table(l_array_count + 1):= faxcurr_record;
117 
118         end if;
119      END IF;
120 
121      --
122      -- Truncate in_num based on the precision
123      --
124      X_num := trunc(X_num, faxcurr_record.precision);
125 
126      return (TRUE);
127 
128 exception
129 	when others then
130 		fa_srvr_msg.add_sql_error (
131 			calling_fn => 'fa_utils_pkg.faxtru'
132 			,p_log_level_rec => p_log_level_rec);
133 		return (FALSE);
134 end FAXTRU;
135 
136 
137 
138 FUNCTION faxceil(X_amount   IN OUT NOCOPY NUMBER,
139                  X_book     IN VARCHAR2,
140                  p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
141                  return BOOLEAN is
142 
143    h_set_of_books_id  number;
144    l_found            boolean := FALSE;
145    l_array_count      number  := faxcurr_table.count;
146    l_count            number  := 0;
147 
148    BEGIN
149 
150      h_set_of_books_id := nvl(FA_CACHE_PKG.fazcbcs_record.set_of_books_id,
151                               FA_CACHE_PKG.fazcbc_record.set_of_books_id);
152 
153      /* look at the record and then the array and if no hit, then select */
154      IF (h_set_of_books_id = faxcurr_record.set_of_books_id) then
155         null;
156      ELSE
157         for i in 1..l_array_count loop
158 
159             l_count := i;
160 
161             if (faxcurr_table(i).set_of_books_id = h_set_of_books_id) then
162                l_found := TRUE;
163                exit;
164             else
165                l_found := FALSE;
166             end if;
167 
168         end loop;
169 
170         if l_found = TRUE then
171            faxcurr_record       := faxcurr_table(l_count);
172         else
173            SELECT h_set_of_books_id,
174                   curr.currency_code,
175                   curr.precision
176            INTO   faxcurr_record.set_of_books_id,
177                   faxcurr_record.currency_code,
178                   faxcurr_record.precision
179            FROM   fnd_currencies curr, gl_sets_of_books sob
180            WHERE  sob.set_of_books_id = h_set_of_books_id AND
181                   curr.currency_code = sob.currency_code;
182 
183            faxcurr_table(l_array_count + 1):= faxcurr_record;
184 
185         end if;
186      END IF;
187 
188       X_amount := ceil(X_amount * power(10,faxcurr_record.precision)) /
189                  power(10,faxcurr_record.precision);
190 
191      return(TRUE);
192 
193 EXCEPTION
194    WHEN OTHERS THEN
195       FA_SRVR_MSG.ADD_SQL_ERROR(CALLING_FN => 'FA_UTILS_PKG.faxceil'
196             ,p_log_level_rec => p_log_level_rec);
197       return(FALSE);
198 
199 END faxceil;
200 
201 
202 FUNCTION faxfloor(X_amount   IN OUT NOCOPY NUMBER,
203                   X_book     IN VARCHAR2,
204                   p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
205                   return BOOLEAN is
206 
207    h_set_of_books_id  number;
208    l_found            boolean := FALSE;
209    l_array_count      number  := faxcurr_table.count;
210    l_count            number  := 0;
211 
212    BEGIN
213 
214      h_set_of_books_id := nvl(FA_CACHE_PKG.fazcbcs_record.set_of_books_id,
215                               FA_CACHE_PKG.fazcbc_record.set_of_books_id);
216 
217      /* look at the record and then the array and if no hit, then select */
218      IF (h_set_of_books_id = faxcurr_record.set_of_books_id) then
219         null;
220      ELSE
221         for i in 1..l_array_count loop
222 
223             l_count := i;
224 
225             if (faxcurr_table(i).set_of_books_id = h_set_of_books_id) then
226                l_found := TRUE;
227                exit;
228             else
229                l_found := FALSE;
230             end if;
231 
232         end loop;
233 
234         if l_found = TRUE then
235            faxcurr_record       := faxcurr_table(l_count);
236         else
237            SELECT h_set_of_books_id,
238                   curr.currency_code,
239                   curr.precision
240            INTO   faxcurr_record.set_of_books_id,
241                   faxcurr_record.currency_code,
242                   faxcurr_record.precision
243            FROM   fnd_currencies curr, gl_sets_of_books sob
244            WHERE  sob.set_of_books_id = h_set_of_books_id AND
245                   curr.currency_code = sob.currency_code;
246 
247            faxcurr_table(l_array_count + 1):= faxcurr_record;
248 
249         end if;
250      END IF;
251 
252      X_amount := trunc(X_amount * power(10,faxcurr_record.precision)) /
253                   power(10,faxcurr_record.precision);
254 
255      return(TRUE);
256 
257 EXCEPTION
258    WHEN OTHERS THEN
259       FA_SRVR_MSG.ADD_SQL_ERROR(CALLING_FN => 'FA_UTILS_PKG.faxfloor'
260             ,p_log_level_rec => p_log_level_rec);
261       return(FALSE);
262 
263 END faxfloor;
264 
265 -- Function faxlkp_meaning()
266 --
267 FUNCTION faxlkp_meaning(X_lookup_type   IN  VARCHAR2,
268                         X_lookup_code   IN  VARCHAR2,
269                         p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
270                   return VARCHAR2 is
271 
272 l_meaning fa_lookups.meaning%TYPE;
273 l_hash_value NUMBER;
274 
275 BEGIN
276   IF X_lookup_code IS NOT NULL AND
277      X_lookup_type IS NOT NULL THEN
278 
279     l_hash_value := DBMS_UTILITY.get_hash_value(
280                                          X_lookup_type||'@*?'||X_lookup_code,
281                                          1000,
282                                          25000);
283 
284     IF faxlkpmg_table.EXISTS(l_hash_value) THEN
285         l_meaning := faxlkpmg_table(l_hash_value);
286     ELSE
287 /*modified the following query for bug no.3876060 */
288 	select 	T.MEANING
289 	into 	l_meaning
290 	from 	FA_LOOKUPS_TL T
291 	where   T.LANGUAGE = USERENV('LANG')
292 	and 	T.LOOKUP_TYPE = X_lookup_type
293 	and 	T.LOOKUP_CODE = X_lookup_code;
294 
295       faxlkpmg_table(l_hash_value) := l_meaning;
296 
297     END IF;
298 
299   END IF;
300 
301   return(l_meaning);
302 
303 EXCEPTION
304    WHEN no_data_found THEN
305       return(null);
306    WHEN OTHERS THEN
307       FA_SRVR_MSG.ADD_SQL_ERROR(CALLING_FN => 'FA_UTILS_PKG.faxlkp_meaning'
308             ,p_log_level_rec => p_log_level_rec);
309       raise;
310 
311 END faxlkp_meaning;
312 
313 FUNCTION faxlkp_code(X_lookup_type   IN  VARCHAR2,
314                      X_meaning       IN  VARCHAR2,
315                      p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)
316                   return VARCHAR2 is
317 
318 l_lookup_code fa_lookups.Lookup_code%TYPE;
319 l_hash_value NUMBER;
320 
321 BEGIN
322  IF X_Meaning IS NOT NULL AND
323     X_lookup_type IS NOT NULL THEN
324 
325     l_hash_value := DBMS_UTILITY.get_hash_value(
326                                          X_lookup_type||'@*?'||X_meaning,
327                                          1000,
328                                          25000);
329     IF faxlkpcd_table.EXISTS(l_hash_value) THEN
330         l_lookup_code := faxlkpcd_table(l_hash_value);
331     ELSE
332 /* modified the following query for bug no.3876060 */
333 	SELECT  T.LOOKUP_CODE
334 	into 	l_lookup_code
335 	FROM 	FA_LOOKUPS_TL T
336 	WHERE   T.LANGUAGE = USERENV('LANG')
337 	AND 	T.LOOKUP_TYPE = X_lookup_type
338 	AND 	T.MEANING = X_meaning;
339 
340         faxlkpcd_table(l_hash_value) := l_lookup_code;
341 
342      END IF;
343   END IF;
344 
345    return(l_lookup_code);
346 
347 EXCEPTION
348    WHEN NO_DATA_FOUND THEN
349       return(null);
350    WHEN OTHERS THEN
351       FA_SRVR_MSG.ADD_SQL_ERROR(CALLING_FN => 'FA_UTILS_PKG.faxlkp_code'
352             ,p_log_level_rec => p_log_level_rec);
353       raise;
354 
355 END faxlkp_code;
356 
357 END FA_UTILS_PKG;