DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_MGB_SHD

Source


1 Package Body pay_mgb_shd as
2 /* $Header: pymgbrhi.pkb 120.0 2005/05/29 06:45:44 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_mgb_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------< return_api_dml_status >-------------------------|
12 -- ----------------------------------------------------------------------------
13 Function return_api_dml_status Return Boolean Is
14 --
15   l_proc        varchar2(72) := g_package||'return_api_dml_status';
16 --
17 Begin
18   hr_utility.set_location('Entering:'||l_proc, 5);
19   --
20   Return (nvl(g_api_dml, false));
21   --
22   hr_utility.set_location(' Leaving:'||l_proc, 10);
23 End return_api_dml_status;
24 --
25 -- ----------------------------------------------------------------------------
26 -- |---------------------------< constraint_error >---------------------------|
27 -- ----------------------------------------------------------------------------
28 Procedure constraint_error
29             (p_constraint_name in all_constraints.constraint_name%TYPE) Is
30 --
31   l_proc        varchar2(72) := g_package||'constraint_error';
32 --
33 Begin
34   hr_utility.set_location('Entering:'||l_proc, 5);
35   --
36   If (p_constraint_name = 'PAY_MAGNETIC_BLOCKS_PK') Then
37     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
38     hr_utility.set_message_token('PROCEDURE', l_proc);
39     hr_utility.set_message_token('STEP','5');
40     hr_utility.raise_error;
41   ElsIf (p_constraint_name = 'PAY_MGB_MAIN_BLOCK_FLAG_CHK') Then
42     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
43     hr_utility.set_message_token('PROCEDURE', l_proc);
44     hr_utility.set_message_token('STEP','10');
45     hr_utility.raise_error;
46   Else
47     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
48     fnd_message.set_token('PROCEDURE', l_proc);
49     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
50     fnd_message.raise_error;
51   End If;
52   --
53   hr_utility.set_location(' Leaving:'||l_proc, 10);
54 End constraint_error;
55 --
56 -- ----------------------------------------------------------------------------
60   (
57 -- |-----------------------------< api_updating >-----------------------------|
58 -- ----------------------------------------------------------------------------
59 Function api_updating
61   p_magnetic_block_id                  in number
62   )      Return Boolean Is
63 --
64   --
65   -- Cursor selects the 'current' row from the HR Schema
66   --
67   Cursor C_Sel1 is
68     select
69         magnetic_block_id,
70         block_name,
71         main_block_flag,
72         report_format,
73         cursor_name,
74         no_column_returned
75     from        pay_magnetic_blocks
76     where       magnetic_block_id = p_magnetic_block_id;
77 --
78   l_proc        varchar2(72)    := g_package||'api_updating';
79   l_fct_ret     boolean;
80 --
81 Begin
82   hr_utility.set_location('Entering:'||l_proc, 5);
83   --
84   If (
85         p_magnetic_block_id is null
86      ) Then
87     --
88     -- One of the primary key arguments is null therefore we must
89     -- set the returning function value to false
90     --
91     l_fct_ret := false;
92   Else
93     If (
94         p_magnetic_block_id = g_old_rec.magnetic_block_id
95        ) Then
96       hr_utility.set_location(l_proc, 10);
97       --
98       -- The g_old_rec is current therefore we must
99       -- set the returning function to true
100       --
101       l_fct_ret := true;
102     Else
103       --
104       -- Select the current row into g_old_rec
105       --
106       Open C_Sel1;
107       Fetch C_Sel1 Into g_old_rec;
108       If C_Sel1%notfound Then
109         Close C_Sel1;
110         --
111         -- The primary key is invalid therefore we must error
112         --
113         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
114         hr_utility.raise_error;
115       End If;
116       Close C_Sel1;
117       --
118       hr_utility.set_location(l_proc, 15);
119       l_fct_ret := true;
120     End If;
121   End If;
122   hr_utility.set_location(' Leaving:'||l_proc, 20);
123   Return (l_fct_ret);
124 --
125 End api_updating;
126 --
127 -- ----------------------------------------------------------------------------
128 -- |---------------------------------< lck >----------------------------------|
129 -- ----------------------------------------------------------------------------
130 Procedure lck
131   (
132   p_magnetic_block_id                  in number
133   ) is
134 --
135 -- Cursor selects the 'current' row from the HR Schema
136 --
137   Cursor C_Sel1 is
138     select      magnetic_block_id,
139         block_name,
140         main_block_flag,
141         report_format,
142         cursor_name,
143         no_column_returned
144     from        pay_magnetic_blocks
145     where       magnetic_block_id = p_magnetic_block_id
146     for update nowait;
147 --
148   l_proc        varchar2(72) := g_package||'lck';
149 --
150 Begin
151   hr_utility.set_location('Entering:'||l_proc, 5);
152   --
153   -- Add any mandatory argument checking here:
154   -- Example:
155   -- hr_api.mandatory_arg_error
156   --   (p_api_name       => l_proc,
157   --    p_argument       => 'object_version_number',
158   --    p_argument_value => p_object_version_number);
159   --
160   Open  C_Sel1;
161   Fetch C_Sel1 Into g_old_rec;
162   If C_Sel1%notfound then
163     Close C_Sel1;
164     --
165     -- The primary key is invalid therefore we must error
166     --
167     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
168     hr_utility.raise_error;
169   End If;
170   Close C_Sel1;
171   --
172 --
173   hr_utility.set_location(' Leaving:'||l_proc, 10);
174 --
175 -- We need to trap the ORA LOCK exception
176 --
177 Exception
178   When HR_Api.Object_Locked then
179     --
180     -- The object is locked therefore we need to supply a meaningful
181     -- error message.
182     --
183     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
184     hr_utility.set_message_token('TABLE_NAME', 'pay_magnetic_blocks');
185     hr_utility.raise_error;
186 End lck;
187 --
188 -- ----------------------------------------------------------------------------
189 -- |-----------------------------< convert_args >-----------------------------|
190 -- ----------------------------------------------------------------------------
191 Function convert_args
192         (
193         p_magnetic_block_id             in number,
194         p_block_name                    in varchar2,
195         p_main_block_flag               in varchar2,
196         p_report_format                 in varchar2,
197         p_cursor_name                   in varchar2,
198         p_no_column_returned            in number
199         )
200         Return g_rec_type is
201 --
202   l_rec   g_rec_type;
203   l_proc  varchar2(72) := g_package||'convert_args';
204 --
205 Begin
206   --
207   hr_utility.set_location('Entering:'||l_proc, 5);
208   --
209   -- Convert arguments into local l_rec structure.
210   --
211   l_rec.magnetic_block_id                := p_magnetic_block_id;
212   l_rec.block_name                       := p_block_name;
213   l_rec.main_block_flag                  := p_main_block_flag;
214   l_rec.report_format                    := p_report_format;
215   l_rec.cursor_name                      := p_cursor_name;
219   --
216   l_rec.no_column_returned               := p_no_column_returned;
217   --
218   -- Return the plsql record structure.
220   hr_utility.set_location(' Leaving:'||l_proc, 10);
221   Return(l_rec);
222 --
223 End convert_args;
224 --
225 -- ----------------------------------------------------------------------------
226 -- |----------------------------< get_magnetic_block_id >---------------------|
227 -- ----------------------------------------------------------------------------
228 Function get_magnetic_block_id
229   (p_block_name                     in varchar2
230   ,p_report_format                  in varchar2
231   )
232   Return number is
233 --
234   cursor csr_magnetic_block_id is
235        select distinct magnetic_block_id
236          from pay_magnetic_blocks
237         where block_name = p_block_name
238           and report_format = p_report_format;
239 --
240   l_proc   varchar2(72) := g_package||'get_magnetic_block_id';
241   l_magnetic_block_id   PAY_MAGNETIC_BLOCKS.MAGNETIC_BLOCK_ID%TYPE;
242 --
243 Begin
244 --
245   hr_utility.set_location('Entering:'||l_proc, 5);
246 
247   if p_block_name is null  or  p_report_format is null  then
248 
249         return  null;
250 
251   end if;
252 
253   open csr_magnetic_block_id;
254   fetch csr_magnetic_block_id into l_magnetic_block_id;
255 
256   if csr_magnetic_block_id%ROWCOUNT > 1 then
257 
258         close csr_magnetic_block_id;
259 
260         fnd_message.set_name( 'PAY' , 'PAY_33255_INV_SKEY' );
261         fnd_message.set_token( 'SURROGATE_ID' , 'MAGNETIC_BLOCK_ID' );
262         fnd_message.set_token( 'ENTITY' , 'MAGNETIC BLOCK' );
263         fnd_message.raise_error ;
264 
265   end if;
266 
267   close csr_magnetic_block_id;
268 
269   hr_utility.set_location(' Leaving:'||l_proc, 10);
270 
271   return l_magnetic_block_id;
272 
273 --
274 End get_magnetic_block_id;
275 --
276 end pay_mgb_shd;