Sunday, January 11, 2009

Invoke the Concurrent Request Output as web page

Hi All,
Many a times, I have seen requirement from Client to invoke the concurrent program output by clicking on a button. It isn't that difficult to submit a program and get the output opened in a separate page when a specific button is clicked.
Try out the following code in order to invoke the output of a Concurrent Program as an HTML page.
BEGIN
SELECT file_name, file_node_name
INTO l_outfile_name, l_outfile_node_name
FROM fnd_conc_req_outputs
WHERE concurrent_request_id = your_request_ID;

SELECT mime_type
INTO l_mime_type
FROM fnd_mime_types_vl
WHERE file_format_code = 'PDF';

l_svc := fnd_conc_private_utils.get_fs_svc_name(l_outfile_node_name);
l_id := fnd_webfile.create_id(l_outfile_name, l_svc, 10, l_mime_type, l_request_id, 'BINARY', 'Y');
IF (l_id IS NULL)
THEN
fnd_message.retrieve;
fnd_message.error;
END IF;

fnd_profile.get('APPS_WEB_AGENT', l_base);
l_pos := INSTR( l_base, '/', 1, 3);

IF (l_pos > 0)
THEN
l_base := SUBSTR(l_base, 1, l_pos - 1);
END IF;

url := l_base '/OA_CGI/FNDWRR.exe?' 'temp_id=' l_id;
fnd_utilities.open_url(url);
END;

Enjoy,
Viral Dhruv