wood burning stoves 2.0*
The moose likes Java in General and the fly likes Java calls to RPG functions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java calls to RPG functions" Watch "Java calls to RPG functions" New topic
Author

Java calls to RPG functions

Anthony_Castillon
Greenhorn

Joined: Jul 17, 2001
Posts: 4
How can I call a function written in RPG for AS/400 from my Java application? I think JNI cannot be used because it can only handle C/C++ functions. What other options are there?
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
IBM has produced a ToolBox for calling/accessing AS/400 specific objects.
Check out this link: http://publib.boulder.ibm.com/pubs/html/as400/v5r1/ic2924/index.htm?info/rzahh/page1.htm
In particular, you probably want to look at the ServiceProgramCall class:
http://publib.boulder.ibm.com/pubs/html/as400/v5r1/ic2924/info/rzahh/javadoc/com/ibm/as400/access/ServiceProgramCall.html
James.
Anthony_Castillon
Greenhorn

Joined: Jul 17, 2001
Posts: 4
Thanks for the tips, James. However, the ServiceProgramCall class API says that a max. of 7 parameters may be passed to the service program. In my program, I may have to pass more params. Have any idea how to handle that?
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
Well that kind of sucks doesn't it ;-)
How about using ProgramCall object then, it apparently allows 35 parameters to be passed to the program.
The only catch being now, the main entry/exit point would be the main line of code in the RPG program (*ENTRY and *PARMLIST part), rather than just a specific method.
James.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Anthony_Castillon
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however, your name is not in keeping with our naming policy here at the ranch. Please re-register under an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!


------------------
Dave
Sun Certified Programmer for the Java� 2 Platform


Dave
Anthony Castillon
Greenhorn

Joined: Nov 30, 2001
Posts: 18
Thanx for the tips, James. Have a question though: Do I have to do any configuration of my system (I'm running a java app from Windows 2000 connected to an AS400 machine) to make the connection. The ProgramCall API and samples I've seen so far looks deceivingly simple or has IBM really abstracted away the fine details of the connection (given that the fully integrated file name has been provided) that I just have to use the setProgram() and run() on the AS400 object?

Originally posted by james swan:
Well that kind of sucks doesn't it ;-)
How about using ProgramCall object then, it apparently allows 35 parameters to be passed to the program.
The only catch being now, the main entry/exit point would be the main line of code in the RPG program (*ENTRY and *PARMLIST part), rather than just a specific method.
James.

James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
Hi Anthony,
yeah it is pretty simple to set up the client (Windows 2000 side).
Just have the jt400.jar in your classpath, and so long as you can see the AS400 on the network (and have a valid AS400 user profile), you should be fine.
From the AS400 side, somebody might have to install some of the IBM java support programs (but don't quote me on this).
check out this link for more info: http://publib.boulder.ibm.com/html/as400/v5r1/ic2924/info/rzahh/rzahnm05.htm#HDRRZAHNRE2-RE2RF
here is a simple example of a CL program call to get you started.
the CL program (get someone to compile it for you, or maybe you can just do it yourself)

the java class that calls it

You might need to adjust these slightly for your environment, in particular the name of the AS/400 you want to connect to, and the library and program name of the CL program.
I don't work on the AS/400 platform anymore, so that's about my limit of being able to help you.
Basically (after maybe program/class compile issues), if you can't run this successfully then the AS/400 might not have the necessary supporting software installed (see the above url).
Hope this helps,
James.
Anthony Castillon
Greenhorn

Joined: Nov 30, 2001
Posts: 18
I created a class and patterned it after the sample code in the ProgramCall API. I also created a client that populates an array of AS400Parameter(which I created) and called on my program. It worked. Thanx again for the tips.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java calls to RPG functions
 
Similar Threads
Is Web Services/SOAP truly language neutral? Can I use COBOL, RPG?
Learning OO concepts & Java 2 for mainframe developers - prefer free
Contracting Offers
A career in Java?
Is there is any way to connect to Database without JDBC