1 package body fnd_webfile as
2 /* $Header: AFCPFILB.pls 120.7 2007/06/26 13:08:09 ddhulla ship $ */
3
4
5 debug varchar2(1) := 'N';
6
7
8 /*--
9 *-- GENERIC_ERROR (Internal)
10 *--
11 *-- Set error message and raise exception for unexpected sql errors.
12 *--
13 */
14 procedure GENERIC_ERROR(routine in varchar2,
15 errcode in number,
16 errmsg in varchar2) is
17 begin
18 fnd_message.set_name('FND', 'SQL_PLSQL_ERROR');
19 fnd_message.set_token('ROUTINE', routine);
20 fnd_message.set_token('ERRNO', errcode);
21 fnd_message.set_token('REASON', errmsg);
22 end;
23
24 /*--
25 *-- UPDATE SVC (Internal)
26 *--
27 *-- Update registered node with full service denotation (for generic services)
28 *-- Created to be autonomous transaction so no commit would occur in get_url
29 *--
30 */
31 procedure UPDATE_SVC(id in number,
32 svc in varchar2) is
33 PRAGMA AUTONOMOUS_TRANSACTION;
34 begin
35 update fnd_file_temp
36 set node_name = svc
37 where file_id = id;
38
39 commit;
40 exception
41 when others then
42 rollback;
43 end update_svc;
44
45 /*
46 * Procedure: update_cfg_info
47 * Internal use only
48 *
49 * Purpose :
50 * Update registered node with full context file information
51 *
52 */
53 procedure update_cfg_info(id in number,
54 dest_file in varchar2,
55 dest_svc in varchar2,
56 tran_type in varchar2) is
57 PRAGMA AUTONOMOUS_TRANSACTION;
58 begin
59 update fnd_file_temp
60 set destination_node = dest_svc,
61 destination_file = dest_file,
62 transfer_type = tran_type
63 where file_id = id;
64
65 commit;
66 exception
67 when others then
68 rollback;
69 end update_cfg_info;
70
71 /*
72 *procedure: update_page_info
73 * is called from get_url function to update the page information(page_number and page_size column).
74 * It is an internal procedure.
75 *
76 *
77 *
78 */
79 procedure update_page_info(id in number,
80 p_page_no in number,
81 p_page_size in number,
82 p_tran_type in varchar2) is
83 PRAGMA AUTONOMOUS_TRANSACTION;
84 begin
85 update fnd_file_temp
86 set page_number = p_page_no,
87 page_size = p_page_size,
88 transfer_type = p_tran_type
89 where file_id =id;
90
91 commit;
92 exception
93 when others then
94 rollback;
95
96 end update_page_info;
97
98
99
100
101 /* Function: GET_URL
102 *
103 * Purpose: Constructs and returns the URL for a Concurrent Processing
104 * log or output file.
105 *
106 * Arguments:
107 * file_type - Specifies the type of file desired:
108 * fnd_webfile.process_log = The log of the concurrent process identified
109 * by the parameter ID.
110 * fnd_webfile.icm_log = The log of the ICM process identified by ID.
111 * Or, the log of the ICM process that spawned
112 * the concurrent process identified by ID.
113 * Or, the log of the most recent ICM process
114 * if ID is null.
115 * fnd_webfile.request_log = The log of the request identified by ID.
116 * fnd_webfile.request_out = The output of the request identified by ID.
117 * fnd_webfile.request_mgr = The log of the concurrent process that ran
118 * the request identified by ID.
119 * fnd_webfile.frd_log = The log of the forms process identified
120 * by ID.
121 * fnd_webfile.generic_log = The log file identified by ID.
122 * fnd_webfile.generic_trc = The trace file identified by ID.
123 * fnd_webfile.generic_ora = The ora file identified by ID.
124 * fnd_webfile.generic_cfg = The config file identified by ID.
125 * fnd_webfile.context_file= The context file identified by ID.
126 * fnd_webfile.generic_text= Generic file using text transfer mode.
127 * fnd_webfile.generic_binary = Generic file using binary transfer mode.
128 * fnd_webfile.request_xml_output = The XML output of Concurrent Request.
129 *
130 * id - A concurrent process ID, concurrent request ID, or file ID
131 * depending on the file type specified.
132 * For fnd_webfile.context_file,fnd_webfile.generic_text,
133 * fnd_webfile.generic_binary this value is null.
134 *
135 * gwyuid - The value of the environment variable GWYUID used in
136 * constructing the URL. No longer used.
137 *
138 * two_task - The database two_task, used in constructing the URL. No longer used.
139 *
140 * expire_time - The number of minutes for which this URL will remain
141 * valid.
142 * source_file - Source file name with full patch
143 *
144 * source_node - Source node name.
145 *
146 * dest_file - Destination file name
147 *
148 * dest_node - Destination node name
149 *
150 * page_no - Current page number
151 *
152 * page_size - Number of lines in a page
153 *
154 * Returns NULL on error. Check the FND message stack.
155 *
156 * Note that gwyuid and two_task are no longer used. They are retained for
157 * compatibility only.
158 *
159 */
160 function get_url( file_type IN number,
161 id IN number,
162 gwyuid IN varchar2,
163 two_task IN varchar2,
164 expire_time IN number,
165 source_file IN varchar2 default null,
166 source_node IN varchar2 default null,
167 dest_file IN varchar2 default null,
168 dest_node IN varchar2 default null,
169 page_no IN number default null,
170 page_size IN number default null) return varchar2
171 is
172 base varchar2(257);
173 base_type varchar2(3) := 'CGI';
174 url varchar2(512);
175 fname varchar2(255);
176 node varchar2(50);
177 mtype varchar2(80) := 'text/plain';
178 x_mode varchar2(30) := 'TEXT';
179 ffcode varchar2(30);
180 fs_enabled varchar2(2);
181 temp_id varchar2(32);
182 pos number;
183 svc varchar2(254);
184 dest_svc varchar2(254);
185 t_node varchar2(50);
186 req_id number;
187 controlling_mgr number;
188 cpid number;
189 fsize number;
190 save_out varchar2(2);
191 ext varchar2(32);
192 cmpext varchar2(32);
193 sqlstmt varchar2(200);
194 ncenc varchar2(1) := 'N';
195 prog_name varchar2(30) := null;
196 appl_name varchar2(30) := null;
197 action_publish_count number;
198 begin
199
200 /* Get URL base. */
201
202 --First check IF there is a url base defined FOR CGI - enh# 4477258
203 IF (fnd_profile.defined('APPS_CGI_AGENT')) THEN
204 fnd_profile.get('APPS_CGI_AGENT', base);
205 END IF;
206
207 --IF CGI agent is null then check the web agent
208 --Also set the base_type to WEB
209 IF (base IS NULL) THEN
210 fnd_profile.get('APPS_WEB_AGENT', base);
211 base_type := 'WEB';
212 END IF;
213
214 if (base is null) then
215 fnd_message.set_name('FND', 'FS-NO URL');
216 return null;
217 end if;
218
219
220 if (file_type = process_log) then
221 /* Concurrent process log */
222 begin
223 select logfile_name, node_name
224 into fname, node
225 from fnd_concurrent_processes
226 where concurrent_process_id = id;
227 exception
228 when no_data_found then
229 fnd_message.set_name('FND', 'CONC-PROCESS MISSING');
230 fnd_message.set_token('ROUTINE','FND_WEBFILE.GET_URL');
231 fnd_message.set_token('CPID', id);
232 return null;
233 end;
234 if (fname is null) then
235 fnd_message.set_name('FND', 'SYSTEM-MANAGER LOGFILE NULL');
236 fnd_message.set_token('PROCESS_ID', id);
237 return null;
238 end if;
239
240 elsif (file_type = icm_log) then
241 /* ICM log */
242 begin
243 select logfile_name, node_name
244 into fname, node
245 from fnd_concurrent_processes
246 where (((id is not null)
247 and concurrent_process_id =
248 ( select max(p.concurrent_process_id)
249 from fnd_concurrent_processes p,
250 fnd_concurrent_processes p2
251 where p.queue_application_id = 0
252 and p.concurrent_queue_id = 1
253 and p2.concurrent_process_id= id
254 and p.process_start_date <=
255 nvl(p2.process_start_date, sysdate) ) )
256 or
257 ((id is null) and concurrent_process_id =
258 ( select max(p.concurrent_process_id)
259 from fnd_concurrent_processes p
260 where p.queue_application_id = 0
261 and p.concurrent_queue_id = 1 ) ));
262 exception
263 when no_data_found then
264 fnd_message.set_name('FND', 'CONC-PROCESS MISSING');
265 fnd_message.set_token('ROUTINE','FND_WEBFILE.GET_URL');
266 fnd_message.set_token('CPID', id);
267 return null;
268 end;
269 if (fname is null) then
270 fnd_message.set_name('FND', 'SYSTEM-MANAGER LOGFILE NULL');
271 fnd_message.set_token('PROCESS_ID', id);
272 return null;
273 end if;
274
275 elsif (file_type = request_log) then
276 /* Request Log */
277 begin
278 select logfile_name, logfile_node_name
279 into fname, node
280 from fnd_concurrent_requests
281 where request_id = id;
282 req_id := id;
283 exception
284 when no_data_found then
285 fnd_message.set_name('FND', 'CONC-REQUEST MISSING');
286 fnd_message.set_token('ROUTINE','FND_WEBFILE.GET_URL');
287 fnd_message.set_token('REQUEST', id);
288 return null;
289 end;
290 if (fname is null) then
291 fnd_message.set_name('FND', 'SYSTEM-REQUEST LOGFILE NULL');
292 fnd_message.set_token('REQUEST_ID', id);
293 return null;
294 end if;
295
296 elsif (file_type = request_out or file_type = request_xml_output) then
297 /* Request Output */
298 ncenc := 'Y';
299 begin
300 select fcr.outfile_name, fcr.outfile_node_name, fmt.mime_type,
301 fcr.save_output_flag, fcr.ofile_size, fmt.file_format_code,
302 fcp.concurrent_program_name, a.application_short_name
303 into fname, node, mtype, save_out, fsize, ffcode, prog_name,appl_name
304 from fnd_concurrent_requests fcr, fnd_mime_types_vl fmt,
305 fnd_concurrent_programs fcp, fnd_application a
306 where fcr.request_id = id
307 and upper(fcr.output_file_type) = upper(fmt.file_format_code)
308 and fcp.concurrent_program_id = fcr.concurrent_program_id
309 and fcp.application_id = fcr.program_application_id
310 and fcp.application_id = a.application_id
311 and rownum = 1;
312
313 /* Bug 6040814. Supporting output file display for FNDREPRINT (REPRINT and REPULISH) programs.
314 * First check whether the program is a FNDREPRINT program.
315 * 1) YES - case a. whether it is a REPRINT and REPUBLISH - check for output details in fnd_conc_req_outputs
316 * case b. Only REPRINT
317 * Check whether the parent program supports republish
318 * 1) YES - Check for output details in fnd_conc_req_outputs which request id as parent request id.
319 * 2) NO - Check for output details in fnd_concurrent_requests with REPRINT request id.
320 * 2) NO (NOT FNDREPRINT)
321 * case a. If the program is layout enabled - check for output details in fnd_conc_req_outputs
322 * case b. Check for the output details in fnd_concurrent_requests as already done in the above sql.
323 */
324
325 /* Check whether the program is a FNDREPRINT program */
326 if (prog_name = 'FNDREPRINT' and appl_name ='FND') then
327
328 select count(1) into action_publish_count from fnd_conc_pp_actions
329 where concurrent_request_id=id and action_type=6;
330
331 if(action_publish_count=1) then /* Check if it is a REPRINT and REPUBLISH request */
332 begin
333 select file_type,file_name,file_node_name,file_size, fmt.mime_type
334 into ffcode, fname, node, fsize, mtype
335 from fnd_conc_req_outputs RO, fnd_mime_types_vl fmt
336 where concurrent_request_id = id
337 and RO.file_type = fmt.file_format_code
338 and rownum = 1;
339 exception
340 when no_data_found then
341 fnd_message.set_name('FND', 'CONC-NO OUTPUT FILE');
342 fnd_message.set_token('REQUEST_ID', id);
343 return null;
344 end;
345 else /* Only a REPRINT request */
346 begin
347 /* Find the parent program for the REPRINT request */
348 select fcp.concurrent_program_name, a.application_short_name
349 into prog_name, appl_name
350 from fnd_concurrent_programs fcp, fnd_application a, fnd_concurrent_requests fcr
351 where fcp.concurrent_program_id = fcr.concurrent_program_id
352 and fcp.application_id = fcr.program_application_id
353 and fcp.application_id = a.application_id
354 and fcr.request_id = (select to_number(argument1) from fnd_concurrent_requests where request_id=id);
355 exception
356 when no_data_found then
357 fnd_message.set_name('FND', 'CONC-REQUEST MISSING');
358 fnd_message.set_token('ROUTINE','FND_WEBFILE.GET_URL');
359 fnd_message.set_token('REQUEST', id);
360 return null;
361 end;
362
363 /* Check if the parent program is layout enabled */
364 if (fnd_conc_sswa.layout_enabled(appl_name, prog_name)) then
365 begin
366 select file_type,file_name,file_node_name,file_size, fmt.mime_type
367 into ffcode, fname, node, fsize, mtype
368 from fnd_conc_req_outputs RO, fnd_mime_types_vl fmt
369 where concurrent_request_id = (select to_number(argument1) from fnd_concurrent_requests where request_id=id)
370 and RO.file_type = fmt.file_format_code
371 and rownum = 1;
372 exception
376 return null;
373 when no_data_found then
374 fnd_message.set_name('FND', 'CONC-NO OUTPUT FILE');
375 fnd_message.set_token('REQUEST_ID', id);
377 end;
378 else /* Parent program is not layout enabled*/
379 begin
380 select output_file_type, outfile_name, outfile_node_name, ofile_size, fmt.mime_type
381 into ffcode, fname, node, fsize, mtype
382 from fnd_concurrent_requests fcr, fnd_mime_types_vl fmt
383 where request_id = id
384 and fcr.output_file_type = fmt.file_format_code
385 and rownum = 1;
386 exception
387 when no_data_found then
388 fnd_message.set_name('FND', 'CONC-NO OUTPUT FILE');
389 fnd_message.set_token('REQUEST_ID', id);
390 return null;
391 end;
392 end if;
393 end if;
394 elsif(fnd_conc_sswa.layout_enabled(appl_name, prog_name) and file_type=request_out) then /* Not a FNDREPRINT request */
395 begin
396 select file_type,file_name,file_node_name,file_size, fmt.mime_type
397 into ffcode, fname, node, fsize, mtype
398 from fnd_conc_req_outputs RO, fnd_mime_types_vl fmt
399 where concurrent_request_id = id
400 and RO.file_type = fmt.file_format_code
401 and rownum = 1;
402 exception
403 when no_data_found then
404 fnd_message.set_name('FND', 'CONC-NO OUTPUT FILE');
405 fnd_message.set_token('REQUEST_ID', id);
406 return null;
407 end;
408 end if;
409
410 req_id := id;
411 exception
412 when no_data_found then
413 fnd_message.set_name('FND', 'CONC-REQUEST MISSING');
414 fnd_message.set_token('ROUTINE','FND_WEBFILE.GET_URL');
415 fnd_message.set_token('REQUEST', id);
416 return null;
417 end;
418 if (save_out = 'N') then
419 fnd_message.set_name('FND', 'CONC-Output file not saved');
420 return null;
421 end if;
422 if (fname is null) then
423 fnd_message.set_name('FND', 'SYSTEM-REQUEST OUTFILE NULL');
424 fnd_message.set_token('REQUEST_ID', id);
425 return null;
426 end if;
427
428 /* Decide the transfer mode, after getting the fnd_file_format datamodal
429 we have to replace these hardcoded values */
430 if ( upper(ffcode) in ('PDF','PS','PCL')) then
431 x_mode := 'BINARY';
432 end if;
433
434 elsif (file_type = request_mgr) then
435 begin
436 select p.logfile_name, p.node_name, r.controlling_manager,
437 p.concurrent_process_id
438 into fname, node, controlling_mgr, cpid
439 from fnd_concurrent_requests r, fnd_concurrent_processes p
440 where r.request_id = id
441 and r.controlling_manager = p.concurrent_process_id(+);
442 /* The outer join makes sure that we don't say that the request
443 row is missing, when the manager row is missing. We know that
444 the manager row was missing if cpid is null. */
445 exception
446 when no_data_found then
447 fnd_message.set_name('FND', 'CONC-REQUEST MISSING');
448 fnd_message.set_token('ROUTINE','FND_WEBFILE.GET_URL');
449 fnd_message.set_token('REQUEST', id);
450 return null;
451 end;
452 if (cpid is null) then
453 fnd_message.set_name('FND', 'CONC-PROCESS MISSING');
454 fnd_message.set_token('ROUTINE','FND_WEBFILE.GET_URL');
455 fnd_message.set_token('CPID', controlling_mgr);
456 return null;
457 end if;
458 if (fname is null) then
459 fnd_message.set_name('FND', 'SYSTEM-MANAGER LOGFILE NULL');
460 fnd_message.set_token('PROCESS_ID', cpid);
461 return null;
462 end if;
463
464 elsif (file_type = frd_log) then
465 begin
466 sqlstmt := 'select node from fnd_oam_forms_rti where rti_id = :id';
467 EXECUTE IMMEDIATE sqlstmt INTO node USING id;
468
469 sqlstmt := 'select filename from fnd_oam_frd_log where rti_id = :id';
470 EXECUTE IMMEDIATE sqlstmt INTO fname USING id;
471
472 exception
473 when no_data_found then
474 fnd_message.set_name('FND', 'CONC-ROW MISSING');
475 return null;
476
477 end;
478 if (fname is null) then
479 fnd_message.set_name('FND', 'SYSTEM-LOGFILE NULL');
480 return null;
481 end if;
482
483 elsif (file_type >= generic_log and file_type <= generic_cfg) then
484 begin
485 select filename, node_name
486 into fname, node
487 from fnd_file_temp
488 where file_id = id;
489
490 pos := instr(fname, '.', -1, 1);
491 ext := substr(fname, (pos + 1));
492
493 exception
494 when no_data_found then
498 if (fname is null) then
495 fnd_message.set_name('FND', 'CONC-ROW MISSING');
496 return null;
497 end;
499 fnd_message.set_name('FND', 'SYSTEM-LOGFILE NULL');
500 return null;
501 end if;
502
503 if(file_type = generic_log) then
504 cmpext := 'LOG';
505 elsif (file_type = generic_trc) then
506 cmpext := 'TRC';
507 elsif (file_type = generic_ora) then
508 cmpext := 'ORA';
509 elsif (file_type = generic_cfg) then
510 cmpext := 'CFG';
511 end if;
512
513 if (upper(ext) <> cmpext) then
514 fnd_message.set_name('FND', 'CONC-BAD EXTENSION');
515 return null;
516 end if;
517
518 elsif ( file_type in (context_file, generic_text, generic_binary) ) then
519 if ( file_type = context_file ) then
520 begin
521 select node_name into t_node
522 from fnd_oam_context_files
523 where path = dest_file
524 and node_name = dest_node
525 and rownum = 1;
526 exception
527 when no_data_found then
528 fnd_message.set_name('FND', 'CONC-ROW MISSING');
529 return null;
530 end;
531 end if;
532
533 node := source_node;
534 fname := source_file;
535
536 if (fnd_profile.defined('FS_SVC_PREFIX')) then
537 fnd_profile.get('FS_SVC_PREFIX', dest_svc);
538 if (dest_svc is not null) then
539 dest_svc := substr(dest_svc || dest_node, 1, 254);
540 else
541 dest_svc := 'FNDFS_' || dest_node;
542 end if;
543 else
544 dest_svc := 'FNDFS_' || dest_node;
545 end if;
546
547 end if;
548
549
550 if (fnd_profile.defined('FS_SVC_PREFIX')) then
551 fnd_profile.get('FS_SVC_PREFIX', svc);
552 if (svc is not null) then
553 svc := substr(svc || node, 1, 254);
554 else
555 svc := 'FNDFS_' || node;
556 end if;
557 else
558 svc := 'FNDFS_' || node;
559 end if;
560
561 if (file_type >= generic_log and file_type <= generic_cfg) then
562 temp_id := id;
563 update_svc(id, svc);
564 else
565 if ( file_type = generic_binary ) then
566 x_mode := 'BINARY';
567 end if;
568
569 temp_id := fnd_webfile.create_id(fname,
570 svc,
571 expire_time,
572 mtype,
573 req_id,
574 x_mode,
575 ncenc);
576 end if;
577
578 -- finally update destination file and node name, transfer_type
579 if ( file_type in ( context_file, generic_text, generic_binary) ) then
580 update_cfg_info(temp_id, dest_file, dest_svc, 'W');
581 end if;
582
583 --It updates the page information. That is page size and page number.It is required to enance a functionallity for
584 --viewing output/log file(only text file) page by page.
585 IF ((page_no IS NOT null) and (page_size IS NOT null)) THEN
586 if(x_mode = 'TEXT') THEN
587 update_page_info(temp_id, page_no, page_size, 'P');
588 end if;
589 end if;
590
591 base := Ltrim(Rtrim(base));
592
593 IF (base_type = 'WEB') THEN
594 -- Strip any file path from the base URL by truncating at the
595 -- third '/'.
596 -- This leaves us with something like 'http://ap363sun:8000'.
597 pos := instr(base, '/', 1, 3);
598 if (pos > 0) then
599 base := substr(base, 1, pos - 1);
600 end if;
601 -- 2638328 - security violation - removing login information from URL
602 url := base || '/OA_CGI/FNDWRR.exe?' || 'temp_id=' || temp_id;
603 ELSIF (base_type = 'CGI') THEN
604 IF (substr(base, length(base)) <> '/') THEN
605 base := base || '/';
606 END IF;
607 url := base || 'FNDWRR.exe?' || 'temp_id=' || temp_id;
608 END IF;
609
610 RETURN url;
611
612 exception
613 when others then
614 generic_error('fnd_webfile.get_url', SQLCODE, SQLERRM);
615 return null;
616 end get_url;
617
618
619
620
621
622
623
624
625 /* Function: get_req_log_urls
626 *
627 * Purpose: Constructs and returns the URLs for a concurrent request log
628 * and the log of the manager that ran the request..
629 *
630 * Arguments:
631 * request_id - Desired request_id.
632 *
633 * gwyuid - The value of the environment variable GWYUID used in
634 * constructing the URL.
635 *
636 * two_task - The database two_task, used in constructing the URL.
637 *
638 * expire_time - The number of minutes for which this URL will remain
639 * valid.
640 *
641 * req_log - Output URL for the request log.
642 *
643 * mgr_log - Output URL for the manager log.
644 *
645 * Returns FALSE on error. Check the FND message stack.
646 */
647
648 function get_req_log_urls( request_id IN number,
649 gwyuid IN varchar2,
650 two_task IN varchar2,
651 expire_time IN number,
652 req_log IN OUT NOCOPY varchar2,
653 mgr_log IN OUT NOCOPY varchar2) return boolean is
654 begin
655 req_log := get_url(request_log, request_id, gwyuid, two_task, expire_time);
656 mgr_log := get_url(request_mgr, request_id, gwyuid, two_task, expire_time);
657
658 if (req_log is not null and mgr_log is not null) then
659 return true;
660 else
661 return false;
662 end if;
663 end get_req_log_urls;
664
665
666
667 function create_id( name IN varchar2,
668 node IN varchar2,
669 lifetime IN number default 10,
670 type IN varchar2 default 'text/plain',
671 req_id IN number default 0,
672 x_mode IN varchar2 default 'TEXT',
673 ncenc IN varchar2 default 'N') return varchar2
674 is
675 PRAGMA AUTONOMOUS_TRANSACTION;
676 my_file_id varchar2(32);
677 fuid number;
678 frand number;
679 collision number;
680 nc_encoding varchar2(240) := NULL;
681 allow_enc varchar2(1);
682 fs_prefix varchar2(254) := NULL;
683 nmptr number;
684 svc varchar2(254) := NULL;
685 ftype fnd_concurrent_requests.output_file_type%TYPE := NULL;
686
687
688 begin
689
690 collision := 1;
691 while (collision > 0) loop
692 my_file_id := fnd_concurrent_file.get_file_id;
693
694 select count(*)
695 into collision
696 from fnd_file_temp T
697 where T.file_id = my_file_id;
698 end loop;
699
700
701 if (ncenc = 'Y') then
702
703 if (req_id <> 0) then
704 begin
705 select upper(output_file_type)
706 into ftype
707 from fnd_concurrent_requests
708 where request_id = req_id;
709 exception
710 when others then
711 null;
712 end;
713 end if;
714
715 begin
716 select allow_client_encoding
717 into allow_enc
718 from fnd_mime_types_vl
719 where mime_type = type
720 and ((ftype is not null and upper(file_format_code) = ftype)
721 or (ftype is null and rownum = 1));
722 exception
723 when others then
724 allow_enc := 'N';
725 end;
726
727 if allow_enc = 'Y' then
728 fnd_profile.get('FND_NATIVE_CLIENT_ENCODING', nc_encoding);
729 if (nc_encoding is null) then
730 fnd_message.set_name('CONC', 'CONC-Cannot get profile value');
731 fnd_message.set_token('ROUTINE', 'CREATE_ID');
732 fnd_message.set_token('PROFILE', 'FND_NATIVE_CLIENT_ENCODING');
733 fnd_message.set_token('REASON', 'Check if profile is set');
734 end if;
735 end if;
736 end if;
737
738 --- Begin Shared Appltop failover code
739 begin
740
741 if (fnd_profile.defined('FS_SVC_PREFIX')) then
742 fnd_profile.get('FS_SVC_PREFIX', fs_prefix);
743 end if;
744
745 if (fs_prefix is null) then
746 fs_prefix := 'FNDFS_';
747 end if;
748
749 -- If prefix already attached - switch node and reattach later
750 if (node LIKE (fs_prefix || '%')) then
751 nmptr := length(fs_prefix) + 1;
752 else -- No prefix, only switch node
753 nmptr := 1;
754 fs_prefix := NULL;
755 end if;
756
757 select substr(fs_prefix || 'APPLTOP_' || b.name, 1, 254)
758 into svc
759 from fnd_nodes n, fnd_appl_tops a, fnd_appl_tops b
760 where n.node_name = substr(node, nmptr, length(node))
761 and n.node_id = a.node_id
762 and a.name = b.name
763 and b.node_id <> a.node_id
764 and ROWNUM = 1;
765
766 exception when NO_DATA_FOUND then
767 svc := node;
768
769 end;
770 --- End Shared Appltop Failover code
771
772 insert into fnd_file_temp( file_id,
773 filename,
774 node_name,
775 mime_type,
776 request_id,
777 expires,
778 transfer_mode,
779 native_client_encoding,
780 enable_logging)
781 values (my_file_id, name, svc, type, req_id,
782 sysdate + (lifetime/1440), x_mode, nc_encoding,
783 debug);
784 commit;
785
786 return my_file_id;
787
788 exception
789 when OTHERS then
790 generic_error('fnd_webfile.create_id', SQLCODE, SQLERRM);
791 rollback;
792 return null;
793
794 end create_id;
795
796
797 procedure set_debug(dbg IN boolean) IS
798 begin
799 if dbg then
800 debug := 'Y';
801 else
802 debug := 'N';
803 end if;
804
805 end set_debug;
806
807
808
809 end;