DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_BGM_BUS

Source


1 Package Body pqh_bgm_bus as
2 /* $Header: pqbgmrhi.pkb 115.3 2002/12/05 16:33:25 rpasapul ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_bgm_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_budget_gl_flex_map_id >------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description
15 --   This procedure is used to check that the primary key for the table
16 --   is created properly. It should be null on insert and
17 --   should not be able to be updated.
18 --
19 -- Pre Conditions
20 --   None.
21 --
22 -- In Parameters
23 --   budget_gl_flex_map_id PK of record being inserted or updated.
24 --   object_version_number Object version number of record being
25 --                         inserted or updated.
26 --
27 -- Post Success
28 --   Processing continues
29 --
30 -- Post Failure
31 --   Errors handled by the procedure
32 --
33 -- Access Status
34 --   Internal table handler use only.
35 --
36 Procedure chk_budget_gl_flex_map_id(p_budget_gl_flex_map_id                in number,
37                            p_object_version_number       in number) is
38   --
39   l_proc         varchar2(72) := g_package||'chk_budget_gl_flex_map_id';
40   l_api_updating boolean;
41   --
42 Begin
43   --
44   hr_utility.set_location('Entering:'||l_proc, 5);
45   --
46   l_api_updating := pqh_bgm_shd.api_updating
47     (p_budget_gl_flex_map_id                => p_budget_gl_flex_map_id,
48      p_object_version_number       => p_object_version_number);
49   --
50   if (l_api_updating
51      and nvl(p_budget_gl_flex_map_id,hr_api.g_number)
52      <>  pqh_bgm_shd.g_old_rec.budget_gl_flex_map_id) then
53     --
54     -- raise error as PK has changed
55     --
56     pqh_bgm_shd.constraint_error('PQH_BUDGET_GL_FLEX_MAPS_PK');
57     --
58   elsif not l_api_updating then
59     --
60     -- check if PK is null
61     --
62     if p_budget_gl_flex_map_id is not null then
63       --
64       -- raise error as PK is not null
65       --
66       pqh_bgm_shd.constraint_error('PQH_BUDGET_GL_FLEX_MAPS_PK');
67       --
68     end if;
69     --
70   end if;
71   --
72   hr_utility.set_location('Leaving:'||l_proc, 10);
73   --
74 End chk_budget_gl_flex_map_id;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |---------------------------< chk_mapped_segments >----------------------------|
78 -- ----------------------------------------------------------------------------
79 --
80 Procedure chk_mapped_segments(p_budget_gl_flex_map_id in number,
81                               p_budget_id            in number,
82                               p_gl_account_segment   in varchar2) is
83 --
84 /*
85   This procedure checks that gl_acc_segments don't repeat more then 1 time for
86   a given budget id
87   This procedure will check that the combination of gl_acc seg and
88   payroll_cost_seg is unique for a given budget id
89 */
90   l_proc         varchar2(72) := g_package||'chk_mapped_segments';
91   l_count        number  := 0;
92   l_api_updating boolean;
93 
94 CURSOR csr_map_count IS
95 SELECT COUNT(*)
96 FROM pqh_budget_gl_flex_maps
97 WHERE budget_id = p_budget_id
98   AND gl_account_segment   = p_gl_account_segment
99   AND budget_gl_flex_map_id <> p_budget_gl_flex_map_id;
100   --
101 Begin
102   --
103   hr_utility.set_location('Entering:'||l_proc, 5);
104   --
105 
106         OPEN csr_map_count;
107           FETCH csr_map_count INTO l_count;
108         CLOSE csr_map_count;
109 
110         IF NVL(l_count,0) <> 0 THEN
111           -- raise error as combination already exists
112            hr_utility.set_message(8302,'PQH_INVALID_BUDGET_GL_MAP');
113            hr_utility.raise_error;
114         END IF;
115 
116 
117   hr_utility.set_location('Leaving:'||l_proc, 10);
118   --
119 End chk_mapped_segments;
120   --
121 --
122 -- ----------------------------------------------------------------------------
123 -- |---------------------------< chk_cost_segments >----------------------------|
124 -- ----------------------------------------------------------------------------
125 --
126 Procedure chk_cost_segments(p_budget_id            in number,
127                               p_gl_account_segment   in varchar2,
128                               p_payroll_cost_segment in varchar2) is
129 --
130 /*
131   This procedure will check that the payroll_cost_segment is NOT NULL in UPDATE
132   This will ONLY be called in update_validate
133 */
134   l_proc         varchar2(72) := g_package||'chk_cost_segments';
135 
136   --
137 Begin
138   --
139   hr_utility.set_location('Entering:'||l_proc, 5);
140   --
141     IF p_gl_account_segment   IS NULL OR
142        p_payroll_cost_segment IS NULL THEN
143 
144       -- raise error as combination already exists
145        hr_utility.set_message(8302,'PQH_COST_GL_MAP_NULL');
146        hr_utility.raise_error;
147     END IF;
148 
149   hr_utility.set_location('Leaving:'||l_proc, 10);
150   --
151 End chk_cost_segments;
152   --
153 -- ----------------------------------------------------------------------------
154 -- |---------------------------< insert_validate >----------------------------|
155 -- ----------------------------------------------------------------------------
156 Procedure insert_validate(p_rec in pqh_bgm_shd.g_rec_type) is
157 --
158   l_proc  varchar2(72) := g_package||'insert_validate';
159 --
160 Begin
161   hr_utility.set_location('Entering:'||l_proc, 5);
162   --
163   -- Call all supporting business operations
164   --
165   chk_budget_gl_flex_map_id
166   (p_budget_gl_flex_map_id          => p_rec.budget_gl_flex_map_id,
167    p_object_version_number => p_rec.object_version_number);
168   --
169 chk_mapped_segments
170   (p_budget_gl_flex_map_id    => p_rec.budget_gl_flex_map_id,
171    p_budget_id            => p_rec.budget_id,
172    p_gl_account_segment   => p_rec.gl_account_segment
173   );
174   --
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 pqh_bgm_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_budget_gl_flex_map_id
193   (p_budget_gl_flex_map_id          => p_rec.budget_gl_flex_map_id,
194    p_object_version_number => p_rec.object_version_number);
195   --
196 chk_mapped_segments
197   (p_budget_gl_flex_map_id    => p_rec.budget_gl_flex_map_id,
198    p_budget_id            => p_rec.budget_id,
199    p_gl_account_segment   => p_rec.gl_account_segment
200   );
201   --
202 chk_cost_segments
203   (p_budget_id            => p_rec.budget_id,
204    p_gl_account_segment   => p_rec.gl_account_segment,
205    p_payroll_cost_segment => p_rec.payroll_cost_segment
206   );
207   --
208   --
209   hr_utility.set_location(' Leaving:'||l_proc, 10);
210 End update_validate;
211 --
212 -- ----------------------------------------------------------------------------
213 -- |---------------------------< delete_validate >----------------------------|
214 -- ----------------------------------------------------------------------------
215 Procedure delete_validate(p_rec in pqh_bgm_shd.g_rec_type) is
216 --
217   l_proc  varchar2(72) := g_package||'delete_validate';
218 --
219 Begin
220   hr_utility.set_location('Entering:'||l_proc, 5);
221   --
222   -- Call all supporting business operations
223   --
224   hr_utility.set_location(' Leaving:'||l_proc, 10);
225 End delete_validate;
226 --
227 end pqh_bgm_bus;