DBA Data[Home] [Help]

PACKAGE BODY: APPS.XLA_ACCT_ATTRIBUTES_F_PKG

Source


1 PACKAGE BODY xla_acct_attributes_f_pkg AS
2 /* $Header: xlathess.pkb 120.6.12010000.1 2008/07/29 10:09:32 appldev ship $ */
3 /*======================================================================+
4 |             Copyright (c) 2001-2002 Oracle Corporation                |
5 |                       Redwood Shores, CA, USA                         |
6 |                         All rights reserved.                          |
7 +=======================================================================+
8 | PACKAGE NAME                                                          |
9 |    xla_acct_attributes                                                |
10 |                                                                       |
11 | DESCRIPTION                                                           |
12 |    Forms PL/SQL Wrapper for xla_acct_attributes                       |
13 |                                                                       |
14 | HISTORY                                                               |
15 |    Generated from XLAUTB.                                             |
16 |                                                                       |
17 +======================================================================*/
18 
19 
20 
21 /*======================================================================+
22 |                                                                       |
23 |  Procedure insert_row                                                 |
24 |                                                                       |
25 +======================================================================*/
26 PROCEDURE insert_row
27   (x_rowid                            IN OUT NOCOPY VARCHAR2
28   ,x_accounting_attribute_code        IN VARCHAR2
29   ,x_assignment_required_code         IN VARCHAR2
30   ,x_assignment_group_code            IN VARCHAR2
31   ,x_datatype_code                    IN VARCHAR2
32   ,x_journal_entry_level_code         IN VARCHAR2
33   ,x_assignment_extensible_flag       IN VARCHAR2
34   ,x_assignment_level_code            IN VARCHAR2
35   ,x_inherited_flag                   IN VARCHAR2
36   ,x_name                             IN VARCHAR2
37   ,x_creation_date                    IN DATE
38   ,x_created_by                       IN NUMBER
39   ,x_last_update_date                 IN DATE
40   ,x_last_updated_by                  IN NUMBER
41   ,x_last_update_login                IN NUMBER)
42 
43 IS
44 
45 CURSOR c IS
46 SELECT rowid
47 FROM   xla_acct_attributes_b
48 WHERE  accounting_attribute_code           = x_accounting_attribute_code
49 ;
50 
51 BEGIN
52 xla_utility_pkg.trace('> xla_acct_attributes_f_pkg.insert_row'                    ,20);
53 
54 INSERT INTO xla_acct_attributes_b
55 (creation_date
56 ,created_by
57 ,accounting_attribute_code
58 ,assignment_required_code
59 ,assignment_group_code
60 ,datatype_code
61 ,journal_entry_level_code
62 ,assignment_extensible_flag
63 ,assignment_level_code
64 ,inherited_flag
65 ,last_update_date
66 ,last_updated_by
67 ,last_update_login)
68 VALUES
69 (x_creation_date
70 ,x_created_by
71 ,x_accounting_attribute_code
72 ,x_assignment_required_code
73 ,x_assignment_group_code
74 ,x_datatype_code
75 ,x_journal_entry_level_code
76 ,x_assignment_extensible_flag
77 ,x_assignment_level_code
78 ,x_inherited_flag
79 ,x_last_update_date
80 ,x_last_updated_by
81 ,x_last_update_login)
82 ;
83 
84 INSERT INTO xla_acct_attributes_tl
85 (name
86 ,creation_date
87 ,created_by
88 ,last_update_date
89 ,last_updated_by
90 ,accounting_attribute_code
91 ,last_update_login
92 ,language
93 ,source_lang)
94 SELECT
95        x_name
96       ,x_creation_date
97       ,x_created_by
98       ,x_last_update_date
99       ,x_last_updated_by
100       ,x_accounting_attribute_code
101       ,x_last_update_login
102       ,l.language_code
103       ,USERENV('LANG')
104 FROM   fnd_languages l
105 WHERE  l.installed_flag                 IN ('I', 'B')
106   AND  NOT EXISTS
107       (SELECT NULL
108        FROM   xla_acct_attributes_tl               t
109        WHERE  t.accounting_attribute_code        = x_accounting_attribute_code
110          AND  t.language                         = l.language_code);
111 
112 OPEN c;
113 FETCH c INTO x_rowid;
114 
115 IF (c%NOTFOUND) THEN
116    CLOSE c;
117    RAISE NO_DATA_FOUND;
118 END IF;
119 CLOSE c;
120 
121 xla_utility_pkg.trace('< xla_acct_attributes_f_pkg.insert_row'                    ,20);
122 END insert_row;
123 
124 /*======================================================================+
125 |                                                                       |
126 |  Procedure lock_row                                                   |
127 |                                                                       |
128 +======================================================================*/
129 PROCEDURE lock_row
130   (x_accounting_attribute_code        IN VARCHAR2
131   ,x_assignment_required_code         IN VARCHAR2
132   ,x_assignment_group_code            IN VARCHAR2
133   ,x_datatype_code                    IN VARCHAR2
134   ,x_journal_entry_level_code         IN VARCHAR2
135   ,x_assignment_extensible_flag       IN VARCHAR2
136   ,x_assignment_level_code            IN VARCHAR2
137   ,x_inherited_flag                   IN VARCHAR2
138   ,x_name                             IN VARCHAR2)
139 
140 IS
141 
142 CURSOR c IS
143 SELECT accounting_attribute_code
144       ,assignment_required_code
145       ,assignment_group_code
146       ,datatype_code
147       ,journal_entry_level_code
148       ,assignment_extensible_flag
149       ,assignment_level_code
150       ,inherited_flag
151 FROM   xla_acct_attributes_b
152 WHERE  accounting_attribute_code           = x_accounting_attribute_code
153 FOR UPDATE OF accounting_attribute_code NOWAIT;
154 
155 recinfo              c%ROWTYPE;
156 
157 CURSOR c1 IS
158 SELECT language
159       ,name
160       ,DECODE(language     , USERENV('LANG'), 'Y', 'N') baselang
161 FROM   xla_acct_attributes_tl
162 WHERE  accounting_attribute_code        = X_accounting_attribute_code
163   AND  USERENV('LANG')                 IN (language     ,source_lang)
164 FOR UPDATE OF accounting_attribute_code NOWAIT;
165 
166 BEGIN
167 xla_utility_pkg.trace('> xla_acct_attributes_f_pkg.lock_row'                      ,20);
168 
169 OPEN c;
170 FETCH c INTO recinfo;
171 
172 IF (c%NOTFOUND) THEN
173    CLOSE c;
174    fnd_message.set_name('FND', 'FORM_RECORD_DELETED');
175    app_exception.raise_exception;
176 END IF;
177 CLOSE c;
178 
179 IF ( (recinfo.assignment_required_code            = x_assignment_required_code)
180  AND ((recinfo.assignment_group_code               = X_assignment_group_code)
181    OR ((recinfo.assignment_group_code               IS NULL)
182   AND (x_assignment_group_code               IS NULL)))
183  AND (recinfo.datatype_code                    = x_datatype_code)
184  AND (recinfo.journal_entry_level_code         = X_journal_entry_level_code)
185  AND (recinfo.assignment_extensible_flag                   = x_assignment_extensible_flag)
186  AND (recinfo.assignment_level_code         = X_assignment_level_code)
187  AND (recinfo.inherited_flag                = X_inherited_flag)
188                    ) THEN
189    NULL;
190 ELSE
191    fnd_message.set_name('FND', 'FORM_RECORD_CHANGED');
192    app_exception.raise_exception;
193 END IF;
194 
195 FOR tlinfo IN c1 LOOP
196    IF (tlinfo.baselang = 'Y') THEN
197       IF (    (tlinfo.name = X_name)
198       ) THEN
199         NULL;
200       ELSE
201          fnd_message.set_name('FND', 'FORM_RECORD_CHANGED');
202          app_exception.raise_exception;
203       END IF;
204    END IF;
205 END LOOP;
206 
207 
208 xla_utility_pkg.trace('< xla_acct_attributes_f_pkg.lock_row'                      ,20);
209 RETURN;
210 
211 END lock_row;
212 
213 /*======================================================================+
214 |                                                                       |
215 |  Procedure update_row                                                 |
216 |                                                                       |
217 +======================================================================*/
218 PROCEDURE update_row
219  (x_accounting_attribute_code           IN VARCHAR2
220  ,x_assignment_required_code            IN VARCHAR2
221  ,x_assignment_group_code               IN VARCHAR2
222  ,x_datatype_code                       IN VARCHAR2
223  ,x_journal_entry_level_code            IN VARCHAR2
224  ,x_assignment_extensible_flag          IN VARCHAR2
225  ,x_assignment_level_code               IN VARCHAR2
226  ,x_inherited_flag                      IN VARCHAR2
227  ,x_name                                IN VARCHAR2
228  ,x_last_update_date                    IN DATE
229  ,x_last_updated_by                     IN NUMBER
230  ,x_last_update_login                   IN NUMBER)
231 
232 IS
233 
234 BEGIN
235 xla_utility_pkg.trace('> xla_acct_attributes_f_pkg.update_row'                    ,20);
236 UPDATE xla_acct_attributes_b
237    SET
238        last_update_date                 = x_last_update_date
239       ,assignment_required_code         = x_assignment_required_code
240       ,assignment_group_code            = x_assignment_group_code
241       ,datatype_code                    = x_datatype_code
242       ,journal_entry_level_code         = x_journal_entry_level_code
243       ,assignment_extensible_flag       = x_assignment_extensible_flag
244       ,assignment_level_code            = x_assignment_level_code
245       ,inherited_flag                   = x_inherited_flag
246       ,last_updated_by                  = x_last_updated_by
247       ,last_update_login                = x_last_update_login
248 WHERE  accounting_attribute_code        = X_accounting_attribute_code;
249 
250 IF (SQL%NOTFOUND) THEN
251    RAISE NO_DATA_FOUND;
252 END IF;
253 
254 UPDATE xla_acct_attributes_tl
255 SET
256        last_update_date                 = x_last_update_date
257       ,name                             = X_name
258       ,last_updated_by                  = x_last_updated_by
259       ,last_update_login                = x_last_update_login
260       ,source_lang                      = USERENV('LANG')
261 WHERE  accounting_attribute_code        = X_accounting_attribute_code
262   AND  USERENV('LANG')                 IN (language, source_lang);
263 
264 IF (SQL%NOTFOUND) THEN
265    RAISE NO_DATA_FOUND;
266 END IF;
267 
268 xla_utility_pkg.trace('< xla_acct_attributes_f_pkg.update_row'                    ,20);
269 END update_row;
270 
271 /*======================================================================+
272 |                                                                       |
273 |  Procedure delete_row                                                 |
274 |                                                                       |
275 +======================================================================*/
276 PROCEDURE delete_row
277   (x_accounting_attribute_code           IN VARCHAR2)
278 
279 IS
280 
281 BEGIN
282 xla_utility_pkg.trace('> xla_acct_attributes_f_pkg.delete_row'                    ,20);
283 DELETE FROM xla_acct_attributes_tl
284 WHERE accounting_attribute_code           = x_accounting_attribute_code;
285 
286 
287 IF (SQL%NOTFOUND) THEN
288    RAISE NO_DATA_FOUND;
289 END IF;
290 
291 DELETE FROM xla_acct_attributes_b
292 WHERE accounting_attribute_code           = x_accounting_attribute_code;
293 
294 
295 IF (SQL%NOTFOUND) THEN
296    RAISE NO_DATA_FOUND;
297 END IF;
298 
299 
300 xla_utility_pkg.trace('< xla_acct_attributes_f_pkg.delete_row'                    ,20);
301 END delete_row;
302 
303 /*======================================================================+
304 |                                                                       |
305 |  Procedure add_language                                               |
306 |                                                                       |
307 +======================================================================*/
308 PROCEDURE add_language
309 
310 IS
311 
312 BEGIN
313 xla_utility_pkg.trace('> xla_acct_attributes_f_pkg.add_language'                  ,20);
314 
315 DELETE FROM xla_acct_attributes_tl T
316 WHERE  NOT EXISTS
317       (SELECT NULL
318        FROM   xla_acct_attributes_b                b
319        WHERE  b.accounting_attribute_code           = t.accounting_attribute_code);
320 
321 UPDATE xla_acct_attributes_tl   t
322 SET   (name)
323    = (SELECT b.name
324       FROM   xla_acct_attributes_tl               b
325       WHERE  b.accounting_attribute_code        = t.accounting_attribute_code
326         AND  b.language                         = t.source_lang)
327 WHERE (t.accounting_attribute_code
328       ,t.language)
329     IN (SELECT subt.accounting_attribute_code
330               ,subt.language
331         FROM   xla_acct_attributes_tl                   subb
332               ,xla_acct_attributes_tl                   subt
333         WHERE  subb.accounting_attribute_code       = subt.accounting_attribute_code
334          AND  subb.language                         = subt.source_lang
335          AND (SUBB.name                             <> SUBT.name
336       ))
337 ;
338 
339 INSERT INTO xla_acct_attributes_tl
340 (name
341 ,creation_date
342 ,created_by
343 ,last_update_date
344 ,last_updated_by
345 ,accounting_attribute_code
346 ,last_update_login
347 ,language
348 ,source_lang)
349 SELECT   /*+ ORDERED */
350        b.name
351       ,b.creation_date
352       ,b.created_by
353       ,b.last_update_date
354       ,b.last_updated_by
355       ,b.accounting_attribute_code
356       ,b.last_update_login
357       ,l.language_code
358       ,b.source_lang
359 FROM   xla_acct_attributes_tl             b
360       ,fnd_languages                    l
361 WHERE  l.installed_flag                IN ('I', 'B')
362   AND  b.language                       = userenv('LANG')
363   AND  NOT EXISTS
364       (SELECT NULL
365        FROM   xla_acct_attributes_tl               t
366        WHERE  t.accounting_attribute_code        = b.accounting_attribute_code
367          AND  t.language                         = l.language_code);
368 
369 xla_utility_pkg.trace('< xla_acct_attributes_f_pkg.add_language'                  ,20);
370 END add_language;
371 
372 /*======================================================================+
373 |                                                                       |
374 |  Procedure load_row                                                   |
375 |                                                                       |
376 +======================================================================*/
377 PROCEDURE load_row
378   (p_accounting_attribute_code        IN VARCHAR2
379   ,p_journal_entry_level_code         IN VARCHAR2
380   ,p_datatype_code                    IN VARCHAR2
381   ,p_assignment_required_code         IN VARCHAR2
382   ,p_assignment_group_code            IN VARCHAR2
383   ,p_assignment_extensible_flag       IN VARCHAR2
384   ,p_assignment_level_code            IN VARCHAR2
385   ,p_inherited_flag                   IN VARCHAR2
386   ,p_name                             IN VARCHAR2
387   ,p_owner                            IN VARCHAR2
388   ,p_last_update_date                 IN VARCHAR2
389   ,p_custom_mode                      IN VARCHAR2)
390 IS
391 
392   l_view_application_id   number(38);
393   l_application_id        number(38);
394   l_flex_value_set_id     number(38);
395   l_rowid                 ROWID;
396   l_exist                 VARCHAR2(1);
397   f_luby                  number(38);  -- entity owner in file
401 
398   f_ludate                date;        -- entity update date in file
399   db_luby                 number(38);  -- entity owner in db
400   db_ludate               date;        -- entity update date in db
402 BEGIN
403 
404   -- Translate owner to file_last_updated_by
405   f_luby := fnd_load_util.owner_id(p_owner);
406 
407   -- Translate char last_update_date to date
408   f_ludate := nvl(to_date(p_last_update_date, 'YYYY/MM/DD'), sysdate);
409 
410   BEGIN
411 
412      SELECT last_updated_by, last_update_date
413        INTO db_luby, db_ludate
414        FROM xla_acct_attributes_vl
415       WHERE accounting_attribute_code      = p_accounting_attribute_code;
416 
417      IF (fnd_load_util.upload_test(f_luby, f_ludate, db_luby,
418                                 db_ludate, null)) then
419         xla_acct_attributes_f_pkg.update_row
420           (x_accounting_attribute_code     => p_accounting_attribute_code
421           ,x_journal_entry_level_code      => p_journal_entry_level_code
422           ,x_datatype_code                 => p_datatype_code
423           ,x_assignment_required_code      => p_assignment_required_code
424           ,x_assignment_group_code         => p_assignment_group_code
425           ,x_assignment_extensible_flag    => p_assignment_extensible_flag
426           ,x_assignment_level_code         => p_assignment_level_code
427           ,x_inherited_flag                => p_inherited_flag
428           ,x_name                          => p_name
429           ,x_last_update_date              => f_ludate
430           ,x_last_updated_by               => f_luby
431           ,x_last_update_login             => 0);
432 
433      END IF;
434 
435   EXCEPTION
436 
437     WHEN NO_DATA_FOUND THEN
438        xla_acct_attributes_f_pkg.insert_row
439          (x_rowid                             => l_rowid
440          ,x_accounting_attribute_code         => p_accounting_attribute_code
441          ,x_journal_entry_level_code          => p_journal_entry_level_code
442          ,x_datatype_code                     => p_datatype_code
443          ,x_assignment_required_code          => p_assignment_required_code
444          ,x_assignment_group_code             => p_assignment_group_code
445          ,x_assignment_extensible_flag        => p_assignment_extensible_flag
446          ,x_assignment_level_code             => p_assignment_level_code
447          ,x_inherited_flag                    => p_inherited_flag
448          ,x_name                              => p_name
449          ,x_creation_date                     => f_ludate
450          ,x_created_by                        => f_luby
451          ,x_last_update_date                  => f_ludate
452          ,x_last_updated_by                   => f_luby
453          ,x_last_update_login                 => 0);
454 
455   END;
456 
457 EXCEPTION
458    WHEN NO_DATA_FOUND THEN
459       null;
460    WHEN OTHERS THEN
461    xla_exceptions_pkg.raise_message
462       (p_location   => 'xla_acct_attributes_f_pkg.load_row');
463 
464 END load_row;
465 
466 /*======================================================================+
467 |                                                                       |
468 |  Procedure translate_row                                              |
469 |                                                                       |
470 +======================================================================*/
471 PROCEDURE translate_row
472   (p_accounting_attribute_code           IN VARCHAR2
473   ,p_name                             IN VARCHAR2
474   ,p_owner                            IN VARCHAR2
475   ,p_last_update_date                 IN VARCHAR2
476   ,p_custom_mode                      IN VARCHAR2)
477 IS
478 
479   l_view_application_id   number(38);
480   l_application_id        number(38);
481   l_row_id                ROWID;
482   l_exist                 VARCHAR2(1);
483   f_luby                  number(38);  -- entity owner in file
484   f_ludate                date;        -- entity update date in file
485   db_luby                 number(38);  -- entity owner in db
486   db_ludate               date;        -- entity update date in db
487 
488 BEGIN
489 
490   -- Translate owner to file_last_updated_by
491   f_luby := fnd_load_util.owner_id(p_owner);
492 
493   -- Translate char last_update_date to date
494   f_ludate := nvl(to_date(p_last_update_date, 'YYYY/MM/DD'), sysdate);
495 
496   BEGIN
497      SELECT last_updated_by, last_update_date
498        INTO db_luby, db_ludate
499        FROM xla_acct_attributes_tl
500       WHERE accounting_attribute_code      = p_accounting_attribute_code
501         AND language                       = userenv('LANG');
502 
503      IF (fnd_load_util.upload_test(f_luby, f_ludate, db_luby,
504                                 db_ludate, p_custom_mode)) then
505         UPDATE xla_acct_attributes_tl
506            SET name                         = p_name
507               ,last_update_date             = f_ludate
508               ,last_updated_by              = f_luby
509               ,last_update_login            = 0
510               ,source_lang                  = userenv('LANG')
511          WHERE userenv('LANG')              IN (language, source_lang)
512            AND accounting_attribute_code    = p_accounting_attribute_code;
513 
514      END IF;
515 
516   END;
520 
517 
518 
519 END translate_row;
521 end xla_acct_attributes_f_PKG;