DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_JP_MAG_UTILITY_PKG

Source


1 package body pay_jp_mag_utility_pkg as
2 /* $Header: pyjpmagu.pkb 120.1 2005/06/13 19:55:28 ttagawa noship $ */
3 --
4 -- Constants
5 --
6 c_package		constant varchar2(31) := 'pay_jp_mag_utility_pkg.';
7 --
8 -- Global Variables
9 --
10 type t_formula_queue is table of number index by binary_integer;
11 g_formula_queue		t_formula_queue;
12 -- ----------------------------------------------------------------------------
13 -- |--------------------------< show_formula_queue >--------------------------|
14 -- ----------------------------------------------------------------------------
15 -- Show all formulas stacked in the formula queue.
16 -- This procedure is only for debug purpose.
17 --
18 procedure show_formula_queue
19 is
20 	l_proc	varchar2(61) := c_package || 'show_formula_queue';
21 	--
22 	l_index	number;
23 begin
24 	hr_utility.set_location('Entering : ' || l_proc, 10);
25 	--
26 	l_index := g_formula_queue.first;
27 	while l_index is not null loop
28 		hr_utility.trace('formula : ' || to_char(l_index, 99) || ' : ' || to_char(g_formula_queue(l_index)));
29 		l_index := g_formula_queue.next(l_index);
30 	end loop;
31 	--
32 	hr_utility.set_location('Leaving : ' || l_proc, 20);
33 end show_formula_queue;
34 -- ----------------------------------------------------------------------------
35 -- |---------------------------< enqueue_formula >----------------------------|
36 -- ----------------------------------------------------------------------------
37 -- Enqueue the formula into the formula queue
38 --
39 procedure enqueue_formula(p_formula_id in number)
40 is
41 	l_index		number;
42 	l_formula_id	number;
43 begin
44 	l_index := nvl(g_formula_queue.last, 0) + 1;
45 	g_formula_queue(l_index) := p_formula_id;
46 end enqueue_formula;
47 -- ----------------------------------------------------------------------------
48 -- |---------------------------< dequeue_formula >----------------------------|
49 -- ----------------------------------------------------------------------------
50 -- Dequeue the latest formula from the formula queue.
51 -- The dequeued formula is removed from the formula queue.
52 --
53 function dequeue_formula return number
54 is
55 	l_index		number;
56 	l_formula_id	number;
57 begin
58 	l_index := g_formula_queue.first;
59 	if l_index is not null then
60 		l_formula_id := g_formula_queue(l_index);
61 		g_formula_queue.delete(l_index);
62 	end if;
63 	--
64 	return l_formula_id;
65 end dequeue_formula;
66 -- ----------------------------------------------------------------------------
67 -- |----------------------------< show_contexts >-----------------------------|
68 -- ----------------------------------------------------------------------------
69 -- Show all contexts in pay_mag_tape.internal_cxt_names/values.
70 -- This procedure is only for debug purpose.
71 --
72 procedure show_contexts
73 is
74 	l_proc	varchar2(61) := c_package || 'show_contexts';
75 begin
76 	hr_utility.set_location('Entering : ' || l_proc, 10);
77 	--
78 	for i in 1..pay_mag_tape.internal_cxt_names.count loop
79 		hr_utility.trace('context : ' || to_char(i, 99) || ' : ' || rpad(pay_mag_tape.internal_cxt_names(i), 30, ' ') || ' : ' || pay_mag_tape.internal_cxt_values(i));
80 	end loop;
81 	--
82 	hr_utility.set_location('Leaving : ' || l_proc, 20);
83 end show_contexts;
84 -- ----------------------------------------------------------------------------
85 -- |----------------------------< clear_contexts >----------------------------|
86 -- ----------------------------------------------------------------------------
87 -- Clear all contexts in pay_mag_tape.internal_cxt_names/values except for
88 -- the first entry "NO_OF_CONTEXTS".
89 --
90 procedure clear_contexts
91 is
92 	l_count	number := pay_mag_tape.internal_cxt_names.count;
93 begin
94 	for i in 2..l_count loop
95 		pay_mag_tape.internal_cxt_names.delete(i);
96 		pay_mag_tape.internal_cxt_values.delete(i);
97 	end loop;
98 	--
99 	pay_mag_tape.internal_cxt_values(1) := fnd_number.number_to_canonical(1);
100 end clear_contexts;
101 -- ----------------------------------------------------------------------------
102 -- |-----------------------------< set_context >------------------------------|
103 -- ----------------------------------------------------------------------------
104 -- Set context value to pay_mag_tape.internal_cxt_names/values.
105 -- All data types "NUMBER", "TEXT" and "DATE" are supported for contexts.
106 -- Need to convert to canonical format.
107 --
108 procedure set_context(
109 	p_context_name		in varchar2,
110 	p_context_value		in varchar2)
111 is
112 	l_found	boolean := false;
113 	l_count	number := pay_mag_tape.internal_cxt_names.count;
114 begin
115 	--
116 	-- If the context with specified name exists,
117 	-- override the context value with specified value.
118 	--
119 	for i in 1..l_count loop
120 		if pay_mag_tape.internal_cxt_names(i) = p_context_name then
121 			pay_mag_tape.internal_cxt_values(i) := p_context_value;
122 			l_found := true;
123 			exit;
124 		end if;
125 	end loop;
126 	--
127 	-- If the context with specified name does not exist,
128 	-- create new entry.
129 	--
130 	if not l_found then
131 		l_count := l_count + 1;
132 		pay_mag_tape.internal_cxt_values(1) := fnd_number.number_to_canonical(l_count);
133 		pay_mag_tape.internal_cxt_names(l_count) := p_context_name;
134 		pay_mag_tape.internal_cxt_values(l_count) := p_context_value;
135 	end if;
136 end set_context;
137 --
138 procedure set_context(
139 	p_context_name		in varchar2,
140 	p_context_value		in number)
141 is
142 begin
143 	set_context(
144 		p_context_name	=> p_context_name,
145 		p_context_value	=> fnd_number.number_to_canonical(p_context_value));
146 end set_context;
147 --
148 procedure set_context(
149 	p_context_name		in varchar2,
150 	p_context_value		in date)
151 is
152 begin
153 	set_context(
154 		p_context_name	=> p_context_name,
155 		p_context_value	=> fnd_date.date_to_canonical(p_context_value));
156 end set_context;
157 -- ----------------------------------------------------------------------------
158 -- |---------------------------< show_parameters >----------------------------|
159 -- ----------------------------------------------------------------------------
160 -- Show all parameters in pay_mag_tape.internal_prm_names/values.
161 -- This procedure is only for debug purpose.
162 --
163 procedure show_parameters
164 is
165 	l_proc	varchar2(61) := c_package || 'show_parameters';
166 begin
167 	hr_utility.set_location('Entering : ' || l_proc, 10);
168 	--
169 	for i in 1..pay_mag_tape.internal_prm_names.count loop
170 		hr_utility.trace('parameter : ' || to_char(i, 99) || ' : ' || rpad(pay_mag_tape.internal_prm_names(i), 60, ' ') || ' : "' || pay_mag_tape.internal_prm_values(i) || '"');
171 	end loop;
172 	--
173 	hr_utility.set_location('Leaving : ' || l_proc, 20);
174 end show_parameters;
175 -- ----------------------------------------------------------------------------
176 -- |----------------------------< get_parameter >-----------------------------|
177 -- ----------------------------------------------------------------------------
178 -- Derive the parameter value from pay_mag_tape.internal_prm_names/values.
179 --
180 function get_parameter(p_parameter_name in varchar2) return varchar2
181 is
182 	l_parameter_value	varchar2(81);
183 begin
184 	for i in 1..pay_mag_tape.internal_prm_names.count loop
185 		if pay_mag_tape.internal_prm_names(i) = p_parameter_name then
186 			l_parameter_value := pay_mag_tape.internal_prm_values(i);
187 			exit;
188 		end if;
189 	end loop;
190 	--
191 	return l_parameter_value;
192 end get_parameter;
193 -- ----------------------------------------------------------------------------
194 -- |----------------------------< set_parameter >-----------------------------|
195 -- ----------------------------------------------------------------------------
196 -- Set parameter value to pay_mag_tape.internal_prm_names/values.
197 -- Note supported parameter data type by PYUMAG is "TEXT" only.
198 -- Here passes parameters with canonical format.
199 --
200 procedure set_parameter(
201 	p_parameter_name	in varchar2,
202 	p_parameter_value	in varchar2,
203 	p_default_value		in varchar2 default ' ')
204 is
205 	l_found	boolean := false;
206 	l_count	number := pay_mag_tape.internal_prm_names.count;
207 begin
208 	--
209 	-- If the parameter with specified name exists,
210 	-- override the parameter value with specified value.
211 	--
212 	for i in 1..l_count loop
213 		if pay_mag_tape.internal_prm_names(i) = p_parameter_name then
214 			pay_mag_tape.internal_prm_values(i) := nvl(p_parameter_value, p_default_value);
215 			l_found := true;
216 			exit;
217 		end if;
218 	end loop;
219 	--
220 	-- If the parameter with specified name does not exist,
221 	-- create new entry.
222 	--
223 	if not l_found then
224 		l_count := l_count + 1;
225 		pay_mag_tape.internal_prm_values(1) := fnd_number.number_to_canonical(l_count);
226 		pay_mag_tape.internal_prm_names(l_count) := p_parameter_name;
227 		pay_mag_tape.internal_prm_values(l_count) := nvl(p_parameter_value, p_default_value);
228 	end if;
229 end set_parameter;
230 --
231 procedure set_parameter(
232 	p_parameter_name	in varchar2,
233 	p_parameter_value	in number,
234 	p_default_value		in number default 0)
235 is
236 begin
237 	set_parameter(
238 		p_parameter_name	=> p_parameter_name,
239 		p_parameter_value	=> fnd_number.number_to_canonical(p_parameter_value),
240 		p_default_value		=> fnd_number.number_to_canonical(p_default_value));
241 end set_parameter;
242 --
243 procedure set_parameter(
244 	p_parameter_name	in varchar2,
245 	p_parameter_value	in date,
246 	p_default_value		in date default trunc(sysdate))
247 is
248 begin
249 	set_parameter(
250 		p_parameter_name	=> p_parameter_name,
251 		p_parameter_value	=> fnd_date.date_to_canonical(p_parameter_value),
252 		p_default_value		=> fnd_date.date_to_canonical(p_default_value));
253 end set_parameter;
254 --
255 -- The following package initialization code is not necessary
256 -- when processed through PYUMAG or PYUGEN which populate the followings.
257 -- This is mainly for debugging purpose.
258 --
259 begin
260 	if not pay_mag_tape.internal_cxt_names.exists(1) then
261 		set_context('NO_OF_CONTEXTS', 1);
262 	end if;
263 	--
264 	if not pay_mag_tape.internal_prm_names.exists(1) then
265 		set_parameter('NO_OF_PARAMETERS', 2);
266 		set_parameter('NEW_FORMULA_ID', 0);
267 	end if;
268 end pay_jp_mag_utility_pkg;