Menu
CL to RPGLE to JAVA
JXLS to JasperReports migration: Rebuilding MHG ERP Reporting module to produce analytical reports based on JasperReports Open Source reporting engine (2011) by Ruslan Pisarenko: JasperReports 3.6 Development Cookbook (2010) by Bilal Siddiqui.
Calling Java methods from RPGLE programs
This post presents two IBM iSeries programs, a CLP and its associated RPG-LE program and a Java class. Together, they serve to illustrate how to call Java methods from an RPG program. The Class-methods reside in a .JAR-file deployed on the IFS.
The CL Program
The CL program presented below simply acts to establish classpath entries for the dependencies. They are LOG4J for logging, which is not illustrated in this post and iText.jar which provides the means for embedding an image file into a .PDF document.
The RPGLE Program
The Java Class
The Java class presented below depends upon iText to place the image-file into a .PDF document.
The iText project can be found here The book “iText in Action” can be found here.
The iText project can be found here The book “iText in Action” can be found here.
The main() method is for testing purposes. It instantiates and calls the methods to test the Java code. Once debugged and proofed in this way, development continues with the RPG layer, but the main method stays.
The Voodoo occurs here:
It’s basically saying this: The name of this function is createPDF. It defines 3 parms. The *JAVA instance of the class, the fully qualified name of the class to be referenced and the method to be called. The *JAVA is a placeholder for the instance of the class. Since we can’t do this: IFSImage2PDF.createPDF() in RPG, we have to pass the instance of the class for every method call. The *JAVA part is the instance. ( i.e. createPDFDoc(IFSImage2PDF : imgSrc : pdfTgt); )
The *JAVA reference is created from this:
Itext 1.2.8 2
After this, it’s 1-2-3,
Create the instance:
Ink2go 1.8.0. To call the method to first convert the parms to Java types:
Then call the method with the parms