DBA Data[Home] [Help]

PACKAGE BODY: APPS.FF_DBI_UTILS_PKG

Source


1 package body ff_dbi_utils_pkg as
2 /* $Header: ffdbiutl.pkb 120.4 2007/03/29 09:58:11 alogue noship $ */
3 
4 --
5 -- Maximum length of a database item name in characters (not bytes).
6 --
7 C_DBI_NAME_LEN constant number := 160;
8 
9 --
10 -- Legislation rule for translations support.
11 --
12 C_TRANS_LEG_RULE constant varchar2(64) := 'FF_TRANSLATE_DATABASE_ITEMS';
13 
14 --
15 -- Caches for supported and unsupported translations.
16 --
17 type t_vc2_16 is table of varchar2(16) index by binary_integer;
18 g_trans_supported t_vc2_16;
19 g_got_supported   boolean := false;
20 
21 ------------------------------ str2dbiname -------------------------------
22 function str2dbiname
23 (p_str in varchar2
24 ) return varchar2 is
25 l_dbi_name   varchar2(2000);
26 l_underscore varchar2(30) := ' -';
27 l_remove     varchar2(30) := '"()''.';
28 l_rgeflg     varchar2(10);
29 l_debug      boolean := hr_utility.debug_enabled;
30 begin
31   -- Get rid of leading and trailing spaces.
32   l_dbi_name := ltrim(rtrim(p_str));
33 
34   -- Process characters to be replaced  by underscores.
35   l_dbi_name :=
36   translate(l_dbi_name, l_underscore, lpad('_', length(l_underscore), '_'));
37 
38   -- Process characters to be removed.
39   l_dbi_name :=
40   translate(l_dbi_name, l_remove, lpad('"', length(l_remove), '"'));
41   l_dbi_name := replace(l_dbi_name, '"', '');
42 
43   -- Uppercase.
44   l_dbi_name := upper(l_dbi_name);
45 
46   -- Shorten to maximum allowable length.
47   l_dbi_name := substr(l_dbi_name, 1, C_DBI_NAME_LEN);
48   --
49   if l_debug then
50     if length(l_dbi_name) < length(p_str) then
51       hr_utility.trace('DBI name: ' || p_str || ' shortened to ' || l_dbi_name);
52     end if;
53   end if;
54 
55   -- Get rid of leading and trailing spaces.
56   l_dbi_name := ltrim(rtrim(l_dbi_name));
57 
58   -- CHECKFORMAT
59   begin
60     hr_chkfmt.checkformat
61     (value   => l_dbi_name
62     ,format  => 'DB_ITEM_NAME'
63     ,output  => l_dbi_name
64     ,minimum => null
65     ,maximum => null
66     ,nullok  => 'N'
67     ,rgeflg  => l_rgeflg
68     ,curcode => null
69     );
70   exception
71     when others then
72       --
73       -- Not in the standard name format so convert to quoted format.
74       --
75       l_dbi_name :=
76       '"' || rtrim(ltrim(substr(l_dbi_name, 1, C_DBI_NAME_LEN - 2))) || '"';
77 
78       if l_debug then
79         hr_utility.trace('Necessary to quote name ' || l_dbi_name);
80       end if;
81   end;
82 
83   return l_dbi_name;
84 end str2dbiname;
85 
86 --------------------------- get_supported_trans --------------------------
87 -- NAME
88 --   get_supported_trans
89 --
90 -- DESCRIPTION
91 --   One-off call to get the legislations supported translations from
92 --   PAY_LEGISLATION_RULES.
93 --
94 procedure get_supported_trans is
95 cursor csr_get_leg_rules(p_rule_mode in varchar2) is
96 select plr.legislation_code
97 from   pay_legislation_rules plr
98 where  plr.rule_type = C_TRANS_LEG_RULE
99 and    plr.rule_mode = p_rule_mode
100 ;
101 begin
102   --
103   -- Fetch legislations where translations are supported.
104   --
105   open csr_get_leg_rules(p_rule_mode => 'Y');
106   fetch csr_get_leg_rules bulk collect
107   into  g_trans_supported
108   ;
109   close csr_get_leg_rules;
110 end get_supported_trans;
111 
112 ------------------------- translations_supported -------------------------
113 function translations_supported
114 (p_legislation_code in varchar2
115 ) return boolean is
116 begin
117   --
118   -- Get the legislations that support translations.
119   --
120   if not g_got_supported then
121     get_supported_trans;
122   end if;
123 
124   --
125   -- Look in cache to see if the legislation supports translations.
126   --
127   for i in 1 .. g_trans_supported.count loop
128     if p_legislation_code = g_trans_supported(i) then
129       return true;
130     end if;
131   end loop;
132 
133   --
134   -- Translations are not supported.
135   --
136   return false;
137 end translations_supported;
138 
139 ------------------------- translations_supported -------------------------
140 function translation_supported
141 (p_legislation_code in varchar2
142 ) return varchar2 is
143 begin
144   --
145   -- Get the legislations that support translations.
146   --
147   if not g_got_supported then
148     get_supported_trans;
149   end if;
150 
151   --
152   -- Look in cache to see if the legislation supports translations.
153   --
154   for i in 1 .. g_trans_supported.count loop
155     if p_legislation_code = g_trans_supported(i) then
156       return 'Y';
157     end if;
158   end loop;
159 
160   --
161   -- Translations are not supported.
162   --
163   return 'N';
164 end translation_supported;
165 
166 
167 end ff_dbi_utils_pkg;