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



Hi All,

Still another JTOpen error.  When I run PgmCall, I get an 
java.lang.ArrayIndexOutOfBoundsException error.  I narrowed it down to these 
lines:

                        // Set up the 2 parameters.
                        ProgramParameter[] parameterList = new 
ProgramParameter[2];
                        // First parameter is to input a number.
                        AS400Text nameText = new AS400Text(5);
                        parameterList[0] = new 
ProgramParameter(nameText.toBytes("00001"));

When I try to get the length of parameterList(0), it comes out as 0.  I checked 
the ProgramCall documentation (API) and the lines above are pretty much the 
same as the example in the doc.  What am I missing?

I've got another question about ProgramParameter.  If the RPG program I'm 
calling accepts two input parameters and returns a string which actually is the 
second input parameter (according to the programmer), should I have two or 
three parameters in the parameter list?

Following is the copy of PgmCall.java:

-----------------------
import com.ibm.as400.access.*;     

public class PgmCall {

        public static void main(String[] args) {
                AS400 system  = new AS400("smarta02", "devusr54", "redge02");
            ProgramCall program = new ProgramCall(system);
                try
                {
                        // Initialize the name of the program to run.
                        String programName = "/QSYS.LIB/DEVUSR52.LIB/JCALL.PGM";
                        // Set up the 2 parameters.
                        ProgramParameter[] parameterList = new 
ProgramParameter[2];
                        // First parameter is to input a number.
                        AS400Text nameText = new AS400Text(5);
                        parameterList[0] = new 
ProgramParameter(nameText.toBytes("00001"));
                        // Second parameter is to input spaces.
                        AS400Text textText = new AS400Text(10);
                        String inoutText = " ";
                        parameterList[1] = new 
ProgramParameter(textText.toBytes(inoutText),10);
                        // Set the program name and parameter list.
                        program.setProgram(programName, parameterList);
                        // Run the program.
                        if (program.run() != true)
                        {
                                // Report failure.
                                System.out.println("Program failed!");
                                // Show the messages.
                                AS400Message[] messagelist = 
program.getMessageList();
                                for (int i = 0; i < messagelist.length; ++i)
                                {
                                        // Show each message.
                                        System.out.println(messagelist[i]);
                                }
                        }
                        // Else no error, get output data.
                        else
                        {
                                AS400Text text = new AS400Text(50);
                                
System.out.println(parameterList[0].getOutputDataLength());
                                
System.out.println(text.toObject(parameterList[0].getOutputData()));
                                
System.out.println(text.toObject(parameterList[1].getOutputData()));
                        }
                }
                catch (Exception e)
                {
                        System.out.println("Program " + program.getProgram() + 
" issued an exception!");
                        e.printStackTrace();
                }
                // Done with the server.
                system.disconnectAllServices();
        }
}

-------------------


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



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.