All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.access.ProgramCall

java.lang.Object
   |
   +----com.ibm.as400.access.ProgramCall

public class ProgramCall
extends Object
implements Serializable
The ProgramCall class allows a user to call an AS/400 program, pass parameters to it (input and output), and access data returned in the output parameters after the program runs. The following example demonstrates the use of Program Call:
// Call programs on system "Hal"
AS400 as400 = new AS400("Hal");
ProgramCall pgm = new ProgramCall( as400 );
try
{
// Initialize the name of the program to run
String progName = "/QSYS.LIB/TESTLIB.LIB/TESTPROG.PGM";
// Setup the 3 parameters
ProgramParameter[] parmlist = new ProgramParameter[3];
// First parameter is to input a name
AS400Text nametext = new AS400Text(8);
parmlist[0] = new ProgramParameter( nametext.toBytes("John Doe") );
// Second parmeter is to get the answer, upto 50 bytes long
parmlist[1] = new ProgramParameter( 50 );
// Third parmeter is to input a quantity and
// return a value up to 30 bytes long
byte[] quantity = new byte[2];
quantity[0] = 1;  quantity[1] = 44;
parmlist[2] = new ProgramParameter( quantity, 30 );
// Set the program name and parameter list
pgm.setProgram( progName, parmlist );
// Run the program
if (pgm.run()!=true)
{
// Note that there was an error
System.out.println( "program failed!" );
// Show the messages
AS400Message[] messagelist = pgm.getMessageList();
for (int i=0; i < messagelist.length; i++)
{
// show each message
System.out.println( messagelist[i] );
}
}
else
{
AS400Text text(50);
System.out.println( text.toObject(parmlist[1].getOutputData()) );
System.out.println( text.toObject(parmlist[2].getOutputData()) );
}
}
catch (Exception e)
{
System.out.println( "Program " + pgm.getProgram() + " did not run!" );
}
// done with the system
as400.disconnectAllServices();
 

See Also:
ProgramParameter, AS400Message

Constructor Index

 o ProgramCall()
Constructs a ProgramCall object.
 o ProgramCall(AS400)
Constructs a ProgramCall object.
 o ProgramCall(AS400, String, ProgramParameter[])
Constructs a program call object.

Method Index

 o addActionCompletedListener(ActionCompletedListener)
Adds an ActionCompletedListener.
 o addParameter(ProgramParameter)
Adds a ProgramParameter to the parameter list.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a PropertyChangeListener.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a VetoableChangeListener.
 o getMessageList()
Returns the list of AS/400 messages returned from running the program.
 o getParameterList()
Returns the list of parameters.
 o getProgram()
Returns the integrated file system pathname for the program.
 o getSystem()
Returns the AS/400 on which the program is to be run.
 o removeActionCompletedListener(ActionCompletedListener)
Removes this ActionCompletedListener from the internal list.
 o removePropertyChangeListener(PropertyChangeListener)
Removes this PropertyChangeListener from the internal list.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes this VetoableChangeListener from the JellyBeans internal list.
 o run()
Runs the program on the AS/400.
 o run(String, ProgramParameter[])
Sets the program name and the parameter list and runs the program on the AS/400.
 o setParameterList(ProgramParameter[])
Sets the list of parameters to pass to the AS/400 program.
 o setProgram(String)
Sets the path name of the program.
 o setProgram(String, ProgramParameter[])
Sets the path name of the program and the parameter list.
 o setSystem(AS400)
Sets the AS/400 to run the program.
 o toString()
Returns a short description of the object.

Constructors

 o ProgramCall
 public ProgramCall()
Constructs a ProgramCall object. The system, program, and parameters must be provided later.

 o ProgramCall
 public ProgramCall(AS400 system)
Constructs a ProgramCall object. It uses the specified AS/400. The program and parameters must be provided later.

Parameters:
system - The AS/400 on which to run the program.
 o ProgramCall
 public ProgramCall(AS400 system,
                    String program,
                    ProgramParameter parmlist[])
Constructs a program call object. It uses the specified AS/400, program name, and parameter list.

Parameters:
system - The AS/400 on which to run the program.
program - The program name as a fully qualified path name in the library file system. The library and program name must each be 10 characters or less.
parmlist - A list of up to 35 parameters with which to run the program.

Methods

 o addActionCompletedListener
 public synchronized void addActionCompletedListener(ActionCompletedListener l)
Adds an ActionCompletedListener. The specified ActionCompletedListeners actionCompleted method will be called each time a command has run. The ActionCompletedListener object is addded to a list of ActionCompletedListeners managed by this CommandCall. It can be removed with removeActionCompletedListener.

