DBA Data[Home] [Help]

PACKAGE BODY: APPS.GL_BUDGETS_PKG

Source


1 PACKAGE BODY gl_budgets_pkg AS
2 /* $Header: glibddfb.pls 120.5 2005/05/05 01:01:17 kvora ship $ */
3 
4   --
5   -- PRIVATE FUNCTIONS
6   --
7 
8   --
9   -- Procedure
10   --   check_detail_budgets
11   -- Purpose
12   --   Checks to make sure the budget isn't assigned to a detail budget
13   --   between the time its last valid period is changed and the time
14   --   this change is committed.  Due to the check done in lock_master_budgets,
15   --   this could only occur if the same user was modifying both budgets.
16   -- History
17   --   10-25-93  D. J. Ogg        Created
18   --   04-02-01  N. A. Alvarez    Replaced set_of_books with ledger_id
19   -- Arguments
20   --   x_budget_version_id        Budget version ID of the updated budget
21   --   x_budget_name              Name of the updated budget
22   --   x_first_valid_period_name  New first valid period of the updated budget
23   --   x_last_valid_period_name   New last valid period of the updated budget
24   -- Example
25   --   gl_budget_misc_pkg.check_detail_budgets(1000, 'JAN-91', 'DEC-91')
26   -- Notes
27   --
28   PROCEDURE check_detail_budgets(
29   		x_budget_version_id NUMBER,
30                 x_budget_name VARCHAR2,
31                 x_first_valid_period_name VARCHAR2,
32                 x_last_valid_period_name VARCHAR2) IS
33     CURSOR chk_details IS
34       SELECT 'Master budget'
35       FROM   gl_budget_versions bv, gl_budgets b
36       WHERE  bv.control_budget_version_id =
37                x_budget_version_id
38       AND    b.budget_name = bv.budget_name
39       AND    b.budget_type = bv.budget_type
40       AND    (    (b.first_valid_period_name <>
41                     x_first_valid_period_name)
42               OR  (b.last_valid_period_name <>
43                     x_last_valid_period_name));
44     dummy VARCHAR2(100);
45   BEGIN
46     OPEN chk_details;
47     FETCH chk_details INTO dummy;
48 
49     IF chk_details%FOUND THEN
50       CLOSE chk_details;
51       fnd_message.set_name('SQLGL',
52                            'GL_BUD_NOT_W_MASTER_DETAIL');
53       app_exception.raise_exception;
54     ELSE
55       CLOSE chk_details;
56     END IF;
57   END check_detail_budgets;
58 
59   --
60   -- Procedure
61   --   lock_master_budgets
62   -- Purpose
63   --   Lock the master budget to make sure its last valid period is not
64   --   changed between the time it is checked in the pre-insert/pre-update
65   --   triggers and the time it is committed.
66   -- History
67   --   10-25-93  D. J. Ogg    Created
68   -- Arguments
69   --   x_budget_version_id        Budget version ID of the updated budget
70   --   x_first_valid_period_name  New first valid period of the updated budget
71   --   x_last_valid_period_name   New last valid period of the updated budget
72   -- Example
73   --   gl_budget_misc_pkg.lock_master_budgets(1000, 'JAN-91', 'DEC-91')
74   -- Notes
75   --
76   PROCEDURE lock_master_budget(
77     		x_master_budget_version_id NUMBER,
78                 x_first_valid_period_name VARCHAR2,
79                 x_last_valid_period_name VARCHAR2) IS
80     CURSOR lock_master IS
81       SELECT 'Master budget'
82       FROM   gl_budgets b
83       WHERE  b.budget_name =
84         (SELECT bv.budget_name
85          FROM   gl_budget_versions bv
86          WHERE  bv.budget_version_id =
87                   x_master_budget_version_id)
88       AND    b.budget_type = 'standard'
89       AND    b.first_valid_period_name =
90                x_first_valid_period_name
91       AND    b.last_valid_period_name =
92                x_last_valid_period_name
93       FOR UPDATE OF b.first_valid_period_name,
94                     b.last_valid_period_name;
95     dummy VARCHAR2(100);
96   BEGIN
97     OPEN lock_master;
98     FETCH lock_master INTO dummy;
99 
100     IF lock_master%FOUND THEN
101       CLOSE lock_master;
102     ELSE
103       CLOSE lock_master;
104       fnd_message.set_name('SQLGL', 'GL_BUD_MASTER_CHANGED');
105       app_exception.raise_exception;
106     END IF;
107   END lock_master_budget;
108 
109 
110   --
111   -- PUBLIC FUNCTIONS
112   --
113 
114   PROCEDURE check_unique(name VARCHAR2,
115                          row_id VARCHAR2) IS
116     CURSOR chk_duplicates IS
117       SELECT 'Duplicate'
118       FROM   GL_BUDGETS bud
119       WHERE  bud.budget_name = name
120       AND    bud.budget_type = 'standard'
121       AND    (   row_id is null
122               OR bud.rowid <> row_id);
123     dummy VARCHAR2(100);
124   BEGIN
125     OPEN chk_duplicates;
126     FETCH chk_duplicates INTO dummy;
127 
128     IF chk_duplicates%FOUND THEN
129       CLOSE chk_duplicates;
130       fnd_message.set_name('SQLGL', 'GL_DUPLICATE_BUDGET_NAME');
131       app_exception.raise_exception;
132     END IF;
133 
134     CLOSE chk_duplicates;
135 
136   EXCEPTION
137     WHEN app_exceptions.application_exception THEN
138       RAISE;
139     WHEN OTHERS THEN
140       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
141       fnd_message.set_token('PROCEDURE', 'gl_budgets_pkg.check_unique');
142       RAISE;
143   END check_unique;
144 
145   FUNCTION get_unique_id RETURN NUMBER IS
146     CURSOR get_new_id IS
147       SELECT gl_budget_versions_s.NEXTVAL
148       FROM dual;
149     new_id number;
150   BEGIN
151     OPEN get_new_id;
152     FETCH get_new_id INTO new_id;
153 
154     IF get_new_id%FOUND THEN
155       CLOSE get_new_id;
156       return(new_id);
157     ELSE
158       CLOSE get_new_id;
159       fnd_message.set_name('SQLGL', 'GL_ERROR_GETTING_UNIQUE_ID');
160       fnd_message.set_token('SEQUENCE', 'GL_BUDGET_VERSIONS_S');
161       app_exception.raise_exception;
162     END IF;
163 
164   EXCEPTION
165     WHEN app_exceptions.application_exception THEN
166       RAISE;
167     WHEN OTHERS THEN
168       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
169       fnd_message.set_token('PROCEDURE', 'gl_budgets_pkg.get_unique_id');
170       RAISE;
171   END get_unique_id;
172 
173 
174   FUNCTION is_budget_journals_not_req(
175     x_ledger_id  NUMBER ) RETURN BOOLEAN  IS
176 
177     CURSOR c_no_journal IS
178       SELECT 'found'
179       FROM   GL_BUDGETS b
180       WHERE  b.ledger_id = x_ledger_id
181       AND    b.require_budget_journals_flag = 'N';
182 
183     dummy VARCHAR2(100);
184 
185   BEGIN
186 
187     OPEN  c_no_journal;
188     FETCH c_no_journal INTO dummy;
189 
190     IF c_no_journal%FOUND THEN
191       CLOSE c_no_journal;
192       RETURN( TRUE );
193     ELSE
194       CLOSE c_no_journal;
195       RETURN( FALSE );
196     END IF;
197 
198   EXCEPTION
199     WHEN app_exceptions.application_exception THEN
200       RAISE;
201     WHEN OTHERS THEN
202       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
203       fnd_message.set_token('PROCEDURE',
204         'GL_BUDGET_ASGM_RNG_PKG.is_budget_journals_not_req');
205       RAISE;
206 
207   END is_budget_journals_not_req;
208 
209 
210   PROCEDURE select_row( recinfo IN OUT NOCOPY gl_budgets%ROWTYPE )  IS
211   BEGIN
212     SELECT  *
213     INTO    recinfo
214     FROM    gl_budgets
215     WHERE   ledger_id = recinfo.ledger_id
216     AND     budget_name = recinfo.budget_name ;
217   EXCEPTION
218     WHEN NO_DATA_FOUND THEN
219       RETURN;
220     WHEN app_exceptions.application_exception THEN
221       RAISE;
222     WHEN OTHERS THEN
223       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
224       fnd_message.set_token('PROCEDURE',
225                             'gl_budgets.select_row');
226       RAISE;
227   END select_row;
228 
229 
230   PROCEDURE select_columns(
231               x_budget_name                     VARCHAR2,
232               x_ledger_id                       NUMBER,
233               x_budget_type                     IN OUT NOCOPY  VARCHAR2,
234               x_status                          IN OUT NOCOPY  VARCHAR2,
235               x_required_bj_flag                IN OUT NOCOPY  VARCHAR2,
236               x_latest_opened_year              IN OUT NOCOPY  NUMBER,
237               x_first_valid_period_name         IN OUT NOCOPY  VARCHAR2,
238               x_last_valid_period_name          IN OUT NOCOPY  VARCHAR2 ) IS
239 
240     recinfo gl_budgets%ROWTYPE;
241 
242   BEGIN
243     recinfo.ledger_id := x_ledger_id;
244     recinfo.budget_name := x_budget_name;
245     select_row( recinfo );
246     x_budget_type := recinfo.budget_type;
247     x_status := recinfo.status;
248     x_required_bj_flag := recinfo.require_budget_journals_flag;
249     x_latest_opened_year := recinfo.latest_opened_year;
250     x_first_valid_period_name := recinfo.first_valid_period_name;
251     x_last_valid_period_name := recinfo.last_valid_period_name;
252 
253   EXCEPTION
254     WHEN NO_DATA_FOUND THEN
255       RETURN;
256     WHEN app_exceptions.application_exception THEN
257       RAISE;
258     WHEN OTHERS THEN
259       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
260       fnd_message.set_token('PROCEDURE',
261                             'gl_budgets.select_columns');
262       RAISE;
263   END select_columns;
264 
265 
266 PROCEDURE Insert_Row(X_Rowid                           IN OUT NOCOPY VARCHAR2,
267                      X_Budget_Type                     VARCHAR2,
268                      X_Budget_Name                     VARCHAR2,
269                      X_ledger_id                       NUMBER,
270                      X_Status                          VARCHAR2,
271                      X_Date_Created                    DATE,
272                      X_Require_Budget_Journals_Flag    VARCHAR2,
273                      X_Current_Version_Id              NUMBER DEFAULT NULL,
274                      X_Latest_Opened_Year              NUMBER DEFAULT NULL,
275                      X_First_Valid_Period_Name         VARCHAR2 DEFAULT NULL,
276                      X_Last_Valid_Period_Name          VARCHAR2 DEFAULT NULL,
277                      X_Description                     VARCHAR2 DEFAULT NULL,
278                      X_Date_Closed                     DATE DEFAULT NULL,
279                      X_Attribute1                      VARCHAR2 DEFAULT NULL,
280                      X_Attribute2                      VARCHAR2 DEFAULT NULL,
281                      X_Attribute3                      VARCHAR2 DEFAULT NULL,
282                      X_Attribute4                      VARCHAR2 DEFAULT NULL,
283                      X_Attribute5                      VARCHAR2 DEFAULT NULL,
284                      X_Attribute6                      VARCHAR2 DEFAULT NULL,
285                      X_Attribute7                      VARCHAR2 DEFAULT NULL,
286                      X_Attribute8                      VARCHAR2 DEFAULT NULL,
287                      X_Context                         VARCHAR2 DEFAULT NULL,
288 		     X_User_Id 			       NUMBER,
289 		     X_Login_Id			       NUMBER,
290 		     X_Date                            DATE,
291 		     X_Budget_Version_Id	       NUMBER,
292 		     X_Master_Budget_Version_Id        NUMBER DEFAULT NULL
293  ) IS
294    CURSOR C IS SELECT rowid FROM GL_BUDGETS
295            WHERE budget_name = X_Budget_Name;
296  BEGIN
297 
298    -- If the budget is the current budget, then make sure there are no
299    -- other current budgets.
300    IF (X_Status = 'C') THEN
301      DECLARE
302         bvid            NUMBER;
303         bname           VARCHAR2(15);
304         bj_required     VARCHAR2(2);
305      BEGIN
306        gl_budget_utils_pkg.get_current_budget(
307          X_ledger_id,
308          bvid,
309          bname,
310          bj_required);
311 
312        IF (    (bvid IS NOT NULL)
313            AND (bvid <> X_Budget_Version_Id)) THEN
314          fnd_message.set_name('SQLGL', 'GL_BUD_MULTIPLE_CURRENT_BUDGET');
315          app_exception.raise_exception;
316 
317        END IF;
318      END;
319    END IF;
320 
321    -- Lock and check the master budget
322    IF (x_master_budget_version_id IS NOT NULL) THEN
323      gl_budgets_pkg.lock_master_budget(x_master_budget_version_id,
324                                        x_first_valid_period_name,
325                                        x_last_valid_period_name);
326    END IF;
327 
328 
329   -- Do the insert
330   INSERT INTO GL_BUDGETS(
331          creation_date,
332          created_by,
333          last_update_date,
334          last_updated_by,
335          last_update_login,
336          budget_type,
337          budget_name,
338          ledger_id,
339          status,
340          date_created,
341          require_budget_journals_flag,
342          current_version_id,
343          latest_opened_year,
344          first_valid_period_name,
345          last_valid_period_name,
346          description,
347          date_closed,
348          attribute1,
349          attribute2,
350          attribute3,
351          attribute4,
352          attribute5,
353          attribute6,
354          attribute7,
355          attribute8,
356          context
357 
358         ) VALUES (
359         X_Date,
360         X_User_Id,
361         X_Date,
362         X_User_Id,
363         X_Login_Id,
364         X_Budget_Type,
365         X_Budget_Name,
366         X_ledger_id,
367         X_Status,
368         X_Date_Created,
369         X_Require_Budget_Journals_Flag,
370         X_Current_Version_Id,
371         X_Latest_Opened_Year,
372         X_First_Valid_Period_Name,
373         X_Last_Valid_Period_Name,
374         X_Description,
375         X_Date_Closed,
376         X_Attribute1,
377         X_Attribute2,
378         X_Attribute3,
379         X_Attribute4,
380         X_Attribute5,
381         X_Attribute6,
382         X_Attribute7,
383         X_Attribute8,
384         X_Context
385 
386   );
387 
388   OPEN C;
389   FETCH C INTO X_Rowid;
390   if (C%NOTFOUND) then
391     CLOSE C;
392     RAISE NO_DATA_FOUND;
393   end if;
394   CLOSE C;
395 
396   -- Insert the associated rows in gl_budget_versions
397   gl_budget_versions_pkg.insert_record(	x_budget_version_id,
398 				 	x_budget_name,
399 					x_status,
400 					x_master_budget_version_id,
401 					x_user_id,
402 					x_login_id);
403 
404   -- Insert the associated rows in gl_budget_batches
405   gl_budget_batches_pkg.insert_budget( 	x_budget_version_id,
406 				      	x_ledger_id,
407 					x_user_id);
408 
409   -- Insert the associated rows in gl_entity_budgets
410   gl_entity_budgets_pkg.insert_budget(	x_budget_version_id,
411 					x_ledger_id,
412 					x_user_id,
413 					x_login_id);
414 
415 END Insert_Row;
416 
417 PROCEDURE Lock_Row(
418 		   X_Rowid                             VARCHAR2,
419                    X_Budget_Type                       VARCHAR2,
420                    X_Budget_Name                       VARCHAR2,
421                    X_ledger_id                         NUMBER,
422                    X_Last_Update_Date                  DATE,
423                    X_Last_Updated_By                   NUMBER,
424                    X_Status                            VARCHAR2,
425                    X_Date_Created                      DATE,
426                    X_Require_Budget_Journals_Flag      VARCHAR2,
427                    X_Creation_Date                     DATE DEFAULT NULL,
428                    X_Created_By                        NUMBER DEFAULT NULL,
429                    X_Last_Update_Login                 NUMBER DEFAULT NULL,
433                    X_Last_Valid_Period_Name            VARCHAR2 DEFAULT NULL,
430                    X_Current_Version_Id                NUMBER DEFAULT NULL,
431                    X_Latest_Opened_Year                NUMBER DEFAULT NULL,
432                    X_First_Valid_Period_Name           VARCHAR2 DEFAULT NULL,
434                    X_Description                       VARCHAR2 DEFAULT NULL,
435                    X_Date_Closed                       DATE DEFAULT NULL,
436                    X_Attribute1                        VARCHAR2 DEFAULT NULL,
437                    X_Attribute2                        VARCHAR2 DEFAULT NULL,
438                    X_Attribute3                        VARCHAR2 DEFAULT NULL,
439                    X_Attribute4                        VARCHAR2 DEFAULT NULL,
440                    X_Attribute5                        VARCHAR2 DEFAULT NULL,
441                    X_Attribute6                        VARCHAR2 DEFAULT NULL,
442                    X_Attribute7                        VARCHAR2 DEFAULT NULL,
443                    X_Attribute8                        VARCHAR2 DEFAULT NULL,
444                    X_Context                           VARCHAR2 DEFAULT NULL
445 
446 ) IS
447   CURSOR C IS
448       SELECT *
449       FROM   GL_BUDGETS
450       WHERE  rowid = X_Rowid
451       FOR UPDATE of Budget_Name NOWAIT;
452   Recinfo C%ROWTYPE;
453 BEGIN
454   OPEN C;
455   FETCH C INTO Recinfo;
456   if (C%NOTFOUND) then
457     CLOSE C;
458     FND_MESSAGE.set_name('FND', 'FORM_RECORD_DELETED');
459     app_exception.raise_exception;
460   end if;
461   CLOSE C;
462 
463   if (
464          (   (Recinfo.budget_type = X_Budget_Type)
465           OR (    (Recinfo.budget_type IS NULL)
466               AND (X_Budget_Type IS NULL)))
467      AND (   (Recinfo.budget_name = X_Budget_Name)
468           OR (    (Recinfo.budget_name IS NULL)
469               AND (X_Budget_Name IS NULL)))
470      AND (   (Recinfo.ledger_id = X_ledger_id)
471           OR (    (Recinfo.ledger_id IS NULL)
472               AND (X_ledger_id IS NULL)))
473      AND (   (Recinfo.last_update_date = X_Last_Update_Date)
474           OR (    (Recinfo.last_update_date IS NULL)
475               AND (X_Last_Update_Date IS NULL)))
476      AND (   (Recinfo.last_updated_by = X_Last_Updated_By)
477           OR (    (Recinfo.last_updated_by IS NULL)
478               AND (X_Last_Updated_By IS NULL)))
479      AND (   (Recinfo.status = X_Status)
480           OR (    (Recinfo.status IS NULL)
481               AND (X_Status IS NULL)))
482      AND (   (Recinfo.date_created = X_Date_Created)
483           OR (    (Recinfo.date_created IS NULL)
484               AND (X_Date_Created IS NULL)))
485      AND (   (Recinfo.require_budget_journals_flag =
486      X_Require_Budget_Journals_Flag)
487           OR (    (Recinfo.require_budget_journals_flag IS NULL)
488               AND (X_Require_Budget_Journals_Flag IS NULL)))
489      AND (   (Recinfo.creation_date = X_Creation_Date)
490           OR (    (Recinfo.creation_date IS NULL)
491               AND (X_Creation_Date IS NULL)))
492      AND (   (Recinfo.created_by = X_Created_By)
493           OR (    (Recinfo.created_by IS NULL)
494               AND (X_Created_By IS NULL)))
495      AND (   (Recinfo.last_update_login = X_Last_Update_Login)
496           OR (    (Recinfo.last_update_login IS NULL)
497               AND (X_Last_Update_Login IS NULL)))
498      AND (   (Recinfo.current_version_id = X_Current_Version_Id)
499           OR (    (Recinfo.current_version_id IS NULL)
500               AND (X_Current_Version_Id IS NULL)))
501      AND (   (Recinfo.latest_opened_year = X_Latest_Opened_Year)
502           OR (    (Recinfo.latest_opened_year IS NULL)
503               AND (X_Latest_Opened_Year IS NULL)))
504      AND (   (Recinfo.first_valid_period_name = X_First_Valid_Period_Name)
505           OR (    (Recinfo.first_valid_period_name IS NULL)
506               AND (X_First_Valid_Period_Name IS NULL)))
507      AND (   (Recinfo.last_valid_period_name = X_Last_Valid_Period_Name)
508           OR (    (Recinfo.last_valid_period_name IS NULL)
509               AND (X_Last_Valid_Period_Name IS NULL)))
510      AND (   (Recinfo.description = X_Description)
511           OR (    (Recinfo.description IS NULL)
512               AND (X_Description IS NULL)))
513      AND (   (Recinfo.date_closed = X_Date_Closed)
514           OR (    (Recinfo.date_closed IS NULL)
515               AND (X_Date_Closed IS NULL)))
516      AND (   (Recinfo.attribute1 = X_Attribute1)
517           OR (    (Recinfo.attribute1 IS NULL)
518               AND (X_Attribute1 IS NULL)))
519      AND (   (Recinfo.attribute2 = X_Attribute2)
520           OR (    (Recinfo.attribute2 IS NULL)
521               AND (X_Attribute2 IS NULL)))
522      AND (   (Recinfo.attribute3 = X_Attribute3)
523           OR (    (Recinfo.attribute3 IS NULL)
524               AND (X_Attribute3 IS NULL)))
525      AND (   (Recinfo.attribute4 = X_Attribute4)
526           OR (    (Recinfo.attribute4 IS NULL)
527               AND (X_Attribute4 IS NULL)))
528      AND (   (Recinfo.attribute5 = X_Attribute5)
529           OR (    (Recinfo.attribute5 IS NULL)
530               AND (X_Attribute5 IS NULL)))
531      AND (   (Recinfo.attribute6 = X_Attribute6)
532           OR (    (Recinfo.attribute6 IS NULL)
536               AND (X_Attribute7 IS NULL)))
533               AND (X_Attribute6 IS NULL)))
534      AND (   (Recinfo.attribute7 = X_Attribute7)
535           OR (    (Recinfo.attribute7 IS NULL)
537      AND (   (Recinfo.attribute8 = X_Attribute8)
538           OR (    (Recinfo.attribute8 IS NULL)
539               AND (X_Attribute8 IS NULL)))
540      AND (   (Recinfo.context = X_Context)
541           OR (    (Recinfo.context IS NULL)
542               AND (X_Context IS NULL)))
543           ) then
544     return;
545   else
546     FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_CHANGED');
547     APP_EXCEPTION.RAISE_EXCEPTION;
548   end if;
549 END Lock_Row;
550 
551 PROCEDURE Update_Row(X_Rowid                           VARCHAR2,
552                      X_Budget_Type                     VARCHAR2,
553                      X_Budget_Name                     VARCHAR2,
554                      X_ledger_id                       NUMBER,
555                      X_Status                          VARCHAR2,
556                      X_Date_Created                    DATE,
557                      X_Require_Budget_Journals_Flag    VARCHAR2,
558                      X_Current_Version_Id              NUMBER DEFAULT NULL,
559                      X_Latest_Opened_Year              NUMBER DEFAULT NULL,
560                      X_First_Valid_Period_Name         VARCHAR2 DEFAULT NULL,
561                      X_Last_Valid_Period_Name          VARCHAR2 DEFAULT NULL,
562                      X_Description                     VARCHAR2 DEFAULT NULL,
563                      X_Date_Closed                     DATE DEFAULT NULL,
564                      X_Attribute1                      VARCHAR2 DEFAULT NULL,
565                      X_Attribute2                      VARCHAR2 DEFAULT NULL,
566                      X_Attribute3                      VARCHAR2 DEFAULT NULL,
567                      X_Attribute4                      VARCHAR2 DEFAULT NULL,
568                      X_Attribute5                      VARCHAR2 DEFAULT NULL,
569                      X_Attribute6                      VARCHAR2 DEFAULT NULL,
570                      X_Attribute7                      VARCHAR2 DEFAULT NULL,
571                      X_Attribute8                      VARCHAR2 DEFAULT NULL,
572                      X_Context                         VARCHAR2 DEFAULT NULL,
573                      X_User_Id                         NUMBER,
574                      X_Login_Id                        NUMBER,
575                      X_Date                            DATE,
576 		     X_Budget_Version_Id	       NUMBER,
577 		     X_Master_Budget_Version_Id        NUMBER DEFAULT NULL
578 
579 ) IS
580 BEGIN
581 
582    -- If the budget is the current budget, then make sure there are no
583    -- other current budgets.
584    IF (X_Status = 'C') THEN
585      DECLARE
586         bvid            NUMBER;
587         bname           VARCHAR2(15);
588         bj_required     VARCHAR2(2);
589      BEGIN
590        gl_budget_utils_pkg.get_current_budget(
591          X_ledger_id,
592          bvid,
593          bname,
594          bj_required);
595 
596        IF (    (bvid IS NOT NULL)
597            AND (bvid <> X_Budget_Version_Id)) THEN
598          fnd_message.set_name('SQLGL', 'GL_BUD_MULTIPLE_CURRENT_BUDGET');
599          app_exception.raise_exception;
600 
601        END IF;
602      END;
603    END IF;
604 
605    -- Lock and check the master budget
606    IF (x_master_budget_version_id IS NOT NULL) THEN
607      gl_budgets_pkg.lock_master_budget(x_master_budget_version_id,
608                                        x_first_valid_period_name,
609                                        x_last_valid_period_name);
610    END IF;
611 
612   -- Check any detail budgets that may have been changed by this same
613   -- commit
614   gl_budgets_pkg.check_detail_budgets(	x_budget_version_id,
615                                         x_budget_name,
616 					x_first_valid_period_name,
617 					x_last_valid_period_name);
618 
619   UPDATE GL_BUDGETS
620   SET
621     last_updated_by                      =   X_User_Id,
622     last_update_login                    =   X_Login_Id,
623     last_update_date                     =   X_Date,
624     budget_type                          =   X_Budget_Type,
625     budget_name                          =   X_Budget_Name,
626     ledger_id                            =   X_ledger_id,
627     status                               =   X_Status,
628     date_created                         =   X_Date_Created,
629     require_budget_journals_flag         =   X_Require_Budget_Journals_Flag,
630     current_version_id                   =   X_Current_Version_Id,
631     latest_opened_year                   =   X_Latest_Opened_Year,
632     first_valid_period_name              =   X_First_Valid_Period_Name,
633     last_valid_period_name               =   X_Last_Valid_Period_Name,
634     description                          =   X_Description,
635     date_closed                          =   X_Date_Closed,
636     attribute1                           =   X_Attribute1,
637     attribute2                           =   X_Attribute2,
638     attribute3                           =   X_Attribute3,
639     attribute4                           =   X_Attribute4,
640     attribute5                           =   X_Attribute5,
641     attribute6                           =   X_Attribute6,
642     attribute7                           =   X_Attribute7,
643     attribute8                           =   X_Attribute8,
644     context                              =   X_Context
648     RAISE NO_DATA_FOUND;
645   WHERE rowid = X_rowid;
646 
647   if (SQL%NOTFOUND) then
649   end if;
650 
651   -- Update the associated row in gl_budget_versions
652   gl_budget_versions_pkg.update_record(	x_budget_version_id,
653 				 	x_budget_name,
654 					x_status,
655 					x_master_budget_version_id,
656 					x_user_id,
657 					x_login_id);
658 
659     exception
660     WHEN app_exceptions.application_exception THEN
661       RAISE;
662     WHEN OTHERS THEN
663       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
664       fnd_message.set_token('PROCEDURE',
665                             'gl_budgets_pkg.update_row');
666       RAISE;
667 
668 END Update_Row;
669 
670 PROCEDURE Delete_Row(X_Rowid VARCHAR2) IS
671 BEGIN
672   DELETE FROM GL_BUDGETS
673   WHERE  rowid = X_Rowid;
674 
675   if (SQL%NOTFOUND) then
676     RAISE NO_DATA_FOUND;
677   end if;
678 END Delete_Row;
679 
680 END gl_budgets_pkg;