EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
  • 1.  TXT Printer Report

    Posted 07/14/16 03:32 PM

     Hi all,

    As I told, I am starting on EGL, and of course, having some problems. I am using RBD EGL 9.5.0.1

    I have a TXT file (is a report saved in TXT format) and I need to print this file directly to printer (not using BIRT or JASPER - report generator).

    I created a Resource Association, with a record of 132 char (that is my entire report line), so I need read my TXT file, and print.

    Follow my examples:

     

    - my report print program

     

    package Reports;

    import reports.CSVRelatorioRecord;
    import reports.textReportHandler;

    program RelReport type BasicProgram {}
        
        RelatorioRec CSVRelatorioRecord;
        myHandler textReportHandler{};
        
        function main()
            myHandler.start();  // passes control to handler

            /* follow where I am having problem, I don't know how to get the record from a TEXT file and Print */

            get next RelatorioRec;  // I am having a error when I DEBUG the program

            while (RelatorioRec not endOfFile)
                myHandler.outputRel(RelatorioRec.Linha_Relatorio);
                get next RelatorioRec;
              end
              
              myHandler.finish();  // close report
        end
    end

     

    - my Record as follow

    package Reports;

    // basic record
    //
    record CSVRelatorioRecord type CSVRecord
        
    {
      fileName = "Relatorio",
      delimiter = ";",
      textQualifier = "\"",
      style = CsvStyle.quoted
    }

      Linha_Relatorio char(132);
        
    end

     

    - my Handler as follow

     

    package Reports;

    import reports.prtRecord;

    handler textReportHandler type BasicHandler

        myReport TextReport{};   // creates instance
        currentReportRecord prtRecord;
        runningTotal MONEY = 0;
        
        function start()

          myReport.onEveryRowListener = onEveryRow;
          myReport.onLastRowListener = onLastRow;
          
          // accept defaults on everything but destination file
          myReport.startReport("c:/temp/customerReport.txt",null,null,null,null,null,null);
          
        end

       function outputRel(cLinha STRING in)
          // this information comes from the forEach loop in the main program
          currentReportRecord.prtPrograma = cLinha;
          
          // pass control to the report engine
          // onEveryRow is called
          myReport.outputToReport();  
       end

       function output(cName STRING in, cIP STRING in)
          // this information comes from the forEach loop in the main program
          currentReportRecord.prtPrograma = cName;
          currentReportRecord.prtEND_IP = cIP;
    //      runningTotal = runningTotal + cIP;
          
          // pass control to the report engine
          // onEveryRow is called
          myReport.outputToReport();  
       end
               
       function finish()
          // pass control to the report engine again
          // onLastRow is called
          myReport.finishReport();
       end
       
       function onEveryRow(myEvent TextReportEvent in)
          myReport.printText(currentReportRecord.prtPrograma);
          myReport.column(40);
          myReport.printText(currentReportRecord.prtEND_IP);
          myReport.println();
       end
       
       function onLastRow(myEvent TextReportEvent in)
          myReport.println();  // skip a line
          myReport.printText("All customers:");
          myReport.column(40);
          myReport.printText(runningTotal);
       end
           
    end

    - my ressource association in attach

    neidossantos


  • 2.  Re: TXT Printer Report

    Posted 07/15/16 02:03 AM

    Hi,

    I think that's not possible at the moment with pure EGL....

    But there is a RFE for this:

     

    http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=90930

     

     

    Or you could use Java external Types.

     

    Kind Regards!

    Marcel-D


  • 3.  Re: TXT Printer Report

    Posted 07/15/16 08:02 AM

    Thanks a lot Marcel-D
    Thinking on a alternative solution, if I load the TXT file, using the Ressource Association to a table on DB2 (with two colums, one of sequence, another with entire line of report), and read this table and print.
    Do you think that could be reasonable?
    In aditional, how could I show this report on screen to my user, which component could I use to that? A List? I have some big reports.
    Thanks in advance.
    Best regards
    Claudinei

    neidossantos


  • 4.  Re: TXT Printer Report

    Posted 07/18/16 02:57 AM

    Hi,

    to put your data in a database is always a good idea.

     

    But then you have the same problem...

    As far as i know you CAN'T print with EGL, you have to use java external types!

     

    Marcel-D