Infolinks

Saturday 21 July 2012

srw-run_report

Description  This procedure invokes RWRUN60 with the string that you specify.
This procedure is useful for:
  • ·         running drill-down reports (i.e., calling a report from a button’s action trigger)
  • ·         sending parts of a report to different recipients (e.g., to send a report via e-mail to each manager with just his or her group’s data)
  • ·         sending parts of a report to different printers (e.g., to send each manager’s report to his or her printer)
  • ·         running multiple reports from a single “driver” report

        SRW.RUN_REPORT executes the specified RWRUN60 command.
Syntax
SRW.RUN_REPORT (command_line CHAR);
Parameters
command_line Is a valid RWRUN60 command.
Restrictions
·         If you want parameter values that are entered on the Runtime Parameter Form to be passed in the RWRUN60 string, you must call SRW.RUN_REPORT after the before form trigger.
·         The string that is specified for or passed to this procedure must follow the syntax and case-sensitivity rules for your operating system.
·         No userid should be specified for the SRW.RUN_REPORT procedure.  The userid is inherited by the “calling” report.
·         If the parent report that invokes SRW.RUN_REPORT is run in batch, then DESTYPE can only be File, Printer, Sysout, or Mail.  Otherwise, DESTYPE can be File, Printer, or Mail.
·
     If SRW.RUN_REPORT is used in the PL/SQL for a button, the Runtime Parameter Form will not appear by default when the button is selected.  If you want the Runtime Parameter Form to appear, you must specify PARAMFORM=YES in the call to SRW.RUN_REPORT.
·         If you do not specify a path, Report Builder will use its file path search order to find the report.
Example
/* Suppose you have the following two reports: MGR_RUN, which queries manager names, and invokes a second report named MAIL_IT. MAIL_IT, which queries employee names for the manager that MGR_RUN passes it,  and sends the report output to the manager via e-mail. The description of MGR_RUN could be as follows:
** Query: SELECT ENAME, EMPNO FROM EMP WHERE JOB=’MANAGER’
** Group Filter:
*/
    FUNCTION FOO RETURN BOOLEAN IS
   BEGIN
    srw.run_report(‘report=MAIL_IT
      desname=’||:ename ||’ desformat=dflt batch=yes
      mgr_no=’|| TO_CHAR(:empno) );
    RETURN (TRUE);
    EXCEPTION
    when srw.run_report_failure then
      srw.message(30, ‘Error mailing reports.’);
      raise srw.program_abort;
   END;
/* This PL/SQL invokes MAIL_IT, specifies that MAIL_IT’s output
** should be sent to the manager via Oracle Mail, and passes the
** manager number, so that the MAIL_IT report can query only the
** manager’s employees.
** Note: EMPNO’s values must be converted to characters
** (TO_CHAR in the PL/SQL above), because SRW.RUN_REPORT
** requires a character string.
** Layout: None is needed, because this report only fetches data,
** then passes it to a second report.
** The description of MAIL_IT could be as follows:
** Query: SELECT DEPTNO, ENAME, SAL FROM EMP WHERE MGR=:MGR_NO
** Layout: Master/Detail
*/
/* Suppose that you have three reports that you almost always run together.
** The reports are named SALARY, COMMISS, and TAXES.  To run these reports
** with one RWRUN60 command, you create a driver report named PAYROLL.
** The description of PAYROLL could be as follows:
** Query: SELECT DEPTNO FROM DEPT
** Before Report Trigger:
*/
   FUNCTION FOO RETURN BOOLEAN IS
   BEGIN
     srw.run_report(‘batch=yes report=SALARY
      destype=file desformat=dflt desname=salary.lis’);
     srw.run_report(‘batch=yes report=COMMISS
      destype=file desformat=dflt desname=comiss.lis’);
     srw.run_report(‘batch=yes report=TAXES
      destype=file desformat=dflt desname=comiss.lis’);
   RETURN (TRUE);
   END;
/* Layout:  Tabular
** When you run PAYROLL from the designer or RWRUN60, the other three
** reports will all be run.  (Note that, in this case, the query and
** the layout for Payroll could be anything.  They are only used here
** in order to make it possible to run PAYROLL.)
*/

No comments:

Post a Comment