DBA Data[Home] [Help]

PACKAGE BODY: APPS.FND_REQUEST

Source


1 package body FND_REQUEST as
2 /* $Header: AFCPREQB.pls 120.15.12010000.3 2008/12/23 17:41:25 pferguso ship $ */
3 
4 --
5 -- Package
6 --   FND_REQUEST
7 --
8 -- Purpose
9 --   Concurrent processing related utilities
10 --
11 -- History
12 --   XX-XXX-93	Ram Bhoopalam		Created
13 --   08-FEB-94	H Pelimuhandiram	Gave life
14 --
15 
16   --
17   -- PRIVATE VARIABLES
18   --
19 	P_OPS_ID		integer		:= null;
20 	P_REL_CLASS_APP_ID	integer		:= null;
21 	P_REL_CLASS_ID		integer		:= null;
22 	P_REL_STALE_DATE	date		:= null;
23 	P_REL_CANCEL_OR_HOLD	varchar2(1)	:= 'H';
24 	P_USES_REL_CLASS	integer		:= 0;
25 	P_ON_PP_ERR_NOTIFY	varchar2(255)	:= null;
26 	P_REPEAT_TIME		varchar2(10)	:= null;
27 	P_REPEAT_INTERVAL	number(15,10)	:= null;
28 	P_REPEAT_INTERVAL_UNIT	varchar2(10)	:= null;
29 	P_REPEAT_INTERVAL_TYPE	varchar2(10)	:= null;
30 	P_REPEAT_END		date		:= null;
31 	P_INCREMENT_DATES	varchar2(1)	:= null;
32 	P_PRINT_STYLE		varchar2(30)	:= null;
33 	P_SAVE_OUTPUT		char		:= null;
34 	P_PRINT_TOGETHER	char		:= null;
35 	P_PROTECTED		char		:= 'N';
36 	P_IMPLICIT 		varchar2(10)	:= 'N';
37 	P_LANGUAGE		varchar2(30)	:= null;
38 	P_TERRITORY		varchar2(30)	:= null;
39         /* NLS Project */
40 	P_NUMERIC_CHARACTERS	varchar2(2)	:= null;
41 	P_DATAGROUP		varchar2(30)	:= null;
42 	P_DB_TRIGGER_MODE	boolean		:= FALSE;
43 	P_CRITICAL_REQUEST	varchar2(1)	:= null;
44 	P_REQUEST_TYPE		varchar2(1)	:= NULL;
45 	P_DEFERRED_MODE		boolean		:= FALSE;
46 	P_DEF_REQUEST_ID	number		:= 0;
47         P_TEMPLATE_APPL         varchar2(50)    := null;
48         P_TEMPLATE_CODE         varchar2(50)     := null;
49         P_TEMPLATE_LANG		varchar2(255)     := null;
50         P_TEMPLATE_TERRITORY    varchar2(6)     := null;
51         P_OUTPUT_FORMAT         varchar2(30)    := null;
52         P_ORG_ID                integer         := null;
53         SQL_WAITS               NUMBER :=  8 ;
54         P_VALIDATE_PRINTER      varchar2(10) := 'RESOLVE';
55         P_NODE_NAME1            varchar2(30)    := null;
56         P_CONNSTR1              varchar2(255)   := null;
57 
58 
59 	TYPE printer_record_type is record
60 		(printer varchar2(30),
61 		copies  number);
62 
63 	TYPE printer_tab_type is table of printer_record_type
64 		index by binary_integer;
65 
66 	TYPE notification_record_type is record
67 		(name 		varchar2(100),
68 		orig_system 	varchar2(48),
69 		orig_system_id 	number,
70 		on_normal         varchar2(1),
71 		on_warning        varchar2(1),
72 		on_error          varchar2(1));
73 
74 	TYPE notification_tab_type is table of notification_record_type
75 		index by binary_integer;
76 
77 	P_PRINTERS printer_tab_type;
78 	P_PRINTER_COUNT number := 0;
79 	P_NOTIFICATIONS notification_tab_type;
80 	P_NOTIFICATION_COUNT number := 0;
81 
82   -- Exception info.
83 
84   --
85   -- PRIVATE FUNCTIONS
86   --
87   -- --
88 
89   -- Name
90   --   init_pvt_vars
91   -- Purpose
92   --   Called after submitting request to re-initialize repeat options
93   --
94   -- --
95 
96   procedure init_pvt_vars is
97 	empty_array printer_tab_type;
98 	empty_notify_array notification_tab_type;
99 	begin
100 		P_OPS_ID				:= null;
101 		P_REL_CLASS_APP_ID		:= null;
102 		P_REL_CLASS_ID			:= null;
103 		P_REL_STALE_DATE		:= null;
104 		P_REL_CANCEL_OR_HOLD		:= 'H';
105 		P_USES_REL_CLASS		:= 0;
106 		P_ON_PP_ERR_NOTIFY		:= null;
107 		P_REPEAT_TIME			:= null;
108 		P_REPEAT_INTERVAL		:= null;
109 		P_REPEAT_INTERVAL_UNIT		:= null;
110 		P_REPEAT_INTERVAL_TYPE		:= null;
111 		P_REPEAT_END			:= null;
112 		P_PRINT_STYLE			:= null;
113 		P_SAVE_OUTPUT			:= null;
114 		P_PRINT_TOGETHER		:= null;
115 		P_PROTECTED			:= 'N';
116 		P_IMPLICIT			:= 'N';
117 		P_LANGUAGE			:= null;
118 		P_TERRITORY			:= null;
119                 /* NLS Project */
120 	        P_NUMERIC_CHARACTERS		:= null;
121 		P_DATAGROUP			:= null;
122 		P_DB_TRIGGER_MODE		:= FALSE;
123 		P_CRITICAL_REQUEST		:= null;
124 		P_REQUEST_TYPE			:= NULL;
125 		P_PRINTERS			:= empty_array;
126 		P_PRINTER_COUNT			:= 0;
127 		P_NOTIFICATIONS			:= empty_notify_array;
128 		P_NOTIFICATION_COUNT		:= 0;
129 		P_DEFERRED_MODE			:= FALSE;
130 		P_DEF_REQUEST_ID		:= 0;
131                 P_TEMPLATE_APPL                 := null;
132                 P_TEMPLATE_CODE                 := null;
133                 P_TEMPLATE_LANG         	:= null;
134                 P_TEMPLATE_TERRITORY    	:= null;
135                 P_OUTPUT_FORMAT         	:= null;
136                 P_ORG_ID                        := null;
137 	end init_pvt_vars;
138 
139 
140   -- Name
141   --  get_request_set_priority
142   -- Purpose
143   --  The priority of a request set is
144   --  equal to the priority of its highest
145   --  priority member.
146   --
147   -- --
148   function get_request_set_priority (
149                  app_id IN number,
150                  set_id IN number
151                                     ) return number is
152     program_priority number;
153     profile_priority_char varchar2(3);
154     profile_priority_number number;
155   begin
156      FND_PROFILE.GET ('CONC_PRIORITY', profile_priority_char);
157      profile_priority_number := to_number(profile_priority_char);
158 
159      Select min(nvl(request_priority, profile_priority_number))
160        Into program_priority
161        From Fnd_Concurrent_Programs P,
162             Fnd_Request_Set_Programs S
163       Where S.set_application_id = app_id
164         and S.request_set_id = set_id
165         and P.concurrent_program_id = S.concurrent_program_id
166         and P.application_id = S.program_application_id;
167 
168       return program_priority;
169   exception
170     when NO_DATA_FOUND then
171       return null;
172   end;
173 
174 procedure set_dest_ops(ops_id IN number default NULL) is
175 
176 begin
177    P_OPS_ID := ops_id;
178 end;
179 
180 
181 procedure set_org_id(org_id IN number default NULL) is
182 
183 begin
184    P_ORG_ID := org_id;
185 end;
186 
187   -- Name
188   --   is_trace_enabled
189   -- Purpose
190   --   Check whether the trace is enabled for the current db session
191   -- Added this function to fix 4438376
192 
193 function is_trace_enabled(trace_type in number) return boolean is
194  event_level number;
195  trace_on boolean;
196  begin
197    if(trace_type < 20) then
198     dbms_system.read_ev(10046,event_level);
199    else
200     dbms_system.read_ev(trace_type,event_level);
201    end if;
202 
203    if event_level > 0 then
204      trace_on:= true;
205    else
206      trace_on:= false;
207    end if;
208  return trace_on;
209  end;
210 
211   -- Name
212   --   submit
213   -- Purpose
214   --   Submit concurrent request
215   --
216   -- --
217 
218   function submit (
219 		  application IN varchar2,
220 		  program     IN varchar2,
221 		  description IN varchar2,
222 		  start_time  IN varchar2,
223 		  sub_request IN boolean,
224 		  argument1   IN varchar2,
225 		  argument2   IN varchar2,
226   		  argument3   IN varchar2,
227 		  argument4   IN varchar2,
228 		  argument5   IN varchar2,
229 		  argument6   IN varchar2,
230 		  argument7   IN varchar2,
231 		  argument8   IN varchar2,
232 		  argument9   IN varchar2,
233 		  argument10  IN varchar2,
234 		  argument11  IN varchar2,
235 		  argument12  IN varchar2,
236   		  argument13  IN varchar2,
237 		  argument14  IN varchar2,
238 		  argument15  IN varchar2,
239 		  argument16  IN varchar2,
240 		  argument17  IN varchar2,
241 		  argument18  IN varchar2,
242 		  argument19  IN varchar2,
243 		  argument20  IN varchar2,
244 		  argument21  IN varchar2,
245 		  argument22  IN varchar2,
246   		  argument23  IN varchar2,
247 		  argument24  IN varchar2,
248 		  argument25  IN varchar2,
249 		  argument26  IN varchar2,
250 		  argument27  IN varchar2,
251 		  argument28  IN varchar2,
252 		  argument29  IN varchar2,
253 		  argument30  IN varchar2,
254 		  argument31  IN varchar2,
255 		  argument32  IN varchar2,
256   		  argument33  IN varchar2,
257 		  argument34  IN varchar2,
258 		  argument35  IN varchar2,
259 		  argument36  IN varchar2,
260 		  argument37  IN varchar2,
261   		  argument38  IN varchar2,
262 		  argument39  IN varchar2,
263 		  argument40  IN varchar2,
264 		  argument41  IN varchar2,
265   		  argument42  IN varchar2,
266 		  argument43  IN varchar2,
267 		  argument44  IN varchar2,
268 		  argument45  IN varchar2,
269 		  argument46  IN varchar2,
270 		  argument47  IN varchar2,
271   		  argument48  IN varchar2,
272 		  argument49  IN varchar2,
273 		  argument50  IN varchar2,
274 		  argument51  IN varchar2,
275 		  argument52  IN varchar2,
276 		  argument53  IN varchar2,
277 		  argument54  IN varchar2,
278 		  argument55  IN varchar2,
279 		  argument56  IN varchar2,
280 		  argument57  IN varchar2,
281 		  argument58  IN varchar2,
282 		  argument59  IN varchar2,
283 		  argument60  IN varchar2,
284 		  argument61  IN varchar2,
285 		  argument62  IN varchar2,
286 		  argument63  IN varchar2,
287 		  argument64  IN varchar2,
288 		  argument65  IN varchar2,
289 		  argument66  IN varchar2,
290 		  argument67  IN varchar2,
291 		  argument68  IN varchar2,
292 		  argument69  IN varchar2,
293 		  argument70  IN varchar2,
294 		  argument71  IN varchar2,
295 		  argument72  IN varchar2,
296 		  argument73  IN varchar2,
297 		  argument74  IN varchar2,
298 		  argument75  IN varchar2,
299 		  argument76  IN varchar2,
300 		  argument77  IN varchar2,
301 		  argument78  IN varchar2,
302 		  argument79  IN varchar2,
303 		  argument80  IN varchar2,
304 		  argument81  IN varchar2,
305 		  argument82  IN varchar2,
306 		  argument83  IN varchar2,
307 		  argument84  IN varchar2,
308 		  argument85  IN varchar2,
309 		  argument86  IN varchar2,
310 		  argument87  IN varchar2,
311 		  argument88  IN varchar2,
312 		  argument89  IN varchar2,
313 		  argument90  IN varchar2,
314 		  argument91  IN varchar2,
315 		  argument92  IN varchar2,
316 		  argument93  IN varchar2,
317 		  argument94  IN varchar2,
318 		  argument95  IN varchar2,
319 		  argument96  IN varchar2,
320 		  argument97  IN varchar2,
321 		  argument98  IN varchar2,
322 		  argument99  IN varchar2,
323 		  argument100 IN varchar2)
324 		  return number is
325 
326         submit_ops_id	   number;
327 	cur_request_id     number;
328 	cur_req_pri_id     number;
329 	par_request_id     number;
330         fgloginid          number;
331 	pri_request_id     number;
332 	resp_id		   number := null;
333 	resp_appl_id	   number := null;
334 	user_id		   number := null;
335 	oraclacct          varchar2(30);
336 	conf_set_id        number;
337 	prog_appl_id       number;
338 	conc_prog_id       number;
339 	loginid		   number := null;
340 	subloginid	   number := null;
341 	hold_request       varchar2(3);
342 	snth_request       varchar2(3);
343 	language           varchar2(15);
344 	req_status	   varchar2(15);
345 	requested_start    date;
346 	priority	   number  := 50;
347 	hold_flag          varchar2(3)  := 'N';
348 	st_flag		   varchar2(3)  := 'N';
349 	profile_buffer	   varchar2(80) := null;
350 	request_threshold  number := -1;
351 	print_copies	   number := 0;
352 	req_limit          char;
353 	phase              char     := 'P';
354 	status		   char     := 'Q';
355 	issubreq           char     := 'N';
356 	has_parent         boolean  := FALSE;
357         program_priority   number;
358 
359         cd_id		   number := -1;	  -- Conf domain id
360 	cd_param           varchar2(150) := null; -- Conf domain param name
361 
362         default_copies     number;
363 	default_printer    varchar2(30);
364         fcr_printer        varchar2(30);
365 	fcp_printer        varchar2(30);
366         curr_printer       varchar2(30);
367         curr_copies        number;
368         tot_copies         number := 0;
369 	print_style        varchar2(30);
370 	valid_style        varchar2(30) := null;
371 	print_warning	   char := 'N';
372         reqrd_flag         char;
373 	minwid             number(4);           -- bug3205755
374 	maxwid             number(4) := null;   -- bug3205755
375 	minlen             number(4);           -- bug3205755
376   	maxlen             number(4) := null;   -- bug3205755
377 	execcode	   char;
378 	saveout            char;
379 	prtflg		   char;
380 	mult_pending_req   char;
381 	qctlflg		   char;
382 	styl_ok            boolean  := FALSE;
383 	nargs		   number := 0;
384 	argtxt		   varchar2(24200) := null;
385 	argtxt2		   varchar2(240);
386 	dummy		   char;
387         request_set_flag   varchar2(1);
388         base_len           number;
389         tz_offset          number(1);
390         encoded_msg	   varchar2(4000);
391 -- bug 1518406 define a local name
392         z_security_group_id  number;
393 
394         ops_req_mode	   varchar2(30);
395         portlet_ref        varchar2(1) := 'N';  -- 'N'ever (no pp plsql actions)
396         p_on_success       varchar2(1) := 'N';
397         p_on_warning       varchar2(1) := 'N';
398         p_on_error         varchar2(1) := 'N';
399         pp_plsql_step      number := -1;
400 
401 	printer_error	   exception;
402 	style_error	   exception;
403 	srw_style_error	   exception;
404 	printer_styl_error exception;
405 	insert_error	   exception;
406 	args_insert_error  exception;
407 	login_insert_error exception;
408 	relclass_insert_error exception;
409 	dual_no_rows	   exception;
410 	dual_too_many_rows exception;
411 	nls_error	   exception;
412 	appl_prog_error	   exception;
413 	start_time_error   exception;
414 	already_msg	   exception;
415 	oracle_name_error  exception;
416         pp_plsql_exception exception;
417 	conc_deferred_insert_error exception;
418 	mult_pending_request_error exception;
419 
420 	rttestid	   number;
421         i                  number;
422 	new_class  boolean;
423         schedule_type      varchar2(1);
424         schedule_info      varchar2(64);
425         sch_req_date       date;
426         sch_end_date       date;
427 
428 	no_pending_req     number;
429 	lang_exists	   number;
430 	adv_sch_ri number(15,10);
431 	adv_sch_riuc varchar2(30);
432 	adv_sch_ritc varchar2(30);
433        trace_enabled varchar2(1) :='N';
434 	discard_status		number;
435 
436   begin
437 	-- Get next request ID from sequence
438 	-- only if it is a normal call without P_DEFERRED_MODE or its deferred call
439 	if ( (P_DEFERRED_MODE) OR (P_DEF_REQUEST_ID = 0)) then
440 	begin
441 		Select Fnd_Concurrent_Requests_S.nextval
442 		Into cur_request_id
443 		From Sys.Dual;
444 	exception
445 		when no_data_found then
446 			raise dual_no_rows;
447 		when too_many_rows then
448 			raise dual_too_many_rows;
449 		when others then
450 			raise;
451 	end;
452 	end if;
453 
454 	if (P_DEFERRED_MODE) then
455 		Insert Into Fnd_Conc_Deferred_Arguments (
456 			request_id, Program_Application_Id, Concurrent_Program_Id,
457 			Argument1, Argument2, Argument3, Argument4, Argument5,
458 			Argument6,  Argument7,  Argument8,  Argument9,  Argument10,
459 			Argument11, Argument12, Argument13, Argument14, Argument15,
460 			Argument16, Argument17, Argument18, Argument19, Argument20,
461 			Argument21, Argument22, Argument23, Argument24, Argument25,
462 			Argument26, Argument27, Argument28, Argument29, Argument30,
463 			Argument31, Argument32, Argument33, Argument34, Argument35,
464 			Argument36, Argument37, Argument38, Argument39, Argument40,
465 			Argument41, Argument42, Argument43, Argument44, Argument45,
466 			Argument46, Argument47, Argument48, Argument49, Argument50,
467 			Argument51, Argument52, Argument53, Argument54, Argument55,
468 			Argument56, Argument57, Argument58, Argument59, Argument60,
469 			Argument61, Argument62, Argument63, Argument64, Argument65,
470 			Argument66, Argument67, Argument68, Argument69, Argument70,
471 			Argument71, Argument72, Argument73, Argument74, Argument75,
472 			Argument76, Argument77, Argument78, Argument79, Argument80,
473 			Argument81, Argument82, Argument83, Argument84, Argument85,
474 			Argument86, Argument87, Argument88, Argument89, Argument90,
475 			Argument91, Argument92, Argument93, Argument94, Argument95,
476 			Argument96, Argument97, Argument98, Argument99, Argument100,
477 			Creation_Date, Created_By, Last_Update_Date, Last_Updated_By,
478 			Last_Update_Login)
479 			Select cur_request_id, FA.Application_ID, FCP.Concurrent_Program_ID,
480 				argument1,  argument2,  argument3,  argument4,  argument5,
481 				argument6,  argument7,  argument8,  argument9,  argument10,
482 				argument11, argument12, argument13, argument14, argument15,
483 				argument16, argument17, argument18, argument19, argument20,
484 				argument21, argument22, argument23, argument24, argument25,
485 				argument26, argument27, argument28, argument29, argument30,
486 				argument31, argument32, argument33, argument34, argument35,
487 				argument36, argument37, argument38, argument39, argument40,
488 				argument41, argument42, argument43, argument44, argument45,
489 				argument46, argument47, argument48, argument49, argument50,
490 				argument51, argument52, argument53, argument54, argument55,
491 				argument56, argument57, argument58, argument59, argument60,
492 				argument61, argument62, argument63, argument64, argument65,
493 				argument66, argument67, argument68, argument69, argument70,
494 				argument71, argument72, argument73, argument74, argument75,
495 				argument76, argument77, argument78, argument79, argument80,
496 				argument81, argument82, argument83, argument84, argument85,
497 				argument86, argument87, argument88, argument89, argument90,
498 				argument91, argument92, argument93, argument94, argument95,
499 				argument96, argument97, argument98, argument99, argument100,
500 				Sysdate, FND_GLOBAL.conc_login_id, Sysdate,
501 				FND_GLOBAL.conc_login_id, FND_GLOBAL.conc_login_id
502 			From Fnd_Application FA,
503 				Fnd_Concurrent_Programs FCP
504 			Where
505 				FCP.Enabled_Flag = 'Y'
506 				And (FCP.Application_ID = FA.Application_ID And
507 				Concurrent_Program_Name   = Upper (program))
508 				And  FA.Application_Short_Name = Upper (application);
509 
510 			if (sql%rowcount = 0) then
511 			  raise conc_deferred_insert_error;
512 			end if;
513 			--
514 			--  raising business event for request submitted
515 			--  bug6623316
516 			--
517                         discard_status:=fnd_concurrent_business_event.raise_cp_bi_event(cur_request_id,fnd_concurrent_business_event.request_submitted);
518 
519 			return (cur_request_id);
520 	else
521 	-- see if it is deferred call or normal call
522 		if (P_DEF_REQUEST_ID <> 0) then
523 			cur_request_id := P_DEF_REQUEST_ID;
524 		end if;
525 	end if;
526 
527 	new_class  := FALSE;
528 	-- Get info. about requests origination
529 	-- If being submitted from another concurrent request get parent
530 	-- request information.
531 
532 	fgloginid := fnd_global.login_id;
533 	par_request_id := FND_GLOBAL.conc_request_id;
534 
535         z_security_group_id := FND_GLOBAL.security_group_id;
536 
537 
538 	if (par_request_id > 0) then
539 	  has_parent := TRUE;
540 	  pri_request_id := FND_GLOBAL.conc_priority_request;
541 
542       -- bug 4438376. check whether the trace is enabled for the parent request.
543       -- if enabled, then enable the trace for child request also
544 
545       if (is_trace_enabled(SQL_WAITS)) then
546         trace_enabled := 'Y';
547       else
548         trace_enabled := 'N';
549       end if;
550 
551 	  loginid := FND_GLOBAL.conc_login_id;
552 
553 	  if (loginid is null) then
554 	    loginid := 0;
555 
556 	  else
557 	    begin
558 	      Select Submitted_Login_ID
559 		Into subloginid
560 		From Fnd_Logins
561 	       Where Login_ID = loginid;
562 
563 	      exception
564 		when no_data_found then
565 		  subloginid := 0;
566 
567 		when others then
568 		  raise;
569 	    end;
570 
571 	  end if; -- (loginid is null)
572 
573 	else -- request being submitted from forms session
574 	     -- Get LOGIN_ID
575 	  subloginid := FND_GLOBAL.login_id;
576 	  pri_request_id := cur_request_id;
577 
578 	end if; -- (par_request_id > 0)
579 
580 
581 	-- Common to both :
582 
583 	if (sub_request AND pri_request_id > 0) then
584 	  cur_req_pri_id := pri_request_id;
585 	else
586 	  cur_req_pri_id := cur_request_id;
587 	end if;
588 
589 	user_id := FND_GLOBAL.user_id;
590 
591 	if (user_id is null) then
592 	  user_id := -1;
593 	end if;
594 
595 	resp_id := FND_GLOBAL.resp_id;
596 
597 	if (resp_id is null) then
598 	  resp_id := -1;
599 	end if;
600 
601 	resp_appl_id := FND_GLOBAL.resp_appl_id;
602 
603 	if (resp_appl_id is null) then
604 	  resp_appl_id := -1;
605 	end if;
606 
607         FND_PROFILE.GET ('CONC_OPS_REQ_MODE', ops_req_mode);
608         if (ops_req_mode is null) then
609           ops_req_mode:= 'EXPLICIT';
610         end if;
611 
612 	FND_PROFILE.GET ('CONC_HOLD', hold_flag);
613 	if (hold_flag is null) then
614 	  hold_flag := 'N';
615 	end if;
616 
617 	FND_PROFILE.GET ('CONC_SINGLE_THREAD', st_flag);
618 	if (st_flag is null) then
619 	  st_flag := 'N';
620 	else
621 	  st_flag := substr (st_flag, 1, 1);
622 	end if;
623 
624         profile_buffer := NULL;
625 	FND_PROFILE.GET ('CONC_REQUEST_THRESHOLD_LEVEL', profile_buffer);
626 	if ( profile_buffer is null) then
627 	   request_threshold := -1;
628 	else
629 	   request_threshold := To_Number (profile_buffer);
630 	end if;
631 
632         profile_buffer := NULL;
633 	FND_PROFILE.GET ('CONC_REQUEST_LIMIT', profile_buffer);
634 	if ( profile_buffer is null) then
635 	   req_limit := 'N';
636         elsif   (To_Number(profile_buffer) >= 0 and (P_REQUEST_TYPE IS NULL or P_REQUEST_TYPE <> 'S')) then
637 	   req_limit := 'Y';
638 	else
639 	   req_limit := 'N';
640 	end if;
641 
642 	FND_PROFILE.GET ('CONC_STATUS', req_status);
643 	if (req_status = 'HOLD') then
644 	  status := 'A';
645 	elsif (sub_request) then
646 	  status := 'Z';
647 	end if;
648 
649         profile_buffer := NULL;
650         FND_PROFILE.GET('CONC_MULTI_TZ', profile_buffer);
651 
652         if (profile_buffer in ('Y', 'y')) then
653           tz_offset := 1;
654         else
655           tz_offset := 0;
656         end if;
657 
658         profile_buffer := NULL;
659 	if (start_time is null) then
660 	  FND_PROFILE.GET ('CONC_REQ_START', profile_buffer);
661 	else
662 	  profile_buffer := start_time;
663 	end if;
664 
665         if (profile_buffer is not null) then
666           requested_start := fnd_conc_date.string_to_date(profile_buffer);
667           if (requested_start is null) then
668             raise start_time_error;
669           end if;
670         else
671           requested_start := null;
672         end if;
673 
674 
675         -- Someone specified a schedule to use.
676         -- If it is a Specific schedule, figure out the correct start date to use.
677         -- If it is a Periodic schedule, populate the correct fields in FND_CONCURRENT_REQUESTS.
678         if (P_USES_REL_CLASS = 1) then
679           begin
680             select class_type, class_info, date1, date2
681             into   schedule_type, schedule_info, sch_req_date, sch_end_date
682             from   fnd_conc_release_classes
683             where  application_id = P_REL_CLASS_APP_ID
684             and    release_class_id = P_REL_CLASS_ID;
685 
686             if schedule_type = 'S' then
687               -- subtract 1 from sch_req_date to account for the possibility that the
688               -- schedule may need to run on sch_req_date.
689               requested_start := fnd_conc_release_class_utils.calc_specific_startdate(sch_req_date - 1, schedule_info);
690 
691               if requested_start > sch_end_date then
692                 raise start_time_error;
693               end if;
694               P_REPEAT_END := sch_end_date;
695 
696             elsif schedule_type = 'P' then
697               fnd_conc_release_class_utils.parse_periodic_schedule(P_REL_CLASS_APP_ID, P_REL_CLASS_ID,
698                                                                    P_REPEAT_INTERVAL,
699                                                                    P_REPEAT_INTERVAL_UNIT,
700                                                                    P_REPEAT_INTERVAL_TYPE,
701                                                                    sch_req_date,
702 								   P_REPEAT_END);
703 
704 
705                if sch_req_date > sch_end_date then
706                  raise start_time_error;
707                end if;
708 
709                requested_start := sch_req_date;
710             end if;
711 
712           exception
713             when no_data_found then
714               requested_start := null;
715 
716           end;
717         end if;
718 
719         if (P_NODE_NAME1 is NULL) then
720          begin
721            select fcpoi.node_name1
722              into P_NODE_NAME1
723              from fnd_conc_prog_onsite_info fcpoi,
724                   fnd_concurrent_programs fcp,
725                   fnd_application fa
726             where fcp.application_id = fcpoi.program_application_id
727               and fcp.concurrent_program_id = fcpoi.concurrent_program_id
728               and fa.application_id = fcp.application_id
729               and fcp.concurrent_program_name = upper(program)
730               and fa.application_short_name = upper(application);
731          exception
732           when no_data_found then
733             P_NODE_NAME1 := null;
734          end;
735         end if;
736 
737         if (P_CONNSTR1 is NULL) then
738          begin
739            select fcpoi.connstr1
740              into P_CONNSTR1
741              from fnd_conc_prog_onsite_info fcpoi,
742                   fnd_concurrent_programs fcp,
743                   fnd_application fa
744             where fcp.application_id = fcpoi.program_application_id
745               and fcp.concurrent_program_id = fcpoi.concurrent_program_id
746               and fa.application_id = fcp.application_id
747               and fcp.concurrent_program_name = upper(program)
748               and fa.application_short_name = upper(application);
749          exception
750           when no_data_found then
751             P_CONNSTR1 := null;
752          end;
753         end if;
754 
755 	if (P_PRINT_TOGETHER is NULL) then
756 	  FND_PROFILE.GET ('CONC_PRINT_TOGETHER', profile_buffer);
757 	  if (substr (profile_buffer, 1, 1) = 'Y') then
758 	    P_PRINT_TOGETHER := 'Y';
759 	  else
760 	    P_PRINT_TOGETHER := 'N';
761 	  end if;
762 	end if;
763 
764 	if (sub_request) then
765 	  issubreq := 'Y';
766 	end if;
767 
768 	-- Default NLS language
769 	if (P_LANGUAGE is NULL) then
770 	  begin
771             select substr(userenv('LANGUAGE'),1,
772               instr(userenv('LANGUAGE'), '_') -1)
773               into P_LANGUAGE
774               from dual;
775 
776 	    exception
777 	      when no_data_found then
778 		raise nls_error;
779 	      when others then
780 		raise;
781 	  end;
782 	end if;
783 
784     	  -- modified by ddhulla to check if the language passed by user is valid language
785 	  -- if the language specified is invalid raise nls_error
786 	  begin
787 
788 		Select count(*) into lang_exists from FND_LANGUAGES L
789 		where NLS_LANGUAGE = P_LANGUAGE and
790 		L.INSTALLED_FLAG in ('I', 'B');
791 
792 		if ( lang_exists = 0 ) then
793 		   raise nls_error;
794 		end if;
795 	  end;
796 
797 	-- Default NLS territory
798 	if (P_TERRITORY is NULL) then
799 	  begin
800 	    select substr ( userenv('LANGUAGE') ,
801 			   instr ( userenv('LANGUAGE') , '_') + 1,
802 			   (instr ( userenv('LANGUAGE') , '.') - 1 -
803                             instr ( userenv('LANGUAGE') , '_') ))
804 	      into P_TERRITORY
805 	      from dual;
806 
807 	    exception
808 	      when no_data_found then
809 		raise nls_error;
810 	      when others then
811 		raise;
812 	  end;
813 	end if;
814 
815 	-- modified by ddhulla to check if the language passed by user is valid language
816 	begin
817 
818 		Select count(*) into lang_exists from FND_LANGUAGES L
819 		where NLS_LANGUAGE = P_LANGUAGE and
820 		L.INSTALLED_FLAG in ('I', 'B');
821 
822 		if ( lang_exists = 0 ) then
823 		   raise nls_error;
824 		end if;
825 	end;
826 
827         -- TAKE THIS OUT after testing
828 	-- NLS Project : Default NLS Numeric Characters
829         -- VENKAT: indicates we want it to be NULL to start and it will be set
830         --         by the Terrirtory default.
831 	-- if (P_NUMERIC_CHARACTERS is NULL) then
832         --   fnd_profile.get('ICX_NUMERIC_CHARACTERS', P_NUMERIC_CHARACTERS);
833 	-- end if;
834 
835 	-- Get program's application ID, Concurrent Program Id, cd_param, Printer, Print Style,
836 	-- Get program's application ID, Concurrent Program Id, cd_param, Printer, Print Style,
837 	-- Save output flag, priority, submit ops id, request set flag
838 	-- and Allow Multiple Pending Request Flag
839 	begin
840 	  Select A.Application_ID, Concurrent_Program_Id, CD_Parameter,
841 		 Printer_Name, NVL(Output_Print_Style, 'PORTRAIT'),
842 		 Required_Style, Minimum_Width,  Minimum_Length,
843 		 Execution_Method_Code, Save_Output_Flag, Print_Flag,
844 		 Queue_Control_Flag, request_priority, request_set_flag,
845 		 DECODE(ops_req_mode,
846     'EXPLICIT', NVL(P_OPS_ID,NVL(P.instance_id,fnd_conc_global.ops_inst_num)),
847 		-1), NVL(Refresh_Portlet, 'N'), NVL(Allow_Multiple_Pending_Request,'Y')
848             Into prog_appl_id, conc_prog_id, cd_param,
849 		 fcp_printer, print_style, reqrd_flag, minwid,
850 		 minlen, execcode, saveout, prtflg,
851 		 qctlflg, program_priority, request_set_flag,
852 		 submit_ops_id, portlet_ref, mult_pending_req
853             From Fnd_Concurrent_Programs P, Fnd_Application A
854            Where Upper(Concurrent_Program_Name)      = upper(program)
855 		 And P.Application_ID                = A.Application_ID
856 		 And Upper(A.Application_Short_Name) = upper(application);
857 
858 	  exception
859 	    when no_data_found then
860 	      raise appl_prog_error;
861 	    when others then
862 	      raise;
863 	end;
864 
865 
866 	-- check if multiple pending requests are allowed.
867 	if (mult_pending_req = 'N') then
868 	-- see if there are some pending requests for this concurrent program
869         -- definition of pending: phase_code in P and hold_flag in N and
870         -- requested_start_date lessthan sysdate
871 	begin
872           select count(*) into no_pending_req
873 	    from fnd_concurrent_requests
874            where program_application_id = prog_appl_id
875 	         And concurrent_program_id = conc_prog_id
876                  And phase_code = 'P'
877                  and hold_flag='N' and requested_start_date <= sysdate;
878 
879           exception
880             when others then
881               raise;
882           end;
883 	end if;
884 
885 	-- there are some pending requests
886 	if (no_pending_req <> 0) then
887 		raise mult_pending_request_error;
888 	end if;
889 
890 
891         -- dishonour request set and stage priority bug #4172967
892 	if ((P_REQUEST_TYPE = 'M') OR (P_REQUEST_TYPE = 'S')) then
893 		program_priority := NULL;
894 	end if;
895 
896 
897         if (request_set_flag = 'Y') then
898           program_priority := get_request_set_priority(
899                                     to_number(argument1),
900                                     to_number(argument2));
901         end if;
902 
903         if (program_priority is null) then
904 	  profile_buffer := NULL;
905 	  FND_PROFILE.GET ('CONC_PRIORITY', profile_buffer);
906 	  priority := to_number(profile_buffer);
907         else
908           priority := program_priority;
909         end if;
910 
911 	-- Set save output flag.  First look for the token.  Then in FCP,
912 	-- profiles, and lastly set it to Y
913 
914 	if (P_SAVE_OUTPUT in ('Y', 'N')) then
915 	  saveout := P_SAVE_OUTPUT;
916 	else
917 	  if (not saveout in ('Y', 'N')) then
918 	    FND_PROFILE.GET ('CONC_SAVE_OUTPUT', profile_buffer);
919 	    if (not profile_buffer in ('Y', 'N')) then
920 	      saveout := 'Y';
921 	    else
922 	      saveout := profile_buffer;
923 	    end if;
924 	  end if;
925 	end if;
926 
927 
928 	-- Printer logic
929 
930 	-- Get default for # of copies
931 	FND_PROFILE.GET ('CONC_COPIES', profile_buffer);
932         if (profile_buffer is not null) then
933 	  default_copies := To_Number (profile_buffer);
934 	  if (default_copies < 0) then
935 	    default_copies := 0;
936 	  end if;
937         else
938           default_copies := 0;
939         end if;
940 
941 	-- Is printer specified in FCP?
942 	if (fcp_printer is null) then
943 	  FND_PROFILE.GET ('PRINTER', default_printer);
944         else
945           default_printer := fcp_printer;
946 	end if;
947 
948 	-- If style is passed as an argument, use it only if style is
949 	-- not required in FCP (fcp.required_style = 'N').
950         if ((reqrd_flag <> 'Y') and (P_PRINT_STYLE is not null)) then
951 	  print_style := P_PRINT_STYLE;
952 	end if;
953 
954         -- Get ready for loop.  If no printers were specified, then
955         -- we need to set up a default printer if the default copies > 0.
956         if ((P_PRINTER_COUNT = 0) and (default_copies >= 0)) then
957           P_PRINTERS(1).printer := default_printer;
958           P_PRINTERS(1).copies := default_copies;
959           P_PRINTER_COUNT := 1;
960         end if;
961 
962         -- Printer Loop
963         for i in 1..P_PRINTER_COUNT loop
964 
965           curr_printer := P_PRINTERS(i).printer;
966           curr_copies  := P_PRINTERS(i).copies;
967 
968           if (curr_copies is null) then
969             curr_copies := default_copies;
970           end if;
971 
972           if (curr_copies >= 0) then
973             tot_copies := tot_copies + curr_copies;
974 
975             if (curr_printer is null) then
976               curr_printer := default_printer;
977             end if;
978 
979   	    -- Printer validation
980 	    -- Validate the printer only if we are going to print, which is,
981 	    -- if the number of copies is > 0, print = Yes, and it is not
982 	    -- a queue control request (e.g. Deactivate Concurrent Manager).
983 	    if ((prtflg = 'Y') and (qctlflg <> 'Y')) then
984 	      -- Error if printer is not specified.
985               if (curr_printer is null) then
986 	        raise printer_error;
987 	      end if;
988 
989               -- If printer is specified in FCP and also passed as an
990               -- argument, but they don't match, check
991               -- P_VALIDATE_PRINTER
992               if ((fcp_printer is not null) and (curr_printer <> fcp_printer)) then
993                    if (P_VALIDATE_PRINTER = 'FAIL') then
994                       raise printer_error;
995                    elsif (P_VALIDATE_PRINTER = 'SKIP') then
996                       if (FND_LOG.LEVEL_EVENT >=
997                               FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
998                         fnd_message.set_name('FND','CONC-Illegal printer spec');
999                         fnd_log.message(FND_LOG.LEVEL_EVENT,
1000                             'fnd.plsql.FND_REQUEST.SUBMIT.printer', FALSE);
1001                       end if;
1002                       GOTO next_iteration;
1003                    else -- P_VALIDATE_PRINTER = 'RESOLVE'
1004                       if (FND_LOG.LEVEL_EVENT >=
1005                               FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
1006                            fnd_message.set_name ('FND',
1007                                                  'CONC-Illegal printer spec');
1008                            fnd_log.message(FND_LOG.LEVEL_EVENT,
1009                                'fnd.plsql.FND_REQUEST.SUBMIT.printer', FALSE);
1010                            fnd_log.string(FND_LOG.LEVEL_EVENT,
1011                               'fnd.plsql.FND_REQUEST.SUBMIT.printer',
1012                               'Invalid printer('||curr_printer||
1013                               ') specified for program(' ||program||
1014                               '). Attempting to resolve by using printer: '
1015                               ||fcp_printer );
1016                       end if;
1017                       curr_printer := fcp_printer;
1018                    end if;
1019               end if; -- curr_printer <> fcp_printer
1020 
1021 	    end if; -- prtflg = 'Y' and qctlflg <> 'Y'
1022 
1023   	    -- Print style logic
1024 
1025 	    -- Print style validation
1026 
1027 	    if ((prtflg = 'Y') and (print_style is null))
1028             then
1029               raise style_error;
1030             end if;
1031 
1032 	    -- We do not need to validate print style if it's a queue
1033 	    -- control request or if the the style is DYNAMIC
1034 	    if ((qctlflg <> 'Y') and (print_style <> 'DYNAMIC')) then
1035 	      styl_ok := fnd_print.get_style (print_style,
1036 					  minwid, maxwid, minlen, maxlen,
1037 					  (reqrd_flag = 'Y'), curr_printer,
1038 					  valid_style);
1039 
1040 	      -- If printer and print_style were incompatible, valid_style
1041 	      -- is null.  Also check to see if fnd_printer.get_style failed.
1042 	      if ((valid_style is null) or (not styl_ok)) then
1043 
1044 	        -- If we still intend to print, bad news.
1045 	        if (prtflg = 'Y') then
1046 
1047                   -- Check for message on stack
1048                   encoded_msg := FND_MESSAGE.GET_ENCODED;
1049                   if (encoded_msg is not null) then
1050                      FND_MESSAGE.SET_ENCODED(encoded_msg);
1051                      raise already_msg;
1052                   end if;
1053 
1054 	          raise printer_styl_error;
1055 
1056 	        end if; -- ((curr_copies > 0) and (prtflg = 'Y'))
1057 	      end if; -- ((valid_style is null) or (not styl_ok))
1058 	    end if; -- ((qctlflg <> 'Y') and (print_style <> 'DYNAMIC'))
1059 
1060             -- insert the action
1061             -- (don't print on failure, print on warning only if
1062             --  CONC_PRINT_WARNING is set to 'Y')
1063 
1064 	    profile_buffer := NULL;
1065 	    FND_PROFILE.GET ('CONC_PRINT_WARNING', profile_buffer);
1066             if (profile_buffer is not null and
1067                 profile_buffer in ('y', 'Y')) then
1068                 print_warning := 'Y';
1069             end if;
1070 
1071 
1072             insert into fnd_conc_pp_actions
1073                (concurrent_request_id, action_type, status_s_flag,
1074                 status_w_flag, status_f_flag, last_update_date,
1075                 last_updated_by, creation_date, last_update_login,
1076                 created_by, arguments, completed, number_of_copies,
1077                 sequence,ops_instance)
1078             values
1079                 (cur_request_id, 1, 'Y', print_warning, 'N', sysdate,
1080                 user_id, sysdate, fgloginid, user_id, curr_printer,
1081                 'N', curr_copies, i, submit_ops_id);
1082 
1083           end if; -- Curr_copies > 0
1084          <<next_iteration>>  --Go to next loop iteration
1085          null;
1086 
1087         end loop;
1088 
1089         -- The first printer in the list will be written into
1090         -- fcr.  Reports might use it.  Product teams might also
1091         -- depend on the printer profile in their requests.
1092         -- bug 2872883 use default settings when the field is null
1093         if (P_PRINTER_COUNT > 0) then
1094            if ( P_PRINTERS(1).printer is null) then
1095              fcr_printer := default_printer;
1096            else
1097              fcr_printer := P_PRINTERS(1).printer;
1098            end if;
1099         else
1100           fcr_printer := fcp_printer;
1101         end if;
1102 
1103         -- Even if we aren't going to print, we'll populate
1104         -- the style.  Styles are required by Oracle Reports.
1105         if (valid_style is null) then
1106 	  -- if it's an Oracle Reports request, we must get
1107 	  -- some (valid) print style
1108 	  if (execcode = 'P') then
1109 	    styl_ok := fnd_print.get_style (print_style,
1110 				            minwid, maxwid,
1111 					    minlen, maxlen,
1112 					    (reqrd_flag = 'Y'),
1113 					    null,
1114 					    valid_style);
1115 
1116 	    if ((valid_style is null) or (not styl_ok)) then
1117               -- Check for message on stack
1118               encoded_msg := FND_MESSAGE.GET_ENCODED;
1119               if (encoded_msg is not null) then
1120                  FND_MESSAGE.SET_ENCODED(encoded_msg);
1121                  raise already_msg;
1122               end if;
1123 
1124               raise srw_style_error;
1125             end if;
1126           else  -- No need to validate style
1127             valid_style := print_style;
1128 	  end if; -- (execcode = 'P')
1129         end if; -- (valid_style is null)
1130 
1131 
1132         -- Insert Notifications
1133 
1134         for i in 1..P_NOTIFICATION_COUNT loop
1135           insert into fnd_conc_pp_actions
1136              (concurrent_request_id, action_type, status_s_flag,
1137               status_w_flag, status_f_flag, last_update_date,
1138               last_updated_by, creation_date, last_update_login,
1139               created_by, arguments, completed, number_of_copies,
1140               sequence, orig_system, orig_system_id, ops_instance)
1141           values
1142               (cur_request_id, 2,
1143                P_NOTIFICATIONS(i).on_normal,
1144                P_NOTIFICATIONS(i).on_warning,
1145                P_NOTIFICATIONS(i).on_error, sysdate,
1146               user_id, sysdate, fgloginid, user_id,
1147               P_NOTIFICATIONS(i).name, 'N', null, i,
1148 	      P_NOTIFICATIONS(i).orig_system,
1149 	      P_NOTIFICATIONS(i).orig_system_id,
1150 	      submit_ops_id);
1151         end loop;
1152 
1153         -- Insert layout options
1154         if (P_TEMPLATE_CODE is not null) then
1155 
1156            insert into fnd_conc_pp_actions
1157               (concurrent_request_id, action_type, status_s_flag,
1158                status_w_flag, status_f_flag, last_update_date,
1159                last_updated_by, creation_date, last_update_login,
1160                created_by, completed, sequence, argument1, argument2,
1161                argument3, argument4, argument5, ops_instance)
1162             values
1163                (cur_request_id, 6, 'Y','Y','Y',
1164                 sysdate, user_id, sysdate, fgloginid, user_id, 'N', 1,
1165                 P_TEMPLATE_APPL, P_TEMPLATE_CODE, P_TEMPLATE_LANG,
1166 		P_TEMPLATE_TERRITORY, P_OUTPUT_FORMAT, submit_ops_id);
1167 
1168         end if;
1169 
1170 	-- Get Oracle ID to run program from
1171 	begin
1172 	  -- First, see if datagroup is set with options
1173 	  if (P_DATAGROUP is not null) then
1174 	    Select Oracle_Username
1175 	      Into oraclacct
1176 	      From Fnd_Data_Group_Units U,
1177 		   Fnd_Data_Groups G,
1178 		   Fnd_Oracle_Userid O
1179 	     Where Data_Group_Name = P_DATAGROUP
1180 	       And U.Data_Group_Id = G.Data_Group_Id
1181 	       And U.Oracle_Id     = O.Oracle_Id
1182 	       And Application_Id  = prog_appl_id;
1183 
1184 	  else -- default dgrp
1185 	    Select O.Oracle_Username
1186 	      Into oraclacct
1187 	      From Fnd_Data_Group_Units U,
1188 		   Fnd_Responsibility R,
1189 		   Fnd_Oracle_Userid O
1190 	     Where R.Application_ID        = resp_appl_id
1191 		   And R.Responsibility_ID = resp_id
1192 		   And R.Data_Group_ID     = U.Data_Group_ID
1193 		   And O.Oracle_ID         = U.Oracle_ID
1194 		   And U.Application_ID    = prog_appl_id;
1195 	  end if;
1196 
1197 	  exception
1198 	    when no_data_found then
1199 	      raise oracle_name_error;
1200 	    when others then
1201 	      raise;
1202 	end;
1203 
1204 	-- Fetch Login ID for the request from the sequnce generator.
1205 	-- Insert the record in Fnd_Logins if the request submission
1206 	-- successful.
1207 	begin
1208 	  Select Fnd_Logins_S.nextval
1209 	    Into loginid
1210 	    From Sys.Dual;
1211 
1212 	  exception
1213 	    when no_data_found then
1214 	      raise dual_no_rows;
1215 	    when too_many_rows then
1216 	      raise dual_too_many_rows;
1217 	    when others then
1218 	      raise;
1219 	end;
1220 
1221 	-- Count the number of arguments and bulid argstr
1222 	if (argument1 = CHR(0)) then goto end_args; end if;
1223 	nargs := 1;
1224 	argtxt := argtxt||argument1;
1225 	if (argument2 = CHR(0)) then goto end_args; end if;
1226 	nargs := 2;
1227 	argtxt := argtxt|| ', '||argument2;
1228 	if (argument3 = CHR(0)) then goto end_args; end if;
1229 	nargs := 3;
1230 	argtxt := argtxt|| ', '||argument3;
1231 	if (argument4 = CHR(0)) then goto end_args; end if;
1232 	nargs := 4;
1233 	argtxt := argtxt||', '||argument4;
1234 	if (argument5 = CHR(0)) then goto end_args; end if;
1235 	nargs := 5;
1236 	argtxt := argtxt||', '||argument5;
1237 	if (argument6 = CHR(0)) then goto end_args; end if;
1238 	nargs := 6;
1239 	argtxt := argtxt||', '||argument6;
1240 	if (argument7 = CHR(0)) then goto end_args; end if;
1241 	nargs := 7;
1242 	argtxt := argtxt||', '||argument7;
1243 	if (argument8 = CHR(0)) then goto end_args; end if;
1244 	nargs := 8;
1245 	argtxt := argtxt||', '||argument8;
1246 	if (argument9 = CHR(0)) then goto end_args; end if;
1247 	nargs := 9;
1248 	argtxt := argtxt||', '||argument9;
1249 	if (argument10 = CHR(0)) then goto end_args; end if;
1250 	nargs := 10;
1251 	argtxt := argtxt||', '||argument10;
1252 	if (argument11 = CHR(0)) then goto end_args; end if;
1253 	nargs := 11;
1254 	argtxt := argtxt||', '||argument11;
1255 	if (argument12 = CHR(0)) then goto end_args; end if;
1256 	nargs := 12;
1257 	argtxt := argtxt||', '||argument12;
1258 	if (argument13 = CHR(0)) then goto end_args; end if;
1259 	nargs := 13;
1260 	argtxt := argtxt||', '||argument13;
1261 	if (argument14 = CHR(0)) then goto end_args; end if;
1262 	nargs := 14;
1263 	argtxt := argtxt||', '||argument14;
1264 	if (argument15 = CHR(0)) then goto end_args; end if;
1265 	nargs := 15;
1266 	argtxt := argtxt||', '||argument15;
1267 	if (argument16 = CHR(0)) then goto end_args; end if;
1268 	nargs := 16;
1269 	argtxt := argtxt||', '||argument16;
1270 	if (argument17 = CHR(0)) then goto end_args; end if;
1271 	nargs := 17;
1272 	argtxt := argtxt||', '||argument17;
1273 	if (argument18 = CHR(0)) then goto end_args; end if;
1274 	nargs := 18;
1275 	argtxt := argtxt||', '||argument18;
1276 	if (argument19 = CHR(0)) then goto end_args; end if;
1277 	nargs := 19;
1278 	argtxt := argtxt||', '||argument19;
1279 	if (argument20 = CHR(0)) then goto end_args; end if;
1280 	nargs := 20;
1281 	argtxt := argtxt||', '||argument20;
1282 	if (argument21 = CHR(0)) then goto end_args; end if;
1283 	nargs := 21;
1284 	argtxt := argtxt||', '||argument21;
1285 	if (argument22 = CHR(0)) then goto end_args; end if;
1286 	nargs := 22;
1287 	argtxt := argtxt||', '||argument22;
1288 	if (argument23 = CHR(0)) then goto end_args; end if;
1289 	nargs := 23;
1290 	argtxt := argtxt||', '||argument23;
1291 	if (argument24 = CHR(0)) then goto end_args; end if;
1292 	nargs := 24;
1293 	argtxt := argtxt||', '||argument24;
1294 	if (argument25 = CHR(0)) then goto end_args; end if;
1295 	nargs := 25;
1296 	argtxt := argtxt||', '||argument25;
1297 	if (argument26 = CHR(0)) then goto end_args; end if;
1298 	nargs := 26;
1299 	argtxt := argtxt||', '||argument26;
1300 	if (argument27 = CHR(0)) then goto end_args; end if;
1301 	nargs := 27;
1302 	argtxt := argtxt||', '||argument27;
1303 	if (argument28 = CHR(0)) then goto end_args; end if;
1304 	nargs := 28;
1305 	argtxt := argtxt||', '||argument28;
1306 	if (argument29 = CHR(0)) then goto end_args; end if;
1307 	nargs := 29;
1308 	argtxt := argtxt||', '||argument29;
1309 	if (argument30 = CHR(0)) then goto end_args; end if;
1310 	nargs := 30;
1311 	argtxt := argtxt||', '||argument30;
1312 	if (argument31 = CHR(0)) then goto end_args; end if;
1313 	nargs := 31;
1314 	argtxt := argtxt||', '||argument31;
1315 	if (argument32 = CHR(0)) then goto end_args; end if;
1316 	nargs := 32;
1317 	argtxt := argtxt||', '||argument32;
1318 	if (argument33 = CHR(0)) then goto end_args; end if;
1319 	nargs := 33;
1320 	argtxt := argtxt||', '||argument33;
1321 	if (argument34 = CHR(0)) then goto end_args; end if;
1322 	nargs := 34;
1323 	argtxt := argtxt||', '||argument34;
1324 	if (argument35 = CHR(0)) then goto end_args; end if;
1325 	nargs := 35;
1326 	argtxt := argtxt||', '||argument35;
1327 	if (argument36 = CHR(0)) then goto end_args; end if;
1328 	nargs := 36;
1329 	argtxt := argtxt||', '||argument36;
1330 	if (argument37 = CHR(0)) then goto end_args; end if;
1331 	nargs := 37;
1332 	argtxt := argtxt||', '||argument37;
1333 	if (argument38 = CHR(0)) then goto end_args; end if;
1334 	nargs := 38;
1335 	argtxt := argtxt||', '||argument38;
1336 	if (argument39 = CHR(0)) then goto end_args; end if;
1337 	nargs := 39;
1338 	argtxt := argtxt||', '||argument39;
1339 	if (argument40 = CHR(0)) then goto end_args; end if;
1340 	nargs := 40;
1341 	argtxt := argtxt||', '||argument40;
1342 	if (argument41 = CHR(0)) then goto end_args; end if;
1343 	nargs := 41;
1344 	argtxt := argtxt||', '||argument41;
1345 	if (argument42 = CHR(0)) then goto end_args; end if;
1346 	nargs := 42;
1347 	argtxt := argtxt||', '||argument42;
1348 	if (argument43 = CHR(0)) then goto end_args; end if;
1349 	nargs := 43;
1350 	argtxt := argtxt||', '||argument43;
1351 	if (argument44 = CHR(0)) then goto end_args; end if;
1352 	nargs := 44;
1353 	argtxt := argtxt||', '||argument44;
1354 	if (argument45 = CHR(0)) then goto end_args; end if;
1355 	nargs := 45;
1356 	argtxt := argtxt||', '||argument45;
1357 	if (argument46 = CHR(0)) then goto end_args; end if;
1358 	nargs := 46;
1359 	argtxt := argtxt||', '||argument46;
1360 	if (argument47 = CHR(0)) then goto end_args; end if;
1361 	nargs := 47;
1362 	argtxt := argtxt||', '||argument47;
1363 	if (argument48 = CHR(0)) then goto end_args; end if;
1364 	nargs := 48;
1365 	argtxt := argtxt||', '||argument48;
1366 	if (argument49 = CHR(0)) then goto end_args; end if;
1367 	nargs := 49;
1368 	argtxt := argtxt||', '||argument49;
1369 	if (argument50 = CHR(0)) then goto end_args; end if;
1370 	nargs := 50;
1371 	argtxt := argtxt||', '||argument50;
1372 	if (argument51 = CHR(0)) then goto end_args; end if;
1373 	nargs := 51;
1374 	argtxt := argtxt||', '||argument51;
1375 	if (argument52 = CHR(0)) then goto end_args; end if;
1376 	nargs := 52;
1377 	argtxt := argtxt||', '||argument52;
1378 	if (argument53 = CHR(0)) then goto end_args; end if;
1379 	nargs := 53;
1380 	argtxt := argtxt||', '||argument53;
1381 	if (argument54 = CHR(0)) then goto end_args; end if;
1382 	nargs := 54;
1383 	argtxt := argtxt||', '||argument54;
1384 	if (argument55 = CHR(0)) then goto end_args; end if;
1385 	nargs := 55;
1386 	argtxt := argtxt||', '||argument55;
1387 	if (argument56 = CHR(0)) then goto end_args; end if;
1388 	nargs := 56;
1389 	argtxt := argtxt||', '||argument56;
1390 	if (argument57 = CHR(0)) then goto end_args; end if;
1391 	nargs := 57;
1392 	argtxt := argtxt||', '||argument57;
1393 	if (argument58 = CHR(0)) then goto end_args; end if;
1394 	nargs := 58;
1395 	argtxt := argtxt||', '||argument58;
1396 	if (argument59 = CHR(0)) then goto end_args; end if;
1397 	nargs := 59;
1398 	argtxt := argtxt||', '||argument59;
1399 	if (argument60 = CHR(0)) then goto end_args; end if;
1400 	nargs := 60;
1401 	argtxt := argtxt||', '||argument60;
1402 	if (argument61 = CHR(0)) then goto end_args; end if;
1403 	nargs := 61;
1404 	argtxt := argtxt||', '||argument61;
1405 	if (argument62 = CHR(0)) then goto end_args; end if;
1406 	nargs := 62;
1407 	argtxt := argtxt||', '||argument62;
1408 	if (argument63 = CHR(0)) then goto end_args; end if;
1409 	nargs := 63;
1410 	argtxt := argtxt||', '||argument63;
1411 	if (argument64 = CHR(0)) then goto end_args; end if;
1412 	nargs := 64;
1413 	argtxt := argtxt||', '||argument64;
1414 	if (argument65 = CHR(0)) then goto end_args; end if;
1415 	nargs := 65;
1416 	argtxt := argtxt||', '||argument65;
1417 	if (argument66 = CHR(0)) then goto end_args; end if;
1418 	nargs := 66;
1419 	argtxt := argtxt||', '||argument66;
1420 	if (argument67 = CHR(0)) then goto end_args; end if;
1421 	nargs := 67;
1422 	argtxt := argtxt||', '||argument67;
1423 	if (argument68 = CHR(0)) then goto end_args; end if;
1424 	nargs := 68;
1425 	argtxt := argtxt||', '||argument68;
1426 	if (argument69 = CHR(0)) then goto end_args; end if;
1427 	nargs := 69;
1428 	argtxt := argtxt||', '||argument69;
1429 	if (argument70 = CHR(0)) then goto end_args; end if;
1430 	nargs := 70;
1431 	argtxt := argtxt||', '||argument70;
1432 	if (argument71 = CHR(0)) then goto end_args; end if;
1433 	nargs := 71;
1434 	argtxt := argtxt||', '||argument71;
1435 	if (argument72 = CHR(0)) then goto end_args; end if;
1436 	nargs := 72;
1437 	argtxt := argtxt||', '||argument72;
1438 	if (argument73 = CHR(0)) then goto end_args; end if;
1439 	nargs := 73;
1440 	argtxt := argtxt||', '||argument73;
1441 	if (argument74 = CHR(0)) then goto end_args; end if;
1442 	nargs := 74;
1443 	argtxt := argtxt||', '||argument74;
1444 	if (argument75 = CHR(0)) then goto end_args; end if;
1445 	nargs := 75;
1446 	argtxt := argtxt||', '||argument75;
1447 	if (argument76 = CHR(0)) then goto end_args; end if;
1448 	nargs := 76;
1449 	argtxt := argtxt||', '||argument76;
1450 	if (argument77 = CHR(0)) then goto end_args; end if;
1451 	nargs := 77;
1452 	argtxt := argtxt||', '||argument77;
1453 	if (argument78 = CHR(0)) then goto end_args; end if;
1454 	nargs := 78;
1455 	argtxt := argtxt||', '||argument78;
1456 	if (argument79 = CHR(0)) then goto end_args; end if;
1457 	nargs := 79;
1458 	argtxt := argtxt||', '||argument79;
1459 	if (argument80 = CHR(0)) then goto end_args; end if;
1460 	nargs := 80;
1461 	argtxt := argtxt||', '||argument80;
1462 	if (argument81 = CHR(0)) then goto end_args; end if;
1463 	nargs := 81;
1464 	argtxt := argtxt||', '||argument81;
1465 	if (argument82 = CHR(0)) then goto end_args; end if;
1466 	nargs := 82;
1467 	argtxt := argtxt||', '||argument82;
1468 	if (argument83 = CHR(0)) then goto end_args; end if;
1469 	nargs := 83;
1470 	argtxt := argtxt||', '||argument83;
1471 	if (argument84 = CHR(0)) then goto end_args; end if;
1472 	nargs := 84;
1473 	argtxt := argtxt||', '||argument84;
1474 	if (argument85 = CHR(0)) then goto end_args; end if;
1475 	nargs := 85;
1476 	argtxt := argtxt||', '||argument85;
1477 	if (argument86 = CHR(0)) then goto end_args; end if;
1478 	nargs := 86;
1479 	argtxt := argtxt||', '||argument86;
1480 	if (argument87 = CHR(0)) then goto end_args; end if;
1481 	nargs := 87;
1482 	argtxt := argtxt||', '||argument87;
1483 	if (argument88 = CHR(0)) then goto end_args; end if;
1484 	nargs := 88;
1485 	argtxt := argtxt||', '||argument88;
1486 	if (argument89 = CHR(0)) then goto end_args; end if;
1487 	nargs := 89;
1488 	argtxt := argtxt||', '||argument89;
1489 	if (argument90 = CHR(0)) then goto end_args; end if;
1490 	nargs := 90;
1491 	argtxt := argtxt||', '||argument90;
1492 	if (argument91 = CHR(0)) then goto end_args; end if;
1493 	nargs := 91;
1494 	argtxt := argtxt||', '||argument91;
1495 	if (argument92 = CHR(0)) then goto end_args; end if;
1496 	nargs := 92;
1497 	argtxt := argtxt||', '||argument92;
1498 	if (argument93 = CHR(0)) then goto end_args; end if;
1499 	nargs := 93;
1500 	argtxt := argtxt||', '||argument93;
1501 	if (argument94 = CHR(0)) then goto end_args; end if;
1502 	nargs := 94;
1503 	argtxt := argtxt||', '||argument94;
1504 	if (argument95 = CHR(0)) then goto end_args; end if;
1505 	nargs := 95;
1506 	argtxt := argtxt||', '||argument95;
1507 	if (argument96 = CHR(0)) then goto end_args; end if;
1508 	nargs := 96;
1509 	argtxt := argtxt||', '||argument96;
1510 	if (argument97 = CHR(0)) then goto end_args; end if;
1511 	nargs := 97;
1512 	argtxt := argtxt||', '||argument97;
1513 	if (argument98 = CHR(0)) then goto end_args; end if;
1514 	nargs := 98;
1515 	argtxt := argtxt||', '||argument98;
1516 	if (argument99 = CHR(0)) then goto end_args; end if;
1517 	nargs := 99;
1518 	argtxt := argtxt||', '||argument99;
1519 	if (argument100 = CHR(0)) then goto end_args; end if;
1520 	nargs := 100;
1521 	argtxt := argtxt||', '||argument100;
1522 
1523 	<<end_args>>
1524 
1525 	argtxt2 := substrb(argtxt, 1, 240);
1526 
1527 	-- Get conflicts domain - cd_id
1528 	-- First, try program parameter
1529 	if (cd_param is not null) then
1530 	   cd_id := fndcp_crm.get_cd_id (
1531 			      application, program,
1532 			      user_id, user_id,
1533 			      cd_param, nargs,
1534 			      argument1,  argument2,  argument3,  argument4,
1535 			      argument5,  argument6,  argument7,  argument8,
1536 			      argument9,  argument10, argument11, argument12,
1537 			      argument13, argument14, argument15, argument16,
1538 			      argument17, argument18, argument19, argument20,
1539 			      argument21, argument22, argument23, argument24,
1540 			      argument25, argument26, argument27, argument28,
1541 			      argument29, argument30, argument31, argument32,
1542 			      argument33, argument34, argument35, argument36,
1543 			      argument37, argument38, argument39, argument40,
1544 			      argument41, argument42, argument43, argument44,
1545 			      argument45, argument46, argument47, argument48,
1546 			      argument49, argument50, argument51, argument52,
1547 			      argument53, argument54, argument55, argument56,
1548 			      argument57, argument58, argument59, argument60,
1549 			      argument61, argument62, argument63, argument64,
1550 			      argument65, argument66, argument67, argument68,
1551 			      argument69, argument70, argument71, argument72,
1552 			      argument73, argument74, argument75, argument76,
1553 			      argument77, argument78, argument79, argument80,
1554 			      argument81, argument82, argument83, argument84,
1555 			      argument85, argument86, argument87, argument88,
1556 			      argument89, argument90, argument91, argument92,
1557 			      argument93, argument94, argument95, argument96,
1558 			      argument97, argument98, argument99, argument100);
1559 	end if;
1560 
1561 	-- Next try profile
1562 	if (cd_id = -1) then
1563 	  profile_buffer := NULL;
1564 	  FND_PROFILE.GET ('CONC_CD_ID', profile_buffer);
1565 	  if (profile_buffer is not null) then
1566 	     cd_id := To_Number (profile_buffer);
1567 	  else
1568 	     cd_id := 0;
1569 	  end if;
1570 	end if;
1571 
1572 	-- Create request
1573 	if (P_REL_CLASS_ID is null) and (P_REPEAT_INTERVAL is not null) then
1574 	 new_class := TRUE;
1575 	 begin
1576 	   Select FND_CONC_RELEASE_CLASSES_S.nextval, 0
1577 	     into P_REL_CLASS_ID, P_REL_CLASS_APP_ID from Sys.dual;
1578 	  exception
1579 	    when no_data_found then
1580 	      raise dual_no_rows;
1581 	    when too_many_rows then
1582 	      raise dual_too_many_rows;
1583 	    when others then
1584 	      raise;
1585 	  end;
1586 	end if;
1587 
1588 	Insert
1589 	  Into Fnd_Concurrent_Requests (
1590 		Request_Id, security_group_id,
1591 		Phase_Code, Status_Code,
1592 		Priority, Parent_Request_ID, Priority_Request_ID,
1593 		Description, Req_Information,
1594 		Is_Sub_Request, Has_Sub_Request, Update_Protected,
1595 		Hold_Flag, Enforce_Seriality_Flag, Single_Thread_Flag,
1596 		Argument_Input_Method_Code, Implicit_Code,
1597 
1598 		Request_Date, Requested_Start_Date, Requested_By,
1599 		Last_Update_Date, Last_Updated_By, Last_Update_Login,
1600 
1601 		Oracle_Id, Conc_Login_Id,
1602 		Responsibility_Id, Responsibility_Application_Id,
1603 		Nls_Language, Nls_Territory, Nls_Numeric_Characters,
1604 
1605 		Program_Application_Id, Concurrent_Program_Id,
1606 		Queue_Method_Code,
1607 		Request_Class_Application_Id, Concurrent_Request_Class_Id,
1608 
1609 		Print_Group, Printer, Print_Style,
1610 		Number_Of_Copies, Save_Output_Flag,  CRM_THRSHLD,
1611 
1612 		Resubmit_Time, Resubmit_Interval,
1613 		Resubmit_Interval_Unit_Code, Resubmit_Interval_Type_Code,
1614 		Resubmit_End_Date, Resubmitted, Critical, Request_Type,
1615 
1616                 RELEASE_CLASS_APP_ID, RELEASE_CLASS_ID,
1617 		STALE_DATE, CANCEL_OR_HOLD,
1618 
1619                 Output_File_Type, nls_compliant,
1620 		CD_ID, Request_Limit, Increment_Dates,
1621                 Enable_Trace, OPS_Instance, ORG_ID,
1622                 Node_Name1, Connstr1,
1623 
1624 		Argument_Text, Number_Of_Arguments,
1625 		Argument1,  Argument2,  Argument3,  Argument4,  Argument5,
1626 		Argument6,  Argument7,  Argument8,  Argument9,  Argument10,
1627 		Argument11, Argument12, Argument13, Argument14, Argument15,
1628 		Argument16, Argument17, Argument18, Argument19, Argument20,
1629 		Argument21, Argument22, Argument23, Argument24, Argument25)
1630 
1631 	Select cur_request_id, z_security_group_id,
1632 	       Phase, Decode (submit.Status,
1633 			      'A', 'A',
1634 			      'Z', 'Z',
1635                                    Decode(FCP.Queue_Method_Code,
1636                                           'B', 'Q',
1637                                            Decode (st_flag,
1638                                                     'Y', 'Q',
1639 						Decode(Req_Limit, 'Y', 'Q',
1640                                                                    'I')))),
1641 	       Decode (FCP.Queue_Control_Flag,
1642 		       'Y', NVL(FCP.Request_Priority, 0),
1643 			    Decode (submit.priority,
1644 				    null, 50,
1645 					  submit.priority)),
1646 	       Decode (par_request_id,
1647 		       0, NULL,
1648 			  par_request_id),
1649 	       cur_req_pri_id,
1650 	       submit.description, NULL,
1651 	       issubreq, 'N', P_PROTECTED,
1652 	       submit.hold_flag, 'Y', st_flag,
1653 	       'S', P_IMPLICIT,
1654 
1655 	       SYSDATE,
1656 	       Decode (requested_start,
1657 		       '', (SYSDATE - tz_offset),
1658 			   Greatest (requested_start,
1659 			  	     Decode (par_request_id,
1660 					     0, (SYSDATE - tz_offset),
1661 						fnd_conc_date.string_to_date (
1662                                                          '01-01-0001')))),
1663 	       submit.user_id,
1664 	       SYSDATE, submit.user_id, loginid,
1665 
1666 	       Oracle_ID, loginid,
1667 	       resp_id, resp_appl_id,
1668 	       P_LANGUAGE, P_TERRITORY, P_NUMERIC_CHARACTERS,
1669 
1670 	       FA.Application_ID, FCP.Concurrent_Program_ID,
1671 	       Decode(Req_Limit,
1672 		      'Y', 'B',
1673 		      Decode(st_flag,
1674 		             'N', FCP.Queue_Method_Code,
1675 			      'B')),
1676 	       FCP.Class_Application_ID, FCP.Concurrent_Class_ID,
1677 
1678 	       P_PRINT_TOGETHER, fcr_printer, valid_style,
1679 	       tot_copies, saveout, request_threshold,
1680 	       Decode (P_REPEAT_TIME,
1681 		       '', NULL,
1682 			   To_Char (fnd_conc_date.string_to_date (
1683                                         '01-01-0001' || P_REPEAT_TIME),
1684 					      'HH24:MI:SS')),
1685 	       Decode (P_REPEAT_INTERVAL,
1686 		       '', NULL,
1687 			   P_REPEAT_INTERVAL),
1688 	       P_REPEAT_INTERVAL_UNIT, P_REPEAT_INTERVAL_TYPE,
1689 	       P_REPEAT_END,
1690 	       'N', P_CRITICAL_REQUEST, P_REQUEST_TYPE,
1691 
1692 	       P_REL_CLASS_APP_ID, P_REL_CLASS_ID,
1693 	       P_REL_STALE_DATE, P_REL_CANCEL_OR_HOLD,
1694 
1695                FCP.Output_File_Type,  FCP.nls_compliant,
1696  	       CD_ID, Req_limit, P_INCREMENT_DATES,
1697                decode(trace_enabled, 'Y', 'Y', FCP.Enable_Trace),
1698                submit_ops_id, P_ORG_ID,
1699                P_NODE_NAME1, P_CONNSTR1,
1700 	       argtxt2, nargs,
1701 	       submit.argument1,  submit.argument2,
1702 	       submit.argument3,  submit.argument4,
1703 	       submit.argument5,  submit.argument6,
1704 	       submit.argument7,  submit.argument8,
1705 	       submit.argument9,  submit.argument10,
1706 	       submit.argument11, submit.argument12,
1707 	       submit.argument13, submit.argument14,
1708 	       submit.argument15, submit.argument16,
1709 	       submit.argument17, submit.argument18,
1710 	       submit.argument19, submit.argument20,
1711 	       submit.argument21, submit.argument22,
1712 	       submit.argument23, submit.argument24,
1713 	       submit.argument25
1714 
1715 	  From Fnd_Application FA,
1716 	       Fnd_Concurrent_Programs FCP,
1717 	       Fnd_Oracle_Userid
1718 	 Where
1719 	       Oracle_Username  = oraclacct
1720 	   And FCP.Enabled_Flag = 'Y'
1721 	   And (FCP.Application_ID = FA.Application_ID And
1722 		Concurrent_Program_Name   = Upper (program))
1723 	   And  FA.Application_Short_Name = Upper (application);
1724 
1725 	if (sql%rowcount = 0) then
1726 	  raise insert_error;
1727 	end if;
1728 
1729 	if (nargs > 25) then
1730 	  Insert
1731 	    Into Fnd_Conc_Request_Arguments (
1732 		Request_Id,
1733 		Argument26, Argument27, Argument28, Argument29, Argument30,
1734 		Argument31, Argument32, Argument33, Argument34, Argument35,
1735 		Argument36, Argument37, Argument38, Argument39, Argument40,
1736 		Argument41, Argument42, Argument43, Argument44, Argument45,
1737 		Argument46, Argument47, Argument48, Argument49, Argument50,
1738 		Argument51, Argument52, Argument53, Argument54, Argument55,
1739 		Argument56, Argument57, Argument58, Argument59, Argument60,
1740 		Argument61, Argument62, Argument63, Argument64, Argument65,
1741 		Argument66, Argument67, Argument68, Argument69, Argument70,
1742 		Argument71, Argument72, Argument73, Argument74, Argument75,
1743 		Argument76, Argument77, Argument78, Argument79, Argument80,
1744 		Argument81, Argument82, Argument83, Argument84, Argument85,
1745 		Argument86, Argument87, Argument88, Argument89, Argument90,
1746 		Argument91, Argument92, Argument93, Argument94, Argument95,
1747 		Argument96, Argument97, Argument98, Argument99, Argument100)
1748 
1749 	  Select cur_request_id,
1750 		submit.argument26,
1751 		submit.argument27, submit.argument28,
1752 		submit.argument29, submit.argument30,
1753 		submit.argument31, submit.argument32,
1754 		submit.argument33, submit.argument34,
1755 		submit.argument35, submit.argument36,
1756 		submit.argument37, submit.argument38,
1757 		submit.argument39, submit.argument40,
1758 		submit.argument41, submit.argument42,
1759 		submit.argument43, submit.argument44,
1760 		submit.argument45, submit.argument46,
1761 		submit.argument47, submit.argument48,
1762 		submit.argument49, submit.argument50,
1763 		submit.argument51, submit.argument52,
1764 		submit.argument53, submit.argument54,
1765 		submit.argument55, submit.argument56,
1766 		submit.argument57, submit.argument58,
1767 		submit.argument59, submit.argument60,
1768 		submit.argument61, submit.argument62,
1769 		submit.argument63, submit.argument64,
1770 		submit.argument65, submit.argument66,
1771 		submit.argument67, submit.argument68,
1772 		submit.argument69, submit.argument70,
1773 		submit.argument71, submit.argument72,
1774 		submit.argument73, submit.argument74,
1775 		submit.argument75, submit.argument76,
1776 		submit.argument77, submit.argument78,
1777 		submit.argument79, submit.argument80,
1778 		submit.argument81, submit.argument82,
1779 		submit.argument83, submit.argument84,
1780 		submit.argument85, submit.argument86,
1781 		submit.argument87, submit.argument88,
1782 		submit.argument89, submit.argument90,
1783 		submit.argument91, submit.argument92,
1784 		submit.argument93, submit.argument94,
1785 		submit.argument95, submit.argument96,
1786 		submit.argument97, submit.argument98,
1787 		submit.argument99, submit.argument100
1788 
1789 	    From Sys.Dual;
1790 	end if; -- (nargs > 25)
1791 
1792 	if (sql%rowcount = 0) then
1793 	  raise args_insert_error;
1794 	end if;
1795 
1796         -- assign any Post Processing PL/SQL actions
1797         Begin
1798            if ( portlet_ref = 'S' ) then  -- on success
1799               p_on_success := 'Y';
1800            elsif ( portlet_ref = 'W' ) then  -- on warning (success and warning)
1801               p_on_success := 'Y';
1802               p_on_warning := 'Y';
1803            elsif (portlet_ref = 'A' ) then  -- always (success,warning,error)
1804               p_on_success := 'Y';
1805               p_on_warning := 'Y';
1806               p_on_error   := 'Y';
1807            end if;
1808 
1809            if ( portlet_ref <> 'N' ) then
1810               pp_plsql_step := FND_CONC_PP.Assign('FND',
1811                                  'FNDPRUPD',
1812                                  cur_request_id,
1813                                  p_on_success, p_on_warning, p_on_error,
1814                                  null, null, null, null, null,
1815                                  null, null, null, null, null );
1816               if ( pp_plsql_step < 0 ) then
1817                 raise pp_plsql_exception;
1818               end if;
1819            end if;
1820 
1821            -- as safe side catching this exception for any fnd_conc_pp.assign
1822            -- call exception
1823            exception when others then
1824               raise pp_plsql_exception;
1825         end;
1826 
1827 	-- Insert into fnd_conc_rel_classes
1828 	if (P_REPEAT_TIME is not NULL) then
1829 	   P_REPEAT_INTERVAL := 1;
1830 	   P_REPEAT_INTERVAL_UNIT := 'DAYS';
1831 	   P_REPEAT_INTERVAL_TYPE := 'START';
1832 	end if;
1833 
1834 
1835 	if (new_class) then
1836 	  begin
1837             INSERT INTO Fnd_Conc_Release_Classes
1838             (APPLICATION_ID,     RELEASE_CLASS_ID,
1839              RELEASE_CLASS_NAME, OWNER_REQ_ID,
1840              ENABLED_FLAG,       LAST_UPDATE_DATE,
1841              LAST_UPDATED_BY,    LAST_UPDATE_LOGIN,
1842              CREATION_DATE,      CREATED_BY,
1843              UPDATED_FLAG,       CLASS_TYPE,
1844              CLASS_INFO,         START_DATE_ACTIVE,
1845              END_DATE_ACTIVE,    DATE1, DATE2)
1846                 Select 0, P_REL_CLASS_ID,
1847                         'Request - '|| cur_request_id, cur_request_id,
1848                         'Y',     Sysdate,
1849                         submit.user_id, loginid,
1850                         Sysdate,   submit.user_id,
1851                         'Y', decode(P_REPEAT_INTERVAL, NULL, 'O', 'P'),
1852                        Decode(P_REPEAT_INTERVAL_UNIT, NULL, NULL,
1853                               P_REPEAT_INTERVAL||':'||
1854                                  Decode(P_REPEAT_INTERVAL_UNIT,
1855 						  'MINUTES', 'N',
1856                                                   'MONTHS', 'M',
1857                                                   'HOURS', 'H',
1858                                                   'DAYS',  'D') || ':' ||
1859                                      Decode(P_REPEAT_INTERVAL_TYPE,
1860 						  'START', 'S', 'C')),
1861                        null, null,
1862                        Requested_start_date, resubmit_end_date
1863                    From Fnd_Concurrent_Requests
1864                   Where Request_ID = cur_request_id;
1865 
1866 	    if (sql%rowcount = 0) then
1867 	      raise relclass_insert_error;
1868 	    end if;
1869 
1870             INSERT INTO Fnd_Conc_Release_Classes_TL
1871             (APPLICATION_ID,     RELEASE_CLASS_ID,
1872              LANGUAGE, SOURCE_LANG, USER_RELEASE_CLASS_NAME,
1873              LAST_UPDATE_DATE,
1874              LAST_UPDATED_BY,    LAST_UPDATE_LOGIN,
1875              CREATION_DATE,      CREATED_BY)
1876                 Select 0, P_REL_CLASS_ID,
1877                         L.LANGUAGE_CODE,userenv('LANG'),
1878 			'Request - '|| cur_request_id,
1879                         Sysdate,
1880                         submit.user_id, loginid,
1881                         Sysdate,  submit.user_id
1882              from FND_LANGUAGES L
1883              where L.INSTALLED_FLAG in ('I', 'B');
1884 
1885 	    if (sql%rowcount = 0) then
1886 	      raise relclass_insert_error;
1887 	    end if;
1888 
1889 	 end;
1890        end if;
1891 
1892 	-- Insert into Fnd_Logins
1893 	if (subloginid is not null) then
1894 	  begin
1895 	    Insert
1896 	      into Fnd_Logins (
1897 		   Login_Id, User_Id,
1898 		   Start_Time, End_Time,
1899 		   Pid, Spid, Terminal_ID,
1900 		   Login_Name, Submitted_Login_Id)
1901 	    Values (
1902                    loginid, submit.user_id,
1903 		   Sysdate, Null,
1904 		   Null, Null, 'Concurrent',
1905 		   Null, subloginid);
1906 
1907 	    if (sql%rowcount = 0) then
1908 	      raise login_insert_error;
1909 	    end if;
1910 	  end;
1911 	end if; -- (subloginid is not null)
1912 
1913 	-- Submitted request successfully
1914 
1915         -- Call FND_GLOBAL.RT_TEST_ID() to see if needs to write the request
1916         -- id into FND_RT_REQUESTS table.
1917         rttestid := FND_GLOBAL.RT_TEST_ID;
1918         if (rttestid <> -1) then
1919 	  FND_RT_REQUEST.LOG_REQUEST(rttestid, cur_request_id);
1920         end if;
1921 	IF (P_USES_REL_CLASS = 1 AND schedule_type = 'X') THEN
1922 		begin
1923 		select c.resubmit_interval, c.resubmit_interval_unit_code, c.resubmit_interval_type_code
1924 		into adv_sch_ri, adv_sch_riuc, adv_sch_ritc
1925 		from fnd_conc_release_classes c, fnd_concurrent_requests r
1926 		where r.request_id = cur_request_id and r.release_class_id = c.release_class_id
1927 			and r.release_class_app_id = c.application_id;
1928 		exception when others then
1929 			adv_sch_ri := null;
1930 			adv_sch_riuc := null;
1931 			adv_sch_ritc := null;
1932 		end;
1933 		update fnd_concurrent_requests fcr
1934 		set  fcr.resubmit_interval = nvl(adv_sch_ri,1),
1935 			fcr.resubmit_interval_unit_code = nvl(adv_sch_riuc,'DAYS'),
1936 			fcr.resubmit_interval_type_code = nvl(adv_sch_ritc,'START'),
1937 			fcr.status_code = 'P'
1938 		where fcr.request_id = cur_request_id;
1939 	END IF ;
1940 	--
1941 	--  raising business event for request submitted
1942 	--  bug6623316
1943 	--
1944         discard_status:=fnd_concurrent_business_event.raise_cp_bi_event(cur_request_id,fnd_concurrent_business_event.request_submitted);
1945 
1946 	return (cur_request_id);
1947 
1948 	exception
1949 	  when printer_error then
1950 	    fnd_message.set_name ('FND', 'CONC-Illegal printer spec');
1951 	    return (0);
1952 	  when style_error then
1953 	    fnd_message.set_name ('FND', 'SRS-Must specify print style');
1954 	    return (0);
1955 	  when printer_styl_error then
1956 	    fnd_message.set_name ('FND', 'CONC-Invalid printer style');
1957 	    fnd_message.set_token ('STYLE', print_style, FALSE);
1958 	    fnd_message.set_token ('PRINTER', curr_printer, FALSE);
1959 	    return (0);
1960 	  when srw_style_error then
1961 	    fnd_message.set_name ('FND', 'SRS-Must specify srw style');
1962 	    return (0);
1963 	  when oracle_name_error then
1964 	    fnd_message.set_name ('FND', 'CONC-Failed to get oracle name');
1965 	    return (0);
1966 	  when start_time_error then
1967 	    fnd_message.set_name ('FND', 'CONC-Invalid Req Start Date');
1968 	    fnd_message.set_token ('START_DATE', requested_start, FALSE);
1969 	    return (0);
1970 	  when dup_val_on_index then
1971 	    fnd_message.set_name ('FND', 'CONC-Duplicate request id');
1972 	    fnd_message.set_token ('REQUEST_ID', cur_request_id, FALSE);
1973 	    return (0);
1974 	  when nls_error then
1975 	    fnd_message.set_name ('FND', 'GLI-Not found');
1976 	    return (0);
1977 	  when appl_prog_error then -- Appl or program invalid
1978 	    begin -- Is the appl short name correct?
1979 	      Select Application_ID
1980 		Into prog_appl_id
1981 		From Fnd_Application
1982 	       Where Application_Short_Name = upper (application);
1983 
1984 	      exception
1985 		when no_data_found then
1986 		  fnd_message.set_name ('FND', 'CONC-Invalid Appl Short Name');
1987 		  fnd_message.set_token ('APPLNAME', application, FALSE);
1988 		  return (0);
1989 		when others then
1990 		  fnd_message.set_name ('FND', 'SQL-Generic error');
1991 		  fnd_message.set_token ('ERRNO', sqlcode, FALSE);
1992 		  fnd_message.set_token ('REASON', sqlerrm, FALSE);
1993 		  fnd_message.set_token (
1994 				'ROUTINE', 'SUBMIT: appl_prog_error', FALSE);
1995 		  return (0);
1996 	    end; -- Is the appl short name correct?
1997 
1998 	    -- It must be the program
1999 	    fnd_message.set_name ('FND', 'CONC-Invalid Conc program');
2000 	    fnd_message.set_token ('PROGRAM', program, FALSE);
2001 	    return (0);
2002 
2003 	  when insert_error then  -- Find the problem
2004 	    begin -- Is the program enabled?
2005 	      Select null
2006 		Into Dummy
2007 		From Fnd_Concurrent_Programs
2008 	       Where Application_ID = prog_appl_id
2009 		 And upper (Concurrent_Program_Name) = upper (program)
2010 		 And Enabled_Flag = 'Y';
2011 
2012 	      exception
2013 		when no_data_found then
2014 		  fnd_message.set_name ('FND', 'CONC-Conc program disabled');
2015 		  fnd_message.set_token ('PROGRAM', program, FALSE);
2016 		  return (0);
2017 		when others then
2018 		  fnd_message.set_name ('FND', 'SQL-Generic error');
2019 		  fnd_message.set_token ('ERRNO', sqlcode, FALSE);
2020 		  fnd_message.set_token ('REASON', sqlerrm, FALSE);
2021 		  fnd_message.set_token (
2022 				'ROUTINE', 'SUBMIT: insert_error2', FALSE);
2023 		  return (0);
2024 	    end; -- Is the program enabled?
2025 
2026 	  when args_insert_error then
2027 	    fnd_message.set_name ('FND', 'SQL-Generic error');
2028 	    fnd_message.set_token ('ERRNO', sqlcode, FALSE);
2029 	    fnd_message.set_token ('REASON', sqlerrm, FALSE);
2030 	    fnd_message.set_token (
2031 				'ROUTINE', 'SUBMIT: args_insert_error', FALSE);
2032 	    return (0);
2033 	  when login_insert_error then
2034 	    fnd_message.set_name ('FND', 'CONC-Login insert failed');
2035 	    fnd_message.set_token ('LOGIN', loginid, FALSE);
2036 	    return (0);
2037 	  when relclass_insert_error then
2038 	    fnd_message.set_name ('FND', 'CONC-RelClass insert failed');
2039 	    fnd_message.set_token ('APPLICATION', P_REL_CLASS_APP_ID, FALSE);
2040 	    fnd_message.set_token ('CLASS', P_REL_CLASS_ID, FALSE);
2041 	    return (0);
2042 	  when dual_no_rows then
2043 	    fnd_message.set_name ('FND', 'No Rows in Dual');
2044 	    return (0);
2045 	  when dual_too_many_rows then
2046 	    fnd_message.set_name ('FND', 'Too many rows in Dual');
2047 	    return (0);
2048 	  when already_msg then
2049 	    return (0);
2050           when pp_plsql_exception then
2051             fnd_message.set_name ('FND', 'CONC-assign pp action failed');
2052             return (0);
2053 	  when conc_deferred_insert_error then
2054 	    fnd_message.set_name ('FND', 'Conc-def-arg insert failed');
2055 	    fnd_message.set_token ('APPLICATION', application, FALSE);
2056 	    fnd_message.set_token ('PROGRAM', program, FALSE);
2057 		return (0);
2058           when mult_pending_request_error then
2059             fnd_message.set_name ('FND', 'CONC-SINGLE PENDING REQUEST');
2060 	    fnd_message.set_token ('PROGRAM', program, FALSE);
2061 		return (0);
2062 	  when others then
2063 	    fnd_message.set_name ('FND', 'SQL-Generic error');
2064 	    fnd_message.set_token ('ERRNO', sqlcode, FALSE);
2065 	    fnd_message.set_token ('REASON', sqlerrm, FALSE);
2066 	    fnd_message.set_token (
2067 				'ROUTINE', 'SUBMIT: others', FALSE);
2068 	    return (0);
2069 
2070   end submit;
2071 
2072 
2073   -- PUBLIC FUNCTIONS
2074   --
2075   -- --
2076 
2077   --
2078   -- Name
2079   --   set_mode
2080   -- Purpose
2081   --   Called before submitting request to set database trigger mode
2082   --
2083   -- Arguments
2084   --   db_trigger	- Set to TRUE for database trigger mode
2085   --
2086   function set_mode (db_trigger  IN boolean) return boolean is
2087   begin
2088     P_DB_TRIGGER_MODE := db_trigger;
2089     return TRUE;
2090   end;
2091 
2092 
2093   -- Name
2094   --   set_options
2095   -- Purpose
2096   --   Called before submitting request to set request attributes
2097   --
2098   -- Arguments
2099   --   implicit		- nature of the request to be submitted
2100   --			- NO/YES/ERROR/WARNING
2101   --   protected	- Is the request protected against updates
2102   --			- YES/NO  default is NO
2103   --   language		- NLS language
2104   --   territory	- Language territory
2105   --   datagroup
2106   --   numeric_characters - NLS Numeric Characters
2107   --
2108   -- --
2109   function set_options (implicit  IN varchar2 default 'NO',
2110 		        protected IN varchar2 default 'NO',
2111 		        language  IN varchar2 default NULL,
2112 		        territory IN varchar2 default NULL,
2113 		        datagroup IN varchar2 default NULL,
2114                         numeric_characters IN varchar2 default NULL)
2115 			return boolean is
2116   dummy_val   varchar2(30);
2117   dummy_count number := 0;
2118   nls_error   exception;
2119   begin
2120 	if ((implicit is null) or
2121 	    (upper (implicit)    = 'NO')) then
2122 	  P_IMPLICIT := 'N';
2123 	elsif (upper (implicit) = 'WARNING') then
2124 	  P_IMPLICIT := 'W';
2125 	elsif (upper (implicit) = 'YES') then
2126 	  P_IMPLICIT := 'Y';
2127 	elsif (upper (implicit) = 'ERROR') then
2128 	  P_IMPLICIT := 'E';
2129 	else
2130 	  Fnd_Message.Set_Name ('FND', 'CONC-Bad implicit argument');
2131 	  init_pvt_vars;
2132 	  return (FALSE);
2133 	end if;
2134 
2135 	if ( language is not null ) then
2136 	   begin
2137 		select nls_language
2138 	 	  into dummy_val
2139 		  from fnd_languages
2140 		 where nls_language = upper(language);
2141 	   exception
2142 		when no_data_found then
2143 		   raise nls_error;
2144 	   end;
2145 	end if;
2146 
2147 	if ( territory is not null ) then
2148 	   begin
2149 		select count(*)
2150 		  into dummy_count
2151 		  from fnd_territories
2152 		 where nls_territory = upper(territory);
2153 	   exception
2154 		when no_data_found then
2155 		   raise nls_error;
2156 	   end;
2157 	   if ( dummy_count < 1 ) then
2158 		raise nls_error;
2159 	   end if;
2160 	end if;
2161 
2162         /* NLS Project */
2163 	if ( numeric_characters is not null ) then
2164            begin
2165              select lookup_code
2166                   into dummy_val
2167                   from fnd_lookup_values_vl
2168                  where lookup_type = 'ICX_NUMERIC_CHARACTERS' and
2169                          lookup_code = numeric_characters;
2170            exception
2171                 when no_data_found then
2172                    raise nls_error;
2173            end;
2174 	end if;
2175 
2176 	P_LANGUAGE := language;
2177 	P_TERRITORY := territory;
2178         /* NLS Project */
2179         P_NUMERIC_CHARACTERS := numeric_characters;
2180 
2181 	if (datagroup is not null) then
2182 	  P_DATAGROUP := datagroup;
2183 	end if;
2184 
2185 	return (TRUE);
2186 
2187      exception
2188 	when nls_error then
2189 	    fnd_message.set_name ('FND', 'GLI-Not found');
2190 	    return(FALSE);
2191 
2192   end set_options;
2193 
2194 
2195   --
2196   -- Name
2197   --   set_repeat_options
2198   -- Purpose
2199   --   Called before submitting request if the request to be submitted
2200   --   is a repeating request.
2201   --
2202   -- Arguments
2203   --   repeat_time	- Time of day at which it has to be repeated
2204   --   repeat_interval  - Frequency at which it has to be repeated
2205   --			- This will be used/applied only when repeat_time
2206   --			- is NULL ( non null repeat_interval overrides )
2207   --   repeat_unit	- Unit for repeat interval. Default is DAYS.
2208   --			- MONTHS/DAYS/HOURS/MINUTES
2209   --   repeat_type	- Apply repeat interval from START or END of request
2210   --			- default is START. START/END
2211   --   repeat_end_time  - Time at which the repetition should be stopped
2212   --   incrment_dates   - 'Y' if dates should be incremented each run,
2213   --                      otherwise 'N'
2214   --
2215   function set_repeat_options (repeat_time      IN varchar2 default NULL,
2216 			       repeat_interval  IN number   default NULL,
2217 			       repeat_unit      IN varchar2 default 'DAYS',
2218 			       repeat_type      IN varchar2 default 'START',
2219 			       repeat_end_time  IN varchar2 default NULL,
2220 			       increment_dates  IN varchar2 default NULL)
2221 			       return boolean is
2222 
2223   rpt_other      exception;
2224   rpt_time_intvl exception;	  -- Both resub time and interval are set
2225   rpt_type_error exception;	  -- Bad resub type
2226   rpt_time_error boolean := TRUE; -- Use this in exception handler to
2227 				  -- determine where the error occurred:
2228 				  -- in resub time or end date.
2229   base_len number;
2230   begin
2231 	P_REPEAT_TIME          := NULL;
2232 	P_REPEAT_INTERVAL      := NULL;
2233 	P_REPEAT_INTERVAL_UNIT := NULL;
2234 	P_REPEAT_INTERVAL_TYPE := NULL;
2235 	P_REPEAT_END           := NULL;
2236 	P_INCREMENT_DATES      := NULL;
2237 
2238 	if ((repeat_time is not NULL) and
2239 	    (repeat_interval is not NULL)) then
2240 	  raise rpt_time_intvl;
2241 
2242 	elsif (repeat_time is not NULL) then
2243 
2244 	  Select To_Char (fnd_conc_date.string_to_date (
2245                               '01-01-0001' || repeat_time),
2246 				    'HH24:MI:SS')
2247 	    Into P_REPEAT_TIME
2248 	    From Sys.Dual;
2249 
2250           if (increment_dates = 'Y') then
2251               P_INCREMENT_DATES := increment_dates;
2252           else
2253               P_INCREMENT_DATES := 'N';
2254           end if;
2255 
2256 	elsif (repeat_interval is not NULL) then
2257 	  P_REPEAT_INTERVAL := repeat_interval;
2258 
2259 	  if (repeat_unit is null) then
2260 	    P_REPEAT_INTERVAL_UNIT := 'DAYS';
2261 	  else
2262 	    Select Lookup_Code
2263 	      Into P_REPEAT_INTERVAL_UNIT
2264 	      From Fnd_Lookups
2265 	     Where upper (Lookup_Code) = upper (repeat_unit)
2266 	       And Lookup_Type = 'CP_RESUBMIT_INTERVAL_UNIT';
2267 	  end if;
2268 
2269 	  if (repeat_type is null) then
2270 	    P_REPEAT_INTERVAL_TYPE := 'START';
2271 	  elsif (upper (repeat_type) in ('START', 'END')) then
2272 	    P_REPEAT_INTERVAL_TYPE := upper (repeat_type);
2273 	  else
2274 	    raise rpt_type_error;
2275 	  end if;
2276 
2277           if (increment_dates = 'Y') then
2278               P_INCREMENT_DATES := increment_dates;
2279           else
2280               P_INCREMENT_DATES := 'N';
2281           end if;
2282 
2283 	end if; -- ((repeat_time is not NULL) and (repeat_interval is..
2284 
2285 	rpt_time_error := FALSE;
2286 
2287 	if (repeat_end_time is not null) then
2288           P_REPEAT_END := fnd_conc_date.string_to_date(repeat_end_time);
2289           if (P_REPEAT_END is null) then
2290             raise rpt_other;
2291           end if;
2292         end if;
2293 
2294 	return (TRUE);
2295 
2296 	exception
2297 	  when rpt_time_intvl then
2298 	    fnd_message.set_name ('FND', 'CONC-Time and interval set');
2299 	    init_pvt_vars;
2300 	    return (FALSE);
2301 
2302 	  when rpt_type_error then
2303 	    fnd_message.set_name ('FND', 'CONC-Bad resubmit type');
2304 	    init_pvt_vars;
2305 	    return (FALSE);
2306 
2307 	  when no_data_found then
2308 	    fnd_message.set_name ('FND', 'CONC-Bad resubmit unit');
2309 	    init_pvt_vars;
2310 	    return (FALSE);
2311 
2312 	  when others then
2313 	    if (rpt_time_error) then
2314 	      fnd_message.set_name ('FND', 'CONC-Invalid resubmit time');
2315 	    else
2316 	      fnd_message.set_name ('FND', 'CONC-Invalid Resub End Date');
2317 	    end if;
2318 	    init_pvt_vars;
2319 	    return (FALSE);
2320   end set_repeat_options;
2321 
2322 
2323 
2324   --
2325   -- Name
2326   --   set_rel_class_options
2327   -- Purpose
2328   --   Called before submitting request if the request to be submitted
2329   --   is using the new scheduler functionality.
2330   --
2331   -- Arguments
2332   --   application	- Application Name of Release Class
2333   --   class_name	- (Developer) Name of Release Class
2334   --   cancel_or_hold	- Cancel or hold flag
2335   --   stale_date	- Cancel request on or after this time if not run
2336   --
2337   function set_rel_class_options (application 	 IN varchar2 default NULL,
2338 			          class_name 	 IN varchar2 default NULL,
2339 			          cancel_or_hold IN varchar2 default 'H',
2340 			          stale_date 	 IN varchar2 default NULL)
2341 			          return boolean is
2342 
2343   stale_date_error exception;  -- Stale date couldn't be interpreted
2344   appl_class_error exception;  -- Couldn't find App or class
2345 
2346   begin
2347         P_REL_CLASS_APP_ID      := null;
2348         P_REL_CLASS_ID          := null;
2349         P_REL_STALE_DATE        := null;
2350         P_REL_CANCEL_OR_HOLD    := cancel_or_hold;
2351 
2352 
2353 	if (stale_date is not NULL) then
2354           P_REL_STALE_DATE := fnd_conc_date.string_to_date(stale_date);
2355           if (P_REL_STALE_DATE is null) then
2356             raise stale_date_error;
2357           end if;
2358         end if;
2359 
2360         if (class_name is not null) then
2361          begin
2362           Select A.Application_ID, C.Release_Class_Id
2363             Into P_REL_CLASS_APP_ID, P_REL_CLASS_ID
2364             From Fnd_Conc_Release_Classes C, Fnd_Application A
2365            Where Upper(Release_class_Name)           = upper(class_name)
2366                  And C.Application_ID                = A.Application_ID
2367                  And A.Application_Short_Name = upper(application);
2368 
2369           exception
2370             when no_data_found then
2371               raise appl_class_error;
2372             when others then
2373               raise;
2374          end;
2375         end if;
2376 
2377 	P_USES_REL_CLASS := 1;
2378 
2379 	return (TRUE);
2380 
2381 	exception
2382 	  when stale_date_error then
2383 	    fnd_message.set_name ('FND', 'CONC-Bad Stale Date');
2384 	    init_pvt_vars;
2385 	    return (FALSE);
2386 
2387 	  when appl_class_error then
2388 	    fnd_message.set_name ('FND', 'CONC-Bad Release Class');
2389 	    init_pvt_vars;
2390 	    return (FALSE);
2391 
2392 	  when others then
2393 	    init_pvt_vars;
2394 	    raise;
2395 	    return (FALSE);
2396   end set_rel_class_options;
2397 
2398   -- Name
2399   --   set_target_options
2400   -- Purpose
2401   --   Called before submitting request to set target node and or connect
2402   --   string (instance) for the request.  Currently only primary target
2403   --   node and connect string are honored and the connect string must be
2404   --   the name of a RAC instance.
2405   --
2406   -- Arguments
2407   --   node_name1       - primary target node
2408   --   instance1        - primary target instance (connect string)
2409   --   node_name2       - secondary target node
2410   --   instance2        - secondary target instance (connect string)
2411   --
2412   -- --
2413   function set_target_options (node_name1  IN varchar2 default NULL,
2414 		        instance1 IN varchar2 default NULL,
2415 		        node_name2    IN varchar2 default NULL,
2416 		        instance2 IN varchar2 default NULL)
2417 			return boolean is
2418 
2419   dummy_val   varchar2(80);
2420 
2421   begin
2422 
2423 	if ( node_name1 is not null ) then
2424 	   begin
2425 		select node_name
2426 	 	  into dummy_val
2427 		  from fnd_nodes
2428 		 where upper(node_name) = upper(node_name1);
2429 	   exception
2430 		when no_data_found then
2431 	           fnd_message.set_name ('FND', 'CONC-Node not found');
2432 	    	   fnd_message.set_token ('NODE_NAME', node_name1, FALSE);
2433 		   raise;
2434 	   end;
2435 	end if;
2436 
2437 	if ( instance1 is not null ) then
2438 	   begin
2439 		select instance
2440 	 	  into dummy_val
2441 		  from v$thread
2442 		 where upper(instance) = upper(instance1);
2443 	   exception
2444 		when no_data_found then
2445 	           fnd_message.set_name ('FND', 'CONC-Instance not found');
2446 	    	   fnd_message.set_token ('INSTANCE_NAME', instance1, FALSE);
2447 		   raise;
2448 	   end;
2449 	end if;
2450 
2451 	P_NODE_NAME1 := node_name1;
2452 	P_CONNSTR1 := instance1;
2453 
2454 	return (TRUE);
2455 
2456      exception
2457 	when others then
2458 	    return(FALSE);
2459 
2460   end set_target_options;
2461 
2462 
2463   --
2464   -- Name
2465   --   set_print_options
2466   -- Purpose
2467   --   Called before submitting request if the printing of output has
2468   --   to be controlled with specific printer/style/copies etc.,
2469   --
2470   -- Arguments
2471   --   printer		- Printer name where the request o/p should be sent
2472   --   style		- Print style that needs to be used for printing
2473   --   copies		- Number of copies to print
2474   --   save_output	- Should the output file be saved after printing
2475   --   			- Default is TRUE.  TRUE/FALSE
2476   --   print_together   - Applies only for sub requests. If 'Y', output
2477   --			- will not be printed until all the sub requests
2478   --			- complete. Default is N. Y/N
2479   --   validate_printer - Once submit function is called
2480   --                    - with a specific program, if the printer specified
2481   --                    - here conflicts with a printer setting at the
2482   --                    - program level, one of three options is available:
2483   --                    - FAIL - raise an error and fail to submit
2484   --                    - SKIP - skip this print pp action, but submit anyway
2485   --                    - RESOLVE - switch to the valid printer, if printer
2486   --                    - and style are compatible
2487   --                    - Default is RESOLVE
2488   function set_print_options (printer	     IN varchar2 default NULL,
2489 			      style	     IN varchar2 default NULL,
2490 			      copies	     IN number	 default NULL,
2491 			      save_output    IN boolean  default TRUE,
2492                               print_together IN varchar2 default 'N',
2493                               validate_printer IN varchar2 default 'RESOLVE')
2494 			      return  boolean is
2495 
2496 	printer_typ		varchar2 (30) := null;
2497 	dummy_fld		varchar (2);
2498 
2499         validate_printer_error  exception;
2500 	print_together_error	exception;
2501 	printer_error		exception;
2502 	style_error		exception;
2503 	printer_style_error	exception;
2504         empty_array             printer_tab_type;
2505         prec  printer_record_type;
2506 
2507   begin
2508         -- Clear any old printer options
2509         -- Just in case this was called twice.
2510         if P_PRINTER_COUNT > 0 then
2511           P_PRINTERS := empty_array;
2512           P_PRINTER_COUNT := 0;
2513           P_VALIDATE_PRINTER := 'RESOLVE';
2514         end if;
2515 
2516         -- 5645007- set P_VALIDATE_PRINTER to determine
2517         -- behavior during submit if the printer specified here
2518         -- conflicts with a printer setting at the program level
2519 
2520         if (UPPER(validate_printer)
2521                                  in ('FAIL','SKIP','RESOLVE')) then
2522           P_VALIDATE_PRINTER := UPPER(validate_printer);
2523         else
2524           raise validate_printer_error;
2525         end if;
2526 
2527 
2528 	if (upper (print_together) not in ('Y', 'N')) then
2529 	  raise print_together_error;
2530 	end if;
2531 
2532 	if (upper (print_together) = 'Y') then
2533 	  P_PRINT_TOGETHER   := 'Y';
2534 	elsif (upper (print_together) = 'N') then
2535 	  P_PRINT_TOGETHER   := 'N';
2536 	else
2537 	  P_PRINT_TOGETHER   := NULL;
2538 	end if;
2539 
2540 	if (save_output is null) then
2541 	  P_SAVE_OUTPUT      := NULL;
2542 	elsif (save_output) then
2543 	  P_SAVE_OUTPUT      := 'Y';
2544         else
2545 	  P_SAVE_OUTPUT      := 'N';
2546 	end if;
2547 
2548 	if (printer is not null) then -- Verify printer
2549 	  begin
2550 	    Select printer_type
2551 	      Into printer_typ
2552 	      From fnd_printer
2553 	     Where printer_name = printer;
2554 
2555 	    exception
2556 	      when no_data_found then
2557 		raise printer_error;
2558 
2559 	      when others then
2560 		raise;
2561 	  end;
2562 	end if; -- Verify printer
2563 
2564 
2565 	if (style is not null) then -- Verify style
2566 	  begin
2567 	    Select Printer_Style_Name
2568 	      Into P_PRINT_STYLE
2569 	      From Fnd_Printer_styles
2570 	     Where Printer_Style_Name = style;
2571 
2572 	    exception
2573 	      when no_data_found then
2574 		raise style_error;
2575 
2576 	      when others then
2577 		raise;
2578 	  end;
2579  	end if; -- Verify style
2580 
2581 	if ((printer is not null) and
2582 	    (style is not null)) then -- Verify printer/style comination
2583 	  begin
2584 	    Select 'X'
2585 	      Into Dummy_fld
2586 	      From Fnd_Printer_Information
2587 	     Where Printer_Style = P_PRINT_STYLE
2588 	       And Printer_Type  = printer_typ;
2589 
2590 	    exception
2591 	      when no_data_found then
2592 		raise printer_style_error;
2593 
2594 	      when others then
2595 		raise;
2596 	  end;
2597 	end if; -- Verify printer/style comination
2598 
2599         -- Add printer/copies to the list.
2600         -- Note that we will attempt to process the defaults
2601         -- for nulls at submission time.  For now, store the
2602         -- nulls.
2603 
2604         if (copies is not null or printer is not null) then
2605           P_PRINTER_COUNT := 1;
2606 
2607           -- The following inderect assignment was required to get
2608           -- the procedure to compile.  The problem, for some reason
2609           -- doesn't seem to affect the other procedures in this package.
2610           prec.printer := printer;
2611           prec.copies := copies;
2612           P_PRINTERS(1) := prec;
2613         end if;
2614 
2615 
2616 	return (TRUE);
2617 
2618 	exception
2619           when validate_printer_error then
2620             fnd_message.set_name ('FND', 'CONC-Bad Validate Printer Parm');
2621             init_pvt_vars;
2622             return (FALSE);
2623 
2624 	  when print_together_error then
2625 	    fnd_message.set_name ('FND', 'CONC-Invalid opt:Print Group');
2626 	    init_pvt_vars;
2627 	    return (FALSE);
2628 
2629 	  when printer_error then
2630 	    fnd_message.set_name ('FND', 'PRINTERS-No system printer');
2631 	    fnd_message.set_token ('PRINTER', printer, FALSE);
2632 	    init_pvt_vars;
2633 	    return (FALSE);
2634 
2635 	  when style_error then
2636 	    fnd_message.set_name ('FND', 'PRT-Invalid print style');
2637 	    fnd_message.set_token ('STYLE', style, FALSE);
2638 	    init_pvt_vars;
2639 	    return (FALSE);
2640 
2641 	  when printer_style_error then
2642 	    fnd_message.set_name ('FND', 'CONC-Invalid printer style');
2643 	    fnd_message.set_token ('STYLE', style, FALSE);
2644 	    fnd_message.set_token ('PRINTER', printer, FALSE);
2645 	    init_pvt_vars;
2646 	    return (FALSE);
2647 
2648 	  when others then
2649 	    init_pvt_vars;
2650 	    fnd_message.set_name ('FND', 'SQL-Generic error');
2651 	    fnd_message.set_token ('ERRNO', sqlcode, FALSE);
2652 	    fnd_message.set_token ('REASON', sqlerrm, FALSE);
2653 	    fnd_message.set_token ('ROUTINE', 'SET_PRINT_OPTIONS', FALSE);
2654 	    return (FALSE);
2655   end set_print_options;
2656 
2657 
2658   --
2659   -- Name
2660   --   use_current_notification
2661   -- Purpose
2662   --   Called before submitting a sub-request to reuse the same notification
2663   --   options as the current request
2664   --
2665   -- Arguments
2666   --   none
2667   function use_current_notification return boolean is
2668   	profile_buffer	varchar2(80);
2669 	reqid		number;
2670         username	varchar2(255);
2671 	result		boolean;
2672         empty_notify_array notification_tab_type;
2673 
2674 	cursor c_users is
2675 		select arguments
2676 		from fnd_conc_pp_actions
2677 		where concurrent_request_id = reqid
2678 		and action_type = 2
2679 		order by sequence;
2680   begin
2681   	-- get current request id
2682 	reqid := FND_GLOBAL.conc_request_id;
2683 
2684   	if ((reqid <= 0) or (reqid is null))
2685 	then
2686 		init_pvt_vars;
2687 		fnd_message.set_name('FND', 'CONC-REQUEST MISSING');
2688 	    	fnd_message.set_token ('ROUTINE', 'USE_CURRENT_NOTIFICATION', FALSE);
2689 		return (FALSE);
2690 	end if;
2691 
2692 	-- clear out notifications
2693 	P_NOTIFICATIONS         := empty_notify_array;
2694         P_NOTIFICATION_COUNT    := 0;
2695 
2696 	-- call add_notification for each user
2697 	open c_users;
2698 	loop
2699 		fetch c_users into username;
2700 		exit when c_users%NOTFOUND;
2701 
2702 		result := add_notification(username);
2703 	end loop;
2704         close c_users;
2705 
2706 	return (TRUE);
2707 
2708   exception
2709 	when others then
2710 	    init_pvt_vars;
2711 	    fnd_message.set_name ('FND', 'SQL-Generic error');
2712 	    fnd_message.set_token ('ERRNO', sqlcode, FALSE);
2713 	    fnd_message.set_token ('REASON', sqlerrm, FALSE);
2714 	    fnd_message.set_token ('ROUTINE', 'USE_CURRENT_NOTIFICATION', FALSE);
2715 	    return (FALSE);
2716 
2717   end use_current_notification;
2718 
2719 
2720 
2721   --
2722   -- Name
2723   --   add_printer
2724   -- Purpose
2725   --   Called after set print options to add a printer to the
2726   --   print list.
2727   --
2728   -- Arguments
2729   --   printer		- Printer name where the request o/p should be sent
2730   --   copies		- Number of copies to print
2731   function add_printer (printer in varchar2 default null,
2732                         copies  in number default null) return boolean is
2733 	printer_typ		varchar2 (30) := null;
2734 	dummy_fld		varchar (2);
2735 	print_together_error	exception;
2736 	printer_error		exception;
2737 	style_error		exception;
2738 	printer_style_error	exception;
2739   begin
2740 	if (printer is not null) then -- Verify printer
2741 	  begin
2742 	    Select printer_type
2743 	      Into printer_typ
2744 	      From fnd_printer
2745 	     Where printer_name = printer;
2746 
2747 	    exception
2748 	      when no_data_found then
2749 		raise printer_error;
2750 
2751 	      when others then
2752 		raise;
2753 	  end;
2754 	end if; -- Verify printer
2755 
2756 
2757 	if ((printer is not null) and
2758 	    (P_PRINT_STYLE is not null)) then -- Verify printer/style combo
2759 	  begin
2760 	    Select 'X'
2761 	      Into Dummy_fld
2762 	      From Fnd_Printer_Information
2763 	     Where Printer_Style = P_PRINT_STYLE
2764 	       And Printer_Type  = printer_typ;
2765 
2766 	    exception
2767 	      when no_data_found then
2768 		raise printer_style_error;
2769 
2770 	      when others then
2771 		raise;
2772 	  end;
2773 	end if; -- Verify printer/style comination
2774 
2775         -- Add printer/copies to the list.
2776         -- Note that we will attempt to process the defaults
2777         -- for nulls at submission time.  For now, store the
2778         -- nulls.
2779         P_PRINTER_COUNT := P_PRINTER_COUNT + 1;
2780         P_PRINTERS(P_PRINTER_COUNT).printer := printer;
2781         P_PRINTERS(P_PRINTER_COUNT).copies := copies;
2782 
2783 	return (TRUE);
2784 
2785 	exception
2786 	  when print_together_error then
2787 	    fnd_message.set_name ('FND', 'CONC-Invalid opt:Print Group');
2788 	    init_pvt_vars;
2789 	    return (FALSE);
2790 
2791 	  when printer_error then
2792 	    fnd_message.set_name ('FND', 'PRINTERS-No system printer');
2793 	    fnd_message.set_token ('PRINTER', printer, FALSE);
2794 	    init_pvt_vars;
2795 	    return (FALSE);
2796 
2797 	  when style_error then
2798 	    fnd_message.set_name ('FND', 'PRT-Invalid print style');
2799 	    fnd_message.set_token ('STYLE', P_PRINT_STYLE, FALSE);
2800 	    init_pvt_vars;
2801 	    return (FALSE);
2802 
2803 	  when printer_style_error then
2804 	    fnd_message.set_name ('FND', 'CONC-Invalid printer style');
2805 	    fnd_message.set_token ('STYLE', P_PRINT_STYLE, FALSE);
2806 	    fnd_message.set_token ('PRINTER', printer, FALSE);
2807 	    init_pvt_vars;
2808 	    return (FALSE);
2809 
2810 	  when others then
2811 	    init_pvt_vars;
2812 	    fnd_message.set_name ('FND', 'SQL-Generic error');
2813 	    fnd_message.set_token ('ERRNO', sqlcode, FALSE);
2814 	    fnd_message.set_token ('REASON', sqlerrm, FALSE);
2815 	    fnd_message.set_token ('ROUTINE', 'SET_PRINT_OPTIONS', FALSE);
2816 	    return (FALSE);
2817 
2818   end;
2819 
2820 
2821   --
2822   -- Name
2823   --   add_notification
2824   -- Purpose
2825   --   Called before submission to add a user to the notify list.
2826   --
2827   -- Arguments
2828   --	User		- User name.
2829   function add_notification (user in varchar2) return boolean is
2830     n_index number;
2831     cursor c1( user_name varchar2) is
2832        select name, orig_system, orig_system_id
2833          from wf_roles
2834         where name = user_name;
2835   begin
2836 
2837    -- Same user may exists in different departments(tables).
2838    -- use cursor because we dont know the given user name will return one row
2839    -- multiple rows.
2840    -- we are considering only the first row that matched in wf_roles.
2841 
2842     n_index := P_NOTIFICATION_COUNT + 1;
2843     open c1( user );
2844     fetch c1 into P_NOTIFICATIONS(n_index).name,
2845 			P_NOTIFICATIONS(n_index).orig_system,
2846 			P_NOTIFICATIONS(n_index).orig_system_id;
2847 
2848     P_NOTIFICATIONS(n_index).on_normal := 'Y';
2849     P_NOTIFICATIONS(n_index).on_warning := 'Y';
2850     P_NOTIFICATIONS(n_index).on_error := 'Y';
2851 
2852     if( c1%notfound ) then
2853       fnd_message.set_name('FND', 'CONC-INVALID NOTIFY USER');
2854       close c1;
2855       return FALSE;
2856     else
2857       P_NOTIFICATION_COUNT := P_NOTIFICATION_COUNT + 1;
2858       close c1;
2859       return TRUE;
2860     end if;
2861 
2862   end;
2863 
2864   --
2865   -- Name
2866   --   add_layout
2867   -- Purpose
2868   --   Called before submission to add layout options for request output.
2869   --
2870   -- Arguments
2871   --    Template_APPL_Name            - Template Application Short name.
2872   --    Template_code                 - Template code
2873   --    Template_Language             - Template File language (iso value)
2874   --    Template_Territory            - Template File Territory (iso value)
2875   --    Output Format                 - Output Format
2876   --
2877   function add_layout (template_appl_name in varchar2,
2878 			template_code     in varchar2,
2879 			template_language in varchar2,
2880  			template_territory in varchar2,
2881 			output_format     in varchar2) return boolean is
2882   begin
2883       -- It is callers responsibility to provide valid values.
2884       P_TEMPLATE_APPL      := template_appl_name;
2885       P_TEMPLATE_CODE      := template_code;
2886       P_TEMPLATE_LANG      := template_language;
2887       P_TEMPLATE_TERRITORY := template_territory;
2888       P_OUTPUT_FORMAT      := output_format;
2889       return (TRUE);
2890   end;
2891 
2892   --
2893   -- Name
2894   --   submit_request
2895   -- Purpose
2896   --   Submits concurrent request to be processed by a concurrent manager
2897   --
2898   -- Arguments
2899   --   application	- Short name of application under which the program
2900   --			- is registered
2901   --   program		- concurrent program name for which the request has
2902   --			- to be submitted
2903   --   description	- Optional. Will be displayed along with user
2904   --			- concurrent program name
2905   --   start_time	- Optional. Time at which the request has to start
2906   --			- running
2907   --   sub_request	- Optional. Set to TRUE if the request is submitted
2908   --   			- from another running request and has to be treated
2909   --			- as a sub request. Default is FALSE
2910   --   argument1..100	- Optional. Arguments for the concurrent request
2911   --
2912   function submit_request (
2913 			  application IN varchar2 default NULL,
2914 			  program     IN varchar2 default NULL,
2915 			  description IN varchar2 default NULL,
2916 			  start_time  IN varchar2 default NULL,
2917 			  sub_request IN boolean  default FALSE,
2918 			  argument1   IN varchar2 default CHR(0),
2919 			  argument2   IN varchar2 default CHR(0),
2920   			  argument3   IN varchar2 default CHR(0),
2921 			  argument4   IN varchar2 default CHR(0),
2922 			  argument5   IN varchar2 default CHR(0),
2923 			  argument6   IN varchar2 default CHR(0),
2924 			  argument7   IN varchar2 default CHR(0),
2925 			  argument8   IN varchar2 default CHR(0),
2926 			  argument9   IN varchar2 default CHR(0),
2927 			  argument10  IN varchar2 default CHR(0),
2928 			  argument11  IN varchar2 default CHR(0),
2929 			  argument12  IN varchar2 default CHR(0),
2930   			  argument13  IN varchar2 default CHR(0),
2931 			  argument14  IN varchar2 default CHR(0),
2932 			  argument15  IN varchar2 default CHR(0),
2933 			  argument16  IN varchar2 default CHR(0),
2934 			  argument17  IN varchar2 default CHR(0),
2935 			  argument18  IN varchar2 default CHR(0),
2936 			  argument19  IN varchar2 default CHR(0),
2937 			  argument20  IN varchar2 default CHR(0),
2938 			  argument21  IN varchar2 default CHR(0),
2939 			  argument22  IN varchar2 default CHR(0),
2940   			  argument23  IN varchar2 default CHR(0),
2941 			  argument24  IN varchar2 default CHR(0),
2942 			  argument25  IN varchar2 default CHR(0),
2943 			  argument26  IN varchar2 default CHR(0),
2944 			  argument27  IN varchar2 default CHR(0),
2945 			  argument28  IN varchar2 default CHR(0),
2946 			  argument29  IN varchar2 default CHR(0),
2947 			  argument30  IN varchar2 default CHR(0),
2948 			  argument31  IN varchar2 default CHR(0),
2949 			  argument32  IN varchar2 default CHR(0),
2950   			  argument33  IN varchar2 default CHR(0),
2951 			  argument34  IN varchar2 default CHR(0),
2952 			  argument35  IN varchar2 default CHR(0),
2953 			  argument36  IN varchar2 default CHR(0),
2954 			  argument37  IN varchar2 default CHR(0),
2955   			  argument38  IN varchar2 default CHR(0),
2956 			  argument39  IN varchar2 default CHR(0),
2957 			  argument40  IN varchar2 default CHR(0),
2958 			  argument41  IN varchar2 default CHR(0),
2959   			  argument42  IN varchar2 default CHR(0),
2960 			  argument43  IN varchar2 default CHR(0),
2961 			  argument44  IN varchar2 default CHR(0),
2962 			  argument45  IN varchar2 default CHR(0),
2963 			  argument46  IN varchar2 default CHR(0),
2964 			  argument47  IN varchar2 default CHR(0),
2965   			  argument48  IN varchar2 default CHR(0),
2966 			  argument49  IN varchar2 default CHR(0),
2967 			  argument50  IN varchar2 default CHR(0),
2968 			  argument51  IN varchar2 default CHR(0),
2969   			  argument52  IN varchar2 default CHR(0),
2970 			  argument53  IN varchar2 default CHR(0),
2971 			  argument54  IN varchar2 default CHR(0),
2972 			  argument55  IN varchar2 default CHR(0),
2973 			  argument56  IN varchar2 default CHR(0),
2974 			  argument57  IN varchar2 default CHR(0),
2975 			  argument58  IN varchar2 default CHR(0),
2976 			  argument59  IN varchar2 default CHR(0),
2977 			  argument60  IN varchar2 default CHR(0),
2978 			  argument61  IN varchar2 default CHR(0),
2979 			  argument62  IN varchar2 default CHR(0),
2980   			  argument63  IN varchar2 default CHR(0),
2981 			  argument64  IN varchar2 default CHR(0),
2982 			  argument65  IN varchar2 default CHR(0),
2983 			  argument66  IN varchar2 default CHR(0),
2984 			  argument67  IN varchar2 default CHR(0),
2985 			  argument68  IN varchar2 default CHR(0),
2986 			  argument69  IN varchar2 default CHR(0),
2987 			  argument70  IN varchar2 default CHR(0),
2988 			  argument71  IN varchar2 default CHR(0),
2989 			  argument72  IN varchar2 default CHR(0),
2990   			  argument73  IN varchar2 default CHR(0),
2991 			  argument74  IN varchar2 default CHR(0),
2992 			  argument75  IN varchar2 default CHR(0),
2993 			  argument76  IN varchar2 default CHR(0),
2994 			  argument77  IN varchar2 default CHR(0),
2995 			  argument78  IN varchar2 default CHR(0),
2996 			  argument79  IN varchar2 default CHR(0),
2997 			  argument80  IN varchar2 default CHR(0),
2998 			  argument81  IN varchar2 default CHR(0),
2999 			  argument82  IN varchar2 default CHR(0),
3000   			  argument83  IN varchar2 default CHR(0),
3001 			  argument84  IN varchar2 default CHR(0),
3002 			  argument85  IN varchar2 default CHR(0),
3003 			  argument86  IN varchar2 default CHR(0),
3004 			  argument87  IN varchar2 default CHR(0),
3005 			  argument88  IN varchar2 default CHR(0),
3006 			  argument89  IN varchar2 default CHR(0),
3007 			  argument90  IN varchar2 default CHR(0),
3008 			  argument91  IN varchar2 default CHR(0),
3009 			  argument92  IN varchar2 default CHR(0),
3010   			  argument93  IN varchar2 default CHR(0),
3011 			  argument94  IN varchar2 default CHR(0),
3012 			  argument95  IN varchar2 default CHR(0),
3013 			  argument96  IN varchar2 default CHR(0),
3014 			  argument97  IN varchar2 default CHR(0),
3015 			  argument98  IN varchar2 default CHR(0),
3016 			  argument99  IN varchar2 default CHR(0),
3017 			  argument100  IN varchar2 default CHR(0))
3018 			  return number is
3019 
3020 	reqid		number;
3021 
3022   begin
3023 	-- If not in database trigger mode:
3024 	-- Rollback to start_of_submission if submit() function fails to
3025 	-- submit the request.
3026 	if (not (P_DB_TRIGGER_MODE)) then
3027 		savepoint start_of_submission;
3028 	end if;
3029 
3030 	reqid := submit (
3031 		 application, program, description, start_time, sub_request,
3032 		 Argument1,  Argument2,  Argument3,  Argument4,  Argument5,
3033 		 Argument6,  Argument7,  Argument8,  Argument9,  Argument10,
3034 		 Argument11, Argument12, Argument13, Argument14, Argument15,
3035 		 Argument16, Argument17, Argument18, Argument19, Argument20,
3036 		 Argument21, Argument22, Argument23, Argument24, Argument25,
3037 		 Argument26, Argument27, Argument28, Argument29, Argument30,
3038 		 Argument31, Argument32, Argument33, Argument34, Argument35,
3039 		 Argument36, Argument37, Argument38, Argument39, Argument40,
3040 		 Argument41, Argument42, Argument43, Argument44, Argument45,
3041 		 Argument46, Argument47, Argument48, Argument49, Argument50,
3042 		 Argument51, Argument52, Argument53, Argument54, Argument55,
3043 		 Argument56, Argument57, Argument58, Argument59, Argument60,
3044 		 Argument61, Argument62, Argument63, Argument64, Argument65,
3045 		 Argument66, Argument67, Argument68, Argument69, Argument70,
3046 		 Argument71, Argument72, Argument73, Argument74, Argument75,
3047 		 Argument76, Argument77, Argument78, Argument79, Argument80,
3048 		 Argument81, Argument82, Argument83, Argument84, Argument85,
3049 		 Argument86, Argument87, Argument88, Argument89, Argument90,
3050 		 Argument91, Argument92, Argument93, Argument94, Argument95,
3051 		 Argument96, Argument97, Argument98, Argument99, Argument100);
3052 
3053 	if (not (P_DB_TRIGGER_MODE)) then
3054 		if (reqid = 0) then
3055 			rollback to start_of_submission;
3056 		end if;
3057 	end if;
3058 
3059 	init_pvt_vars;
3060 
3061 	return (reqid);
3062 
3063   end submit_request;
3064 
3065   --
3066   -- Name
3067   --   submit_svc_ctl_request
3068   -- Purpose
3069   --   Submits concurrent request to be processed by a concurrent manager
3070   --
3071   -- Arguments
3072   --   command          - concurrent program name for which the request has
3073   --                    - to be submitted: ACTIVATE, DEACTIVATE, RESTART,
3074   --                    - ABORT (ie. terminate), VERIFY, SUSPEND, or RESUME
3075   --   service          - Service instance or manager developer name.
3076   --   service_app      - manager or service instance's application short name
3077 
3078 function submit_svc_ctl_request (
3079                           command     IN varchar2,
3080                           service     IN varchar2,
3081                           service_app IN varchar2)
3082                           return number is
3083 
3084  mgr_app_id  number;		-- Arg2
3085  mgr_id      number;		-- Arg1
3086  my_descr    varchar2(2000);	-- DESCRIPTION
3087  now	     date;		-- START_TIME
3088  reqid	     number;
3089  prog_id     number;
3090 
3091 
3092 begin
3093      begin -- Is the program name correct?
3094          Select concurrent_program_id
3095                 Into prog_id
3096                 From Fnd_concurrent_programs
3097                Where concurrent_program_name = command
3098 		and application_id = 0;
3099 
3100          exception
3101              when no_data_found then
3102                   fnd_message.set_name ('FND', 'CONC-Invalid Conc program');
3103                   fnd_message.set_token ('PROGRAM', command, FALSE);
3104                   return (0);
3105              when others then
3106                   fnd_message.set_name ('FND', 'SQL-Generic error');
3107                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3108                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3109                   fnd_message.set_token (
3110                                 'ROUTINE', 'submit_svc_ctl_request', FALSE);
3111                   return (0);
3112      end; -- Is the program name correct?
3113 
3114      begin -- Is the appl short name correct?
3115          Select Application_ID, sysdate
3116                 Into mgr_app_id, now
3117                 From Fnd_Application
3118                Where Application_Short_Name = upper (service_app);
3119 
3120          exception
3121              when no_data_found then
3122                   fnd_message.set_name ('FND', 'CONC-Invalid Appl Short Name');
3123                   fnd_message.set_token ('APPLNAME', service_app, FALSE);
3124                   return (0);
3125              when others then
3126                   fnd_message.set_name ('FND', 'SQL-Generic error');
3127                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3128                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3129                   fnd_message.set_token (
3130                                 'ROUTINE', 'submit_svc_ctl_request', FALSE);
3131                   return (0);
3132      end; -- Is the appl short name correct?
3133 
3134      begin -- Is the svc inst short name correct?
3135          Select Concurrent_queue_id
3136                 Into mgr_id
3137                 From Fnd_Concurrent_queues
3138                Where Application_id = mgr_app_id
3139 		and Concurrent_queue_name = service;
3140          exception
3141              when no_data_found then
3142                   fnd_message.set_name ('FND', 'CONC-Invalid Queue Name');
3143                   fnd_message.set_token ('QUEUENAME', service, FALSE);
3144                   return (0);
3145              when others then
3146                   fnd_message.set_name ('FND', 'SQL-Generic error');
3147                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3148                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3149                   fnd_message.set_token (
3150                                 'ROUTINE', 'submit_svc_ctl_request', FALSE);
3151                   return (0);
3152      end; -- Is the svc inst short name correct?
3153 
3154      my_descr := fnd_concurrent.Build_Svc_Ctrl_Desc(
3155 		mgr_id, mgr_app_id, null, command);
3156 
3157      if (not (P_DB_TRIGGER_MODE)) then
3158          savepoint start_of_qc_submission;
3159      end if;
3160 
3161      reqid := submit_request(
3162 		'FND', command, my_descr, now, FALSE, mgr_id, mgr_app_id);
3163 
3164      if (reqid = 0) then
3165 	return(0);
3166      end if;
3167 
3168      begin -- Update queue cntrl code
3169          update fnd_concurrent_queues
3170             set CONTROL_CODE = decode(prog_id, 0, 'A', 1, 'D', 2, 'V', 3, 'R',
3171 			4, 'T', 5, 'D', 6, 'A', 7, 'O', 8, 'Q', null)
3172 	  where concurrent_queue_id = mgr_id
3173 	    and application_id = mgr_app_id;
3174      exception
3175              when others then
3176 		  if (not (P_DB_TRIGGER_MODE)) then
3177          		rollback to start_of_qc_submission;
3178 		  end if;
3179                   fnd_message.set_name ('FND', 'SQL-Generic error');
3180                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3181                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3182                   fnd_message.set_token (
3183                        'ROUTINE', 'submit_svc_ctl_request(update)', FALSE);
3184                   return (0);
3185      end; -- update cntl code
3186 
3187      commit;
3188      return (reqid);
3189 end submit_svc_ctl_request;
3190 
3191 function submit_svc_ctl_by_app (
3192                           command     IN varchar2,
3193                           application IN varchar2,
3194 			  svc_type    IN NUMBER default 2)
3195                           return number is
3196 
3197  mgr_app_id  number;		-- Arg2
3198  my_descr    varchar2(2000);	-- DESCRIPTION
3199  now	     date;		-- START_TIME
3200  reqid	     number;
3201  prog_id     number;
3202 
3203 
3204 begin
3205      begin -- Is the program name correct?
3206          Select concurrent_program_id
3207                 Into prog_id
3208                 From Fnd_concurrent_programs
3209                Where concurrent_program_name = command
3210 		and application_id = 0;
3211 
3212          exception
3213              when no_data_found then
3214                   fnd_message.set_name ('FND', 'CONC-Invalid Conc program');
3215                   fnd_message.set_token ('PROGRAM', command, FALSE);
3216                   return (0);
3217              when others then
3218                   fnd_message.set_name ('FND', 'SQL-Generic error');
3219                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3220                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3221                   fnd_message.set_token (
3222                                 'ROUTINE', 'submit_svc_ctl_by_app', FALSE);
3223                   return (0);
3224      end; -- Is the program name correct?
3225 
3226      begin -- Is the appl short name correct?
3227          Select Application_ID, sysdate
3228                 Into mgr_app_id, now
3229                 From Fnd_Application
3230                Where Application_Short_Name = upper (application);
3231 
3232          exception
3233              when no_data_found then
3234                   fnd_message.set_name ('FND', 'CONC-Invalid Appl Short Name');
3235                   fnd_message.set_token ('APPLNAME', application, FALSE);
3236                   return (0);
3237              when others then
3238                   fnd_message.set_name ('FND', 'SQL-Generic error');
3239                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3240                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3241                   fnd_message.set_token (
3242                                 'ROUTINE', 'submit_svc_ctl__by_app', FALSE);
3243                   return (0);
3244      end; -- Is the appl short name correct?
3245 
3246      my_descr := fnd_concurrent.Build_Svc_Ctrl_Desc(
3247 		-1, mgr_app_id, svc_type, command);
3248 
3249      if (not (P_DB_TRIGGER_MODE)) then
3250          savepoint start_of_qc_submission;
3251      end if;
3252 
3253      reqid := submit_request(
3254 		'FND', command, my_descr, now, FALSE, -1, mgr_app_id, svc_type);
3255 
3256      if (reqid = 0) then
3257 	return(0);
3258      end if;
3259 
3260      begin -- Update queue cntrl code
3261          update fnd_concurrent_queues
3262             set CONTROL_CODE = decode(prog_id, 0, 'A', 1, 'D', 2, 'V', 3, 'R',
3263 			4, 'T', 5, 'D', 6, 'A', 7, 'O', 8, 'Q', null)
3264 	  where
3265            /* either CM or TM and request is for mgrs (or both) */
3266            (((manager_type = '1') or (manager_type = '3'))
3267 		and ((svc_type = 0) or (svc_type = 2)))
3268        or  /* or service and request is for services (or both) */
3269            ((manager_type > 999) and ((svc_type = 1) or (svc_type = 2)))
3270 	    and application_id = mgr_app_id;
3271      exception
3272              when others then
3273 		  if (not (P_DB_TRIGGER_MODE)) then
3274          		rollback to start_of_qc_submission;
3275 		  end if;
3276                   fnd_message.set_name ('FND', 'SQL-Generic error');
3277                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3278                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3279                   fnd_message.set_token (
3280                        'ROUTINE', 'submit_svc_ctl_by_app(update)', FALSE);
3281                   return (0);
3282      end; -- update cntl code
3283 
3284      commit;
3285      return (reqid);
3286 end submit_svc_ctl_by_app;
3287 
3288   --
3289   -- Name
3290   --   submit_svc_ctl_by_svc
3291   -- Purpose
3292   --   Submits Queue Control Request
3293   --   WARNING PERFORMS A COMMIT!!!
3294   --
3295   -- Arguments
3296   --   command          - concurrent program name for which the request has
3297   --                    - to be submitted: ACTIVATE, DEACTIVATE, RESTART,
3298   --                    - ABORT (ie. terminate), VERIFY, SUSPEND, or RESUME
3299   --   service          - Service instance or manager developer name.
3300 
3301 function submit_svc_ctl_by_svc (
3302                           command     IN varchar2,
3303                           service     IN varchar2)
3304                           return number is
3305 
3306  svc_id      number;		-- Arg2
3307  my_descr    varchar2(2000);	-- DESCRIPTION
3308  now	     date;		-- START_TIME
3309  reqid	     number;
3310  prog_id     number;
3311 
3312 
3313 begin
3314      begin -- Is the program name correct?
3315          Select concurrent_program_id
3316                 Into prog_id
3317                 From Fnd_concurrent_programs
3318                Where concurrent_program_name = command
3319 		and application_id = 0;
3320 
3321          exception
3322              when no_data_found then
3323                   fnd_message.set_name ('FND', 'CONC-Invalid Conc program');
3324                   fnd_message.set_token ('PROGRAM', command, FALSE);
3325                   return (0);
3326              when others then
3327                   fnd_message.set_name ('FND', 'SQL-Generic error');
3328                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3329                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3330                   fnd_message.set_token (
3331                                 'ROUTINE', 'submit_svc_ctl_by_svc', FALSE);
3332                   return (0);
3333      end; -- Is the program name correct?
3334 
3335      begin -- Is the svc name correct?
3336          Select service_id
3337                 Into svc_id
3338                 From Fnd_Cp_services
3339                Where service_handle = service;
3340          exception
3341              when no_data_found then
3342                   fnd_message.set_name ('FND', 'CONC-SM INVALID SVC HANDLE');
3343                   fnd_message.set_token ('HANDLE', service, FALSE);
3344                   return (0);
3345              when others then
3346                   fnd_message.set_name ('FND', 'SQL-Generic error');
3347                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3348                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3349                   fnd_message.set_token (
3350                                 'ROUTINE', 'submit_svc_ctl_by_svc', FALSE);
3351                   return (0);
3352      end; -- Is the svc name correct?
3353 
3354      my_descr := fnd_concurrent.Build_Svc_Ctrl_Desc(-3, svc_id, null, command);
3355 
3356      if (not (P_DB_TRIGGER_MODE)) then
3357          savepoint start_of_qc_submission;
3358      end if;
3359 
3360      reqid := submit_request('FND', command, my_descr, now, FALSE, -3, svc_id);
3361 
3362      if (reqid = 0) then
3363 	return(0);
3364      end if;
3365 
3366      begin -- Update queue cntrl code
3367          update fnd_concurrent_queues
3368             set CONTROL_CODE = decode(prog_id, 0, 'A', 1, 'D', 2, 'V', 3, 'R',
3369 			4, 'T', 5, 'D', 6, 'A', 7, 'O', 8, 'Q', null)
3370 	  where manager_type = to_char(svc_id);
3371      exception
3372              when others then
3373 		  if (not (P_DB_TRIGGER_MODE)) then
3374          		rollback to start_of_qc_submission;
3375 		  end if;
3376                   fnd_message.set_name ('FND', 'SQL-Generic error');
3377                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3378                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3379                   fnd_message.set_token (
3380                        'ROUTINE', 'submit_svc_ctl_by_svc(update)', FALSE);
3381                   return (0);
3382      end; -- update cntl code
3383 
3384      commit;
3385      return (reqid);
3386 end submit_svc_ctl_by_svc;
3387 
3388   --
3389   -- Name
3390   --   submit_svc_ctl_cpinfra
3391   -- Purpose
3392   --   Submits Queue Control Request
3393   --   WARNING PERFORMS A COMMIT!!!
3394   --
3395   -- Arguments
3396   --   command          - concurrent program name for which the request has
3397   --                    - to be submitted: ACTIVATE, DEACTIVATE, RESTART,
3398   --                    - ABORT (ie. terminate), VERIFY, SUSPEND, or RESUME
3399 
3400 function submit_svc_ctl_cpinfra (
3401                           command     IN varchar2)
3402                           return number is
3403 
3404  my_descr    varchar2(2000);	-- DESCRIPTION
3405  now	     date;		-- START_TIME
3406  reqid	     number;
3407  prog_id     number;
3408 
3409 
3410 begin
3411      begin -- Is the program name correct?
3412          Select concurrent_program_id
3413                 Into prog_id
3414                 From Fnd_concurrent_programs
3415                Where concurrent_program_name = command
3416 		and application_id = 0;
3417 
3418          exception
3419              when no_data_found then
3420                   fnd_message.set_name ('FND', 'CONC-Invalid Conc program');
3421                   fnd_message.set_token ('PROGRAM', command, FALSE);
3422                   return (0);
3423              when others then
3424                   fnd_message.set_name ('FND', 'SQL-Generic error');
3425                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3426                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3427                   fnd_message.set_token (
3428                                 'ROUTINE', 'submit_svc_ctl_cpinfra', FALSE);
3429                   return (0);
3430      end; -- Is the program name correct?
3431 
3432      my_descr := fnd_concurrent.Build_Svc_Ctrl_Desc(-2, null, null, command);
3433 
3434      if (not (P_DB_TRIGGER_MODE)) then
3435          savepoint start_of_qc_submission;
3436      end if;
3437 
3438      reqid := submit_request('FND', command, my_descr, now, FALSE, -2);
3439 
3440      if (reqid = 0) then
3441 	return(0);
3442      end if;
3443 
3444      begin -- Update queue cntrl code
3445          update fnd_concurrent_queues
3446             set CONTROL_CODE = decode(prog_id, 0, 'A', 1, 'D', 2, 'V', 3, 'R',
3447 			4, 'T', 5, 'D', 6, 'A', 7, 'O', 8, 'Q', null)
3448 	  where manager_type in ('1','3','4','5');
3449      exception
3450              when others then
3451 		  if (not (P_DB_TRIGGER_MODE)) then
3452          		rollback to start_of_qc_submission;
3453 		  end if;
3454                   fnd_message.set_name ('FND', 'SQL-Generic error');
3455                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3456                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3457                   fnd_message.set_token (
3458                        'ROUTINE', 'submit_svc_ctl_cpinfra(update)', FALSE);
3459                   return (0);
3460      end; -- update cntl code
3461 
3462      commit;
3463      return (reqid);
3464 end submit_svc_ctl_cpinfra;
3465 
3466   --
3467   -- Name
3468   --   submit_svc_ctl_cpall
3469   -- Purpose
3470   --   Submits Queue Control Request
3471   --   WARNING PERFORMS A COMMIT!!!
3472   --
3473   -- Arguments
3474   --   command          - concurrent program name for which the request has
3475   --                    - to be submitted: ACTIVATE, DEACTIVATE, RESTART,
3476   --                    - ABORT (ie. terminate), VERIFY, SUSPEND, or RESUME
3477 
3478 function submit_svc_ctl_cpall (
3479                           command     IN varchar2)
3480                           return number is
3481 
3482  my_descr    varchar2(2000);	-- DESCRIPTION
3483  now	     date;		-- START_TIME
3484  reqid	     number;
3485  prog_id     number;
3486 
3487 
3488 begin
3489      begin -- Is the program name correct?
3490          Select concurrent_program_id
3491                 Into prog_id
3492                 From Fnd_concurrent_programs
3493                Where concurrent_program_name = command
3494 		and application_id = 0;
3495 
3496          exception
3497              when no_data_found then
3498                   fnd_message.set_name ('FND', 'CONC-Invalid Conc program');
3499                   fnd_message.set_token ('PROGRAM', command, FALSE);
3500                   return (0);
3501              when others then
3502                   fnd_message.set_name ('FND', 'SQL-Generic error');
3503                   fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3504                   fnd_message.set_token ('REASON', sqlerrm, FALSE);
3505                   fnd_message.set_token (
3506                                 'ROUTINE', 'submit_svc_ctl_cpall', FALSE);
3507                   return (0);
3508      end; -- Is the program name correct?
3509 
3510      my_descr := fnd_concurrent.Build_Svc_Ctrl_Desc(-4, null, null, command);
3511 
3512      if (not (P_DB_TRIGGER_MODE)) then
3513          savepoint start_of_qc_submission;
3514      end if;
3515 
3516      reqid := submit_request('FND', command, my_descr, now, FALSE, -4);
3517 
3518      if (reqid = 0) then
3519 	return(0);
3520      end if;
3521 
3522      commit;
3523      return (reqid);
3524 end submit_svc_ctl_cpall;
3525 
3526 procedure internal(critical in varchar2 default null,
3527                    type     in varchar2 default null) is
3528 begin
3529   P_CRITICAL_REQUEST := critical;
3530   P_REQUEST_TYPE := type;
3531 end;
3532 
3533   --
3534   -- Name
3535   --   add_notification
3536   -- Purpose
3537   --   Called before submission to add a user to the notify list.
3538   --   Added this new method since changing the add_notification will need
3539   --   generation of all calling forms.
3540   --   In a major release we can merge this one with previous one with default
3541   --   values.
3542   --
3543   -- Arguments
3544   --    User            - User name.
3545   --    on_normal       - Notify when normal completion (Values Y/N)
3546   --    on_warning      - Notify when request completes with warning (Y/N)
3547   --    on_error        - Notify when request completed with error (Y/N)
3548   function add_notification (user       in varchar2,
3549                              on_normal  in varchar2,
3550                              on_warning in varchar2,
3551                              on_error   in varchar2)
3552             return boolean is
3553     n_index number;
3554     ret_val boolean;
3555   begin
3556 
3557     ret_val := add_notification(user);
3558     if ( ret_val ) then
3559 
3560        n_index := P_NOTIFICATION_COUNT;
3561 
3562        P_NOTIFICATIONS(n_index).on_normal := add_notification.on_normal;
3563        P_NOTIFICATIONS(n_index).on_warning := add_notification.on_warning;
3564        P_NOTIFICATIONS(n_index).on_error := add_notification.on_error;
3565 
3566        return TRUE;
3567     else
3568        return FALSE;
3569     end if;
3570 
3571   end;
3572 
3573 
3574   -- Name
3575   --   set_deferred
3576   -- Purpose
3577   --   Called before calling request submission page by other product teams
3578   --
3579   -- Arguments
3580   --
3581   --
3582   function set_deferred return boolean is
3583   begin
3584     P_DEFERRED_MODE := TRUE;
3585     return TRUE;
3586   end;
3587 
3588 
3589   -- Name
3590   --   set_def_request_id
3591   -- Purpose
3592   --   Called for setting global request id and the request id will be used while creating actual request
3593   --
3594   -- Arguments
3595   -- 	request_id - used while creating actual request in fnd_concurrent_request
3596   --
3597   function set_def_request_id (request_id IN number)
3598   	return boolean is
3599   begin
3600   	P_DEF_REQUEST_ID := request_id;
3601   	return TRUE;
3602   end;
3603 
3604   -- Name
3605   --   get_fnd_debug_rules_sequence
3606   -- Purpose
3607   --   Called to obtain the next sequence value for fnd_debug_rules table
3608   --
3609   -- Arguments
3610   --    none
3611   --
3612   function get_fnd_debug_rules_sequence return number is
3613 
3614   l_sequence number;
3615   dual_no_rows	   exception;
3616   dual_too_many_rows exception;
3617 
3618   begin
3619 
3620      begin
3621         select fnd_debug_rules_s.nextval
3622           into l_sequence
3623           from sys.dual;
3624 
3625         exception
3626           when no_data_found then
3627             raise dual_no_rows;
3628           when too_many_rows then
3629             raise dual_too_many_rows;
3630           when others then
3631             raise;
3632      end;
3633 
3634      return l_sequence;
3635   end;
3636 
3637 
3638   -- Name
3639   --   update_fnd_debug_rules_req_id
3640   -- Purpose
3641   --   Called to set the request id for the specific fnd_debug_rule_id
3642   --
3643   -- Arguments
3644   --    request_id - the actual request id that debug options is being set for.
3645   --    fnd_debug_rule_id - the specific row in fnd_debug_rules to get updated
3646   --
3647   function update_fnd_debug_rules_req_id (
3648                req_id             IN number,
3649                fnd_debug_rule_id  IN number )
3650         return boolean is
3651   begin
3652 
3653      begin
3654         update fnd_debug_rules
3655            set request_id = req_id
3656          where debug_rule_id = fnd_debug_rule_id;
3657 
3658         exception
3659           when others then
3660             fnd_message.set_name ('FND', 'SQL-Generic error');
3661             fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3662             fnd_message.set_token ('REASON', sqlerrm, FALSE);
3663             fnd_message.set_token (
3664                 'ROUTINE', 'update_fnd_debug_rules_req_id', FALSE);
3665             return FALSE;
3666      end;
3667 
3668      commit;
3669      return TRUE;
3670   end;
3671 
3672   -- Name
3673   --   delete_fnd_debug_rules_id
3674   -- Purpose
3675   --   Called to delete the specific fnd_debug_rule_id from fnd_debug_rules
3676   --   and fnd_debug_rules_options
3677   --
3678   -- Arguments
3679   --    fnd_debug_rule_id - the specific sequence number to be deleted
3680   --
3681   function delete_fnd_debug_rules_id (
3682                fnd_debug_rule_id  IN number )
3683         return boolean is
3684   l_count_rows  number;
3685   begin
3686      select count(*)
3687        into l_count_rows
3688        from fnd_debug_rules
3689       where debug_rule_id = fnd_debug_rule_id;
3690 
3691      if (l_count_rows > 0) then
3692         delete from fnd_debug_rules
3693          where debug_rule_id = fnd_debug_rule_id;
3694      end if;
3695 
3696      select count(*)
3697        into l_count_rows
3698        from fnd_debug_rule_options
3699       where debug_rule_id = fnd_debug_rule_id;
3700 
3701      if (l_count_rows > 0) then
3702         delete from fnd_debug_rule_options
3703          where debug_rule_id = fnd_debug_rule_id;
3704      end if;
3705 
3706      commit;
3707      return TRUE;
3708 
3709   end;
3710 
3711   -- NAME
3712   --    get_num_char_for_terr
3713   -- Purpose
3714   --    Called to retrieve the num char associated with a territory
3715   --
3716   -- Arguments
3717   --    original_terr
3718   --    check_terr
3719   --
3720   function get_num_char_for_terr (
3721                original_terr  IN varchar2,
3722                check_terr     IN varchar2 )
3723         return varchar2 is
3724   cursor cparam (param_name in varchar2) is
3725          select value
3726            from V$NLS_PARAMETERS
3727           where parameter = param_name;
3728 
3729   l_num_char  varchar2(3);
3730   begin
3731 
3732      dbms_session.set_nls('NLS_TERRITORY', ''''||UPPER(check_terr)||'''');
3733 
3734      open cparam('NLS_NUMERIC_CHARACTERS');
3735      fetch cparam into l_num_char;
3736      close cparam;
3737 
3738      dbms_session.set_nls('NLS_TERRITORY', ''''||UPPER(original_terr)||'''');
3739 
3740      return (l_num_char);
3741 
3742   end;
3743 
3744   -- NAME
3745   --    validate_num_char_for_terr
3746   -- Purpose
3747   --    Called to validate the num char associated with a territory
3748   --
3749   -- Arguments
3750   --    num_char
3751   --
3752   function validate_num_char_for_terr (
3753                num_char  IN varchar2 )
3754         return boolean is
3755   l_lookup_cnt number;
3756   begin
3757 
3758      select count(*)
3759        into l_lookup_cnt
3760        from fnd_lookup_values_vl
3761       where lookup_type = 'ICX_NUMERIC_CHARACTERS'
3762         and lookup_code = num_char;
3763 
3764      if ( l_lookup_cnt > 0 ) then
3765         return TRUE;
3766      else
3767         return FALSE;
3768      end if;
3769   end;
3770 FUNCTION INSERT_USER_SCHEDULE(P_RELEASE_CLASS_NAME IN VARCHAR2,
3771                               P_REQUESTED_START_DATE IN VARCHAR2,
3772                               P_REQUESTED_END_DATE IN VARCHAR2,
3773                               P_REPEAT_INTERVAL IN NUMBER,
3774                               P_REPEAT_INTERVAL_UNIT in VARCHAR2,
3775                               P_REPEAT_INTERVAL_TYPE IN VARCHAR2,
3776                               P_CLASS_TYPE IN VARCHAR2,
3777                               P_CLASS_INFO IN VARCHAR2,
3778                               P_DESCRIPTION IN VARCHAR2
3779                               ) RETURN BOOLEAN IS
3780 
3781 
3782 P_REPEAT_VALUE VARCHAR2(10);
3783 RELCLASS_INSERT_ERROR EXCEPTION;
3784 P_RELEASE_CLASS_ID NUMBER;
3785 P_RELEASE_CLASS_APP_ID NUMBER;
3786 P_REPEAT_START_DATE		DATE		:= null;
3787 P_REPEAT_END_DATE		DATE		:= null;
3788 
3789 BEGIN
3790 
3791   if(P_REQUESTED_START_DATE is null) then
3792     P_REPEAT_START_DATE := null;
3793   else
3794     P_REPEAT_START_DATE := FND_CONC_DATE.STRING_TO_DATE(P_REQUESTED_START_DATE);
3795   end if;
3796 
3797   if(P_REQUESTED_END_DATE is null) then
3798     P_REPEAT_END_DATE := null;
3799   else
3800     P_REPEAT_END_DATE := FND_CONC_DATE.STRING_TO_DATE(P_REQUESTED_END_DATE);
3801   end if;
3802 
3803   Select FND_CONC_RELEASE_CLASSES_S.nextval, 0
3804 	     into P_RELEASE_CLASS_ID, P_RELEASE_CLASS_APP_ID from Sys.dual;
3805 
3806   SELECT (DECODE(P_CLASS_TYPE, 'P', Decode(P_REPEAT_INTERVAL_UNIT, NULL, NULL,
3807                               P_REPEAT_INTERVAL||':'||
3808                                  Decode(P_REPEAT_INTERVAL_UNIT,
3809 						                        'MINUTES', 'N',
3810                                     'MONTHS', 'M',
3811                                     'HOURS', 'H',
3812                                     'DAYS',  'D') || ':' ||
3813                                     Decode(P_REPEAT_INTERVAL_TYPE,
3814 						                        'START', 'S', 'C')), NULL)) INTO P_REPEAT_VALUE FROM SYS.DUAL;
3815 
3816   -- Bug 6808926. Consider repeat start date as SYSDATE if null
3817 
3818   INSERT INTO FND_CONC_RELEASE_CLASSES
3819     (APPLICATION_ID, RELEASE_CLASS_ID, RELEASE_CLASS_NAME,
3820     ENABLED_FLAG, LAST_UPDATE_DATE, LAST_UPDATED_BY,
3821     LAST_UPDATE_LOGIN, CREATION_DATE, CREATED_BY,
3822     UPDATED_FLAG, DATE1, DATE2,
3823     CLASS_TYPE, CLASS_INFO)
3824   VALUES (P_RELEASE_CLASS_APP_ID, P_RELEASE_CLASS_ID, P_RELEASE_CLASS_NAME,
3825     'Y', SYSDATE, FND_GLOBAL.USER_ID,
3826     FND_GLOBAL.CONC_LOGIN_ID, SYSDATE, FND_GLOBAL.USER_ID,
3827     'Y', decode(P_REPEAT_START_DATE, null, SYSDATE, P_REPEAT_START_DATE), P_REPEAT_END_DATE,
3828     P_CLASS_TYPE, DECODE(P_CLASS_TYPE, 'P', P_REPEAT_VALUE, P_CLASS_INFO));
3829 
3830   if (sql%rowcount = 0) then
3831 	      raise RELCLASS_INSERT_ERROR;
3832   end if;
3833 
3834   INSERT INTO FND_CONC_RELEASE_CLASSES_TL
3835     (APPLICATION_ID,     RELEASE_CLASS_ID,
3836     LANGUAGE, SOURCE_LANG, USER_RELEASE_CLASS_NAME,
3837     LAST_UPDATE_DATE, LAST_UPDATED_BY, LAST_UPDATE_LOGIN,
3838     CREATION_DATE, CREATED_BY, DESCRIPTION)
3839   SELECT P_RELEASE_CLASS_APP_ID, P_RELEASE_CLASS_ID,
3840     L.LANGUAGE_CODE, USERENV('LANG'),	P_RELEASE_CLASS_NAME,
3841     SYSDATE, FND_GLOBAL.USER_ID, FND_GLOBAL.CONC_LOGIN_ID,
3842     SYSDATE, FND_GLOBAL.USER_ID, P_DESCRIPTION
3843   FROM FND_LANGUAGES L
3844   WHERE L.INSTALLED_FLAG in ('I', 'B');
3845 
3846   if (sql%rowcount = 0) then
3847 	      raise RELCLASS_INSERT_ERROR;
3848   end if;
3849 
3850   return (TRUE);
3851 
3852 EXCEPTION
3853 
3854 when RELCLASS_INSERT_ERROR then
3855 	    fnd_message.set_name ('FND', 'CONC-RelClass insert failed');
3856 	    fnd_message.set_token ('APPLICATION', P_REL_CLASS_APP_ID, FALSE);
3857 	    fnd_message.set_token ('CLASS', P_REL_CLASS_ID, FALSE);
3858 	    return (FALSE);
3859 
3860 when OTHERS then
3861 	    fnd_message.set_name ('FND', 'SQL-Generic error');
3862 	    fnd_message.set_token ('ERRNO', sqlcode, FALSE);
3863 	    fnd_message.set_token ('REASON', sqlerrm, FALSE);
3864 	    fnd_message.set_token (
3865 				'ROUTINE', 'SUBMIT: others', FALSE);
3866 	    return (FALSE);
3867 END;
3868 
3869 end FND_REQUEST;