Having been trying Reports6i Server to generate reports so that I can print them over the Web using orarrp.exe, I encountered several problems, which were also on MetaLink, but

didn't seem to have satisfactory responses as to how to solve them in some cases. I've tried to document them and how to get around them so as to aid anyone who's been trying

to get this to work.

 

The document that comes with orarrp.exe explains the basics and covers most things pretty well, but there are some problems:

 

1. Typo on page 6 regarding PDF file extension:

The document lists "ppra" as the extension to be used for PDF files. This is incorrect and should be "rrpa" as used elsewhere in the doc.

 

2. FIND_REPORT_OBJECT() resulting in FRM-41219 error explained:

Unlike when you use the RUN_PRODUCT built-in and can refer to the report by the name that corresponds to the .REP file, the FIND_REPORT_OBJECT built-in looks for the report in the Object Navigator of Form itself under the "Reports" node. If the report given in the FIND_REPORT_OBJECT('<REPORT_NAME>') doesn't exist there, it will return the error "FRM-41219: Report ID not found".

 

Our generic report running form had no reports listed here and referenced dozens of reports by their filename using RUN_PRODUCT.

 

The approach I used (following a suggestion by Bela on MetaLink) was to create a DUMMY report under the Reports node and dynamically specify the actual report filename programmatically. A couple of notes here:

 

- make sure you enter the "Filename" property: I used "dummy.rep"

- make sure you specify the "Reports Server" property: I used "dummy"

 

See the code sample below for an example of how to programmatically assign the actual report properties.

 

3. FRM-41213 and FRM-41218 Errors - known bug:

If you gave the Reports Server a name containing underscores (as default by the installer), you will get one of these errors if you try to use RUN_REPORT_OBJECT or it's associated built-ins like REPORT_OBJECT_STATUS as given in the orarrp code examples. This is bug 1137236.

 

I fixed this by adding an additional entry for my Reports Server in my TNSNAMES.ORA file:

 

# Oracle Reports Server (WebForms) configuration entry - Service wont start without it

REP60_COMPAQ_SERVER,REP60_COMPAQ_SERVER.WORLD =

  (ADDRESS=

    (PROTOCOL=tcp)

    (HOST=compaq_server.wsp.co.uk)

    (PORT=1949)

  )

 

# Added because of bug 1137236 which causes problems when using underscores

REP6ISERVER,REP6ISERVER.WORLD =

  (ADDRESS=

    (PROTOCOL=tcp)

    (HOST=compaq_server.wsp.co.uk)

    (PORT=1949)

  )

 

Making these changes allowed me to get the reports to correctly print from the client, although I still have problems getting PostScript to work. Here's the code I used which is

based on that in the document, but with some changes:

 

WHEN-BUTTON-PRESSED Trigger calls this Program Unit passing Report name (Eg 'BTREP1'):

 

PROCEDURE print_web_report (rep_name in varchar2) IS

  report_id     report_object;

  report_timer  timer;

  report_file   varchar2(50);

  output_file   varchar2(255);

  output_format varchar2(3);

  file_exten    varchar2(5);

BEGIN

  -- Set printer output format

  --*******************************************************************************************

  --   Format          Extension     Output Extension    Notes

  --   PostScript       use null           rrpp          Printed directly by orarrp.exe

  --   PCL                PCL              rrpp          Printed directly by orarrp.exe

  --   Delimited          -                rrpt          Printed directly by orarrp.exe

  --   Plain Text         TXT              rrpt          Printed directly by orarrp.exe

  --   PDF                PDF              rrpa          Passed to Acrobat to print

  --   RTF                RTF              rrpr          Passed to word processor to print

  --

  --   NOTE: HTML, HTMLCSS, HTMLCSSIE and XML formats not supported by orarrp

  --*******************************************************************************************

  output_format := 'PDF';

      

  if (output_format is null) or (output_format = 'PCL') then

    file_exten := '.rrpp';

  elsif output_format = 'PDF' then

    file_exten := '.rrpa';

  elsif output_format = 'RTF' then

    file_exten := '.rrpr';

  else

    file_exten := '.rrpt';

  end if;

      

  -- Genereate a pseudo-unique filename

  output_file := get_application_property(USERNAME) || to_char(sysdate, 'YYYYMMDDHHMISS');

 

  -- Append appropriate file extension for orarrp based on output_format

  output_file := output_file || file_exten;

 

  -- Use DUMMY as find_report_object looks at Reports attached to Form NOT filenames

  report_id := find_report_object('DUMMY');

 

  -- Create real report filename for report_object

  report_file := lower(rep_name) || '.rep';

 

  -- Dynamically change the report_object definition to point to correct report file

  set_report_object_property(report_id, REPORT_FILENAME, report_file);

 

  -- Specify for report to run in batch mode and output to file for return to browser

  set_report_object_property(report_id, REPORT_EXECUTION_MODE, BATCH);

  set_report_object_property(report_id, REPORT_DESTYPE, FILE);

 

  -- Specify report format to use

  set_report_object_property(report_id, REPORT_DESFORMAT, output_format);

 

  -- Desname to our generated filename

  -- NOTE: refers to location on the Web Server from which the report file will be printed

  --       (SHOULD BE SOFT-CODED) using the web.show_document() command

  set_report_object_property(report_id, REPORT_DESNAME, 'E:\Dev6iServer\Deployment\temp\' || output_file);

                           

  -- Set the name of the Reports Server, this SHOULD BE SOFT-CODED

  set_report_object_property(report_id, REPORT_SERVER, 'Rep6iServer');

 

  -- Save the Report Handle to a global variable

  :global.report_handle := run_report_object(report_id);

 

  -- Save the generated filename for use in When-Timer-Expired

  :global.print_output := output_file;

 

  -- Create a timer to monitor the Report to check 4 times a minute

  report_timer := create_timer('PRINTER_QUEUE', '5000', REPEAT);

END;

 

 

 

WHEN-TIMER-EXPIRED Trigger:

 

-- Web timer to check for report completion

if :global.web = 'Y' then

 

  DECLARE

    report_status     varchar2(20);

    last_exp_timer    varchar2(30);

  BEGIN

    -- Get the name of the last expired timer

    last_exp_timer := get_application_property(timer_name);

 

    -- If the last expired timer is PRINTER_QUEUE check Web report status

    if last_exp_timer = 'PRINTER_QUEUE' then

 

      report_status := report_object_status(:global.report_handle);

  

      if report_status in ('RUNNING', 'OPENING_REPORT', 'ENQUEUED') then

        null;

      elsif report_status = 'FINISHED' then

        -- Return report output file to browser for printing

        web.show_document('/temp/' || :global.print_output, '_BLANK');

   

        -- Clean-up the timer

        delete_timer(last_exp_timer);

      else

        -- Report has not worked for some reason, inform the user

        io.ack_message('Printing of report has failed');

        delete_timer(last_exp_timer);

      end if;

  

    end if;

  END;

 

end if;