Parameters:
l - The ActionCompletedListener.
See Also:
removeActionCompletedListener
 o addParameter
 public void addParameter(ProgramParameter parameter) throws PropertyVetoException
Adds a ProgramParameter to the parameter list.

Parameters:
parameter - The ProgramParameter.
Throws: PropertyVetoException
If the change is vetoed.
 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener l)
Adds a PropertyChangeListener. The specified PropertyChangeListeners propertyChange method will be called each time the value of any bound property is changed. The PropertyListener object is addded to a list of PropertyChangeListeners managed by this CommandCall, it can be removed with removePropertyChangeListener.

Parameters:
l - The PropertyChangeListener.
See Also:
removePropertyChangeListener
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener l)
Adds a VetoableChangeListener. The specified VetoableChangeListeners vetoableChange method will be called each time the value of any constrained property is changed.

Parameters:
l - The VetoableChangeListener.
See Also:
removeVetoableChangeListener
 o getMessageList
 public AS400Message[] getMessageList()
Returns the list of AS/400 messages returned from running the program. It will return an empty list if the program has not been run yet.

Returns:
The array of messages returned by the AS/400 for the program.
 o getParameterList
 public ProgramParameter[] getParameterList()
Returns the list of parameters. It will return null if not previously set.

Returns:
The list of parameters.
 o getProgram
 public String getProgram()
Returns the integrated file system pathname for the program. It will return null if not previously set.

Returns:
The integrated file system pathname for the program.
 o getSystem
 public AS400 getSystem()
Returns the AS/400 on which the program is to be run.

Returns:
The AS/400 on which the program is to be run.
 o removeActionCompletedListener
 public synchronized void removeActionCompletedListener(ActionCompletedListener l)
Removes this ActionCompletedListener from the internal list. If the ActionCompletedListener is not on the list, nothing is done.

Parameters:
l - The ActionCompletedListener.
See Also:
addActionCompletedListener
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener l)
Removes this PropertyChangeListener from the internal list. If the PropertyChangeListener is not on the list, nothing is done.

Parameters:
l - The PropertyChangeListener.
See Also:
addPropertyChangeListener
 o removeVetoableChangeListener
 public void removeVetoableChangeListener(VetoableChangeListener l)
Removes this VetoableChangeListener from the JellyBeans internal list. If the VetoableChangeListener is not on the list, nothing is done.

Parameters:
l - The VetoableChangeListener.
See Also:
addVetoableChangeListener
 o run
 public boolean run() throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, ExtendedIllegalStateException, IOException, ObjectDoesNotExistException
Runs the program on the AS/400. The program and parameter list need to be set prior to this call.

Returns:
true if program ran successfully; false otherwise.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
 o run
 public boolean run(String program,
                    ProgramParameter parmlist[]) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException, PropertyVetoException
Sets the program name and the parameter list and runs the program on the AS/400.

Parameters:
program - The fully qualified integrated file system path name to the program. The library and program name must each be 10 characters or less.
parmlist - The list of parameters with which to run the program.
Returns:
true if program ran successfully, false otherwise.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: UnknownHostException
If the AS/400 system cannot be located.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: PropertyVetoException
If a change is vetoed.
 o setParameterList
 public void setParameterList(ProgramParameter parameterList[]) throws PropertyVetoException
Sets the list of parameters to pass to the AS/400 program.

Parameters:
parmlist - A list of up to 35 parameters with which to run the program.
Throws: PropertyVetoException
If a change is vetoed.
 o setProgram
 public void setProgram(String program,
                        ProgramParameter parmlist[]) throws PropertyVetoException
Sets the path name of the program and the parameter list.

Parameters:
program - The fully qualified integrated file system path name to the program. The library and program name must each be 10 characters or less.
parmlist - A list of up to 35 parameters with which to run the program.
Throws: PropertyVetoException
If a change is vetoed.
 o setProgram
 public void setProgram(String program) throws PropertyVetoException
Sets the path name of the program.

Parameters:
program - The fully qualified integrated file system path name to the program. The library and program name must each be 10 characters or less.
Throws: PropertyVetoException
If a change is vetoed.
 o setSystem
 public void setSystem(AS400 system) throws ExtendedIllegalStateException, PropertyVetoException
Sets the AS/400 to run the program.

Parameters:
system - The AS/400 on which to run the program.
Throws: PropertyVetoException
If a change is vetoed.
 o toString
 public String toString()
Returns a short description of the object.

Returns:
The String describing this program call.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index