DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_BDT_SHD

Source


1 Package Body pay_bdt_shd as
2 /* $Header: pybdtrhi.pkb 120.3 2005/11/24 05:36:48 arashid noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_bdt_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< constraint_error >---------------------------|
12 -- ----------------------------------------------------------------------------
13 Procedure constraint_error
14   (p_constraint_name in all_constraints.constraint_name%TYPE
15   ) Is
16 --
17   l_proc        varchar2(72) := g_package||'constraint_error';
18 --
19 Begin
20   --
21   If (p_constraint_name = 'PAY_BALANCE_DIMENSIONS_TL_PK') Then
22     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
23     fnd_message.set_token('PROCEDURE', l_proc);
24     fnd_message.set_token('STEP','5');
25     fnd_message.raise_error;
26   Else
27     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
28     fnd_message.set_token('PROCEDURE', l_proc);
29     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
30     fnd_message.raise_error;
31   End If;
32   --
33 End constraint_error;
34 --
35 -- ----------------------------------------------------------------------------
36 -- |-----------------------------< api_updating >-----------------------------|
37 -- ----------------------------------------------------------------------------
38 Function api_updating
39   (p_balance_dimension_id                 in     number
40   ,p_language                             in     varchar2
41   )      Return Boolean Is
42 --
43   --
44   -- Cursor selects the 'current' row from the HR Schema
45   --
46   Cursor C_Sel1 is
47     select
48        balance_dimension_id
49       ,language
50       ,source_lang
51       ,dimension_name
52       ,database_item_suffix
53       ,description
54     from  pay_balance_dimensions_tl
55     where balance_dimension_id = p_balance_dimension_id
56     and   language = p_language;
57 --
58   l_fct_ret     boolean;
59 --
60 Begin
61   --
62   If (p_balance_dimension_id is null or
63       p_language is null
64      ) Then
65     --
66     -- One of the primary key arguments is null therefore we must
67     -- set the returning function value to false
68     --
69     l_fct_ret := false;
70   Else
71     If (p_balance_dimension_id
72         = pay_bdt_shd.g_old_rec.balance_dimension_id and
73         p_language
74         = pay_bdt_shd.g_old_rec.language
75        ) Then
76       --
77       -- The g_old_rec is current therefore we must
78       -- set the returning function to true
79       --
80       l_fct_ret := true;
81     Else
82       --
83       -- Select the current row into g_old_rec
84       --
85       Open C_Sel1;
86       Fetch C_Sel1 Into pay_bdt_shd.g_old_rec;
87       If C_Sel1%notfound Then
88         Close C_Sel1;
89         --
90         -- The primary key is invalid therefore we must error
91         --
92         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
93         fnd_message.raise_error;
94       End If;
95       Close C_Sel1;
96       --
97       l_fct_ret := true;
98     End If;
99   End If;
100   Return (l_fct_ret);
101 --
102 End api_updating;
103 --
104 -- ----------------------------------------------------------------------------
105 -- |---------------------------------< lck >----------------------------------|
106 -- ----------------------------------------------------------------------------
107 Procedure lck
108   (p_balance_dimension_id                 in     number
109   ,p_language                             in     varchar2
110   ) is
111 --
112 -- Cursor selects the 'current' row from the HR Schema
113 --
114   Cursor C_Sel1 is
115     select
116        balance_dimension_id
117       ,language
118       ,source_lang
119       ,dimension_name
120       ,database_item_suffix
121       ,description
122     from        pay_balance_dimensions_tl
123     where       balance_dimension_id = p_balance_dimension_id
124     and   language = p_language
125     for update nowait;
126 --
127   l_proc        varchar2(72) := g_package||'lck';
128 --
129 Begin
130   hr_utility.set_location('Entering:'||l_proc, 5);
131   --
132   hr_api.mandatory_arg_error
133     (p_api_name           => l_proc
134     ,p_argument           => 'BALANCE_DIMENSION_ID'
135     ,p_argument_value     => p_balance_dimension_id
136     );
137   hr_utility.set_location(l_proc,6);
138   hr_api.mandatory_arg_error
139     (p_api_name           => l_proc
140     ,p_argument           => 'LANGUAGE'
141     ,p_argument_value     => p_language
142     );
143   --
144   Open  C_Sel1;
145   Fetch C_Sel1 Into pay_bdt_shd.g_old_rec;
146   If C_Sel1%notfound then
147     Close C_Sel1;
148     --
149     -- The primary key is invalid therefore we must error
150     --
151     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
152     fnd_message.raise_error;
153   End If;
154   Close C_Sel1;
155   --
156   --
157   hr_utility.set_location(' Leaving:'||l_proc, 10);
158   --
159   -- We need to trap the ORA LOCK exception
160   --
161 Exception
162   When HR_Api.Object_Locked then
163     --
164     -- The object is locked therefore we need to supply a meaningful
165     -- error message.
166     --
167     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
168     fnd_message.set_token('TABLE_NAME', 'pay_balance_dimensions_tl');
169     fnd_message.raise_error;
170 End lck;
171 --
172 -- ----------------------------------------------------------------------------
173 -- |----------------------------< add_language >------------------------------|
174 -- ----------------------------------------------------------------------------
175 PROCEDURE add_language IS
176 Begin
177   delete from PAY_BALANCE_DIMENSIONS_TL T
178   where not exists
179     (select NULL
180     from PAY_BALANCE_DIMENSIONS B
181     where B.BALANCE_DIMENSION_ID = T.BALANCE_DIMENSION_ID
182     );
183 update PAY_BALANCE_DIMENSIONS_TL T set (
184       DIMENSION_NAME,
185       DESCRIPTION
186     ) = (select
187       B.DIMENSION_NAME,
188       B.DESCRIPTION
189     from PAY_BALANCE_DIMENSIONS_TL B
190     where B.BALANCE_DIMENSION_ID = T.BALANCE_DIMENSION_ID
191     and B.LANGUAGE = T.SOURCE_LANG)
192   where (
193       T.BALANCE_DIMENSION_ID,
194       T.LANGUAGE
195   ) in (select
196       SUBT.BALANCE_DIMENSION_ID,
197       SUBT.LANGUAGE
198     from PAY_BALANCE_DIMENSIONS_TL SUBB, PAY_BALANCE_DIMENSIONS_TL SUBT
199     where SUBB.BALANCE_DIMENSION_ID = SUBT.BALANCE_DIMENSION_ID
200     and SUBB.LANGUAGE = SUBT.SOURCE_LANG
201     and (SUBB.DIMENSION_NAME <> SUBT.DIMENSION_NAME
202       or SUBB.DESCRIPTION <> SUBT.DESCRIPTION
203       or (SUBB.DESCRIPTION is null and SUBT.DESCRIPTION is not null)
204       or (SUBB.DESCRIPTION is not null and SUBT.DESCRIPTION is null)
205   ));
206   insert into PAY_BALANCE_DIMENSIONS_TL (
207     BALANCE_DIMENSION_ID,
208     DIMENSION_NAME,
209     DATABASE_ITEM_SUFFIX,
210     DESCRIPTION,
211     LAST_UPDATE_DATE,
212     LAST_UPDATED_BY,
213     LAST_UPDATE_LOGIN,
214     CREATED_BY,
215     CREATION_DATE,
216     LANGUAGE,
217     SOURCE_LANG
218   ) select
219     B.BALANCE_DIMENSION_ID,
220     B.DIMENSION_NAME,
221     B.DATABASE_ITEM_SUFFIX,
222     B.DESCRIPTION,
223     B.LAST_UPDATE_DATE,
224     B.LAST_UPDATED_BY,
225     B.LAST_UPDATE_LOGIN,
226     B.CREATED_BY,
227     B.CREATION_DATE,
228     L.LANGUAGE_CODE,
229     B.SOURCE_LANG
230   from PAY_BALANCE_DIMENSIONS_TL B, FND_LANGUAGES L
231   where L.INSTALLED_FLAG in ('I', 'B')
232   and B.LANGUAGE = userenv('LANG')
233   and not exists
234     (select NULL
235     from PAY_BALANCE_DIMENSIONS_TL T
236     where T.BALANCE_DIMENSION_ID = B.BALANCE_DIMENSION_ID
237     and T.LANGUAGE = L.LANGUAGE_CODE);
238 End add_language;
239 --
240 --
241 -- ----------------------------------------------------------------------------
242 -- |-----------------------------< convert_args >-----------------------------|
243 -- ----------------------------------------------------------------------------
244 Function convert_args
245   (p_balance_dimension_id           in number
246   ,p_language                       in varchar2
247   ,p_source_lang                    in varchar2
248   ,p_dimension_name                 in varchar2
249   ,p_database_item_suffix           in varchar2
250   ,p_description                    in varchar2
251   )
252   Return g_rec_type is
253 --
254   l_rec   g_rec_type;
255 --
256 Begin
257   --
258   -- Convert arguments into local l_rec structure.
259   --
260   l_rec.balance_dimension_id             := p_balance_dimension_id;
261   l_rec.language                         := p_language;
262   l_rec.source_lang                      := p_source_lang;
263   l_rec.dimension_name                   := p_dimension_name;
264   l_rec.database_item_suffix             := p_database_item_suffix;
265   l_rec.description                      := p_description;
266   --
267   -- Return the plsql record structure.
268   --
269   Return(l_rec);
270 --
271 End convert_args;
272 --
273 end pay_bdt_shd;