DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_TBC_SHD

Source


1 Package Body pay_tbc_shd as
2 /* $Header: pytbcrhi.pkb 120.0 2005/05/29 09:00:32 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_tbc_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_BAL_CAT_F_TL_PRIMARY_KEY') 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_category_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_category_id
49       ,language
50       ,source_lang
51       ,user_category_name
52     from  pay_balance_categories_f_tl
53     where balance_category_id = p_balance_category_id
54     and   language = p_language;
55 --
56   l_fct_ret     boolean;
57 --
58 Begin
59   --
60   If (p_balance_category_id is null or
61       p_language is null
62      ) Then
63     --
64     -- One of the primary key arguments is null therefore we must
65     -- set the returning function value to false
66     --
67     l_fct_ret := false;
68   Else
69     If (p_balance_category_id
70         = pay_tbc_shd.g_old_rec.balance_category_id and
71         p_language
72         = pay_tbc_shd.g_old_rec.language
73        ) Then
74       --
75       -- The g_old_rec is current therefore we must
76       -- set the returning function to true
77       --
78       l_fct_ret := true;
79     Else
80       --
81       -- Select the current row into g_old_rec
82       --
83       Open C_Sel1;
84       Fetch C_Sel1 Into pay_tbc_shd.g_old_rec;
85       If C_Sel1%notfound Then
86         Close C_Sel1;
87         --
88         -- The primary key is invalid therefore we must error
89         --
90         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
91         fnd_message.raise_error;
92       End If;
93       Close C_Sel1;
94       --
95       l_fct_ret := true;
96     End If;
97   End If;
98   Return (l_fct_ret);
99 --
100 End api_updating;
101 --
102 -- ----------------------------------------------------------------------------
103 -- |---------------------------------< lck >----------------------------------|
104 -- ----------------------------------------------------------------------------
105 Procedure lck
106   (p_balance_category_id                  in     number
107   ,p_language                             in     varchar2
108   ) is
109 --
110 -- Cursor selects the 'current' row from the HR Schema
111 --
112   Cursor C_Sel1 is
113     select
114        balance_category_id
115       ,language
116       ,source_lang
117       ,user_category_name
118     from        pay_balance_categories_f_tl
119     where       balance_category_id = p_balance_category_id
120     and   language = p_language
121     for update nowait;
122 --
123   l_proc        varchar2(72) := g_package||'lck';
124 --
125 Begin
126   hr_utility.set_location('Entering:'||l_proc, 5);
127   --
128   hr_api.mandatory_arg_error
129     (p_api_name           => l_proc
130     ,p_argument           => 'BALANCE_CATEGORY_ID'
131     ,p_argument_value     => p_balance_category_id
132     );
133   hr_utility.set_location(l_proc,6);
134   hr_api.mandatory_arg_error
135     (p_api_name           => l_proc
136     ,p_argument           => 'LANGUAGE'
137     ,p_argument_value     => p_language
138     );
139   --
140   Open  C_Sel1;
141   Fetch C_Sel1 Into pay_tbc_shd.g_old_rec;
142   If C_Sel1%notfound then
143     Close C_Sel1;
144     --
145     -- The primary key is invalid therefore we must error
146     --
147     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
148     fnd_message.raise_error;
149   End If;
150   Close C_Sel1;
151   --
152   --
153   hr_utility.set_location(' Leaving:'||l_proc, 10);
154   --
155   -- We need to trap the ORA LOCK exception
156   --
157 Exception
158   When HR_Api.Object_Locked then
159     --
160     -- The object is locked therefore we need to supply a meaningful
161     -- error message.
162     --
163     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
164     fnd_message.set_token('TABLE_NAME', 'pay_balance_categories_f_tl');
165     fnd_message.raise_error;
166 End lck;
167 --
168 -- ----------------------------------------------------------------------------
169 -- |----------------------------< add_language >------------------------------|
170 -- ----------------------------------------------------------------------------
171 PROCEDURE add_language IS
172 Begin
173   delete from PAY_BALANCE_CATEGORIES_F_TL T
174   where not exists
175     (select NULL
176     from PAY_BALANCE_CATEGORIES_F B
177     where B.BALANCE_CATEGORY_ID = T.BALANCE_CATEGORY_ID
178     );
179 update PAY_BALANCE_CATEGORIES_F_TL T set (
180       USER_CATEGORY_NAME
181     ) = (select
182       B.USER_CATEGORY_NAME
183     from PAY_BALANCE_CATEGORIES_F_TL B
184     where B.BALANCE_CATEGORY_ID = T.BALANCE_CATEGORY_ID
185     and B.LANGUAGE = T.SOURCE_LANG)
186   where (
187       T.BALANCE_CATEGORY_ID,
188       T.LANGUAGE
189   ) in (select
190       SUBT.BALANCE_CATEGORY_ID,
191       SUBT.LANGUAGE
192     from PAY_BALANCE_CATEGORIES_F_TL SUBB, PAY_BALANCE_CATEGORIES_F_TL SUBT
193     where SUBB.BALANCE_CATEGORY_ID = SUBT.BALANCE_CATEGORY_ID
194     and SUBB.LANGUAGE = SUBT.SOURCE_LANG
195     and (SUBB.USER_CATEGORY_NAME <> SUBT.USER_CATEGORY_NAME));
196   insert into PAY_BALANCE_CATEGORIES_F_TL (
197     BALANCE_CATEGORY_ID,
198     USER_CATEGORY_NAME,
199     LAST_UPDATE_DATE,
200     LAST_UPDATED_BY,
201     LAST_UPDATE_LOGIN,
202     CREATED_BY,
203     CREATION_DATE,
204     LANGUAGE,
205     SOURCE_LANG
206   ) select
207     B.BALANCE_CATEGORY_ID,
208     B.USER_CATEGORY_NAME,
209     B.LAST_UPDATE_DATE,
210     B.LAST_UPDATED_BY,
211     B.LAST_UPDATE_LOGIN,
212     B.CREATED_BY,
213     B.CREATION_DATE,
214     L.LANGUAGE_CODE,
215     B.SOURCE_LANG
216   from PAY_BALANCE_CATEGORIES_F_TL B, FND_LANGUAGES L
217   where L.INSTALLED_FLAG in ('I', 'B')
218   and B.LANGUAGE = userenv('LANG')
219   and not exists
220     (select NULL
221     from PAY_BALANCE_CATEGORIES_F_TL T
222     where T.BALANCE_CATEGORY_ID = B.BALANCE_CATEGORY_ID
223     and T.LANGUAGE = L.LANGUAGE_CODE);
224 End add_language;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |-----------------------------< convert_args >-----------------------------|
228 -- ----------------------------------------------------------------------------
229 Function convert_args
230   (p_balance_category_id            in number
231   ,p_language                       in varchar2
232   ,p_source_lang                    in varchar2
233   ,p_user_category_name             in varchar2
234   )
235   Return g_rec_type is
236 --
237   l_rec   g_rec_type;
238 --
239 Begin
240   --
241   -- Convert arguments into local l_rec structure.
242   --
243   l_rec.balance_category_id              := p_balance_category_id;
244   l_rec.language                         := p_language;
245   l_rec.source_lang                      := p_source_lang;
246   l_rec.user_category_name               := p_user_category_name;
247   --
248   -- Return the plsql record structure.
249   --
250   Return(l_rec);
251 --
252 End convert_args;
253 --
254 end pay_tbc_shd;