Executes a native command which returns data.
Class EasycomConnection
Syntax
public void RemoteRtvCommand(String strCommand)
Description
EasycomConnection.RemoteRtvCommand executes a command on the current connection, with capability to have return values. The command syntax is like CL language.
This command can affect the environment (JOB) of the current connection or retrieve some values depending on the job or the system.
The strCommand syntax is like a regular CL syntax, with & as variables prefixes. For example:
RTVJOBA USER(&USR)
If a variable as a length superior to 20 characters or if a variable is not character type, you need to declare it with CHAR(len) orDEC(len dec). All declarations are semicolon-separated. For example:
LIBL=CHAR(2750);DFTWAIT=DEC(7 0);RTVJOBA USRLIBL(&LIBL)
Subsequent calls of EasycomConnection.RemoteRtvCommandGetValue function is used to get the returned variables.
An exception (EasycomException) will be thrown if the command syntax is incorrect. However, an exception is not thrown upon failure (as opposed to the EasycomConnection.RemoteCommand method).
If the command syntax was correct, but the execution failed, a special variable name "RC" will contain the CPF code of the error (no exception thrown). So, a typical use of this method will execute the command, test the "RC" variable, and finally get the other variable(s).
Remark: it is recommended to use RemoteCommand method if the command is not returning any values (better performance, and better error handling).
Example of use (VB.NET):
Dim my_cnx As EasycomConnection
Dim result As String
my_cnx = New EasycomConnection
my_cnx.ConnectionString = "Server=194.206.160.111;User"
my_cnx.Open()
my_cnx.RemoteRtvCommand("LIBL=CHAR(2750);DFTWAIT=DEC(7 0);RTVJOBA USRLIBL(&LIBL)")
If my_cnx.RemoteRtvCommandGetValue("RC") = "0" Then
MessageBox.Show("User Library List: " + my_cnx.RemoteRtvCommandGetValue("LIBL"))
MessageBox.Show("User Default Wait: " + my_cnx.RemoteRtvCommandGetValue("DFTWAIT"))
Else
MessageBox.Show("The command call returned the following message" + my_cnx.RemoteRtvCommandGetValue("RC"))
End If
Example of use (C#):
EasycomConnection my_cnx = new EasycomConnection();
my_cnx.ConnectionString = "Server=194.206.160.111;User Id=";
my_cnx.Open();
my_cnx.RemoteRtvCommand("LIBL=CHAR(2750);DFTWAIT=DEC(7 0);RTVJOBA USRLIBL(&LIBL)");
if( my_cnx.RemoteRtvCommandGetValue("RC") == "0")
{
MessageBox.Show("User Library List: " + my_cnx.RemoteRtvCommandGetValue("LIBL"));
MessageBox.Show("User Default Wait: " + my_cnx.RemoteRtvCommandGetValue("DFTWAIT"));
}
else
{
MessageBox.Show("The command call returned the following message" + my_cnx.RemoteRtvCommandGetValue("RC"));
}