1 PACKAGE BODY gl_budget_utils_pkg AS
2 /* $Header: glubdmsb.pls 120.11.12010000.2 2009/03/20 06:05:14 skotakar ship $ */
3
4 --
5 -- PUBLIC FUNCTIONS
6 --
7
8 PROCEDURE get_current_budget(x_ledger_id NUMBER,
9 x_budget_version_id IN OUT NOCOPY NUMBER,
10 x_budget_name IN OUT NOCOPY VARCHAR2,
11 x_bj_required IN OUT NOCOPY VARCHAR2) IS
12
13 CURSOR chk_budget IS
14 SELECT bv.budget_version_id, b.budget_name,
15 b.require_budget_journals_flag
16 FROM gl_budgets b, gl_budget_versions bv
17 WHERE b.ledger_id = x_ledger_id
18 AND b.status = 'C'
19 AND bv.budget_name = b.budget_name
20 AND bv.budget_type = b.budget_type;
21 BEGIN
22 OPEN chk_budget;
23 FETCH chk_budget INTO x_budget_version_id, x_budget_name, x_bj_required;
24 CLOSE chk_budget;
25 END get_current_budget;
26
27 FUNCTION is_funding_budget(x_ledger_id NUMBER,
28 x_funct_curr VARCHAR2,
29 x_budget_version_id NUMBER)
30 RETURN BOOLEAN IS
31
32 CURSOR chk_funding IS
33 SELECT 'Funding budget'
34 FROM gl_budget_assignment_ranges rng, gl_budorg_bc_options bc
35 WHERE rng.ledger_id = x_ledger_id
36 AND rng.currency_code = x_funct_curr
37 AND bc.range_id = rng.range_id
38 AND bc.funds_check_level_code IN ('D', 'B')
39 AND bc.funding_budget_version_id = x_budget_version_id;
40 CURSOR chk_sum_funding IS
41 SELECT 'Summary Funding budget'
42 FROM gl_summary_templates sum, gl_summary_bc_options bc
43 WHERE sum.ledger_id = x_ledger_id
44 AND bc.template_id = sum.template_id
45 AND bc.funds_check_level_code IN ('D','B')
46 AND bc.funding_budget_version_id = x_budget_version_id;
47 dummy VARCHAR2(100);
48 dummy2 VARCHAR2(100);
49 BEGIN
50 OPEN chk_funding;
51 FETCH chk_funding INTO dummy;
52
53 OPEN chk_sum_funding;
54 FETCH chk_sum_funding INTO dummy2;
55
56 IF chk_funding%FOUND OR chk_sum_funding%FOUND THEN
57 CLOSE chk_funding;
58 CLOSE chk_sum_funding;
59 return(TRUE);
60 ELSE
61 CLOSE chk_funding;
62 CLOSE chk_sum_funding;
63 return(FALSE);
64 END IF;
65 END is_funding_budget;
66
67 FUNCTION is_master_budget(budget_id NUMBER)
68 RETURN BOOLEAN IS
69
70 CURSOR chk_master IS
71 SELECT 'Used as master'
72 FROM gl_budget_versions detail
73 WHERE detail.control_budget_version_id = budget_id;
74 dummy VARCHAR2(100);
75 BEGIN
76 OPEN chk_master;
77 FETCH chk_master INTO dummy;
78
79 IF chk_master%FOUND THEN
80 CLOSE chk_master;
81 return(TRUE);
82 ELSE
83 CLOSE chk_master;
84 return(FALSE);
85 END IF;
86 END is_master_budget;
87
88 FUNCTION frozen_budget(budget_version_id NUMBER) RETURN BOOLEAN IS
89 CURSOR chk_frozen IS
90 SELECT status
91 FROM gl_budget_versions
92 WHERE budget_version_id = frozen_budget.budget_version_id;
93 tmp_status VARCHAR2(1);
94 BEGIN
95 OPEN chk_frozen;
96 FETCH chk_frozen INTO tmp_status;
97
98 IF chk_frozen%FOUND THEN
99 CLOSE chk_frozen;
100 IF (tmp_status = 'F') THEN
101 return(TRUE);
102 ELSE
103 return(FALSE);
104 END IF;
105 ELSE
106 CLOSE chk_frozen;
107 RAISE NO_DATA_FOUND;
108 END IF;
109 END frozen_budget;
110
111 FUNCTION frozen_budget_entity(budget_version_id NUMBER,
112 budget_entity_id NUMBER) RETURN BOOLEAN IS
113 CURSOR chk_frozen IS
114 SELECT frozen_flag
115 FROM gl_entity_budgets
116 WHERE budget_version_id = frozen_budget_entity.budget_version_id
117 AND budget_entity_id = frozen_budget_entity.budget_entity_id;
118 tmp_status VARCHAR2(1);
119 BEGIN
120 OPEN chk_frozen;
121 FETCH chk_frozen INTO tmp_status;
122
123 IF chk_frozen%FOUND THEN
124 CLOSE chk_frozen;
125 IF (tmp_status = 'Y') THEN
126 return(TRUE);
127 ELSE
128 return(FALSE);
129 END IF;
130 ELSE
131 CLOSE chk_frozen;
132 RAISE NO_DATA_FOUND;
133 END IF;
134 END frozen_budget_entity;
135 /* Bug Fix 3866812 */
136 /*
137 Modications in frozen_account function:
138 Added two new parameters:
139 Parameters 1. ledger_id 2. Currency_code
140 Added four new cursors :
141 Cursors 1. get_org_name : Fetch the budget organization name
142 corresponding to budget organization id.
143 2. get_entity_id: Fetch the budget organization id to which
144 a code combination belongs.
145 3. get_status : Fetch the status of the given budget organization.
146 4. get_all_meaning : Fetch the meaning of lookup_code 'ALL'.
147 Modified cursor chk_frozen:Added parameter entity_id to the cursor.
148 Change in logic:
149 Fetch the organization name from the organization ID
150 IF organization name is found THEN
151 IF organization name is 'ALL' THEN
152 Fetch user organization (ALL is system defined),
153 based on LEDGER_ID, CCID and CURRENCY.
154 IF user organization is found THEN
155 Check if user organization is frozen
156 IF user organization frozen info found THEN
157 IF user organization is frozen THEN
158 return 'TRUE' (frozen org)
159 Else
160 Check if acccount (CCID) is frozen in the organization.
161 IF account is frozen THEN
162 return 'TRUE'
163 Else
164 return 'FALSE'
165 Else -- user organization frozen info not found then
166 -- donot register new message since this will rarely happen,
167 -- if data modified externally to the system
168 Raise NO_DATA_FOUND
169 Else -- user organization not found
170 -- happens only if data is corrupted
171 Raise NO_DATA_FOUND
172 Else -- organization name is not 'ALL'
173 Check if acccount (CCID) is frozen in the organization.
174 IF account is frozen then
175 return 'TRUE'
176 Else
177 return 'FALSE'
178 Else
179 -- happens only if data is corrupted
180 Raise NO_DATA_FOUND
181 */
182 FUNCTION frozen_account(coa_id NUMBER,
183 budget_version_id NUMBER,
184 budget_entity_id NUMBER,
185 code_combination_id NUMBER,
186 ledger_id NUMBER,
187 currency_code VARCHAR2) RETURN BOOLEAN IS
188 CURSOR chk_frozen (entity_id NUMBER) IS
189 SELECT 'Frozen'
190 FROM gl_code_combinations cc, gl_budget_frozen_ranges bfr
191 WHERE bfr.budget_version_id = frozen_account.budget_version_id
192 AND bfr.budget_entity_id = entity_id
193 AND cc.code_combination_id = frozen_account.code_combination_id
194 AND cc.chart_of_accounts_id = frozen_account.coa_id
195 AND nvl(cc.segment1,'XXX') between nvl(bfr.segment1_low,'XXX')
196 and nvl(bfr.segment1_high,'XXX')
197 AND nvl(cc.segment2,'XXX') between nvl(bfr.segment2_low,'XXX')
198 and nvl(bfr.segment2_high,'XXX')
199 AND nvl(cc.segment3,'XXX') between nvl(bfr.segment3_low,'XXX')
200 and nvl(bfr.segment3_high,'XXX')
201 AND nvl(cc.segment4,'XXX') between nvl(bfr.segment4_low,'XXX')
202 and nvl(bfr.segment4_high,'XXX')
203 AND nvl(cc.segment5,'XXX') between nvl(bfr.segment5_low,'XXX')
204 and nvl(bfr.segment5_high,'XXX')
205 AND nvl(cc.segment6,'XXX') between nvl(bfr.segment6_low,'XXX')
206 and nvl(bfr.segment6_high,'XXX')
207 AND nvl(cc.segment7,'XXX') between nvl(bfr.segment7_low,'XXX')
208 and nvl(bfr.segment7_high,'XXX')
209 AND nvl(cc.segment8,'XXX') between nvl(bfr.segment8_low,'XXX')
210 and nvl(bfr.segment8_high,'XXX')
211 AND nvl(cc.segment9,'XXX') between nvl(bfr.segment9_low,'XXX')
212 and nvl(bfr.segment9_high,'XXX')
213 AND nvl(cc.segment10,'XXX') between nvl(bfr.segment10_low,'XXX')
214 and nvl(bfr.segment10_high,'XXX')
215 AND nvl(cc.segment11,'XXX') between nvl(bfr.segment11_low,'XXX')
216 and nvl(bfr.segment11_high,'XXX')
217 AND nvl(cc.segment12,'XXX') between nvl(bfr.segment12_low,'XXX')
218 and nvl(bfr.segment12_high,'XXX')
219 AND nvl(cc.segment13,'XXX') between nvl(bfr.segment13_low,'XXX')
220 and nvl(bfr.segment13_high,'XXX')
221 AND nvl(cc.segment14,'XXX') between nvl(bfr.segment14_low,'XXX')
222 and nvl(bfr.segment14_high,'XXX')
223 AND nvl(cc.segment15,'XXX') between nvl(bfr.segment15_low,'XXX')
224 and nvl(bfr.segment15_high,'XXX')
225 AND nvl(cc.segment16,'XXX') between nvl(bfr.segment16_low,'XXX')
226 and nvl(bfr.segment16_high,'XXX')
227 AND nvl(cc.segment17,'XXX') between nvl(bfr.segment17_low,'XXX')
228 and nvl(bfr.segment17_high,'XXX')
229 AND nvl(cc.segment18,'XXX') between nvl(bfr.segment18_low,'XXX')
230 and nvl(bfr.segment18_high,'XXX')
231 AND nvl(cc.segment19,'XXX') between nvl(bfr.segment19_low,'XXX')
232 and nvl(bfr.segment19_high,'XXX')
233 AND nvl(cc.segment20,'XXX') between nvl(bfr.segment20_low,'XXX')
234 and nvl(bfr.segment20_high,'XXX')
235 AND nvl(cc.segment21,'XXX') between nvl(bfr.segment21_low,'XXX')
236 and nvl(bfr.segment21_high,'XXX')
237 AND nvl(cc.segment22,'XXX') between nvl(bfr.segment22_low,'XXX')
238 and nvl(bfr.segment22_high,'XXX')
239 AND nvl(cc.segment23,'XXX') between nvl(bfr.segment23_low,'XXX')
240 and nvl(bfr.segment23_high,'XXX')
241 AND nvl(cc.segment24,'XXX') between nvl(bfr.segment24_low,'XXX')
242 and nvl(bfr.segment24_high,'XXX')
243 AND nvl(cc.segment25,'XXX') between nvl(bfr.segment25_low,'XXX')
244 and nvl(bfr.segment25_high,'XXX')
245 AND nvl(cc.segment26,'XXX') between nvl(bfr.segment26_low,'XXX')
246 and nvl(bfr.segment26_high,'XXX')
247 AND nvl(cc.segment27,'XXX') between nvl(bfr.segment27_low,'XXX')
248 and nvl(bfr.segment27_high,'XXX')
249 AND nvl(cc.segment28,'XXX') between nvl(bfr.segment28_low,'XXX')
250 and nvl(bfr.segment28_high,'XXX')
251 AND nvl(cc.segment29,'XXX') between nvl(bfr.segment29_low,'XXX')
252 and nvl(bfr.segment29_high,'XXX')
253 AND nvl(cc.segment30,'XXX') between nvl(bfr.segment30_low,'XXX')
254 and nvl(bfr.segment30_high,'XXX');
255 CURSOR get_org_name is
256 SELECT name
257 FROM gl_budget_entities
258 WHERE budget_entity_id = frozen_account.budget_entity_id;
259
260 CURSOR get_entity_id is
261 SELECT budget_entity_id
262 FROM gl_budget_assignments
263 WHERE ledger_id = frozen_account.ledger_id AND
264 code_combination_id = frozen_account.code_combination_id AND
265 currency_code=frozen_account.currency_code;
266
267 CURSOR get_status(entity_id number) is
268 SELECT frozen_flag
269 FROM gl_entity_budgets
270 WHERE budget_version_id=frozen_account.budget_version_id and budget_entity_id=entity_id;
271
272 CURSOR get_all_meaning is
273 SELECT meaning
274 FROM gl_lookups
275 WHERE lookup_type='LITERAL' AND lookup_code='ALL';
276
277 tmp_status VARCHAR2(100);
278 budget_org_all VARCHAR2(30);
279 budget_org_name VARCHAR2(100);
280 bud_entity_id NUMBER;
281 frozen_flag VARCHAR2(2);
282 BEGIN
283 OPEN get_all_meaning;
284 FETCH get_all_meaning INTO budget_org_all;
285 IF get_all_meaning%FOUND THEN
286 CLOSE get_all_meaning;
287 ELSE
288 CLOSE get_all_meaning;
289 END IF;
290 OPEN get_org_name;
291 FETCH get_org_name INTO budget_org_name;
292 IF get_org_name%FOUND THEN
293 CLOSE get_org_name;
294 ELSE
295 CLOSE get_org_name;
296 END IF;
297 IF UPPER(budget_org_name)= UPPER(budget_org_all) THEN
298 OPEN get_entity_id;
299 FETCH get_entity_id INTO bud_entity_id;
300 IF get_entity_id%FOUND THEN
301 CLOSE get_entity_id;
302 OPEN get_status(bud_entity_id);
303 FETCH get_status INTO frozen_flag;
304 IF get_status%FOUND THEN
305 CLOSE get_status;
306 IF frozen_flag='Y' THEN
307 return(TRUE);
308 END IF;
309 ELSE
310 CLOSE get_status;
311 RAISE NO_DATA_FOUND;
312 END IF;
313 ELSE
314 CLOSE get_entity_id;
315 RAISE NO_DATA_FOUND;
316 END IF;
317 OPEN chk_frozen(bud_entity_id);
318 FETCH chk_frozen INTO tmp_status;
319 IF chk_frozen%FOUND THEN
320 CLOSE chk_frozen;
321 return(TRUE);
322 ELSE
323 CLOSE chk_frozen;
324 return(FALSE);
325 END IF;
326 ELSE
327 OPEN chk_frozen(frozen_account.budget_entity_id);
328 FETCH chk_frozen INTO tmp_status;
329 IF chk_frozen%FOUND THEN
330 CLOSE chk_frozen;
331 return(TRUE);
332 ELSE
333 CLOSE chk_frozen;
334 return(FALSE);
335 END IF;
336 END IF;
337 END frozen_account;
338
339 PROCEDURE validate_budget_account(lgr_id NUMBER,
340 coa_id NUMBER,
341 budget_version_id NUMBER,
342 code_combination_id NUMBER,
343 currency_code VARCHAR2,
344 return_code IN OUT NOCOPY VARCHAR2,
345 budget_entity_id IN OUT NOCOPY NUMBER,
346 budget_entity IN OUT NOCOPY VARCHAR2,
347 password_flag IN OUT NOCOPY VARCHAR2,
348 encrypted_password IN OUT NOCOPY VARCHAR2,
349 status_code IN OUT NOCOPY VARCHAR2) IS
350 BEGIN
351
352 -- Find out which budget organization the account is assigned to
353 DECLARE
354 entry_code VARCHAR2(1);
355 retvalue VARCHAR2(1);
356 security_flag VARCHAR2(1);--Added as part of bug7382899
357 BEGIN
358 gl_budget_assignment_pkg.select_columns(lgr_id,
359 code_combination_id,
360 currency_code,
361 budget_entity_id,
362 entry_code);
363
364 --Pulled this call from below:bug7382899
365 -- Get various information about the budget organization
366 gl_budget_entities_pkg.select_columns(budget_entity_id,
367 budget_entity,
368 password_flag,
369 encrypted_password,
370 status_code,
371 security_flag);
372
373
374 IF security_flag = 'Y' THEN--Added as part of bug7382899
375 retvalue := fnd_data_security.check_function(1.0,'GL_DAS_BUDGET_ORG_U',
376 'GL_DAS_BUDGET_ORG', to_char(budget_entity_id),null,
377 null,null,null,fnd_global.user_name);
378 IF(retvalue <> 'T') THEN
379 return_code := 'A';
380 return;
381 END IF;
382 END IF;----Added as part of bug7382899
383
384 EXCEPTION
385 WHEN NO_DATA_FOUND THEN
386 return_code := 'A';
387 return;
388 END;
389
390
391 --Commented as part of bug7382899: Moving this procedure above
392 --as we need security flag for conditional calling of data security api.
393 /*-- Get various information about the budget organization
394 gl_budget_entities_pkg.select_columns(budget_entity_id,
395 budget_entity,
396 password_flag,
397 encrypted_password,
398 status_code);*/
399
400 -- Verify that the budget organization is not frozen
401 IF (gl_budget_utils_pkg.frozen_budget_entity(budget_version_id,
402 budget_entity_id)) THEN
403 return_code := 'O';
404 return;
405 END IF;
406
407 -- Verify that the account is not frozen
408 /* Bug Fix 3866812 */
409 /* Added two parameters lgr_id and currency_code */
410 IF (gl_budget_utils_pkg.frozen_account(coa_id,
411 budget_version_id,
412 budget_entity_id,
413 code_combination_id,
414 lgr_id,
415 currency_code)) THEN
416 return_code := 'F';
417 return;
418 END IF;
419
420 return_code := 'Z';
421 return;
422 END validate_budget_account;
423
424
425 FUNCTION get_unique_id RETURN NUMBER IS
426 -- get unique id for range_id
427 CURSOR c_getid IS
428 SELECT GL_BUDGET_FROZEN_RANGES_S.NEXTVAL
429 FROM dual;
430 id number;
431
432 BEGIN
433 OPEN c_getid;
434 FETCH c_getid INTO id;
435
436 IF c_getid%FOUND THEN
437 CLOSE c_getid;
438 RETURN( id );
439 ELSE
440 CLOSE c_getid;
441 fnd_message.set_name('SQLGL', 'GL_ERROR_GETTING_UNIQUE_ID');
442 fnd_message.set_token('SEQUENCE', 'GL_BUDGET_FROZEN_RANGES_S');
443 app_exception.raise_exception;
444 END IF;
445
446 EXCEPTION
447 WHEN APP_EXCEPTION.application_exception THEN
448 RAISE;
449 WHEN OTHERS THEN
450 fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
451 fnd_message.set_token('PROCEDURE',
452 'gl_budget_utils_pkg.get_unique_id');
453 RAISE;
454 END get_unique_id;
455
456 FUNCTION get_opyr_per_range ( x_budget_version_id IN NUMBER,
457 x_start_period_year IN OUT NOCOPY NUMBER,
458 x_start_period_name IN OUT NOCOPY VARCHAR2,
459 x_start_period_num IN OUT NOCOPY NUMBER,
460 x_end_period_year IN OUT NOCOPY NUMBER,
461 x_end_period_name IN OUT NOCOPY VARCHAR2,
462 x_end_period_num IN OUT NOCOPY NUMBER)
463 RETURN BOOLEAN IS
464 CURSOR get_prd IS
465 SELECT prs.period_year,
466 prs.start_period_name,
467 prs.start_period_num,
468 pre.period_year,
469 pre.end_period_name,
470 pre.end_period_num
471 FROM gl_budget_period_ranges prs,
472 gl_budget_period_ranges pre
473 WHERE prs.budget_version_id = pre.budget_version_id
474 AND prs.budget_version_id = x_budget_version_id
475 AND prs.period_year * 100000 + prs.start_period_num =
476 (SELECT MIN(period_year * 100000 + start_period_num)
477 FROM gl_budget_period_ranges
478 WHERE budget_version_id = x_budget_version_id
479 AND open_flag = 'O')
480 AND pre.period_year * 100000 + pre.start_period_num =
481 (SELECT MAX(period_year * 100000 + start_period_num)
482 FROM gl_budget_period_ranges
483 WHERE budget_version_id = x_budget_version_id
484 AND open_flag = 'O');
485 BEGIN
486 OPEN get_prd;
487 FETCH get_prd INTO x_start_period_year,
488 x_start_period_name,
489 x_start_period_num,
490 x_end_period_year,
491 x_end_period_name,
492 x_end_period_num;
493
494 IF get_prd%FOUND THEN
495 CLOSE get_prd;
496 return (TRUE);
497 ELSE
498 CLOSE get_prd;
499 return (FALSE);
500 END IF;
501 END get_opyr_per_range;
502
503
504
505 PROCEDURE validate_budget(
506 X_Rowid IN OUT NOCOPY VARCHAR2,
507 X_Budget_Type VARCHAR2,
508 X_Budget_Name VARCHAR2,
509 X_Ledger_Id NUMBER,
510 X_Status VARCHAR2,
511 X_Date_Created DATE,
512 X_Require_Budget_Journals_Flag VARCHAR2,
513 X_Current_Version_Id NUMBER DEFAULT NULL,
514 X_Latest_Opened_Year NUMBER DEFAULT NULL,
515 X_First_Valid_Period_Name VARCHAR2 DEFAULT NULL,
516 X_Last_Valid_Period_Name VARCHAR2 DEFAULT NULL,
517 X_Description VARCHAR2 DEFAULT NULL,
518 X_Date_Closed DATE DEFAULT NULL,
519 X_Attribute1 VARCHAR2 DEFAULT NULL,
520 X_Attribute2 VARCHAR2 DEFAULT NULL,
521 X_Attribute3 VARCHAR2 DEFAULT NULL,
522 X_Attribute4 VARCHAR2 DEFAULT NULL,
523 X_Attribute5 VARCHAR2 DEFAULT NULL,
524 X_Attribute6 VARCHAR2 DEFAULT NULL,
525 X_Attribute7 VARCHAR2 DEFAULT NULL,
526 X_Attribute8 VARCHAR2 DEFAULT NULL,
527 X_Context VARCHAR2 DEFAULT NULL,
528 X_User_Id NUMBER,
529 X_Login_Id NUMBER,
530 X_Date DATE,
531 X_Budget_Version_Id NUMBER,
532 X_Master_Budget_Version_Id NUMBER DEFAULT NULL) IS
533
534 CURSOR chk_first_period IS
535 SELECT period_year, period_num
536 FROM gl_period_statuses
537 WHERE application_id = 101
538 AND ledger_id = X_Ledger_Id
539 AND period_num between 1 and 60
540 AND period_name = X_First_Valid_Period_Name;
541
542 CURSOR chk_last_period
543 (p_first_valid_period_year NUMBER,
544 p_first_valid_period_num NUMBER) IS
545 SELECT period_year, period_num
546 FROM gl_period_statuses
547 WHERE application_id = 101
548 AND ledger_id = X_Ledger_Id
549 AND period_num between 1 and 60
550 AND period_year * 10000 + period_num >=
551 p_first_valid_period_year * 10000 + p_first_valid_period_num
552 AND period_name = X_Last_Valid_Period_Name;
553
554 v_rbj_flag VARCHAR2(1);
555 v_func_curr_code VARCHAR2(15);
556 v_ledger_name VARCHAR2(30);
557 v_first_valid_period_year NUMBER;
558 v_first_valid_period_num NUMBER;
559 v_last_valid_period_year NUMBER;
560 v_last_valid_period_num NUMBER;
561
562 BEGIN
563
564 -- validate Require_Budget_Journals_Flag
565 -- the flag cannot be 'N' if
566 -- the set_of_books has its require_budget_journals_flag checked, or
567 -- the budget is a funding budget
568 IF (X_Require_Budget_Journals_Flag = 'N') THEN
569
570 SELECT require_budget_journals_flag, currency_code, name
571 INTO v_rbj_flag, v_func_curr_code, v_ledger_name
572 FROM gl_ledgers
573 WHERE ledger_id = X_Ledger_Id;
574
575 IF (v_rbj_flag = 'Y') THEN
576 fnd_message.set_name('SQLGL', 'GL_API_BUDGET_REQUIRE_JOURNALS');
577 fnd_message.set_token('LEDGER_NAME', v_ledger_name);
578 app_exception.raise_exception;
579 END IF;
580
581 IF (gl_budget_utils_pkg.is_funding_budget(
582 X_Ledger_Id,
583 v_func_curr_code,
584 X_Budget_Version_Id)) THEN
585 fnd_message.set_name('SQLGL', 'GL_API_BUDGET_FUNDING_JOURNALS');
586 fnd_message.set_token('BUDGET', X_Budget_Name);
587 app_exception.raise_exception;
588 END IF;
589 END IF;
590
591 -- validate First_Valid_Period_Name
592 OPEN chk_first_period;
593 FETCH chk_first_period
594 INTO v_first_valid_period_year, v_first_valid_period_num;
595
596 IF chk_first_period%NOTFOUND THEN
597 CLOSE chk_first_period;
598 fnd_message.set_name('SQLGL', 'GL_API_INVALID_VALUE');
599 fnd_message.set_token('VALUE', NVL(X_First_Valid_Period_Name, 'null'));
600 fnd_message.set_token('ATTRIBUTE', 'FirstValidPeriodName');
601 app_exception.raise_exception;
602 END IF;
603
604 CLOSE chk_first_period;
605
606 -- validate Last_Valid_Period_Name
607 OPEN chk_last_period(v_first_valid_period_year, v_first_valid_period_num);
608 FETCH chk_last_period
609 INTO v_last_valid_period_year, v_last_valid_period_num;
610
611 IF chk_last_period%NOTFOUND THEN
612 CLOSE chk_last_period;
613 fnd_message.set_name('SQLGL', 'GL_API_INVALID_VALUE');
614 fnd_message.set_token('VALUE', NVL(X_Last_Valid_Period_Name, 'null'));
615 fnd_message.set_token('ATTRIBUTE', 'LastValidPeriodName');
616 app_exception.raise_exception;
617 END IF;
618
619 CLOSE chk_last_period;
620
621 EXCEPTION
622 WHEN app_exceptions.application_exception THEN
623 RAISE;
624 WHEN OTHERS THEN
625 fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
626 RAISE;
627
628 END validate_budget;
629
630
631 END gl_budget_utils_pkg;