|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.as400.access.ProgramCall | +--com.ibm.as400.access.ServiceProgramCall
The ServiceProgramCall class allows a user to call an AS/400 service program, passing data via input parameters, then accessing data returned via output parameters. ProgramParameter objects are used to pass data between the Java program and the AS/400 service program.
ServiceProgramCall subclasses ProgramCall. Much of the setup to call the service program is done via methods inherited from ProgramCall. For example setSystem() and getSystem() are methods inherited from ProgramCall.
Limitations of this class:
The name of the service program to call is the fully qualified name in the AS/400's integrated file system. The extension is ".SRVPGM". For example, to call MySrvPgm in MyLib, the program name is /QSYS.LIB/MYLIB.LIB/MYSRVPGM.SRVPGM.
Service program entry point notes:
The following example calls procedure int_int in service program ENTRYPTS in library MYPGM. The procedure takes one input parameter, an integer, and returns an integer.
// Construct the parameter list. It contains the single parameter to the service program. ProgramParameter[] parameterList = new ProgramParameter[1]; // Create the input parameter. In this case we are sending the number 9 to the service program. AS400Bin4 bin4 = new AS400Bin4(); byte[] parameter = bin4.toBytes(9); parameterList[0] = new ProgramParameter(parameter); // Construct the AS/400 object. The service program is on this AS/400. AS400 system = new AS400("mySystem"); // Construct the ServiceProgramCall object. ServiceProgramCall sPGMCall = new ServiceProgramCall(system); // Set the fully qualified service program and the parameter list. sPGMCall.setProgram("/QSYS.LIB/MYPGM.LIB/ENTRYPTS.SRVPGM", parameterList); // Set the procedure to call in the service program. sPGMCall.setProcedureName("int_int"); // Set the format of returned value. The program we call returns an integer. sPGMCall.setReturnValueFormat(ServiceProgramCall.RETURN_INTEGER); // Call the service program. If true is returned the program was successfully called. If false is returned the program could not be started. A list of messages is returned when the program cannot be started. if (sPGMCall.run() != true) { // Get the error messages when the call fails. AS400Message[] messageList = sPGMCall.getMessageList(); for (int i = 0; i < messageList.length; ++i) { System.out.println(messageList[i].getText()); } } else { // Get the returned value when the call is successful. int i = bin4.toInt(sPGMCall.getReturnValue()); System.out.println("Result is: " + i); }
ProgramParameter
,
ProgramCall
, Serialized FormField Summary | |
static int |
NO_RETURN_VALUE
Constant indicating the service program returns void. |
static int |
RETURN_INTEGER
Constant indicating the service program returns an integer. |
Constructor Summary | |
ServiceProgramCall()
Constructs a ServiceProgramCall object. |
|
ServiceProgramCall(AS400 system)
Constructs a ServiceProgramCall object. |
|
ServiceProgramCall(AS400 system,
java.lang.String serviceProgram,
ProgramParameter[] parameterList)
Constructs a ServiceProgramCall object. |
|
ServiceProgramCall(AS400 system,
java.lang.String serviceProgram,
java.lang.String procedureName,
int returnValueFormat,
ProgramParameter[] parameterList)
Constructs a ServiceProgramCall object. |
|
ServiceProgramCall(AS400 system,
java.lang.String serviceProgram,
java.lang.String procedureName,
ProgramParameter[] parameterList)
Constructs a ServiceProgramCall object. |
Method Summary | |
int |
getErrno()
Returns the error number (errno). |
int |
getIntegerReturnValue()
Returns the return data when the service program returns an integer. |
java.lang.String |
getProcedureName()
Returns the service program procedure to be called. |
byte[] |
getReturnValue()
Returns the data returned from the service program. |
int |
getReturnValueFormat()
Returns the format of the returned data. |
boolean |
run()
Calls the service program. |
boolean |
run(AS400 system,
java.lang.String serviceProgram,
java.lang.String procedureName,
int returnValueFormat,
ProgramParameter[] parameterList)
Calls the service program. |
boolean |
run(java.lang.String serviceProgram,
ProgramParameter[] parameterList)
Calls the service program. |
void |
setProcedureName(java.lang.String procedureName)
Sets the service program procedure to call. |
void |
setProcedureName(java.lang.String procedureName,
int procedureNameCCSID)
Sets the service program procedure to call. |
void |
setProgram(java.lang.String serviceProgram)
Sets the path name of the service program. |
void |
setReturnValueFormat(int returnValueFormat)
Sets the format of the returned data. |
Methods inherited from class com.ibm.as400.access.ProgramCall |
addActionCompletedListener,
addParameter,
addPropertyChangeListener,
addVetoableChangeListener,
getJob,
getMessageList,
getParameterList,
getProgram,
getSystem,
getSystemThread,
isStayOnThread,
isThreadSafe,
removeActionCompletedListener,
removePropertyChangeListener,
removeVetoableChangeListener,
setParameterList,
setProgram,
setSystem,
setThreadSafe,
toString |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final int NO_RETURN_VALUE
public static final int RETURN_INTEGER
Constructor Detail |
public ServiceProgramCall()
public ServiceProgramCall(AS400 system)
system
- The AS/400 that contains the program.public ServiceProgramCall(AS400 system, java.lang.String serviceProgram, ProgramParameter[] parameterList)
system
- The AS/400 which contains the program.serviceProgram
- The service program name as a fully qualified name in the integrated file system.parameterList
- A list of up to 7 parameters with which to call the program.public ServiceProgramCall(AS400 system, java.lang.String serviceProgram, java.lang.String procedureName, ProgramParameter[] parameterList)
system
- The AS/400 which contains the program.serviceProgram
- The program name as a fully qualified name in the integrated file system.procedureName
- The procedure in the service program to call.parameterList
- A list of up to 7 parameters with which to call the program.public ServiceProgramCall(AS400 system, java.lang.String serviceProgram, java.lang.String procedureName, int returnValueFormat, ProgramParameter[] parameterList)
system
- The AS/400 which contains the program.serviceProgram
- The program name as a fully qualified name in the integrated file system.procedureName
- The procedure in the service program to call.returnValueFormat
- The format of the returned data. The value must be one of the following:
parameterList
- A list of up to 7 parameters with which to call the program.Method Detail |
public int getErrno()
public int getIntegerReturnValue()
public java.lang.String getProcedureName()
public byte[] getReturnValue()
public int getReturnValueFormat()
public boolean run() throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException, ObjectDoesNotExistException
public boolean run(java.lang.String serviceProgram, ProgramParameter[] parameterList) throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException, ObjectDoesNotExistException, java.beans.PropertyVetoException
serviceProgram
- The program name as a fully qualified name in the integrated file system.parameterList
- A list of up to 7 parameters with which to call the program.public boolean run(AS400 system, java.lang.String serviceProgram, java.lang.String procedureName, int returnValueFormat, ProgramParameter[] parameterList) throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException, ObjectDoesNotExistException, java.beans.PropertyVetoException
system
- The AS/400 which contains the program.serviceProgram
- The program name as a fully qualified name in the integrated file system.procedureName
- The procedure in the service program to call.returnValueFormat
- The format of the returned data. The value must be one of the following:
parameterList
- A list of up to 7 parameters with which to call the program.public void setProcedureName(java.lang.String procedureName) throws java.beans.PropertyVetoException
procedureName
- The procedure in the service program to call.public void setProcedureName(java.lang.String procedureName, int procedureNameCCSID) throws java.beans.PropertyVetoException
procedureName
- The procedure in the service program to call.procedureNameCCSID
- The CCSID to use when converting the procedure name from a Java String to EBCDIC.public void setProgram(java.lang.String serviceProgram) throws java.beans.PropertyVetoException
serviceProgram
- The fully qualified integrated file system path name to the service program. The library and service program name must each be 10 characters or less.public void setReturnValueFormat(int returnValueFormat) throws java.beans.PropertyVetoException
returnValueFormat
- The format of the returned data. The value must be one of the following:
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |