DBA Data[Home] [Help]

PACKAGE BODY: APPS.FND_PRODUCT_INITIALIZATION_PKG

Source


1 package body Fnd_Product_Initialization_Pkg as
2 /* $Header: AFPINITB.pls 120.6 2007/01/17 18:01:23 rsheh ship $ */
3 
4 --
5 -- Register (PUBLIC)
6 --   Called by product team to register their re-initialization function
7 -- Input
8 --   x_apps_name: application short name
9 --   x_init_function: re-initialization function
10 procedure Register(x_apps_name          in varchar2,
11                    x_init_function      in varchar2 default null,
12                    x_owner              in varchar2 default 'SEED') is
13 begin
14  Register(x_apps_name           => x_apps_name,
15           x_init_function       => x_init_function,
16           x_owner               => x_owner,
17           x_last_update_date    => null,
18           x_custom_mode         => null);
19 
20 end Register;
21 
22 --
23 -- Remove (PUBLIC)
24 --   Called by product team to delete their re-initialization function
25 -- Input
26 --   x_apps_name: application short name
27 --   x_init_function: re-initialization function
28 procedure Remove(x_apps_name     in varchar2) is
29 begin
30   begin
31     delete from FND_PRODUCT_INITIALIZATION
32     where APPLICATION_SHORT_NAME = upper(x_apps_name);
33 
34   exception
35     when others then
36       fnd_message.set_name('FND', 'SQL_PLSQL_ERROR');
37       fnd_message.set_token('ROUTINE', 'Remove');
38       fnd_message.set_token('ERRNO', to_char(sqlcode));
39       fnd_message.set_token('REASON', sqlerrm);
40       app_exception.raise_exception(NULL, NULL,
41         'Exception in FND_PRODUCT_INITIALIZATION_PKG.REMOVE');
42       raise;
43   end;
44 
45 end Remove;
46 
47 -- AddInitCondition (PUBLIC)
48 --   Called by anybody who wants to register their product's re-initialization
49 --   conditions.
50 --
51 -- Input
52 --   x_apps_name:  the application short name
53 --   x_condition:  one of the following conditions:
54 --                 'APPL', 'RESP', 'USER', 'NLS', 'ORG'
55 --
56 procedure AddInitCondition(x_apps_name in varchar2,
57                            x_condition in varchar2,
58                            x_owner     in varchar2) is
59 begin
60  AddInitCondition(x_apps_name              => x_apps_name,
61                   x_condition              => x_condition,
62                   x_owner                  => x_owner,
63                   x_last_update_date       => null,
64                   x_custom_mode            => null);
65 end AddInitCondition;
66 
67 -- RemoveInitCondition (PUBLIC)
68 --   Called by anybody who wants to remove their product's re-initialization
69 --   conditions.
70 --
71 -- Input
72 --   x_apps_name:  the application short name
73 --   x_condition:  one of the following conditions:
74 --                 'APPL', 'RESP', 'USER', 'NLS', 'ORG'
75 --
76 procedure RemoveInitCondition(x_apps_name in varchar2,
77                               x_condition in varchar2) is
78 begin
79   begin
80     delete from FND_PRODUCT_INIT_CONDITION
81     where APPLICATION_SHORT_NAME = upper(x_apps_name)
82     and   RE_INIT_CONDITION = upper(x_condition);
83 
84   exception
85     when others then
86       fnd_message.set_name('FND', 'SQL_PLSQL_ERROR');
87       fnd_message.set_token('ROUTINE', 'RemoveInitCondition');
88       fnd_message.set_token('ERRNO', to_char(sqlcode));
89       fnd_message.set_token('REASON', sqlerrm);
90       app_exception.raise_exception(NULL, NULL,
91         'Exception in FND_PRODUCT_INITIALIZATION_PKG.RemoveInitCondition');
92       raise;
93   end;
94 
95 end RemoveInitCondition;
96 
97 --
98 -- AddDependency (PUBLIC)
99 --   Called by anybody who wants to register their product dependency
100 --
101 -- Input
102 --   x_apps_name:  the application short name
103 --   x_dependency: the dependency application short name
104 --
105 procedure AddDependency(x_apps_name   in varchar2,
106                         x_dependency  in varchar2,
107                         x_owner       in varchar2) is
108 begin
109  AddDependency(x_apps_name              => x_apps_name,
110                x_dependency             => x_dependency,
111                x_owner                  => x_owner,
112                x_last_update_date       => null,
113                x_custom_mode            => null);
114 
115 end AddDependency;
116 
117 --
118 -- RemoveDependency (PUBLIC)
119 --   Called by anybody who wants to remove their product dependency
120 --
121 -- Input
122 --   x_apps_name:  the application short name
123 --   x_dependency: the dependency application short name
124 --
125 procedure RemoveDependency(x_apps_name   in varchar2,
126                            x_dependency  in varchar2) is
127 
128 begin
129   begin
130     delete from FND_PRODUCT_INIT_DEPENDENCY
131     where APPLICATION_SHORT_NAME = upper(x_apps_name)
132     and   PRODUCT_DEPENDENCY = upper(x_dependency);
133 
134   exception
135     when others then
136       fnd_message.set_name('FND', 'SQL_PLSQL_ERROR');
137       fnd_message.set_token('ROUTINE', 'RemoveDependency');
138       fnd_message.set_token('ERRNO', to_char(sqlcode));
139       fnd_message.set_token('REASON', sqlerrm);
140       app_exception.raise_exception(NULL, NULL,
141         'Exception in FND_PRODUCT_INITIALIZATION_PKG.RemoveDependency');
142       raise;
143   end;
144 
145 end RemoveDependency;
146 
147 --
148 -- ExecInitFunction (PUBLIC)
149 --   Called by FND_GLOBAL.INITIALIZE() which decides the current application
150 --   short name and the conditions occurred.
151 --
152 -- Input
153 --   x_apps_name:  the application short name
154 --   x_conditions: it is assumed in the format of ('APPL', 'USER')
155 --
156 -- Note:
157 --   WE HAVE TO HAVE GOOD ERROR HANDLING HERE BECAUSE IT IS CALLED BY
158 --   BY GLOBAL.INITIALIZE()
159 procedure ExecInitFunction(x_apps_name in varchar2,
160                            x_conditions in varchar2) is
161   conditions varchar2(80);
162   sqlbuf varchar2(2000);
163   init_function varchar2(240);
164   deparr TextArrayTyp;
165   i number;
166   tmpbuf varchar2(240);
167 
168   -- Construct a dependency list for x_apps_name.
169   -- Duplidate dependency is taken care by using distinct command.
170   -- And the invoking ordering is taken care by the LEVEL order by.
171   cursor dependency is
172   select distinct PRODUCT_DEPENDENCY, LEVEL
173   from FND_PRODUCT_INIT_DEPENDENCY p1
174   where LEVEL =
175     (select max(LEVEL)
176      from FND_PRODUCT_INIT_DEPENDENCY p2
177      where p2.PRODUCT_DEPENDENCY = p1.PRODUCT_DEPENDENCY
178      connect by prior p2.PRODUCT_DEPENDENCY = p2.APPLICATION_SHORT_NAME
179      start with p2.APPLICATION_SHORT_NAME = upper(x_apps_name))
180   connect by prior PRODUCT_DEPENDENCY = APPLICATION_SHORT_NAME
181   start with APPLICATION_SHORT_NAME = upper(x_apps_name)
182   order by LEVEL desc;
183 
184   -- The following was added to fix Bug#3654609
185     n number :=0;
186     pos number :=0;
187     initfunc_str varchar2(240);
188     TYPE initfunc_array IS TABLE OF VARCHAR2(25)
189     INDEX BY BINARY_INTEGER;
190     strings initfunc_array;
191     p_delim varchar2(6):= ',';
192 
193 begin
194 
195   -- Logging info
196   if (fnd_log.LEVEL_PROCEDURE >= fnd_log.g_current_runtime_level) then
197     fnd_log.string(fnd_log.LEVEL_PROCEDURE,
198                  'PLSQL.FND.SECURITY.INIT.FND_INITIALIZATION_PKG',
199                  'Entering Fnd_Product_Initialization.ExecInitFunction');
200     tmpbuf := 'The current Apps and Context condition is'||
201               '('||x_apps_name||','||x_conditions||')';
202     fnd_log.string(fnd_log.LEVEL_PROCEDURE,
203                    'PLSQL.FND.SECURITY.INIT.FND_INITIALIZATION_PKG',tmpbuf);
204   end if;
205 
206   -- Reformat the x_conditions so that we can use that in our IN clause.
207   conditions := replace(x_conditions, '_', ',');
208   initfunc_str := conditions;
209 
210   Fnd_Product_Initialization_Pkg.init_conditions := conditions;
211 
212    -- Added the following to fix Bug#3654609
213         -- determine first chuck of string
214         pos := instr(initfunc_str,p_delim,1,1);
215 
216         if (pos <> 0) then
217               -- while there are chunks left, loop
218               while ( pos <> 0) loop
219                     -- increment counter
220                     n := n + 1;
221                     -- create array element for chuck of string
222                     strings(n) := ltrim(rtrim(substr(initfunc_str,1,pos-1), ''''), '''');
223                     -- remove chunk from string
224                     initfunc_str := substr(initfunc_str,pos+1,length(initfunc_str));
225                     -- determine next chunk
226                     pos := instr(initfunc_str,p_delim,1,1);
227                     -- no last chunk, add to array
228                     if pos = 0 then
229                        strings(n+1) := ltrim(rtrim(initfunc_str, ''''), '''');
230                     end if;
231               end loop;
232               n := n+1;
233         else
234              if (pos = 0) and (conditions is not null) then
235                  strings(1) := ltrim(rtrim(initfunc_str, ''''), '''');
236                  n := 1;
237              end if;
238         end if;
239 
240   begin
241   i := 0;
242   for dep in dependency loop
243     deparr(i) := upper(dep.PRODUCT_DEPENDENCY);
244     i := i+1;
245   end loop;
246   deparr(i) := upper(x_apps_name);
247   deparr(i+1) := '';
248 
249   exception
250     when others then
251     if (fnd_log.LEVEL_EXCEPTION >= fnd_log.g_current_runtime_level) then
252       fnd_log.string(fnd_log.LEVEL_EXCEPTION,
253                    'PLSQL.FND.SECURITY.INIT.FND_INITIALIZATION_PKG',
254                    'Unable to fetch product dependency');
255     end if;
256     fnd_message.set_name('FND', 'SQL_PLSQL_ERROR');
257     fnd_message.set_token('ROUTINE',sqlbuf);
258     fnd_message.set_token('ERRNO', to_char(sqlcode));
259     fnd_message.set_token('REASON', sqlerrm);
260     app_exception.raise_exception;
261   end;
262 
263   i := 0;
264   while(deparr(i) is not null) loop
265     -- For a given application, check if any of its re-init-conditions
266     -- match with our input x_conditions.
267     -- don't need to trap "no row selected"
268     begin
269       init_function := null;
270 
271       -- Fix Bug#3654609 - Performance issue using dynamic sql
272       /* sqlbuf := 'select INIT_FUNCTION_NAME '||
273       'from FND_PRODUCT_INITIALIZATION '||
274       'where APPLICATION_SHORT_NAME = :v1 '||
275       'and exists '||
276       '(select 1 '||
277       'from FND_PRODUCT_INIT_CONDITION C '||
278       'where C.APPLICATION_SHORT_NAME = :v2 '||
279       'and C.RE_INIT_CONDITION in ('||conditions||'))';
280 
281       if (fnd_log.LEVEL_STATEMENT >= fnd_log.g_current_runtime_level) then
282         tmpbuf := 'Start fetching init_function for product '||deparr(i);
283         fnd_log.string(fnd_log.LEVEL_STATEMENT,
284                       'PLSQL.FND.SECURITY.INIT.FND_INITIALIZATION_PKG',tmpbuf);
285       end if;
286 
287       execute immediate sqlbuf into init_function
288       using deparr(i), deparr(i); */
289 
290       -- Fetch init function
291       if (fnd_log.LEVEL_STATEMENT >= fnd_log.g_current_runtime_level) then
292         tmpbuf := 'Start fetching init_function for product '||deparr(i);
293         fnd_log.string(fnd_log.LEVEL_STATEMENT,
294                      'PLSQL.FND.SECURITY.INIT.FND_INITIALIZATION_PKG',tmpbuf);
295       end if;
296 
297       if (n = 1) then
298          select INIT_FUNCTION_NAME
299          into init_function
300          from FND_PRODUCT_INITIALIZATION
301          where APPLICATION_SHORT_NAME = deparr(i)
302          and exists
303           (select 1
304            from FND_PRODUCT_INIT_CONDITION C
305            where C.APPLICATION_SHORT_NAME = deparr(i)
306            and C.RE_INIT_CONDITION in (strings(1)));
307       elsif (n = 2) then
308          select INIT_FUNCTION_NAME
309          into init_function
310          from FND_PRODUCT_INITIALIZATION
311          where APPLICATION_SHORT_NAME = deparr(i)
312          and exists
313           (select 1
314            from FND_PRODUCT_INIT_CONDITION C
315            where C.APPLICATION_SHORT_NAME = deparr(i)
316            and C.RE_INIT_CONDITION in (strings(1), strings(2)));
317       elsif (n = 3) then
318          select INIT_FUNCTION_NAME
319          into init_function
320          from FND_PRODUCT_INITIALIZATION
321          where APPLICATION_SHORT_NAME = deparr(i)
322          and exists
323           (select 1
324            from FND_PRODUCT_INIT_CONDITION C
325            where C.APPLICATION_SHORT_NAME = deparr(i)
326            and C.RE_INIT_CONDITION in (strings(1), strings(2), strings(3)));
327       elsif (n = 4) then
328          select INIT_FUNCTION_NAME
329          into init_function
330          from FND_PRODUCT_INITIALIZATION
331          where APPLICATION_SHORT_NAME = deparr(i)
332          and exists
333          (select 1
334           from FND_PRODUCT_INIT_CONDITION C
335           where C.APPLICATION_SHORT_NAME = deparr(i)
336           and C.RE_INIT_CONDITION in (strings(1), strings(2), strings(3), strings(4)));
337       elsif (n = 5) then
338          select INIT_FUNCTION_NAME
339          into init_function
340          from FND_PRODUCT_INITIALIZATION
341          where APPLICATION_SHORT_NAME = deparr(i)
342          and exists
343          (select 1
344           from FND_PRODUCT_INIT_CONDITION C
345           where C.APPLICATION_SHORT_NAME = deparr(i)
346           and C.RE_INIT_CONDITION in (strings(1), strings(2), strings(3), strings(4), strings(5)));
347       elsif (n = 6) then
348          select INIT_FUNCTION_NAME
349          into init_function
350          from FND_PRODUCT_INITIALIZATION
351          where APPLICATION_SHORT_NAME = deparr(i)
352          and exists
353          (select 1
354           from FND_PRODUCT_INIT_CONDITION C
355           where C.APPLICATION_SHORT_NAME = deparr(i)
356           and C.RE_INIT_CONDITION in (strings(1), strings(2), strings(3), strings(4), strings(5), strings(6)));
357       elsif (n = 7) then
358          select INIT_FUNCTION_NAME
359          into init_function
360          from FND_PRODUCT_INITIALIZATION
361          where APPLICATION_SHORT_NAME = deparr(i)
362          and exists
363          (select 1
364           from FND_PRODUCT_INIT_CONDITION C
365           where C.APPLICATION_SHORT_NAME = deparr(i)
366           and C.RE_INIT_CONDITION in (strings(1), strings(2), strings(3), strings(4), strings(5), strings(6), strings(7)));
367       elsif (n = 8) then
368          select INIT_FUNCTION_NAME
369          into init_function
370          from FND_PRODUCT_INITIALIZATION
371          where APPLICATION_SHORT_NAME = deparr(i)
372          and exists
373          (select 1
374           from FND_PRODUCT_INIT_CONDITION C
375           where C.APPLICATION_SHORT_NAME = deparr(i)
376           and C.RE_INIT_CONDITION in (strings(1), strings(2), strings(3), strings(4), strings(5), strings(6), strings(7), strings(8)));
377       elsif (n = 9) then
378          select INIT_FUNCTION_NAME
379          into init_function
380          from FND_PRODUCT_INITIALIZATION
381          where APPLICATION_SHORT_NAME = deparr(i)
382          and exists
383          (select 1
384           from FND_PRODUCT_INIT_CONDITION C
388          select INIT_FUNCTION_NAME
385           where C.APPLICATION_SHORT_NAME = deparr(i)
386           and C.RE_INIT_CONDITION in (strings(1), strings(2), strings(3), strings(4), strings(5), strings(6), strings(7), strings(8), strings(9)));
387       elsif (n = 10) then
389          into init_function
390          from FND_PRODUCT_INITIALIZATION
391          where APPLICATION_SHORT_NAME = deparr(i)
392          and exists
393          (select 1
394           from FND_PRODUCT_INIT_CONDITION C
395           where C.APPLICATION_SHORT_NAME = deparr(i)
396           and C.RE_INIT_CONDITION in (strings(1), strings(2), strings(3), strings(4), strings(5), strings(6), strings(7), strings(8), strings(9), strings(10)));
397       end if;
398     exception
399       when no_data_found then
400         -- This is ok. It means that the dependency product has no
401         -- initialization routine or don't care about the current conditions.
402         if (fnd_log.LEVEL_STATEMENT >= fnd_log.g_current_runtime_level) then
403           tmpbuf := deparr(i)||' has either no init routine or no matching '||
404                     'init condition';
405           fnd_log.string(fnd_log.LEVEL_STATEMENT,
406                          'PLSQL.FND.SECURITY.INIT.FND_INITIALIZATION_PKG',
407                          tmpbuf);
408         end if;
409       when others then
410         if (fnd_log.LEVEL_EXCEPTION >= fnd_log.g_current_runtime_level) then
411           tmpbuf := 'Unable to fetch init_function of product '||deparr(i);
412           fnd_log.string(fnd_log.LEVEL_EXCEPTION,
413                          'PLSQL.FND.SECURITY.INIT.FND_INITIALIZATION_PKG',
414                          tmpbuf);
415         end if;
416         fnd_message.set_name('FND', 'SQL_PLSQL_ERROR');
417         fnd_message.set_token('ROUTINE',sqlbuf);
418         fnd_message.set_token('ERRNO', to_char(sqlcode));
419         fnd_message.set_token('REASON', sqlerrm);
420         app_exception.raise_exception;
421     end;
422 
423     if (init_function is not null) then
424       -- Execute the init function
425       begin
426         if (fnd_log.LEVEL_STATEMENT >= fnd_log.g_current_runtime_level) then
427           tmpbuf := 'Calling initialization routine: '||init_function;
428           fnd_log.string(fnd_log.LEVEL_STATEMENT,
429                          'PLSQL.FND.SECURITY.INIT.FND_INITIALIZATION_PKG',
430                          tmpbuf);
431         end if;
432 
433         init_function := 'begin '||init_function||'; end;';
434         execute immediate init_function;
435 
436       exception
437         when others then
438           if (fnd_log.LEVEL_EXCEPTION >= fnd_log.g_current_runtime_level) then
439             tmpbuf := 'Unable to execute init_function of product '||deparr(i);
440             fnd_log.string(fnd_log.LEVEL_EXCEPTION,
441                            'PLSQL.FND.SECURITY.INIT.FND_INITIALIZATION_PKG',
442                            tmpbuf);
443           end if;
444           fnd_message.set_name('FND', 'PRODUCT_INITIALIZATION_FAILED');
445           fnd_message.set_token('APPS', deparr(i));
446           fnd_message.set_token('ROUTINE', init_function);
447           fnd_message.set_token('SQLCODE', to_char(sqlcode));
448           fnd_message.set_token('SQLERROR', sqlerrm);
449           app_exception.raise_exception;
450       end;
451     end if;
452     i := i+1;
453   end loop;
454 
455 end ExecInitFunction;
456 
457 
458 procedure Test(x_apps_name in varchar2) is
459 begin
460 
461   fnd_product_initialization_pkg.execinitfunction(x_apps_name,
462                               '''APPL''_''RESP''');
463 end Test;
464 
465 -- Register (PUBLIC)
466 --   Called by product team to register their re-initialization function
467 -- Input
468 --   x_apps_name: application short name
469 --   x_init_function: re-initialization function
470 procedure Register(x_apps_name          in varchar2,
471                    x_init_function      in varchar2 default null,
472                    x_owner              in varchar2 default 'SEED',
473                    x_last_update_date   in varchar2,
474                    x_custom_mode        in varchar2) is
475   f_luby    number;  -- entity owner in file
476   f_ludate  date;    -- entity update date in file
477   db_luby   number;  -- entity owner in db
478   db_ludate date;    -- entity update date in db
479 begin
480 
481  -- Translate owner to file_last_updated_by
482   f_luby := fnd_load_util.owner_id(x_owner);
483 
484   -- Translate char last_update_date to date
485   f_ludate := nvl(to_date(x_last_update_date, 'YYYY/MM/DD'), sysdate);
486 
487   begin
488     select LAST_UPDATED_BY, LAST_UPDATE_DATE
489     into db_luby, db_ludate
490     from FND_PRODUCT_INITIALIZATION
491     where APPLICATION_SHORT_NAME = upper(x_apps_name);
492 
493     if (fnd_load_util.upload_test(f_luby, f_ludate, db_luby,
494                                   db_ludate, X_CUSTOM_MODE)) then
495 
496      update FND_PRODUCT_INITIALIZATION
497      set INIT_FUNCTION_NAME = upper(x_init_function),
498         LAST_UPDATED_BY = f_luby,
499         LAST_UPDATE_DATE = f_ludate,
500         LAST_UPDATE_LOGIN = f_luby
501      where APPLICATION_SHORT_NAME = upper(x_apps_name);
502     end if;
503 
504     exception
505      when no_data_found then
506       insert into FND_PRODUCT_INITIALIZATION(
507       APPLICATION_SHORT_NAME,
508       INIT_FUNCTION_NAME,
509       LAST_UPDATED_BY,
510       LAST_UPDATE_DATE,
511       LAST_UPDATE_LOGIN,
512       CREATION_DATE,
513       CREATED_BY)
514       values(
515       upper(x_apps_name),
516       upper(x_init_function),
517       f_luby,
518       f_ludate,
519       f_luby,
520       f_ludate,
521       f_luby);
522 
523     when others then
524       fnd_message.set_name('FND', 'SQL_PLSQL_ERROR');
525       fnd_message.set_token('ROUTINE', 'Register');
526       fnd_message.set_token('ERRNO', to_char(sqlcode));
527       fnd_message.set_token('REASON', sqlerrm);
528       app_exception.raise_exception(NULL, NULL,
529         'Exception in FND_PRODUCT_INITIALIZATION_PKG.REGISTER');
530  end;
531 end Register;
532 
533 --
534 -- AddDependency (PUBLIC) - Overloaded
535 --   Called by anybody who wants to register their product dependency
536 --
537 -- Input
538 --   x_apps_name:  the application short name
539 --   x_dependency: the dependency application short name
540 --
541 procedure AddDependency(x_apps_name   in varchar2,
542                         x_dependency  in varchar2,
543                         x_owner       in varchar2,
544                         x_last_update_date   in varchar2,
545                         x_custom_mode        in varchar2) is
546 
547   f_luby    number;  -- entity owner in file
548   f_ludate  date;    -- entity update date in file
549 
550 begin
551  -- Translate owner to file_last_updated_by
552   f_luby := fnd_load_util.owner_id(x_owner);
553 
554   -- Translate char last_update_date to date
555   f_ludate := nvl(to_date(x_last_update_date, 'YYYY/MM/DD'), sysdate);
556 
557   begin
558     insert into FND_PRODUCT_INIT_DEPENDENCY(
559     APPLICATION_SHORT_NAME,
560     PRODUCT_DEPENDENCY,
561     LAST_UPDATED_BY,
562     LAST_UPDATE_DATE,
563     LAST_UPDATE_LOGIN,
564     CREATION_DATE,
565     CREATED_BY)
566     values(
567     upper(x_apps_name),
568     upper(x_dependency),
569     f_luby,
570     f_ludate,
571     f_luby,
572     f_ludate,
573     f_luby);
574   exception
575     when dup_val_on_index then
576       null;
577     when others then
578       fnd_message.set_name('FND', 'SQL_PLSQL_ERROR');
579       fnd_message.set_token('ROUTINE', 'AddDependency');
580       fnd_message.set_token('ERRNO', to_char(sqlcode));
581       fnd_message.set_token('REASON', sqlerrm);
582       app_exception.raise_exception(NULL, NULL,
583         'Exception in FND_PRODUCT_INITIALIZATION_PKG.AddDependency');
584       raise;
585   end;
586 
587 end AddDependency;
588 -- AddInitCondition (PUBLIC)
589 --   Called by anybody who wants to register their product's re-initialization
590 --   conditions.
591 --
592 -- Input
593 --   x_apps_name:  the application short name
594 --   x_condition:  one of the following conditions:
595 --                 'APPL', 'RESP', 'USER', 'NLS', 'ORG'
596 --
597 procedure AddInitCondition(x_apps_name in varchar2,
598                            x_condition in varchar2,
599                            x_owner     in varchar2,
600                            x_last_update_date   in varchar2,
601                            x_custom_mode        in varchar2) is
602 
603   f_luby    number;  -- entity owner in file
604   f_ludate  date;    -- entity update date in file
605 
606 begin
607  -- Translate owner to file_last_updated_by
608   f_luby := fnd_load_util.owner_id(x_owner);
609 
610   -- Translate char last_update_date to date
611   f_ludate := nvl(to_date(x_last_update_date, 'YYYY/MM/DD'), sysdate);
612 
613   begin
614     insert into FND_PRODUCT_INIT_CONDITION(
615     APPLICATION_SHORT_NAME,
616     RE_INIT_CONDITION,
617     LAST_UPDATED_BY,
618     LAST_UPDATE_DATE,
619     LAST_UPDATE_LOGIN,
620     CREATION_DATE,
621     CREATED_BY)
622     values(
623     upper(x_apps_name),
624     upper(x_condition),
625     f_luby,
626     f_ludate,
627     f_luby,
628     f_ludate,
629     f_luby);
630 
631   exception
632     when dup_val_on_index then
633       null;
634     when others then
635       fnd_message.set_name('FND', 'SQL_PLSQL_ERROR');
636       fnd_message.set_token('ROUTINE', 'AddInitCondition');
637       fnd_message.set_token('ERRNO', to_char(sqlcode));
638       fnd_message.set_token('REASON', sqlerrm);
639       app_exception.raise_exception(NULL, NULL,
640         'Exception in FND_PRODUCT_INITIALIZATION_PKG.AddInitCondition');
641   end;
642 
643 end AddInitCondition;
644 
645 -- DiscoInit (PUBLIC)
646 --   Called by Disco trigger to run all product initialization code inside
647 --   fnd_product_initialization table with all true conditions.
648 --
649 -- Input
650 --   no input argument
651 --
652 function DiscoInit return number is
653 begin
654 
655   fnd_product_initialization_pkg.ExecInitFunction(
656                           fnd_global.application_short_name,
657                           '''APPL''_''RESP''_''USER''_''NLS''_''ORG''');
658   return(ExecInitSuccess);
659 
660 exception
661   when others then
662     return(ExecInitFailure);
663 
664 end DiscoInit;
665 
666 -- RemoveAll (PUBLIC)
667 --   Called by anybody who wants to remove all their product initialization
668 --   data.
669 --
670 -- Input
671 --   x_apps_short_name:  the application short name
672 --
673 procedure RemoveAll(apps_short_name in varchar2) is
674 begin
675   delete from fnd_product_init_dependency
676   where application_short_name = apps_short_name;
677 
678   delete from fnd_product_init_condition
679   where application_short_name = apps_short_name;
680 
681   delete from fnd_product_initialization
682   where application_short_name = apps_short_name;
683 
684 end RemoveAll;
685 
686 
687 
688 end Fnd_Product_Initialization_Pkg;