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



Thanks for the help!

Got the program to work.  It was the .setInputData that I missed.

________________________
Redge C. Rafols
Smart Communications, Inc.
IT - Customer Care Systems
Office Tel. No. 511-6252

~+~+~+~+~+~+~+~+~+~+~
If you give someone a program,
you will frustrate them for a day; 
if you teach them how to program, 
you will frustrate them for a lifetime. 


-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx]On Behalf Of Joe Pluta
Sent: Wednesday, March 31, 2004 12:30 AM
To: 'Java Programming on and around the iSeries / AS400'
Subject: RE: JTOpen: Using ProgramCall


> From: RCRafols@xxxxxxxxxxxx
> 
> Still another JTOpen error.  When I run PgmCall, I get an
> java.lang.ArrayIndexOutOfBoundsException error.

This works:

        // Create a call with two 5-byte parameters
        AS400 host = new AS400();
        ProgramCall pc = new ProgramCall(host);
        ProgramParameter[] plist = new ProgramParameter[] {
                new ProgramParameter(5),
                new ProgramParameter(5)
        };
        pc.setProgram("/QSYS.LIB/SANDBOX.LIB/SB0002.PGM");
        pc.setParameterList(plist);
                
        // Set each parameter with EBCDIC data by converting Strings
        AS400Text cvtAlpha5 = new AS400Text(5);
        plist[0].setInputData(cvtAlpha5.toBytes("00001"));              
        plist[1].setInputData(cvtAlpha5.toBytes("XXXXX"));              
        pc.run();
                
        // Get the result and print it
        String result = (String)
cvtAlpha5.toObject(plist[1].getOutputData());
        System.out.println(result);
        host.disconnectAllServices();


This will create a program call with a parameter list containing two
parameters, each length 5.  This is the length in bytes.  The length
required depends on the data type; for alpha data it is one byte per
character.

The cvtAlpha5 converter can convert from a Java String to an array of
EBCDIC bytes and vice versa.  You use it to put data into an alpha
parameter and to get data out of an alpha parameter.  Since both
parameters are the same length, I was able to use the same converter.

The RPG program SB0002 moves the data from parameter one into parameter
2.  After the call, the Java program prints the results of the second
parameter.

d xidata          s              5                              
                                                                
C     *entry        plist                                       
C                   parm                    xidata            5 
C                   parm                    xidata2           5 
C                                                               
C                   eval      xidata2 = xidata                  
C                   eval      *inlr = *on                       
C                   return                                      

The output is "00001".

Joe

_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) 
mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.