DBA Data[Home] [Help]

PACKAGE BODY: APPS.FNDCP_SCH

Source


1 package body FNDCP_SCH as
2 /* $Header: AFCPSCHB.pls 115.6 99/08/08 20:20:07 porting ship $ */
3 
4 /* Exceptions */
5 bad_parameter EXCEPTION;
6 PRAGMA EXCEPTION_INIT(bad_parameter, -06501); -- program error
7 
8 /* Flag for datamerge or customer data */
9 who_mode VARCHAR2(20) := 'customer_data';  /* customer_data or seed_data */
10 
11 /* Message buffer */
12 internal_messages VARCHAR2(10000);
13 
14 --
15 -- Set the contents of the message buffer */
16 --
17 PROCEDURE message(msg VARCHAR2) IS
18 BEGIN
19    internal_messages := internal_messages || msg || fnd_global.newline;
20 END;
21 
22 --
23 -- Clear the message buffer.
24 --
25 PROCEDURE message_init IS
26 BEGIN
27    internal_messages := '';
28 END;
29 
30 
31 /* ------------------------------------------------------------ */
32 /*  who information functions                                   */
33 /* ------------------------------------------------------------ */
34 
35 FUNCTION customer_mode RETURN BOOLEAN IS
36 BEGIN
37    IF(who_mode = 'customer_data') THEN
38       RETURN TRUE;
39     ELSIF(who_mode = 'seed_data') THEN
40       RETURN FALSE;
41     ELSE
42       message('bad session mode:' || who_mode);
43       message('use set_session_mode to specify');
44       RAISE bad_parameter;
45    END IF;
46 END;
47 
48 
49 FUNCTION created_by_f RETURN NUMBER IS
50 BEGIN
51    IF(customer_mode) THEN
52       RETURN 0;
53     ELSE
54       RETURN 1;
55    END IF;
56 END;
57 
58 FUNCTION creation_date_f RETURN DATE IS
59 BEGIN
60    IF(customer_mode) THEN
61       RETURN Sysdate;
62     ELSE
63       RETURN To_date('01011980', 'MMDDYYYY');
64    END IF;
65 END;
66 
67 FUNCTION last_updated_by_f RETURN NUMBER IS
68 BEGIN
69    RETURN created_by_f;
70 END;
71 
72 FUNCTION last_update_date_f RETURN DATE IS
73 BEGIN
74    RETURN creation_date_f;
75 END;
76 
77 FUNCTION last_update_login_f RETURN NUMBER IS
78 BEGIN
79    return 0;
80 END;
81 
82 /* ------------------------------------------------------------ */
83 PROCEDURE check_notnull(val IN VARCHAR2) IS
84 BEGIN
85    IF(val IS NULL) THEN
86       message('A NULL value was specified for a NOT NULL parameter.');
87       RAISE bad_parameter;
88    END IF;
89 END;
90 
91 PROCEDURE check_notnull(val IN NUMBER) IS
92 BEGIN
93    IF(val IS NULL) THEN
94       message('A NULL value was specified for a NOT NULL parameter.');
95       RAISE bad_parameter;
96    END IF;
97 END;
98 
99 PROCEDURE check_notnull(val IN DATE) IS
100 BEGIN
101    IF(val IS NULL) THEN
102       message('A NULL value was specified for a NOT NULL parameter.');
103       RAISE bad_parameter;
104    END IF;
105 END;
106 /* ------------------------------------------------------------ */
107 
108 
109 --
110 -- get the application id, given the name (or short name)
111 --
112 FUNCTION application_id_f(application_name_in IN VARCHAR2)
113   RETURN fnd_application.application_id%TYPE
114   IS
115      application_id_ret fnd_application.application_id%TYPE;
116 BEGIN
117    IF(application_name_in IS NULL) THEN
118       message('A null application_name was specified.');
119       RAISE bad_parameter;
120    END IF;
121    /* Check the short name first. */
122    SELECT application_id
123      INTO application_id_ret
124      FROM fnd_application
125      WHERE application_short_name = application_name_in;
126    RETURN application_id_ret;
127 EXCEPTION
128    WHEN no_data_found THEN  /* Try the translated name. */
129      BEGIN
130        SELECT application_id
131          INTO application_id_ret
132          FROM fnd_application_tl
133         WHERE application_name = application_name_in
134           AND rownum = 1;
135        RETURN application_id_ret;
136      EXCEPTION
137        when NO_DATA_FOUND then
138          message('Invalid application name: ' || application_name_in);
139          RAISE bad_parameter;
140      END;
141 END;
142 
143 
144 --
145 -- Get a class ID given appl ID and name
146 --
147 FUNCTION class_id_f(	class_application_id number,
148                         class_name varchar2) return number is
149 
150 class_id number;
151 
152 BEGIN
153   SELECT Release_Class_id
154     INTO class_id
155     FROM fnd_conc_release_classes
156    WHERE application_id = class_application_id
157      AND class_name = release_class_name;
158 
159   RETURN class_id;
160 
161 EXCEPTION
162   WHEN no_data_found THEN
163     message('Could not find class: '||class_name);
164     RAISE bad_parameter;
165 END;
166 
167 
168 --
169 -- Get a disj ID given appl ID and name
170 --
171 FUNCTION disj_id_f(	disj_application_id number,
172                         disj_name varchar2) return number is
173 
174 disj_id number;
175 
176 BEGIN
177   SELECT Disjunction_id
178     INTO disj_id FROM fnd_conc_release_Disjs
179    WHERE application_id = disj_application_id
180      AND disj_name = Disjunction_name;
181 
182   RETURN disj_id;
183 
184 EXCEPTION
185   WHEN no_data_found THEN
186     message('Could not find disjunction: '||disj_name);
187     RAISE bad_parameter;
188 END;
189 
190 
191 --
192 -- Get a period ID given appl ID and name
193 --
194 FUNCTION period_id_f(	period_application_id number,
195                         period_name varchar2) return number is
196 
197 period_id number;
198 
199 BEGIN
200   SELECT Concurrent_Period_id
201     INTO period_id
202     FROM fnd_conc_release_periods
203    WHERE application_id = period_application_id
204      AND period_name = Concurrent_Period_name;
205 
206   RETURN period_id;
207 
208 EXCEPTION
209   WHEN no_data_found THEN
210     message('Could not find period: '||period_name);
211     RAISE bad_parameter;
212 END;
213 
214 
215 --
216 -- Get a state ID given appl ID and name
217 --
218 FUNCTION state_id_f(	state_application_id number,
219                         state_name varchar2) return number is
220 
221 state_id number;
222 
223 BEGIN
224   SELECT concurrent_state_id
225     INTO state_id
226     FROM fnd_conc_release_states
227    WHERE application_id = state_application_id
228      AND state_name = Concurrent_state_name;
229 
230   RETURN state_id;
231 
232 EXCEPTION
233   WHEN no_data_found THEN
234     message('Could not find state: '||state_name);
235     RAISE bad_parameter;
236 END;
237 
238 
239 --
240 -- Get a val_set ID given name
241 --
242 FUNCTION val_set_id_f( val_set_name varchar2) return number is
243 
244 val_set_id number;
245 
246 BEGIN
247   SELECT LOOKUP_TYPE_ID
248     INTO val_set_id
249     FROM FND_CONC_STATE_LOOKUP_TYPES
250    WHERE val_set_name = LOOKUP_TYPE_NAME;
251 
252   RETURN val_set_id;
253 
254 EXCEPTION
255   WHEN no_data_found THEN
256     message('Could not find value set: '||val_set_name);
257     RAISE bad_parameter;
258 END;
259 
260 --
261 -- Get a value ID given name and value set name or id
262 --
263 FUNCTION val_id_f( val_set_name varchar2 DEFAULT NULL,
264 		       value_name IN  varchar2,
265 		       value_set_id IN number DEFAULT NULL) return number is
266 
267 val_id number;
268 set_id number;
269 
270 BEGIN
271 
272   if value_set_id is NULL then
273    set_id := val_set_id_f(val_set_name);
274   else
275    set_id := value_set_id;
276   end if;
277 
278   SELECT LOOKUP_VALUE
279     INTO val_id
280     FROM FND_CONC_STATE_LOOKUPS_TL L
281     WHERE L.LOOKUP_TYPE_ID = set_id
282          and L.MEANING = value_name
283          and rownum = 1;
284 
285   RETURN val_id;
286 
287 EXCEPTION
288   WHEN no_data_found THEN
289     message('Could not find value: '||value_name);
290     RAISE bad_parameter;
291 END;
292 
293 
294 --
295 -- Procedure
296 --   SET_SESSION_MODE
297 --
298 -- Purpose
299 --   Sets the package mode for the current session.
300 --
301 -- Arguments:
302 --   session_mode - 'seed_data' if new data is for Datamerge.
303 --                  'customer_data' is the default.
304 --
305 PROCEDURE set_session_mode(session_mode IN VARCHAR2) IS
306 BEGIN
307    IF(lower(session_mode) NOT IN ('customer_data', 'seed_data')) THEN
308       message('bad mode:'|| session_mode);
309       message('valid values are: customer_data, seed_data');
310       RAISE bad_parameter;
311    END IF;
312    who_mode := lower(session_mode);
313 END;
314 
315 
316 -- Function
317 --   MESSAGE
318 --
319 -- Purpose
320 --   Return an error message.  Messages are set when
321 --   validation (program) errors occur.
322 --
323 FUNCTION message RETURN VARCHAR2 IS
324 BEGIN
325    RETURN internal_messages;
326 END;
327 
328 -- Procedure
329 --   LOCK_SCH;
330 --
331 -- Lock the Master state row to prevent deadlock and notify runtime that
332 -- it needs to reload cache.
333 --
334 
335 PROCEDURE LOCK_SCH IS
336   my_last_update_login number := last_update_login_f;
337   my_last_update_date date    := last_update_date_f;
338   my_last_updated_by number   := last_updated_by_f;
339   my_creation_date date       := creation_date_f;
340   my_created_by number        := created_by_f;
341 
342 Begin
343   update FND_CONC_RELEASE_STATES
344         SET STATUS = 1,
345         LAST_UPDATE_DATE = my_last_update_date,
346 	last_updated_by = my_last_updated_by,
347 	last_update_login = my_last_update_login,
348 	creation_date = my_creation_date,
349 	created_by = my_created_by
350         WHERE APPLICATION_ID = 0
351         AND CONCURRENT_STATE_NAME = 'AFPSCHED_STATUS';
352 
353 end LOCK_SCH;
354 
355 --
356 -- Commit changes
357 --
358 
359 PROCEDURE COMMIT_CHANGES is
360 
361 BEGIN
362    LOCK_SCH;
363    commit;
364 END;
365 
366 
367 --
368 -- Function
369 --   Class_Enable
370 --
371 -- Purpose
372 --   Sets enabled flag for Concurrent Release Class.
373 --
374 -- Arguments:
375 --   Application     - Application Short Name
376 --
377 --   Class_Name            - Class Name
378 --
379 PROCEDURE Class_Enable(Application   IN Varchar2,
380                        Class_Name      IN Varchar2
381                        ) is
382 appl_id number;
383 obj_id  number;
384 l_last_update_login number := last_update_login_f;
385 l_last_update_date date    := last_update_date_f;
386 l_last_updated_by number   := last_updated_by_f;
387 
388 cur_lang fnd_languages.language_code%TYPE;
389 
390   CURSOR lang_cur IS
391     SELECT language_code
392       FROM fnd_languages
393      WHERE installed_flag IN ('I', 'B');
394 
395 begin
396   message_init;
397 
398   check_notnull(Application);
399   check_notnull(Class_Name);
400 
401   if  NOT Class_Exists(Application,
402                          Class_Name) then
403       message('Submitted Class does not exist.');
404       raise bad_parameter;
405       return;
406   end if;
407 
408   appl_id := application_id_f(application);
409 
410   /* Do the update */
411   update fnd_conc_release_classes c
412             set c.enabled_flag  = 'Y',
413                 c.last_update_date  = l_last_update_date,
414 		c.last_updated_by   = l_last_updated_by,
415 		c.last_update_login = l_last_update_login
416           where c.application_id = appl_id
417 	    and c.release_class_name = Class_Name;
418 end;
419 
420 --
421 -- Function
422 --   Class_Disable
423 --
424 -- Purpose
425 --   Reset enabled flag for Concurrent Release Class.
426 --
427 -- Arguments:
428 --   Class_Name            - Class Name
429 --
430 PROCEDURE Class_Disable(Application   IN Varchar2,
431                        Class_Name      IN Varchar2
432                        ) is
433 appl_id number;
434 obj_id  number;
435 l_last_update_login number := last_update_login_f;
436 l_last_update_date date    := last_update_date_f;
437 l_last_updated_by number   := last_updated_by_f;
438 
439 cur_lang fnd_languages.language_code%TYPE;
440 
441   CURSOR lang_cur IS
442     SELECT language_code
443       FROM fnd_languages
444      WHERE installed_flag IN ('I', 'B');
445 
446 begin
447   message_init;
448 
449   check_notnull(Application);
450   check_notnull(Class_Name);
451 
452   if  NOT Class_Exists(Application,
453                          Class_Name) then
454       message('Submitted Class does not exist.');
455       raise bad_parameter;
456       return;
457   end if;
458 
459   appl_id := application_id_f(application);
460 
461   /* Do the update */
462  update fnd_conc_release_classes c
463                 set c.enabled_flag  = 'N',
464                 c.last_update_date  = l_last_update_date,
465 		c.last_updated_by   = l_last_updated_by,
466 		c.last_update_login = l_last_update_login
467          where c.application_id = appl_id
468 		and c.release_class_name = Class_Name;
469 end;
470 
471 -- Purpose
472 --   Reset enabled flag for Concurrent Release Class.
473 --
474 -- Arguments:
475 --   Application     - Application Short Name
476 --
477 --   Class_Name      - Class Name
478 --
479 --   Resub_Interval  - How long of a delay for resubmission
480 --
481 --   Resub_Int_Unit_Code - Units for Resub_Interval
482 --                      (MINUTES, HOURS, DAYS, MONTHS,SMART)
483 --
484 --   Resub_Int_Type_Code - Offset from start or end of request?
485 --                      (START, END)
486 --
487 PROCEDURE Set_Class_Resub(Application   IN Varchar2,
488                         Class_Name      IN Varchar2,
489                         Resub_Interval  IN Number,
493 appl_id number;
490                         Resub_Int_Unit_Code IN Varchar,
491                         Resub_Int_Type_Code IN Varchar
492                        ) is
494 obj_id  number;
495 l_last_update_login number := last_update_login_f;
496 l_last_update_date date    := last_update_date_f;
497 l_last_updated_by number   := last_updated_by_f;
498 
499 cur_lang fnd_languages.language_code%TYPE;
500 
501   CURSOR lang_cur IS
502     SELECT language_code
503       FROM fnd_languages
504      WHERE installed_flag IN ('I', 'B');
505 
506 begin
507   message_init;
508 
509   check_notnull(Application);
510   check_notnull(Class_Name);
511 
512   if  NOT Class_Exists(Application,
513                          Class_Name) then
514       message('Submitted Class does not exist.');
515       raise bad_parameter;
516       return;
517   end if;
518 
519   if (Resub_Interval is null) then
520       message('Resubmission interval must be not null');
521       raise bad_parameter;
522       return;
523   end if;
524 
525   if (Resub_Interval <= 0) then
526       message('Resubmission interval must be Greater than 0');
527       raise bad_parameter;
528       return;
529   end if;
530 
531   if ((Resub_Int_Unit_Code <> 'MINUTES') and
532       (Resub_Int_Unit_Code <> 'HOURS') and
533       (Resub_Int_Unit_Code <> 'SMART') and
534       (Resub_Int_Unit_Code <> 'DAYS') and
535       (Resub_Int_Unit_Code <> 'MONTHS')) then
536       message('Resubmission Unit code must be MINUTES, HOURS, DAYS, MONTHS, or SMART');
537       raise bad_parameter;
538       return;
539   end if;
540 
541   if ((Resub_Int_Type_code <> 'START') and (Resub_Int_Type_code <> 'END')) then
542       message('Resubmission Type code must be START, or END');
543       raise bad_parameter;
544       return;
545   end if;
546 
547   appl_id := application_id_f(application);
548 
549   /* Do the update */
550  update fnd_conc_release_classes c
551                 set RESUBMIT_INTERVAL= Resub_Interval,
552 		RESUBMIT_INTERVAL_UNIT_CODE = Resub_Int_Unit_Code,
553                 RESUBMIT_INTERVAL_TYPE_CODE = Resub_Int_Type_Code,
554                 c.last_update_date  = l_last_update_date,
555                 c.last_updated_by   = l_last_updated_by,
556                 c.last_update_login = l_last_update_login
557          where c.application_id = appl_id
558                 and c.release_class_name = Class_Name;
559 end;
560 
561 
562 --
563 -- Procedure
564 --   Class
565 --
566 -- Purpose
567 --   Register a Concurrent Release Class.
568 --
569 -- Arguments:
570 --   Application     - Application Short Name
571 --
572 --   Class_Name	     - Class Name
573 --
574 --   User_Class_Name - User Class Name
575 --
576 --   Description     - Description
577 --
578 PROCEDURE	Class(	Application 	IN Varchar2,
579 			Class_Name      IN Varchar2,
580 			User_Class_Name IN Varchar2,
581 			Description	IN Varchar2	Default NULL,
582 			Lang_CODE       IN Varchar2) IS
583 
584 appl_id number;
585 obj_id  number;
586 last_update_login number := last_update_login_f;
587 last_update_date date    := last_update_date_f;
588 last_updated_by number   := last_updated_by_f;
589 creation_date date       := creation_date_f;
590 created_by number        := created_by_f;
591 
592 cur_lang fnd_languages.language_code%TYPE;
593 
594   CURSOR lang_cur IS
595     SELECT language_code
596       FROM fnd_languages
597      WHERE installed_flag IN ('I', 'B');
598 
599 begin
600   message_init;
601 
602   check_notnull(Application);
603   check_notnull(Class_Name);
604   check_notnull(User_Class_Name);
605 
606   -- Set the language for the seed data
607   if (lang_code is not null) then
608     cur_lang := upper(lang_code);
609   else
610     cur_lang := USERENV('LANG');
611     if (cur_lang is null) then
612       message('Could not find current language.');
613       raise bad_parameter;
614     end if;
615   end if;
616 
617   /* Get new ID */
618     select fnd_conc_release_classes_s.nextval
619       into obj_id
620       from sys.dual;
621 
622   appl_id := application_id_f(application);
623 
624     /* Do the insert */
625   insert into fnd_conc_release_classes
626 		(application_id, release_class_id, release_class_name,
627 		 enabled_flag, class_type,
628                  last_update_date, last_updated_by, last_update_login,
629                  creation_date, created_by, updated_flag)
630 	values
631 		(appl_id, obj_id,  Class_Name,
632 		 'Y', 'X',
633 		 last_update_date, last_updated_by, last_update_login,
634 		 creation_date, created_by, 'Y');
635 
636   --   insert rows for each installed language into the tl table
637   for lang_rec in lang_cur loop
638     insert into fnd_conc_release_classes_tl
639                 (application_id, release_class_id, language,
640                  creation_date, created_by,
641                  last_update_date, last_updated_by, last_update_login,
642                  description, user_release_class_name, source_lang)
643            values
644                 (appl_id, obj_id, lang_rec.language_code,
645                  creation_date, created_by,
646                  last_update_date, last_updated_by, last_update_login,
647                  description, User_Class_Name, cur_lang);
648   end loop;
649 end Class;
650 
651 --
652 -- Function
653 --   Class_Exists
654 --
655 -- Purpose
656 --   Determine Existence of Concurrent Release Class.
657 --
661 --   Class_Name	     - Class Name
658 -- Arguments:
659 --   Application     - Application Short Name
660 --
662 --
663 FUNCTION Class_Exists (	Application 	IN Varchar2,
664 			Class_Name      IN Varchar2
665 			) Return Boolean is
666   appl_id number;
667   dummy varchar2(4);
668 begin
669   message_init;
670   appl_id := application_id_f(Application);
671 
672   select 'Y'
673   into dummy
674   from fnd_conc_release_classes
675   where application_id = appl_id
676   and release_class_name = Class_Name
677   and rownum = 1;
678 
679   return TRUE;
680 exception
681   when others then
682     return FALSE;
683 end Class_Exists;
684 
685 
686 -- Procedure
687 --   Class_Member
688 -- Purpose
689 --   Add Disjunction to a Concurrent Release Class.
690 --
691 -- Arguments:
692 --   Class Application - Application Short Name
693 --
694 --   Class_Name      - Class Name
695 --
696 --   Disjunction_Application - Application Short Name
697 --
698 --   Disjunction_Name      - Disjunction Name
699 --
700 PROCEDURE Class_Member(	Class_Application 	IN Varchar2,
701 			Class_Name      IN Varchar2,
702 			Disjunction_Application IN Varchar2,
703 			Disjunction_Name IN Varchar2
704 			) IS
705 
706 c_app_id number;
707 c_id number;
708 d_app_id number;
709 d_id number;
710 
711 last_update_login number := last_update_login_f;
712 last_update_date date    := last_update_date_f;
713 last_updated_by number   := last_updated_by_f;
714 creation_date date       := creation_date_f;
715 created_by number        := created_by_f;
716 
717 begin
718   message_init;
719 
720   check_notnull(Class_Application);
721   check_notnull(Class_Name);
722   check_notnull(Disjunction_Application);
723   check_notnull(Disjunction_Name);
724 
725   c_app_id := application_id_f(Class_Application);
726   c_id := Class_id_f(c_app_id, Class_Name);
727   d_app_id := application_id_f(Disjunction_Application);
728   d_id := Disj_id_f(d_app_id, Disjunction_Name);
729 
730 
731   insert into FND_CONC_REL_CONJ_MEMBERS
732 	(CLASS_APPLICATION_ID, RELEASE_CLASS_ID, DISJUNCTION_APPLICATION_ID,
733 	 DISJUNCTION_ID, created_by, last_update_login,
734 	 last_update_date, last_updated_by, creation_date)
735 	Values
736 	(c_app_id, c_id, d_app_id, d_id, created_by, last_update_login,
737 	 last_update_date, last_updated_by, creation_date);
738 
739   update FND_CONC_RELEASE_CLASSES
740   set updated_flag = 'Y'
741   where APPLICATION_ID = c_app_id
742     and RELEASE_CLASS_ID = c_id;
743 
744 end Class_Member;
745 
746 -- Procedure
747 --   Class_DisMember
748 --
749 -- Purpose
750 --   Remove Disjunction from a Concurrent Release Class.
751 --
752 -- Arguments:
753 --   Class Application - Application Short Name
754 --
755 --   Class_Name      - Class Name
756 --
757 --   Disjunction_Application - Application Short Name
758 --
759 --   Disjunction_Name      - Disjunction Name
760 --
761 PROCEDURE Class_DisMember(Class_Application 	IN Varchar2,
762 			Class_Name      IN Varchar2,
763 			Disjunction_Application IN Varchar2,
764 			Disjunction_Name IN Varchar2
765 			) IS
766 
767 c_app_id number;
768 c_id number;
769 d_app_id number;
770 d_id number;
771 
772 begin
773   message_init;
774 
775   /* Error checks params as well as the described membership */
776   if  NOT Class_Member_Exists(Class_Application,
777 			 Class_Name,
778 			 Disjunction_Application,
779 			 Disjunction_Name) then
780       message('Submitted Membership does not exist.');
781       raise bad_parameter;
782       return;
783   end if;
784 
785 
786   c_app_id := application_id_f(Class_Application);
787   c_id := Class_id_f(c_app_id,Class_Name);
788   d_app_id := application_id_f(Disjunction_Application);
789   d_id := Disj_id_f(d_app_id,Disjunction_Name);
790 
791 
792   DELETE FROM FND_CONC_REL_CONJ_MEMBERS
793   WHERE CLASS_APPLICATION_ID = c_app_id
794     AND RELEASE_CLASS_ID = c_id
795     AND DISJUNCTION_APPLICATION_ID = d_app_id
796     AND DISJUNCTION_ID = d_id;
797 
798 end Class_DisMember;
799 
800 
801 
802 -- Function
803 --   Class_Member_Exists
804 --
805 -- Purpose
806 --   Check Membership in a Concurrent Release Class.
807 --
808 -- Arguments:
809 --   Class Application - Application Short Name
810 --
811 --   Class_Name      - Class Name
812 --
813 --   Disjunction_Application - Application Short Name
814 --
815 --   Disjunction_Name      - Disjunction Name
816 --
817 Function Class_Member_Exists(Class_Application 	IN Varchar2,
818 			Class_Name      IN Varchar2,
819 			Disjunction_Application IN Varchar2,
820 			Disjunction_Name IN Varchar2
821 			)return Boolean IS
822 
823   c_id number;
824   c_appl_id number;
825   d_id number;
826   d_appl_id number;
827   dummy varchar2(4);
828 begin
829   message_init;
830 
831   check_notnull(Class_Application);
832   check_notnull(Class_Name);
833   check_notnull(Disjunction_Application);
834   check_notnull(Disjunction_Name);
835 
836   c_appl_id := application_id_f(Class_Application);
837   d_appl_id := application_id_f(Disjunction_Application);
838   c_id      := class_id_f(c_appl_id, Class_Name);
839   d_id      := disj_id_f(d_appl_id, Disjunction_Name);
840 
841   begin
842     select 'Y'
843     into dummy
844     from fnd_conc_rel_conj_members
848       and DISJUNCTION_ID = d_id
845     where CLASS_APPLICATION_ID = c_appl_id
846       and RELEASE_CLASS_ID = c_id
847       and DISJUNCTION_APPLICATION_ID = d_appl_id
849       and rownum = 1;
850 
851     return TRUE;
852   exception
853   when others then
854     return FALSE;
855   end;
856 end Class_Member_Exists;
857 
858 -- Procedure
859 --   Disjunction
860 --
861 -- Purpose
862 --   Register a Concurrent Release Disjunction.
863 --
864 -- Arguments:
865 --   Application     - Application Short Name
866 --
867 --   Disj_Name       - Disjunction Name
868 --
869 --   User_Disj_Name  - User Disjunction Name
870 --
871 --   Description     - Description
872 --
873 PROCEDURE       Disjunction(  	Application     IN Varchar2,
874                         	Disj_Name      	IN Varchar2,
875                         	User_Disj_Name	IN Varchar2,
876                         	Description     IN Varchar2 DEFAULT NULL,
877                         	Lang_CODE       IN Varchar2
878                         ) IS
879 
880 appl_id number;
881 obj_id  number;
882 last_update_login number := last_update_login_f;
883 last_update_date date    := last_update_date_f;
884 last_updated_by number   := last_updated_by_f;
885 creation_date date       := creation_date_f;
886 created_by number        := created_by_f;
887 
888 cur_lang fnd_languages.language_code%TYPE;
889 
890   CURSOR lang_cur IS
891     SELECT language_code
892       FROM fnd_languages
893      WHERE installed_flag IN ('I', 'B');
894 begin
895   message_init;
896 
897   check_notnull(Application);
898   check_notnull(Disj_Name);
899   check_notnull(User_Disj_Name);
900 
901   -- Set the language for the seed data
902   if (lang_code is not null) then
903     cur_lang := upper(lang_code);
904   else
905     cur_lang := USERENV('LANG');
906     if (cur_lang is null) then
907       message('Could not find current language.');
908       raise bad_parameter;
909     end if;
910   end if;
911 
912   /* Get new ID */
913     select fnd_conc_release_disjs_s.nextval
914       into obj_id
915       from sys.dual;
916 
917   appl_id := application_id_f(application);
918 
919     /* Do the insert */
920   insert into fnd_conc_release_disjs
921                 (application_id, disjunction_id, disjunction_name,
922                  enabled_flag,
923                  last_update_date, last_updated_by, last_update_login,
924                  creation_date, created_by, updated_flag)
925         values
926                 (appl_id, obj_id,  Disj_Name,
927                  'Y',
928                  last_update_date, last_updated_by, last_update_login,
929                  creation_date, created_by, 'Y');
930 
931 
932   --   insert rows for each installed language into the tl table
933   for lang_rec in lang_cur loop
934     insert into fnd_conc_release_disjs_tl
935                 (application_id, disjunction_id, language,
936                  creation_date, created_by,
937                  last_update_date, last_updated_by, last_update_login,
938                  description, user_disjunction_name, source_lang)
939            values
940                 (appl_id, obj_id, lang_rec.language_code,
941                  creation_date, created_by,
942                  last_update_date, last_updated_by, last_update_login,
943                  description, User_Disj_Name, cur_lang);
944   end loop;
945 end Disjunction;
946 
947 -- Function
948 --   Disjunction_Exists
949 --
950 -- Purpose
951 --   Determine Existence of a Concurrent Release Disjunction.
952 --
953 -- Arguments:
954 --   Application     - Application Short Name
955 --
956 --   Disj_Name       - Disjunction Name
957 --
958 FUNCTION Disjunction_Exists(  	Application     IN Varchar2,
959                         	Disj_Name      	IN Varchar2
960                         ) Return Boolean is
961   appl_id number;
962   dummy varchar2(4);
963 begin
964   message_init;
965   appl_id := application_id_f(Application);
966 
967   select 'Y'
968   into dummy
969   from fnd_conc_release_Disjs
970   where application_id = appl_id
971   and Disjunction_name = Disj_Name
972   and rownum = 1;
973 
974   return TRUE;
975 exception
976   when others then
977     return FALSE;
978 end Disjunction_Exists;
979 
980 
981 
982 
983 -- Procedure
984 --   Disj_Member_S
985 --
986 -- Purpose
987 --   Add State to a Concurrent Release Disjunction.
988 --
989 -- Arguments:
990 --   Disj Application - Application Short Name
991 --
992 --   Disj_Name      - Disj Name
993 --
994 --   State_Application - Application Short Name
995 --
996 --   State_Name      - State Name
997 --
998 --   State_Value      - Value Name
999 --
1000 --   Negation Flag    - 'Y' or 'N'
1001 --
1002 PROCEDURE Disj_Member_S(Disj_Application 	IN Varchar2,
1003 			Disj_Name      IN Varchar2,
1004 			State_Application IN Varchar2,
1005 			State_Name IN Varchar2,
1006 			State_Value IN Varchar2,
1007 			Negation_Flag IN Varchar2 DEFAULT 'N'
1008 			)IS
1009 
1010 s_app_id number;
1011 s_id number;
1012 d_app_id number;
1013 d_id number;
1014 t_id number;
1015 v_id number;
1016 
1017 last_update_login number := last_update_login_f;
1018 last_update_date date    := last_update_date_f;
1019 last_updated_by number   := last_updated_by_f;
1020 creation_date date       := creation_date_f;
1021 created_by number        := created_by_f;
1022 
1026   check_notnull(State_Application);
1023 begin
1024   message_init;
1025 
1027   check_notnull(State_Name);
1028   check_notnull(State_Value);
1029   check_notnull(Disj_Application);
1030   check_notnull(Disj_Name);
1031 
1032   s_app_id := application_id_f(State_Application);
1033   s_id := State_id_f(s_app_id,State_Name);
1034   d_app_id := application_id_f(Disj_Application);
1035   d_id := Disj_id_f(d_app_id,Disj_Name);
1036 
1037   SELECT lookup_type_id
1038   into t_id
1039   from fnd_CONC_RELEASE_STATES
1040   where CONCURRENT_STATE_ID = s_id
1041   and application_id = s_app_id;
1042 
1043   v_id := Val_id_f(null,State_Value,t_id);
1044 
1045 
1046   insert into FND_CONC_REL_DISJ_MEMBERS
1047         (DISJUNCTION_APPLICATION_ID, DISJUNCTION_ID, STATE_APPLICATION_ID,
1048          STATE_ID, STATUS_VALUE, NEGATION_FLAG,
1049          PERIOD_OR_STATE_FLAG, created_by,
1050 	 last_update_login, last_update_date, last_updated_by, creation_date)
1051         Values
1052         (d_app_id, d_id, s_app_id, s_id, v_id, Negation_Flag,
1053 	 'S', created_by,
1054 	 last_update_login, last_update_date, last_updated_by, creation_date);
1055 
1056   update FND_CONC_RELEASE_DISJS
1057   set updated_flag = 'Y'
1058   where APPLICATION_ID = d_app_id
1059     and DISJUNCTION_ID = d_id;
1060 
1061 end Disj_Member_S;
1062 
1063 
1064 -- Procedure
1065 --   Disj_Member_P
1066 --
1067 -- Purpose
1068 --   Add Period to a Concurrent Release Disjunction.
1069 --
1070 -- Arguments:
1071 --   Disj Application - Application Short Name
1072 --
1073 --   Disj_Name      - Disj Name
1074 --
1075 --   Period_Application - Application Short Name
1076 --
1077 --   Period_Name      - Period Name
1078 --
1079 --   Negation Flag    - 'Y' or 'N'
1080 --
1081 PROCEDURE Disj_Member_P(Disj_Application 	IN Varchar2,
1082 			Disj_Name      IN Varchar2,
1083 			Period_Application IN Varchar2,
1084 			Period_Name IN Varchar2,
1085 			Negation_Flag IN Varchar2 DEFAULT 'N'
1086 			) IS
1087 
1088 
1089 p_app_id number;
1090 p_id number;
1091 d_app_id number;
1092 d_id number;
1093 
1094 last_update_login number := last_update_login_f;
1095 last_update_date date    := last_update_date_f;
1096 last_updated_by number   := last_updated_by_f;
1097 creation_date date       := creation_date_f;
1098 created_by number        := created_by_f;
1099 
1100 begin
1101   message_init;
1102 
1103   check_notnull(Period_Application);
1104   check_notnull(Period_Name);
1105   check_notnull(Disj_Application);
1106   check_notnull(Disj_Name);
1107 
1108   p_app_id := application_id_f(Period_Application);
1109   p_id := Period_id_f(p_app_id,Period_Name);
1110   d_app_id := application_id_f(Disj_Application);
1111   d_id := Disj_id_f(d_app_id,Disj_Name);
1112 
1113 
1114   insert into FND_CONC_REL_DISJ_MEMBERS
1115         (DISJUNCTION_APPLICATION_ID, DISJUNCTION_ID, PERIOD_APPLICATION_ID,
1116          PERIOD_ID,PERIOD_OR_STATE_FLAG,NEGATION_FLAG,created_by,
1117 	last_update_login, last_update_date, last_updated_by, creation_date)
1118         Values
1119         (d_app_id, d_id, p_app_id, p_id, 'P', Negation_Flag, created_by,
1120 	 last_update_login, last_update_date, last_updated_by, creation_date);
1121 
1122   update FND_CONC_RELEASE_DISJS
1123   set updated_flag = 'Y'
1124   where APPLICATION_ID = d_app_id
1125     and DISJUNCTION_ID = d_id;
1126 
1127 end Disj_Member_P;
1128 
1129 -- Procedure
1130 --   Disj_DisMember
1131 --
1132 -- Purpose
1133 --   Remove State or Period from a Concurrent Release Disjunction.
1134 --
1135 -- Arguments:
1136 --   Disj_Application - Application Short Name
1137 --
1138 --   Disj_Name          - Disjunction Name
1139 --
1140 --   Member_Application - Application Short Name
1141 --
1142 --   Member_Name      - Member Name
1143 --
1144 --   Member_Type      - 'S' or 'P'
1145 --
1146 PROCEDURE Disj_DisMember(Disj_Application 	IN Varchar2,
1147 			Disj_Name      IN Varchar2,
1148 			Member_Application IN Varchar2,
1149 			Member_Name IN Varchar2,
1150 			Member_Type IN Varchar2
1151 			) is
1152 m_app_id number;
1153 m_id number;
1154 d_app_id number;
1155 d_id number;
1156 
1157 begin
1158   message_init;
1159 
1160   /* Error checks params as well as the described membership */
1161   if NOT Disj_Member_Exists(Disj_Application,
1162                          Disj_Name,
1163 			 Member_Application,
1164 			 Member_Name,
1165                          Member_Type) then
1166       message('Submitted Membership does not exist.');
1167       raise bad_parameter;
1168       return;
1169   end if;
1170 
1171   m_app_id := application_id_f(Member_Application);
1172 
1173   if (Member_Type = 'S') then
1174      m_id := State_id_f(m_app_id,Member_Name);
1175   else
1176      m_id := Period_id_f(m_app_id,Member_Name);
1177   end if;
1178 
1179   d_app_id := application_id_f(Disj_Application);
1180   d_id := Disj_id_f(d_app_id,Disj_Name);
1181 
1182 
1183   DELETE FROM FND_CONC_REL_DISJ_MEMBERS
1184   WHERE DISJUNCTION_APPLICATION_ID = d_app_id
1185     AND DISJUNCTION_ID = d_id
1186     AND PERIOD_OR_STATE_FLAG = Member_Type
1187     AND DECODE(Member_Type, 'S', STATE_APPLICATION_ID,
1188 				 PERIOD_APPLICATION_ID) = m_app_id
1189     AND DECODE(Member_Type, 'S', STATE_ID,
1190                                  PERIOD_ID) = m_id;
1191 
1192 end Disj_DisMember;
1193 
1194 
1195 
1196 -- Function
1197 --   Disj_Member_Exists
1198 --
1199 -- Purpose
1200 --   Check Membership in a Concurrent Release Disjunction.
1201 --
1205 --   Class_Name      - Class Name
1202 -- Arguments:
1203 --   Class Application - Application Short Name
1204 --
1206 --
1207 --   Member_Application - Application Short Name
1208 --
1209 --   Member_Name      - Member Name
1210 --
1211 --   Member_Type      - 'S' or 'P'
1212 --
1213 FUNCTION Disj_Member_Exists(Disj_Application       IN Varchar2,
1214                         Disj_Name      IN Varchar2,
1215                         Member_Application IN Varchar2,
1216                         Member_Name IN Varchar2,
1217                         Member_Type IN Varchar2
1218 			)return Boolean IS
1219 
1220   m_id number;
1221   m_app_id number;
1222   d_id number;
1223   d_app_id number;
1224   dummy varchar2(4);
1225 begin
1226   message_init;
1227 
1228   check_notnull(Member_Application);
1229   check_notnull(Member_Name);
1230   check_notnull(Member_Type);
1231   check_notnull(Disj_Application);
1232   check_notnull(Disj_Name);
1233 
1234   m_app_id := application_id_f(Member_Application);
1235 
1236   if (Member_Type = 'S') then
1237      m_id := State_id_f(m_app_id,Member_Name);
1238   else
1239      m_id := Period_id_f(m_app_id,Member_Name);
1240   end if;
1241 
1242   d_app_id := application_id_f(Disj_Application);
1243   d_id := Disj_id_f(d_app_id,Disj_Name);
1244 
1245   begin
1246     select 'Y'
1247     into dummy
1248     from fnd_conc_rel_disj_members
1249     where DISJUNCTION_APPLICATION_ID = d_app_id
1250       and DISJUNCTION_ID = d_id
1251       and PERIOD_OR_STATE_FLAG = Member_Type
1252       AND DECODE(Member_Type, 'S', STATE_APPLICATION_ID,
1253                                  PERIOD_APPLICATION_ID) = m_app_id
1254       AND DECODE(Member_Type, 'S', STATE_ID,
1255                                  PERIOD_ID) = m_id
1256       and rownum = 1;
1257 
1258     return TRUE;
1259   exception
1260   when others then
1261     return FALSE;
1262   end;
1263 end Disj_Member_Exists;
1264 
1265 -- Function
1266 --   Period_Exists
1267 --
1268 -- Purpose
1269 --   Determine Existence of a Concurrent Release Period.
1270 --
1271 -- Arguments:
1272 --   Application     - Application Short Name
1273 --
1274 --   Period_Name     - Period Name
1275 --
1276 FUNCTION Period_Exists     (    Application     IN Varchar2,
1277                                 Period_Name     IN Varchar2
1278                         ) return Boolean is
1279   appl_id number;
1280   dummy varchar2(4);
1281 begin
1282   message_init;
1283   appl_id := application_id_f(Application);
1284 
1285   select 'Y'
1286   into dummy
1287   from fnd_conc_release_periods
1288   where application_id = appl_id
1289   and Concurrent_period_name = Period_Name
1290   and rownum = 1;
1291 
1292   return TRUE;
1293 exception
1294   when others then
1295     return FALSE;
1296 end Period_Exists;
1297 
1298 
1299 -- Procedure
1300 --   Period
1301 --
1302 -- Purpose
1303 --   Register a Concurrent Release Period.
1304 --
1305 -- Arguments:
1306 --   Application     - Application Short Name
1307 --
1308 --   Period_Name     - Period Name
1309 --
1310 --   User_Period_Name - User Period Name
1311 --
1312 --   Description     - Description
1313 --
1314 --   Period_Type     - Day, Month, Year, or Reverse Month
1315 --
1316 --   Period_Length   - Length of period in terms of Period_Type
1317 --
1318 --   Period_Start    - Start point of a period
1319 --
1320 --   Period_Stop     - Stop point of a period
1321 
1322 PROCEDURE       Period	   (    Application     IN Varchar2,
1323                                 Period_Name     IN Varchar2,
1324                                 User_Period_Name IN Varchar2,
1325                                 Description     IN Varchar2,
1326 				Period_Type	IN Varchar2,
1327 				Period_Length   IN Number,
1328 				Period_Start    IN Date,
1329 				Period_Stop     IN Date,
1330                         	Lang_CODE       IN Varchar2
1331                         ) IS
1332 
1333 appl_id number;
1334 obj_id  number;
1335 last_update_login number := last_update_login_f;
1336 last_update_date date    := last_update_date_f;
1337 last_updated_by number   := last_updated_by_f;
1338 creation_date date       := creation_date_f;
1339 created_by number        := created_by_f;
1340 
1341 cur_lang fnd_languages.language_code%TYPE;
1342 
1343   CURSOR lang_cur IS
1344     SELECT language_code
1345       FROM fnd_languages
1346      WHERE installed_flag IN ('I', 'B');
1347 
1348 begin
1349   message_init;
1350 
1351   check_notnull(Application);
1352   check_notnull(Period_Name);
1353   check_notnull(User_Period_Name);
1354   check_notnull(Period_Type);
1355   check_notnull(Period_Length);
1356   check_notnull(Period_Start);
1357   check_notnull(Period_Stop);
1358 
1359   -- Set the language for the seed data
1360   if (lang_code is not null) then
1361     cur_lang := upper(lang_code);
1362   else
1363     cur_lang := USERENV('LANG');
1364     if (cur_lang is null) then
1365       message('Could not find current language.');
1366       raise bad_parameter;
1367     end if;
1368   end if;
1369 
1370   /* Get new ID */
1371     select fnd_conc_release_periods_s.nextval
1372       into obj_id
1373       from sys.dual;
1374 
1375   appl_id := application_id_f(application);
1376 
1377     /* Do the insert */
1378   insert into fnd_conc_release_periods
1379                 (application_id, concurrent_period_id,
1380                  concurrent_period_name, enabled_flag, Periodicity_code,
1384         values
1381                  Period_Length, Period_Start_time, Period_Stop_time,
1382                  last_update_date, last_updated_by, last_update_login,
1383                  creation_date, created_by, updated_flag)
1385                 (appl_id, obj_id,  Period_Name, 'Y', Period_Type,
1386 		 Period_Length, Period_Start, Period_Stop,
1387                  last_update_date, last_updated_by, last_update_login,
1388                  creation_date, created_by, 'Y');
1389 
1390 
1391   --   insert rows for each installed language into the tl table
1392   for lang_rec in lang_cur loop
1393     insert into fnd_conc_release_periods_tl
1394                 (application_id, concurrent_period_id, language,
1395                  creation_date, created_by,
1396                  last_update_date, last_updated_by, last_update_login,
1397                  description, user_concurrent_period_name, source_lang)
1398            values
1399                 (appl_id, obj_id, lang_rec.language_code,
1400                  creation_date, created_by,
1401                  last_update_date, last_updated_by, last_update_login,
1402                  description, User_period_Name, cur_lang);
1403   end loop;
1404 end Period;
1405 
1406 
1407 -- Procedure
1408 --   State_Value_Set
1409 --
1410 -- Purpose
1411 --   Register a Concurrent Release State Value Set
1412 --
1413 -- Arguments:
1414 --   Set_Name        - SetName
1415 --
1416 --   User_Set_Name   - User Set Name
1417 --
1418 --   Description     - Description
1419 --
1420 PROCEDURE       State_Value_Set(Set_Name        IN Varchar2,
1421                                 User_Set_Name   IN Varchar2,
1422                                 Description     IN Varchar2  Default null,
1423                         	Lang_CODE       IN Varchar2
1424                         )  IS
1425 
1426 obj_id  number;
1427 last_update_login number := last_update_login_f;
1428 last_update_date date    := last_update_date_f;
1429 last_updated_by number   := last_updated_by_f;
1430 creation_date date       := creation_date_f;
1431 created_by number        := created_by_f;
1432 
1433 cur_lang fnd_languages.language_code%TYPE;
1434 
1435   CURSOR lang_cur IS
1436     SELECT language_code
1437       FROM fnd_languages
1438      WHERE installed_flag IN ('I', 'B');
1439 
1440 begin
1441   message_init;
1442 
1443   check_notnull(set_Name);
1444   check_notnull(User_set_Name);
1445 
1446   -- Set the language for the seed data
1447   if (lang_code is not null) then
1448     cur_lang := upper(lang_code);
1449   else
1450     cur_lang := USERENV('LANG');
1451     if (cur_lang is null) then
1452       message('Could not find current language.');
1453       raise bad_parameter;
1454     end if;
1455   end if;
1456 
1457   /* Get new ID */
1458     select FND_CONC_STATE_LOOKUP_TYPES_S.nextval
1459       into obj_id
1460       from sys.dual;
1461 
1462     /* Do the insert */
1463   insert into FND_CONC_STATE_LOOKUP_TYPES
1464                 (LOOKUP_TYPE_ID, LOOKUP_TYPE_NAME, enabled_flag,
1465                  last_update_date, last_updated_by, last_update_login,
1466                  creation_date, created_by)
1467         values
1468                 (obj_id,  Set_Name, 'Y',
1469                  last_update_date, last_updated_by, last_update_login,
1470                  creation_date, created_by);
1471 
1472   --   insert rows for each installed language into the tl table
1473   for lang_rec in lang_cur loop
1474     insert into FND_CONC_STATE_LOOKUP_TYPES_TL
1475                 (LOOKUP_TYPE_ID, language,
1476                  creation_date, created_by,
1477                  last_update_date, last_updated_by, last_update_login,
1478                  description, USER_LOOKUP_TYPE_NAME, source_lang)
1479            values
1480                 (obj_id, lang_rec.language_code,
1481                  creation_date, created_by,
1482                  last_update_date, last_updated_by, last_update_login,
1483                  description, User_set_Name, cur_lang);
1484   end loop;
1485 end State_Value_Set;
1486 
1487 -- Procedure
1488 --   State_Value
1489 --
1490 -- Purpose
1491 --   Register a Concurrent Release State Value
1492 --
1493 -- Arguments:
1494 --   Value_Name      - Value Name
1495 --
1496 --   Value_Set_Name  - Set Name
1497 --
1498 PROCEDURE       State_Value(	Value_Name     IN Varchar2,
1499 				Value_Set_Name IN Varchar2,
1500 				DESCRIPTION IN VARCHAR2 DEFAULT NULL,
1501                         	Lang_CODE       IN Varchar2
1502                         ) IS
1503 
1504 t_id number;
1505 obj_id  number;
1506 last_update_login number := last_update_login_f;
1507 last_update_date date    := last_update_date_f;
1508 last_updated_by number   := last_updated_by_f;
1509 creation_date date       := creation_date_f;
1510 created_by number        := created_by_f;
1511 
1512 cur_lang fnd_languages.language_code%TYPE;
1513 
1514   CURSOR lang_cur IS
1515     SELECT language_code
1516       FROM fnd_languages
1517      WHERE installed_flag IN ('I', 'B');
1518 
1519 begin
1520   message_init;
1521 
1522   check_notnull(Value_Name);
1523   check_notnull(Value_Set_Name);
1524 
1525   t_id := Val_set_id_f(Value_Set_Name);
1526 
1527   -- Set the language for the seed data
1528   if (lang_code is not null) then
1529     cur_lang := upper(lang_code);
1530   else
1531     cur_lang := USERENV('LANG');
1532     if (cur_lang is null) then
1533       message('Could not find current language.');
1534       raise bad_parameter;
1535     end if;
1536   end if;
1537 
1538   /* Get new ID */
1539     select FND_CONC_STATE_LOOKUPS_S.nextval
1540       into obj_id
1544   insert into FND_CONC_STATE_LOOKUPS
1541       from sys.dual;
1542 
1543     /* Do the insert */
1545                 (LOOKUP_TYPE_ID, LOOKUP_VALUE, enabled_flag,
1546                  last_update_date, last_updated_by, last_update_login,
1547                  creation_date, created_by)
1548         values
1549                 (t_id,  obj_id, 'Y',
1550                  last_update_date, last_updated_by, last_update_login,
1551                  creation_date, created_by);
1552 
1553   --   insert rows for each installed language into the tl table
1554   for lang_rec in lang_cur loop
1555     insert into FND_CONC_STATE_LOOKUPS_TL
1556                 (LOOKUP_TYPE_ID, LOOKUP_VALUE, language, MEANING,
1557                  creation_date, created_by,
1558                  last_update_date, last_updated_by, last_update_login,
1559                  description, source_lang)
1560            values
1561                 (t_id, obj_id, lang_rec.language_code, Value_Name,
1562                  creation_date, created_by,
1563                  last_update_date, last_updated_by, last_update_login,
1564                  description, cur_lang);
1565   end loop;
1566 end State_Value;
1567 
1568 -- Function
1569 --   State_Value_Set_Exists
1570 --
1571 -- Purpose
1572 --   Determine Existence of a Concurrent Release State Value Set
1573 --
1574 -- Arguments:
1575 --   Set_Name        - SetName
1576 --
1577 FUNCTION State_Value_Set_Exists(Set_Name        IN Varchar2
1578                         	) return Boolean is
1579   dummy varchar2(4);
1580 begin
1581   message_init;
1582 
1583   select 'Y'
1584   into dummy
1585   from fnd_conc_state_lookup_types
1586   where LOOKUP_TYPE_NAME= Set_Name
1587   and rownum = 1;
1588 
1589   return TRUE;
1590 exception
1591   when others then
1592     return FALSE;
1593 end State_Value_Set_Exists;
1594 
1595 
1596 -- Function
1597 --   State_Value_Exists
1598 --
1599 -- Purpose
1600 --   Determine Existence of a Concurrent Release State Value
1601 --
1602 -- Arguments:
1603 --   Value_Name      - Value Name
1604 --
1605 --   Value_Set_Name  - Set Name
1606 --
1607 FUNCTION State_Value_Exists(	Value_Name     IN Varchar2,
1608 				Value_Set_Name IN Varchar2
1609                         ) return Boolean  is
1610   dummy varchar2(4);
1611   t_id number;
1612 begin
1613   message_init;
1614 
1615   t_id := Val_set_id_f(Value_Set_Name);
1616 
1617   select 'Y'
1618   into dummy
1619   from fnd_conc_state_lookups_tl
1620   where meaning=Value_Name
1621   and LOOKUP_TYPE_ID = t_id
1622   and rownum = 1;
1623 
1624   return TRUE;
1625 exception
1626   when others then
1627     return FALSE;
1628 end State_Value_Exists;
1629 
1630 
1631 
1632 -- Procedure
1633 --   State
1634 --
1635 -- Purpose
1636 --   Register a Concurrent Release State
1637 --
1638 -- Arguments:
1639 --   Application     - Application Short Name
1640 --
1641 --   State_Name      - Period Name
1642 --
1643 --   User_State_Name - User Period Name
1644 --
1645 --   Description     - Description
1646 --
1647 --   Value_Name      - Value Name of initial value
1648 --
1649 --   Value_Set_Name  - Set Name used by this state
1650 --
1651 PROCEDURE       State(   	Application     IN Varchar2,
1652                                 State_Name      IN Varchar2,
1653                                 User_State_Name IN Varchar2,
1654                                 Description     IN Varchar2 DEFAULT NULL,
1655 				Value_Set_Name  IN Varchar2,
1656 				Value_Name      IN Varchar2,
1657                         	Lang_CODE       IN Varchar2
1658                         ) is
1659 appl_id number;
1660 obj_id  number;
1661 t_id number;
1662 v_id number;
1663 last_update_login number := last_update_login_f;
1664 last_update_date date    := last_update_date_f;
1665 last_updated_by number   := last_updated_by_f;
1666 creation_date date       := creation_date_f;
1667 created_by number        := created_by_f;
1668 
1669 cur_lang fnd_languages.language_code%TYPE;
1670 
1671   CURSOR lang_cur IS
1672     SELECT language_code
1673       FROM fnd_languages
1674      WHERE installed_flag IN ('I', 'B');
1675 
1676 begin
1677   message_init;
1678 
1679   check_notnull(Application);
1680   check_notnull(State_Name);
1681   check_notnull(Value_Set_Name);
1682   check_notnull(Value_Name);
1683   check_notnull(User_State_Name);
1684 
1685   t_id := val_set_id_f(Value_Set_Name);
1686   v_id := val_id_f(Value_Set_Name, Value_Name, null);
1687 
1688   -- Set the language for the seed data
1689   if (lang_code is not null) then
1690     cur_lang := upper(lang_code);
1691   else
1692     cur_lang := USERENV('LANG');
1693     if (cur_lang is null) then
1694       message('Could not find current language.');
1695       raise bad_parameter;
1696     end if;
1697   end if;
1698 
1699   /* Get new ID */
1700     select fnd_conc_release_states_s.nextval
1701       into obj_id
1702       from sys.dual;
1703 
1704   appl_id := application_id_f(application);
1705 
1706     /* Do the insert */
1707   insert into fnd_conc_release_states
1708                 (application_id, concurrent_state_id,
1709                  concurrent_state_name, enabled_flag, LOOKUP_TYPE_ID, STATUS,
1710                  last_update_date, last_updated_by, last_update_login,
1711                  creation_date, created_by, updated_flag)
1712         values
1713                 (appl_id, obj_id,  State_Name, 'Y', t_id, v_id,
1714                  last_update_date, last_updated_by, last_update_login,
1718   --   insert rows for each installed language into the tl table
1715                  creation_date, created_by, 'Y');
1716 
1717 
1719   for lang_rec in lang_cur loop
1720     insert into fnd_conc_release_states_tl
1721                 (application_id, concurrent_state_id, language,
1722                  creation_date, created_by,
1723                  last_update_date, last_updated_by, last_update_login,
1724                  description, USER_CONCURRENT_STATE_NAME, source_lang)
1725            values
1726                 (appl_id, obj_id, lang_rec.language_code,
1727                  creation_date, created_by,
1728                  last_update_date, last_updated_by, last_update_login,
1729                  description, User_state_Name, cur_lang);
1730   end loop;
1731 end State;
1732 
1733 -- Function
1734 --   State_Exists
1735 --
1736 -- Purpose
1737 --   Determine Existence of a Concurrent Release State
1738 --
1739 -- Arguments:
1740 --   Application     - Application Short Name
1741 --
1742 --   State_Name      - Period Name
1743 --
1744 FUNCTION State_Exists(   	Application     IN Varchar2,
1745                                 State_Name      IN Varchar2
1746                         ) return Boolean is
1747   appl_id number;
1748   dummy varchar2(4);
1749 begin
1750   message_init;
1751   appl_id := application_id_f(Application);
1752 
1753   select 'Y'
1754   into dummy
1755   from fnd_conc_release_States
1756   where application_id = appl_id
1757   and Concurrent_state_name = state_Name
1758   and rownum = 1;
1759 
1760   return TRUE;
1761 exception
1762   when others then
1763     return FALSE;
1764 end state_Exists;
1765 
1766 
1767 end FNDCP_SCH;