i5_XmlCallProgram

 

This function calls a program or procedure, exchanging parameter values.

array i5_XmlCallProgram (

string Program_Name
, array Input_Values,
[ , string Ret_Values_Var_Name ]
[ , resource Connection ])

 

 

Details

 

This function combines i5_XmlCrtPgmRequest, i5_XmlSetInputValue, i5_XmlExecrequest and i5_XmlGetOutputValue.

Parameter values on input and output are passed using associative arrays.

 

Parameters

 

Program_Name

Name of the program or procedure to call.
This name must have been previously prototyped from a PCML or RPG source, using i5_XmlDefine(), or i5_XmlExecRequest() with a <define> tag in the request.

This name is a virtual name. Real program or procedure name is given in the prototype. See Calling Programs or Procedures example.

 

Input_Values

Input values in an associative array.

 

Ret_Values_Var_Name

When a procedure from a servive program is called, it can return a return value, in addition to output parameters.
When a return value is present, the variable is created.
If return value is a data structure, variable is created as an associative array.

 

Connection

Easycom Connection - Result of i5_connect() or i5_pconnect().

 

Returns:

If function succeeds, it returns an associative array with output parameter values.

 

Examples

 

Calling a a program with no return value. Only output parameters are retrieved.

 

// Define SAMPLESDS1 procedure prototype

$SRPG = "DS_A      DS;

           MBR1    10a;

           MBR2    10a;

           MBR3     8p2;

         SampleDS1 PR  extpgm(SampleDS1);

           PARM1   10a;

           PARM2    8p2;

           PARM3   likeds(DS_A);";

i5_XmlDefine ("s-rpg", $SRPG); 

 

// Call it!

$ArrayIn = array("PARM1"=>"pararm 1", "PARM2"=>12345, PARM3"=>array("MBR1"=>"Param 3-1"));

 

$ArrayOut = i5_XmlCallProgram("SAMPLEDS1", $ArrayIn);

echo '<p>Param 1='. $ArrayOut['PARM1'].'</p>';

echo '<p>Param 3, Member 3='. $ArrayOut['PARM3']['MBR3'].'</p>';

 

Calling a procedure returning a DS.

 

// Define FSPCUST procedure. Procedure is in SRVPTEST1 service program.

// FSPCUST returns a DS.

$SRPG = "DS_CUST    E DS  extname(SP_CUST);

         FSPCUST      PR  LIKEDS(DS_CUST);

           TERM1      5S 0;";

$XMLStr = i5_XmlDefine ("s-rpg", $SRPG 

i5_XmlBindSrvPgm ("SRVPTEST1");

 

$ArrayIn = array("TERM1"=>1551);

$ArrayOut = i5_XmlCallProgram ("FSPCUST", $ArrayIn, "RetVal");

 

echo '<p>Return Value=';

var_dump($RetVal);

echo '</p>';

 

 

 

See also

i5_XmlBindSrvPgm

i5_XmlDefine

i5_XmlLoadDefinition

i5_XmlExecRequest