× 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 am trying to call the following RPG Service program using the
ServiceProgramCall Class.  The input and output parms are data
structures (I can get it to work with regular fields but not with data
structures).

     D CallRPG_myDS    DS                  Qualified
     D  alpha1                       10A
     D  alpha2                        5A
     D  int1                         10P 0
     D  packed1                       3P 0 

     P CallRPG_ds      B                   Export
     D CallRPG_ds      PI
     D  pInput                             Value LikeDS(CallRPG_myDS)
     D  pOutput                            LikeDS(CallRPG_myDS)
      /Free

       pOutput = pInput;
       Return;

      /End-Free
     P CallRPG_ds      E

Here is the Java code that I can't get to work.  It bombs on
"myConverter.toBytes(inData)" with a ClassCastException.  It appears
that I need to get my input parm into a byte array and along the way use
AS400Text and AS400PackedDecimal to ensure field length and precision,
but I am not for sure.  BTW, is there any other documentation other than
this
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/ic2924/index.htm?i
nfo/rzahh/spgcall.htm ?

java.lang.ClassCastException: java.lang.Object
        at
com.ibm.as400.access.AS400PackedDecimal.toBytes(AS400PackedDecimal.java:
182)
        at
com.ibm.as400.access.AS400Structure.toBytes(AS400Structure.java:262)
        at
com.ibm.as400.access.AS400Structure.toBytes(AS400Structure.java:219)
        at
com.taylor.tax.RPGProgramHelper.main(RPGProgramHelper.java:33)


    public static void main(String[] parameters) {

        AS400 as400 = new AS400("172.25.6.40", "JDBC", "JDBC");
        ProgramCall pgmc = new ProgramCall(as400);

        AS400DataType[] myStruct =
            { new AS400Text(10), new AS400Text(5), new
AS400PackedDecimal(10, 0), new AS400PackedDecimal(3, 0)};

        AS400PackedDecimal pd10 = new AS400PackedDecimal(10, 0);
        AS400PackedDecimal pd3 = new AS400PackedDecimal(3, 0);
        double d10 = 1234567890;
        double d3 = 123;
        Object[] inData = { "hi12345678", "hi123", pd10.toBytes(d10),
pd3.toBytes(d3)};
        Object[] outData = { "", "", new String("0"), new String("0")};

        AS400Structure myConverter = new AS400Structure(myStruct);
        byte[] input = myConverter.toBytes(inData);
        byte[] output = myConverter.toBytes(outData);
        ProgramParameter[] parmlist = new ProgramParameter[3];

        parmlist[0] = new ProgramParameter(input);
        parmlist[1] = new ProgramParameter(output);

        try {
            pgmc.setProgram("/QSYS.LIB/ALBARTELL.LIB/CALLRPGSV.SRVPGM");
            pgmc.setParameterList(parmlist);
        } catch (Exception e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
        }
        try {
            pgmc.run();
        } 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.