DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_MGB_BUS

Source


1 Package Body pay_mgb_bus 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_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |-----------------------------< chk_unique_key >---------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure is used to check the uniqueness of the combination
17 --   block_name and report_format which forms the true key.
18 --
19 --
20 -- Pre Conditions:
21 --   Should be called only while insert. Since these columns are non-updatable
22 --   it is not required to check the uniqueness while update.
23 --
24 -- In Arguments:
25 --   block_name
26 --   report_format
27 --
28 -- Post Success:
29 --   Processing Continues.
30 --
31 --
32 -- Post Failure:
33 --   Failure might occur if any of the parameters are null or the combination
34 --   already exists for a different magnetic block.
35 --   Errors are trapped and reported.
36 --
37 -- {End Of Comments}
38 -- ----------------------------------------------------------------------------
39 Procedure chk_unique_key
40   ( p_block_name      in  varchar2
41    ,p_report_format   in  varchar2
42   ) IS
43 --
44 cursor csr_unique_key  is
45   select null
46   from   pay_magnetic_blocks
47   where  block_name = p_block_name
48   and    report_format   = p_report_format;
49 --
50   l_proc     varchar2(72) := g_package || 'chk_unique_key';
51   l_exists   varchar2(1);
52 --
53 Begin
54   --
55   hr_utility.set_location('Entering:'|| l_proc, 10);
56   --
57         hr_api.mandatory_arg_error
58               ( p_api_name       =>  l_proc
59                ,p_argument       =>  'BLOCK_NAME'
60                ,p_argument_value =>  p_block_name
61               );
62 
63         hr_api.mandatory_arg_error
64               ( p_api_name       =>  l_proc
65                ,p_argument       =>  'REPORT_FORMAT'
66                ,p_argument_value =>  p_report_format
67               );
68 
69         open csr_unique_key;
70         fetch csr_unique_key into l_exists;
71 
72         if csr_unique_key%found then
73 
74              close csr_unique_key;
75 
76              fnd_message.set_name( 'PAY' , 'PAY_33256_INV_UKEY1' );
77              fnd_message.set_token( 'COL1' , 'BLOCK_NAME');
78              fnd_message.set_token( 'COL2' , 'REPORT_FORMAT');
79              fnd_message.set_token( 'COL1_VAL', p_block_name);
80              fnd_message.set_token( 'COL2_VAL', p_report_format);
81              fnd_message.raise_error ;
82 
83         end if ;
84 
85         close csr_unique_key;
86   --
87   hr_utility.set_location(' Leaving:'|| l_proc, 20);
88   --
89 End chk_unique_key;
90 --
91 -- ----------------------------------------------------------------------------
92 -- |-----------------------< chk_non_updateable_args >------------------------|
93 -- ----------------------------------------------------------------------------
94 -- {Start Of Comments}
95 --
96 -- Description:
97 --   This procedure is used to ensure that non updateable attributes have
98 --   not been updated. If an attribute has been updated an error is generated.
99 --
100 -- Pre Conditions:
101 --   g_old_rec has been populated with details of the values currently in
102 --   the database.
103 --
104 -- In Arguments:
105 --   p_rec has been populated with the updated values the user would like the
106 --   record set to.
107 --
108 -- Post Success:
109 --   Processing continues if all the non updateable attributes have not
110 --   changed.
111 --
112 -- Post Failure:
113 --   An application error is raised if any of the non updatable attributes
114 --   have been altered.
115 --
116 -- {End Of Comments}
117 -- ----------------------------------------------------------------------------
118 Procedure chk_non_updateable_args
119   (p_rec in pay_mgb_shd.g_rec_type
120   ) IS
121 --
122   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
123 --
124 Begin
125   --
126   -- Only proceed with the validation if a row exists for the current
127   -- record in the HR Schema.
128   --
129   IF NOT pay_mgb_shd.api_updating
130       (p_magnetic_block_id                 => p_rec.magnetic_block_id
131       ) THEN
132      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
133      fnd_message.set_token('PROCEDURE ', l_proc);
134      fnd_message.set_token('STEP ', '5');
135      fnd_message.raise_error;
136   END IF;
137   --
138   --
139   if nvl(p_rec.block_name, hr_api.g_varchar2) <>
140      pay_mgb_shd.g_old_rec.block_name then
141      hr_api.argument_changed_error
142      (p_api_name => l_proc
143      ,p_argument => 'BLOCK_NAME'
144      ,p_base_table => pay_mgb_shd.g_tab_nam
145      );
146   end if;
147   --
148   if nvl(p_rec.report_format, hr_api.g_varchar2) <>
149      pay_mgb_shd.g_old_rec.report_format then
150      hr_api.argument_changed_error
151      (p_api_name => l_proc
152      ,p_argument => 'REPORT_FORMAT'
153      ,p_base_table => pay_mgb_shd.g_tab_nam
154      );
155   end if;
156   --
157 End chk_non_updateable_args;
158 --
159 -- ----------------------------------------------------------------------------
160 -- |---------------------------< insert_validate >----------------------------|
161 -- ----------------------------------------------------------------------------
162 Procedure insert_validate(p_rec in pay_mgb_shd.g_rec_type) is
163 --
164   l_proc  varchar2(72) := g_package||'insert_validate';
165 --
166 Begin
167   hr_utility.set_location('Entering:'||l_proc, 5);
168   --
169   -- Call all supporting business operations
170   --
171   --
172     chk_unique_key
173      ( p_block_name       => p_rec.block_name
174       ,p_report_format    => p_rec.report_format
175      );
176   --
177   hr_utility.set_location(' Leaving:'||l_proc, 10);
178 End insert_validate;
179 --
180 -- ----------------------------------------------------------------------------
181 -- |---------------------------< update_validate >----------------------------|
182 -- ----------------------------------------------------------------------------
183 Procedure update_validate(p_rec in pay_mgb_shd.g_rec_type) is
184 --
185   l_proc  varchar2(72) := g_package||'update_validate';
186 --
187 Begin
188   hr_utility.set_location('Entering:'||l_proc, 5);
189   --
190   -- Call all supporting business operations
191   --
192  chk_non_updateable_args
193         ( p_rec  => p_rec );
194   --
195   hr_utility.set_location(' Leaving:'||l_proc, 10);
196 End update_validate;
197 --
198 -- ----------------------------------------------------------------------------
199 -- |---------------------------< delete_validate >----------------------------|
200 -- ----------------------------------------------------------------------------
201 Procedure delete_validate(p_rec in pay_mgb_shd.g_rec_type) is
202 --
203   l_proc  varchar2(72) := g_package||'delete_validate';
204 --
205 Begin
206   hr_utility.set_location('Entering:'||l_proc, 5);
207   --
208   -- Call all supporting business operations
209   --
210   hr_utility.set_location(' Leaving:'||l_proc, 10);
211 End delete_validate;
212 --
213 end pay_mgb_bus;