Data structures are defined via PHP as follows:
Main data is the array of values, having the following fields:
• Name - name of the field
• Type - type of the field, can be:
I5_TYPE_CHAR
I5_TYPE_INT
I5_TYPE_PACKED
I5_TYPE_ZONED
I5_TYPE_FLOAT
I5_TYPE_BYTE
I5_TYPE_STRUCT
• Length
- for CHAR, BYTE - integer describing length. Length can be number or
name of the variable holding the length in the data structure.
- for PACKED, ZONED - string "NUMBER.NUMBER" defining length and
precision
- for STRUCT - array containing data definition of the structure
- for INT, FLOAT – ignored
• IO
- I5_IN
- I5_OUT
- I5_INOUT ( = I5_IN | I5_OUT)
- default is input, these values can be OR'ed together to get input-output
value
• Count (optional) - repetition count if the field is an array
• CountRef (optional) - reference to the repetition count if the field is an array
Data structure is defined via PHP as follows:
• DSName - name of the parameter
• DSParm (optional) - array of the parameter of the Data structure. Each
parameter is defined by a simple data definition.
/*Call a program passing a DS as parameter */
$description = array (
array ("Name"=>"P1", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>10, "Count"=>5),
array ("Name"=>"P2C", "IO"=>I5_INOUT,"Type"=>I5_TYPE_LONG, "Length"=>4),
array ("Name"=>"P2", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>1, "CountRef"=>"P2C" ),
array ("DSName"=>"PS", "Count"=>2, "DSParm"=>array (
array ("Name"=>"PS1", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>10),
array ("Name"=>"PS2", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>10),
array ("Name"=>"PS3", "IO"=>I5_INOUT, "Type"=>I5_TYPE_CHAR, "Length"=>10)
)
)
);
$hdlPgm = i5_program_prepare("EASYCOM/RPCTEST", $description);
$Psparameter = array(
array("PS1"=>"test1", "PS2"=>"test2", "PS3"=>"test3"),
array("PS1"=>"test3", "PS2"=>"test4", "PS3"=>"test5")
);
$parameter2 = Array(
"P1"=>array("t1", "t2", "t3", "t4", "t5"),
"P2C"=>2,
"P2"=>array("a", "b"),
"PS"=>$Psparameter);
$parmOut2 = array("P1"=>"P1", "PS"=>"PS");
$ret = i5_program_call($hdlPgm, $parameter2, $parmOut2);
if (!$ret){
print_r(i5_error());
trigger_error("i5_execute error : ".i5_errormsg(), E_USER_ERROR);
}
echo "P1 : $P1<BR>";
echo "PS: ";print_r($PS);echo "<BR>";