DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_CIT_SHD

Source


1 Package Body per_cit_shd as
2 /* $Header: pecitrhi.pkb 115.3 2004/06/28 22:24:21 jpthomas noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_cit_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 = 'PER_CAGR_ENT_ITEMS_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_cagr_entitlement_item_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        cagr_entitlement_item_id
49       ,item_name
50       ,language
51       ,source_lang
52     from  per_cagr_entitlement_items_tl
53     where cagr_entitlement_item_id = p_cagr_entitlement_item_id
54     and   language = p_language;
55 --
56   l_fct_ret     boolean;
57 --
58 Begin
59   --
60   If (p_cagr_entitlement_item_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_cagr_entitlement_item_id
70         = per_cit_shd.g_old_rec.cagr_entitlement_item_id and
71         p_language
72         = per_cit_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 per_cit_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_cagr_entitlement_item_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        cagr_entitlement_item_id
115       ,item_name
116       ,language
117       ,source_lang
118     from        per_cagr_entitlement_items_tl
119     where       cagr_entitlement_item_id = p_cagr_entitlement_item_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           => 'CAGR_ENTITLEMENT_ITEM_ID'
131     ,p_argument_value     => p_cagr_entitlement_item_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 per_cit_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', 'per_cagr_entitlement_items_tl');
165     fnd_message.raise_error;
166 End lck;
167 --
168 -- ----------------------------------------------------------------------------
169 -- |----------------------------< add_language >------------------------------|
170 -- ----------------------------------------------------------------------------
171 --
172 -- EDIT_HERE:  Execute AOL's tltblgen(UNIX) program to generate the
173 --             ADD_LANGUAGE procedure.  Only the add_language procedure
174 --             should be added here.  Remove the following skeleton
175 --             procedure.
176 --
177 -- ----------------------------------------------------------------------------
178 procedure ADD_LANGUAGE
179 is
180 begin
181   delete from PER_CAGR_ENTITLEMENT_ITEMS_TL T
182   where not exists
183     (select NULL
184     from PER_CAGR_ENTITLEMENT_ITEMS B
185     where B.CAGR_ENTITLEMENT_ITEM_ID = T.CAGR_ENTITLEMENT_ITEM_ID
186     );
187 
188   update PER_CAGR_ENTITLEMENT_ITEMS_TL T set (
189       ITEM_NAME
190     ) = (select
191       B.ITEM_NAME
192     from PER_CAGR_ENTITLEMENT_ITEMS_TL B
193     where B.CAGR_ENTITLEMENT_ITEM_ID = T.CAGR_ENTITLEMENT_ITEM_ID
194     and B.LANGUAGE = T.SOURCE_LANG)
195   where (
196       T.CAGR_ENTITLEMENT_ITEM_ID,
197       T.LANGUAGE
198   ) in (select
199       SUBT.CAGR_ENTITLEMENT_ITEM_ID,
200       SUBT.LANGUAGE
201     from PER_CAGR_ENTITLEMENT_ITEMS_TL SUBB, PER_CAGR_ENTITLEMENT_ITEMS_TL SUBT
202     where SUBB.CAGR_ENTITLEMENT_ITEM_ID = SUBT.CAGR_ENTITLEMENT_ITEM_ID
203     and SUBB.LANGUAGE = SUBT.SOURCE_LANG
204     and (SUBB.ITEM_NAME <> SUBT.ITEM_NAME
205   ));
206 
207   insert into PER_CAGR_ENTITLEMENT_ITEMS_TL (
208     CREATED_BY,
209     CREATION_DATE,
210     LAST_UPDATE_LOGIN,
211     LAST_UPDATE_DATE,
212     LAST_UPDATED_BY,
213     CAGR_ENTITLEMENT_ITEM_ID,
214     ITEM_NAME,
215     LANGUAGE,
216     SOURCE_LANG
217   ) select /*+ ORDERED */
218     B.CREATED_BY,
219     B.CREATION_DATE,
220     B.LAST_UPDATE_LOGIN,
221     B.LAST_UPDATE_DATE,
222     B.LAST_UPDATED_BY,
223     B.CAGR_ENTITLEMENT_ITEM_ID,
224     B.ITEM_NAME,
225     L.LANGUAGE_CODE,
226     B.SOURCE_LANG
227   from PER_CAGR_ENTITLEMENT_ITEMS_TL B, FND_LANGUAGES L
228   where L.INSTALLED_FLAG in ('I', 'B')
229   and B.LANGUAGE = userenv('LANG')
230   and not exists
231     (select NULL
232     from PER_CAGR_ENTITLEMENT_ITEMS_TL T
233     where T.CAGR_ENTITLEMENT_ITEM_ID = B.CAGR_ENTITLEMENT_ITEM_ID
234     and T.LANGUAGE = L.LANGUAGE_CODE);
235 
236 end ADD_LANGUAGE;
237 
238 
239 --
240 -- ----------------------------------------------------------------------------
241 -- |-----------------------------< convert_args >-----------------------------|
242 -- ----------------------------------------------------------------------------
243 Function convert_args
244   (p_cagr_entitlement_item_id       in number
245   ,p_item_name                      in varchar2
246   ,p_language                       in varchar2
247   ,p_source_lang                    in varchar2
248   )
249   Return g_rec_type is
250 --
251   l_rec   g_rec_type;
252 --
253 Begin
254   --
255   -- Convert arguments into local l_rec structure.
256   --
257   l_rec.cagr_entitlement_item_id         := p_cagr_entitlement_item_id;
258   l_rec.item_name                        := p_item_name;
259   l_rec.language                         := p_language;
260   l_rec.source_lang                      := p_source_lang;
261   --
262   -- Return the plsql record structure.
263   --
264   Return(l_rec);
265 --
266 End convert_args;
267 --
268 end per_cit_shd;