i5_program_call

 

This function calls the Program or Procedure described with the i5_program_prepare and optionally accepts results.

 

bool i5_program_call (

resource program ,
array params
[, array retvals])

 

 

Details

 

Several calls can be made with the same description using the same program resource.

 

Parameters

 

 

program

Program resource opened by i5_program_prepare(), or i5_program_prepare_PCML().

params

Parameters according to description.

 

Can be given as flat array, then parameters are assigned in order, or

as key => value pairs then the values are assigned to the parameter

named by the key

 

retvals

Array of key => value pairs where keys describe output parameter name and

values name PHP variable that would receive the parameter

 

 


Fetch should still work even if the return parameters are defined and assigned.

 

Returns:

True if OK, false if failed. 

 

I5_ERR_PARSEXML

42

Internal error; please contact Aura Equipement; error number 42

I5_ERR_PHP_OPTIONSTYPE

259

The type of " I5_OPTIONS_ALIAS" option must be x and not x

I5_ERR_PHP_OPTIONSNUMBER

260

Option number -1 is unknown.

I5_ERR_PHP_TYPEPARAM

262

Type of element x in parameter -1 must be y. Type z was provided.

I5_ERR_PHP_VARIABLE

281

You can't use the I5_bind_param function and specify parameters

I5_ERR_PHP_LOCALHOST_NOT_PERMIT

286

you must specify the AS/400 address

I5_ERR_PHP_EXECUTE

289

You cannot read a request with parameters without calling the I5_execute function.

I5_ERR_PHP_NO_COMMAND

290

Empty command line or name

I5_ERR_PHP_NO_PARMNAME

293

Internal error; please contact Aura Equipement; error number 293

 

 

Example

 

 

 

/* call a program passing simple parameters and an associative array */

$description = array (

  array ("Name"=>"OP1", "IO"=>I5_IN, "Type"=>I5_TYPE_PACKED, "Length"=>"5.2"),

  array ("Name"=>"STR1", "IO"=>I5_IN, "Type"=>I5_TYPE_CHAR, "Length"=>20),

  array ("Name"=>"OP2", "IO"=>I5_INOUT, "Type"=>I5_TYPE_PACKED, "Length"=>"5.2"),

   array ("Name"=>"STR2", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>30),

   array ("Name"=>"OP3", "IO"=>I5_OUT, "Type"=>I5_TYPE_PACKED, "Length"=>"10.4")

 );

 $hdlPgm = i5_program_prepare("EASYCOM/RPCSAMPLE", $description);

 

$parameterIn = Array("OP2"=> 20.2, "STR2"=>"test", "STR1"=>"Hello", "OP1"=> 10.1);

$parameterOut = array("OP2"=>"parmOperator2", "STR2"=> "parmString2");

$ret = i5_program_call($hdlPgm, $parameterIn, $parameterOut);

if (!$ret){

   print_r(i5_error());

    trigger_error("i5_execute error : ".i5_errormsg(), E_USER_ERROR);

}

 echo "Parameter 3(P1+ P3, 10.1 + 20.2) : $parmOperator2<BR>";

 echo "Parameter 4(P2), Hello : $parmString2<BR>";

$ret = i5_program_close ($hdlPgm);

 if (!$ret){

  trigger_error("i5_program_close error : ".i5_errormsg(), E_USER_ERROR);

}

 

 

/*call a program passing simple parameters and an indexed array */

$description = array (

  array ("Name"=>"OP1", "IO"=>I5_IN, "Type"=>I5_TYPE_PACKED, "Length"=>"5.2"),

  array ("Name"=>"STR1", "IO"=>I5_IN, "Type"=>I5_TYPE_CHAR, "Length"=>20),

  array ("Name"=>"OP2", "IO"=>I5_INOUT, "Type"=>I5_TYPE_PACKED, "Length"=>"5.2"),

   array ("Name"=>"STR2", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>30),

   array ("Name"=>"OP3", "IO"=>I5_OUT, "Type"=>I5_TYPE_PACKED, "Length"=>"10.4")

 );

 $hdlPgm = i5_program_prepare("EASYCOM/RPCSAMPLE", $description);

 

$parameterIn = Array(10.1, "Hello", 20.2, "test");

$parameterOut = array("OP2"=>"parmOperator2", "STR2"=> "parmString2");

$ret = i5_program_call($hdlPgm, $parameterIn, $parameterOut);

if (!$ret){

   print_r(i5_error());

    trigger_error("i5_execute error : ".i5_errormsg(), E_USER_ERROR);

}

 echo "Parameter 3(P1+ P3, 10.1 + 20.2) : $parmOperator2<BR>";

 echo "Parameter 4(P2), Hello : $parmString2<BR>";

$ret = i5_program_close ($hdlPgm);

 if (!$ret){

  trigger_error("i5_program_close error : ".i5_errormsg(), E_USER_ERROR);

}

 

 

Note


Use i5_command in order to invoke a program without parameters. For example,

i5_command("call LIB_NAME/PROGRAM_NAME").