Monday, June 15, 2020

create or get URL of concurrent program request output or log file by fnd_webfile

--SET SERVEROUTPUT ON
--It will work for Paper Layout RDF report for Sure
DECLARE
   l_request_id   NUMBER := 60277934;--:P_REQ_ID;                       -- The request id
   l_two_task     VARCHAR2 (256);
   l_gwyuid       VARCHAR2 (256);
   l_url          VARCHAR2 (1024);
BEGIN
   -- Get the value of the profile option named, Gateway User ID (GWYUID)
   --- l_gwyuid := fnd_profile.VALUE ('APPLSYSPUB/PUB');

   SELECT   profile_option_value
     INTO   l_gwyuid
     FROM   fnd_profile_options o, fnd_profile_option_values ov
    WHERE       profile_option_name = 'GWYUID'
            AND o.application_id = ov.application_id
            AND o.profile_option_id = ov.profile_option_id;


   -- Get the value of the profile option named, Two Task(TWO_TASK)

   SELECT   profile_option_value
     INTO   l_two_task
     FROM   fnd_profile_options o, fnd_profile_option_values ov
    WHERE       profile_option_name = 'TWO_TASK'
            AND o.application_id = ov.application_id
            AND o.profile_option_id = ov.profile_option_id;


   l_url :=
      fnd_webfile.get_url (file_type     => fnd_webfile.request_out, -- for out file
                           ID            => l_request_id,
                           gwyuid        => l_gwyuid,
                           two_task      => l_two_task,
                           expire_time   => 500-- minutes, security!.
                           );

   DBMS_OUTPUT.put_line (l_url);
END;
=========================================================================

--It will work for  RDF-XML-RTF Report for Sure
DECLARE
   l_outfile_name        fnd_conc_req_outputs.file_name%TYPE;
   l_outfile_node_name   fnd_conc_req_outputs.file_node_name%TYPE;
   l_mime_type           fnd_mime_types_vl.mime_type%TYPE;
   l_svc                 VARCHAR2 (100);
   l_id                  VARCHAR2 (100);
   l_base                VARCHAR2 (100);
   l_pos                 VARCHAR2 (100);
   url                   VARCHAR2 (100);
   l_request_id   NUMBER;
BEGIN
    xx_ff_calculation.xx_salary_slip_creation (:xx_payroll_header.month_year,
                                              :xx_payroll_header.person_id
                                               ,l_request_id
                                             );
   
   SELECT file_name, file_node_name
     INTO l_outfile_name, l_outfile_node_name
     FROM fnd_conc_req_outputs
    WHERE concurrent_request_id = l_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;

No comments:

Post a Comment