midrange.com code scratchpad
Name:
RPG Report Generator API Sample
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
04/23/2008 09:21:57 pm
IP:
Logged
Description:
Sample of RPG Report Generator API use
Code:
  1.       *  Demonstration of using RRE to create a Jasper Report
  2.       *
  3.       *  To compile:
  4.       *      Make sure you've already created RRE. See the instructions
  5.       *      on that source member for details.
  6.       *
  7.       *
  8.       *      CRTBNDRPG PGM(TEST7_RRE) SRCFILE(RRG/QSOURCE) DBGVIEW(*LIST)
  9.       *
  10.       *
  11.  
  12.      H DFTACTGRP(*NO)
  13.      H OPTION(*SRCSTMT: *NODEBUGIO: *NOSHOWCPY)
  14.      H THREAD(*SERIALIZE)
  15.      H BNDDIR('RRE')
  16.  
  17.       /copy qsource,rre_h
  18.  
  19.      D  lReportName    s                   like(jString)
  20.      D  lReportOut     s                   like(jString)
  21.      D  lReParam       s                   like(jMap)
  22.      D  lOutFormat     s                   like(jString)
  23.      D success         s               N
  24.      D  lkey           s                   like(jString)
  25.      D  lvalue         s                   like(jString)
  26.      D OutputType      S              4A
  27.       *-------------------------------------------------
  28.       *     Test the report generator
  29.       *
  30.       *     We need the following jars in the classpath:
  31.       *     ReportGenerator.jar  - Simple wrapper over Jasper
  32.       *     commons-beanutils.jar
  33.       *     commons-collections-2.1.jar
  34.       *     commons-dbcp-1.2.1.jar
  35.       *     commons-digester-1.7.jar
  36.       *     commons-logging-1.0.2.jar
  37.       *     commons-logging-api-1.0.2.jar
  38.       *     itext-1.3.1.jar
  39.       *     jasperreports-2.0.5.jar
  40.       *     jt400.jar
  41.       *     poi-3.0.2-FINAL-20080204.jar
  42.       *
  43.       *     These parameters will be passed:
  44.       *
  45.       *     key  - Name of Parameter being passed
  46.       *
  47.       *     Value - Actual value of parameter being passed
  48.       *
  49.       *     ReportName - Report Template Name - FULL PATH and either the compiled jasper
  50.       *                    file name OR the jrxml file name (if compiling)
  51.       *     ReportOut  - Report Output Name - FULL path and file name (extension will
  52.       *                    be added by output routine)
  53.       *     reportParameters = A hashmap will key/value pairs for any parameters that are passed
  54.  
  55.       *     OutFormat  - Extension (basically) PDF, HTML, XLS, RTF, TXT, CSV, ODT
  56.  
  57.      C     *ENTRY        PLIST
  58.      C                   PARM                    OutputType
  59.  
  60.       /free
  61.        rre_begin_object_group(100);
  62.         lSender = new_String('pete@valadd.com');
  63.         lRecipient = new_String('pete@opensource4i.com');
  64.         lReportName =
  65.          new_String('/reports/templates/employee_listing.jasper');
  66.         lReportOut = new_String('/reports/output/employee_listing');
  67.         lReParam = new_jMap();
  68.         lOutFormat = new_String(%trim(OutputType));
  69.  
  70.        success = rre_iPrintCompiledReport(
  71.                               lReportName :lReportOut
  72.                               :lReParam
  73.                               :lOutFormat );
  74.  
  75.         rre_end_object_group();
  76.         *inlr = *on;
  77.       /end-free  
© 2004-2019 by midrange.com generated in 0.006s valid xhtml & css