<p>The traditional method has been to embark on a long and potentially risk-strewn path to a Java development environment. IBM now provides another option, the Enterprise Generation Language, known as EGL. <br /><br />EGL is seen by IBM as its ""newest business language"" and whilst aimed squarely at current COBOL and RPG developers, provides a productive environment for all developers creating a wide range of applications from batch systems through traditional web applications to its latest trick, a powerful and simple way of developing Web 2.0 sites.<br /><br />EGL is designed to be a high-level, abstract language, which can be configured to produce Java or COBOL source to suit your target environment. As well as presenting itself as a procedural language and adopting many of the syntax and coding conventions of COBOL and RPG, EGL has strengthened its appeal to business developers by providing a simple way of incorporating BIRT into the applications they are writing.<br /><br />Rational Business Developer, the only current development tool for EGL, in common with the rest of the Rational suite, is built on Eclipse and takes advantage of the many development tools available, including the BIRT Report Design tools. You can build your reports in exactly the same way as you are doing now. EGL comes into play when you want to manipulate the data backing your reports and create scripted data sources; or simply provide a custom application to compile and deliver your reports to your users.<br /><br />The code below has been taken from a demonstration application available at
http://blog.morpheus.co.uk/blog/blog.nsf/dx/birt-and-egl-in-action.htm. The application retrieves a list of customer records, allows you to look at them one by one or use BIRT to generate a simple customer listing in a PDF.<br /><br /><span style=""color: #3366ff; font-family: courier new,courier;""> function createReport()<br /><br /> reportDesign string = HttpUtils.resolvePath(""/WEB-INF/reports/CustomerList.rptdesign"");<br /> reportDir string = HttpUtils.resolvePath(""/output"");<br /> reportFile JavaFile = FileUtils.createTemporaryFile(""rpt"", "".pdf"", reportDir);<br /><br /> report BirtReport;<br /> reportHandler CustomerListReportHandler = new CustomerListReportHandler; <br /> reportHandler.setCustomers(customerList);<br /> <br /> report = new BirtReport(reportDesign, null, reportFile.getPath(), ""pdf"", reportHandler);<br /> report.createReportFromDesign();<br /> <br /> forward to url ""./output/"" + reportFile.getName();<br /> end<br /><br /></span>The CustomerListReportHandler is responsible for feeding the data to BIRT as it is required and is shown below:<br /><br /><span style=""color: #3366ff; font-family: courier new,courier;""> Handler CustomerListReportHandler type BirtHandler<br /><br /> index int;<br /> customerList Customl3[];<br /> <br /> function setCustomers(customers Customl3[])<br /> customerList = customers;<br /> end<br /> <br /> function openFunction( d DataSetInstance in)<br /> { eventType = openEvent, elementName=""CustomerList""}<br /> index = 0;<br /> end<br /> <br /> function fetchFunction(d DataSetInstance in, row UpdatableDataSetRow in) returns(boolean)<br /> {eventType = fetchEvent, elementName=""CustomerList"" }<br /> index = index + 1;<br /> if( index <= customerList.getSize() )<br /> row.setColumnValue(""CustomerName"", customerList[index].Custna);<br /> row.setColumnValue(""CustomerNumber"", customerList[index].Custno);<br /> row.setColumnValue(""ContactName"", customerList[index].Contac);<br /> row.setColumnValue(""Telephone"", customerList[index].Cphone);<br /> row.setColumnValue(""Fax"", customerList[index].Cfax);<br /> row.setColumnValue(""Address"", customerList[index].Caddr);<br /> row.setColumnValue(""City"", customerList[index].Ccity);<br /> row.setColumnValue(""PostalCode"", customerList[index].Czip);<br /> row.setColumnValue(""Country"", customerList[index].Ccount);<br /> return (true);<br /> else<br /> return (false);<br /> end<br /> end<br /> end<br /></span><br />There is a thriving community around EGL, which can be found at
http://www-949.ibm.com/software/rational/cafe/community/egl and you can read a little more about our experiences with BIRT and EGL at
http://blog.morpheus.co.uk. It was a comment from Virgil Dodson on one of our blog posts that prompted me to write this and I'm grateful to him for pointing us to another resource to help with our BIRT efforts.</p>
<p>Andy</p>
http://blog.morpheus.co.uk/blog/blog.nsf/dx/birt-and-egl-in-action.htm