The PGMCall Method

Program Call Method

The program call method allows calling program (*PGM) or service program (*SRVPGM). (Not a *MODULE, which is a non-runnable intermediate object).

PgmCall($Program, $Library, $Parameters, $Returnvalue, $options)






  •  Program name
  • *OFF
  • *NONE

Program name to be called


Library name (or blank to use library list)

Library where the program is located


See parameters section

Program  parameters



Program return value parameter definition, to define what sort of value will be returned by a subprocedure or function.


An array of options

A popular option is to provide a service program function name: 'func' => 'myfuncname' Function name is case-sensitive.

Sample Code

This sample shows how to run an RPG program that has the following parameters:

  • Code
  • Name

Usage Example

include_once 'authorization.php';
include_once '../API/ToolkitService.php';
include_once 'helpshow.php';
try {
    $ToolkitServiceObj = ToolkitService::getInstance($db, $user, $pass, $extension);
    catch (Exception $e)
        echo  $e->getMessage(), "\n";
$code = ‘1’;;
$desc = ' ';
$param[] = $ToolkitServiceObj->AddParameterChar('both', 10,'InventoryCode', 'code',
$param[] = $ToolkitServiceObj->AddParameterChar('both', 10,'Description', 'desc',
$result = $ToolkitServiceObj->PgmCall("COMMONPGM", "ZENDSVR", $param, null, null);
  showTable( $result['io_param']);
    echo "Execution failed.";
/* Do not use the disconnect() function for "state full" connection */