• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java calls to RPG functions

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic