× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



> From: James H H Lampert
> 
> Is there a quick, easy way for Java (on the AS/400) to call an
> AS/400-native program (on the same box) and get a single character
string
> return value, of which I'm not yet aware?

Yup.  The ProgramCall class.

Off the top of my head:


ProgramCall pgm = new ProgramCall(
        new AS400(),
        "/QSYS.LIB/MYLIB.LIB/MYPGM.PGM",
        new ProgramParameter[] {
                new ProgramParameter(1)
        });


This creates a ProgramCall object to MYLIB/MYPGM with a single one-byte
parm.


pgm.run();
String rc =
        new AS400Text(1).toObject(
                pgm.getParameterList()[0].getOutputData());


This is a little convoluted, but it creates an EBCDIC-Java converter
with a length of one and uses it to parse the returned data from the
first parameter.  Personally, I'd do it a little more verbosely:


AS400 host = new AS400();
String pgmpath = "/QSYS.LIB/MYLIB.LIB/MYPGM.PGM";
ProgramParameter[] parms =
        new ProgramParameter[] {
                new ProgramParameter(1)
        };
ProgramCall mypgm = new ProgramCall(host, pgmpath, parms);

AS400Text alpha1cvt = new AS400Text(1);

mypgm.run();
String rc = alpha1cvt.toObject(parms[0].getOutputData());


Don't forget try/catch as appropriate.  Hopefully I got the syntax
right.

Joe



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.