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
-
ProgramCall()
- Constructs a ProgramCall object.
-
ProgramCall(AS400)
- Constructs a ProgramCall object.
-
ProgramCall(AS400, String, ProgramParameter[])
- Constructs a program call object.
-
addActionCompletedListener(ActionCompletedListener)
- Adds an ActionCompletedListener.
-
addParameter(ProgramParameter)
- Adds a ProgramParameter to the parameter list.
-
addPropertyChangeListener(PropertyChangeListener)
- Adds a PropertyChangeListener.
-
addVetoableChangeListener(VetoableChangeListener)
- Adds a VetoableChangeListener.
-
getMessageList()
- Returns the list of AS/400 messages returned from running the program.
-
getParameterList()
- Returns the list of parameters.
-
getProgram()
- Returns the integrated file system pathname for the program.
-
getSystem()
- Returns the AS/400 on which the program is to be run.
-
removeActionCompletedListener(ActionCompletedListener)
- Removes this ActionCompletedListener from the internal list.
-
removePropertyChangeListener(PropertyChangeListener)
- Removes this PropertyChangeListener from the internal list.
-
removeVetoableChangeListener(VetoableChangeListener)
- Removes this VetoableChangeListener from the internal list.
-
run()
- Runs the program on the AS/400.
-
run(String, ProgramParameter[])
- Sets the program name and the parameter list and
runs the program on the AS/400.
-
setParameterList(ProgramParameter[])
- Sets the list of parameters to pass to the AS/400 program.
-
setProgram(String)
- Sets the path name of the program.
-
setProgram(String, ProgramParameter[])
- Sets the path name of the program
and the parameter list.
-
setSystem(AS400)
- Sets the AS/400 to run the program.
-
toString()
- Returns a short description of the object.
ProgramCall
public ProgramCall()
- Constructs a ProgramCall object.
The system, program, and parameters must be provided later.
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.
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.
addActionCompletedListener
public synchronized void addActionCompletedListener(ActionCompletedListener l)
- Adds an ActionCompletedListener.
The specified ActionCompletedListeners actionCompleted method will
be called each time a program has run.
The ActionCompletedListener object is addded to a list of ActionCompletedListeners
managed by this ProgramCall. It can be removed with removeActionCompletedListener.
- Parameters:
- l - The ActionCompletedListener.
- See Also:
- removeActionCompletedListener
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.
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 ProgramCall, it can be removed with removePropertyChangeListener.
- Parameters:
- l - The PropertyChangeListener.
- See Also:
- removePropertyChangeListener
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
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.
getParameterList
public ProgramParameter[] getParameterList()
- Returns the list of parameters.
It will return null if not previously set.
- Returns:
- The list of parameters.
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.
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.
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
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
removeVetoableChangeListener
public void removeVetoableChangeListener(VetoableChangeListener l)
- Removes this VetoableChangeListener from the internal list.
If the VetoableChangeListener is not on the list, nothing is done.
- Parameters:
- l - The VetoableChangeListener.
- See Also:
- addVetoableChangeListener
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.
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.
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.
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.
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.
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.
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