× 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.



I found out what my problem was.  For the output variable in the parm
list I needed this:

parmlist[1] = new ProgramParameter(30);

...Instead of this...

parmlist[1] = new ProgramParameter(new AS400Text(30,
as400).toBytes("output")); 


I am now able to get a value back in the second parm.  I am not quite
sure why this works, but it works.  I think the Toolbox developers have
some assumed implementations that aren't readily apparent by just
looking at the classes.

Aaron Bartell


Here is the working code for anybody else that might run into this:

     P CallRPG_var     B                   Export
     D CallRPG_var     PI
     D  pInput                       30A   Const
     D  pOutput                      30A
      /Free

       pOutput = 'It is working yahoo!';
       Return;

      /End-Free
     P CallRPG_var     E 



import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400Message;
import com.ibm.as400.access.AS400Text;
import com.ibm.as400.access.ProgramParameter;
import com.ibm.as400.access.ServiceProgramCall;

/** 
 * @author ALBartell
 *
 */
public class CallRPG_var {

    public static void main(String[] parameters) {
        try {
            AS400 as400 = new AS400("xxx.xxx.xxx.xxx", "xxxx", "xxxx");

            ProgramParameter[] parmlist = new ProgramParameter[2];
            parmlist[0] = new ProgramParameter(new AS400Text(30,
as400).toBytes("jjjeeeeuuuunnnkkkkk!!!!!"));
            parmlist[1] = new ProgramParameter(30);
 
parmlist[0].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
 
parmlist[1].setParameterType(ProgramParameter.PASS_BY_REFERENCE);

            ServiceProgramCall srvPgm =
                new ServiceProgramCall(
                    as400,
                    "/QSYS.LIB/ALBARTELL.LIB/CALLRPGSV.SRVPGM",
                    "CALLRPG_VAR",
                    ServiceProgramCall.NO_RETURN_VALUE,
                    parmlist);

            srvPgm.run();
            AS400Message[] msgList = srvPgm.getMessageList();
            System.out.println("AS/400 messages : ");
            for (int i = 0; i < msgList.length; i++) {
                System.out.println(msgList[i].getText());
            }

            System.out.println(new AS400Text(30,
as400).toObject(parmlist[1].getOutputData()));
        } catch (Exception e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
        }
    }
}


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.