Running reports from PL/SQL
Run a report in your own database session and receive the Excel file as a BLOB, or submit it as a concurrent request.
Run in the session
Use this when your code needs the file directly, for example to store it, attach it to a record or return it to an APEX page. The report runs in your session, so its run time adds to your transaction.
declare
l_run_id number;
l_row_count pls_integer;
l_file blob;
l_file_name varchar2(1000);
l_status varchar2(1);
l_message varchar2(4000);
begin
fnd_global.apps_initialize(user_id=><user id>,resp_id=><responsibility id>,resp_appl_id=><application id>);
l_run_id:=xxen_api.create_run_id_('FND Users');
xxen_api.set_parameter_value_(p_parameter_name=>'User Name',p_value=>'OPERATIONS',p_run_id=>l_run_id);
xxen_api.set_parameter_value_(p_parameter_name=>'User Name',p_value=>'SYSADMIN',p_run_id=>l_run_id);
xxen_api.run_report(l_run_id,l_row_count,l_file,l_file_name,l_status,l_message);
if l_status='E' then
raise_application_error(-20001,l_message);
end if;
end;- Calling
set_parameter_value_twice for the same parameter selects both values. - Parameter default values are not evaluated by the API. Set every parameter the report needs, including hidden ones whose default the report SQL relies on.
- For a parameter whose list of values has an id column, pass the id; otherwise pass the displayed value. Pass dates as
DD-MON-YYYY. xxen_api.parameters(l_run_id)returns the values the run used, for logging.
Submit a concurrent request
Use this for long-running reports, for email delivery, or to write the file to a server directory. Set the values without a run id, then submit with a null run id:
declare
l_run_id number;
l_request_id number;
l_message varchar2(4000);
begin
fnd_global.apps_initialize(user_id=><user id>,resp_id=><responsibility id>,resp_appl_id=><application id>);
xxen_api.clear;
xxen_report.initialize_run_param_vals_tmp(xxen_api.report_id('FND Users'));
xxen_api.set_parameter_value_(p_parameter_name=>'User Name',p_value=>'OPERATIONS',p_report_name=>'FND Users');
xxen_api.set_runtime_option('TEMPLATE_NAME','<template name>');
xxen_api.set_runtime_option('EMAIL','<recipient>');
l_message:=xxen_api.report_submit_concurrent(xxen_api.report_id('FND Users'),l_run_id,l_request_id);
if l_message is not null then
raise_application_error(-20001,l_message);
end if;
commit;
end;Runtime options: TEMPLATE_NAME, OUTPUT_FORMAT, OUTPUT_FILE_NAME, EMAIL, SERVER_OUTPUT_DIRECTORY, SERVER_FILE_NAME. Options set against a run id from create_run_id do not reach the request.
Offer the file for download from EBS
xxen_api.report_file_id(l_run_id) runs the report and stores the file through the EBS generic file manager. Pass the returned id to fnd_gfm to open it in the user's browser, for example from a button in a custom form or OA Framework page.
Moving content between instances
xxen_api.export_report returns a report's definition as XML, xxen_api.import_xml loads it into another instance. The import matches reports, templates and lists of values by GUID, so a re-import updates the existing definition.
Generated from Blitz Report 3.3.7 on .