Exact name is required when calling a service program’s procedure
Some developers make a common mistake when calling a procedure in a service program using the PHP Toolkit for IBM i or any toolkit based on XMLSERVICE. It’s easy to supply the wrong procedure name, or the right name in the wrong case (upper/lower/mixed). Using this example of calling a procedure using the toolkit, we find the following (correct) program/procedure call:
|
|
$result = $conn->PgmCall('MYPGM', 'MYLIB', $params, $retParam, array('func'=>'myproc')); |
The procedure name ‘myproc’ must be given exactly as it is, not ‘MYPROC’ or ‘MyProc’, because under some circumstances the name may be case-sensitive.
How to determine the correct procedure name
Run the DSPSRVPGM command, using your desired library and program names as parameters:
|
|
DSPSRVPGM SRVPGM(MYLIB/MYPGM) DETAIL(*PROCEXP) |
The above command will return service program information, including the names of all procedure exports. For example:
|
|
Display Service Program Information Service program . . . . . . . . . . . . : MYPGM Library . . . . . . . . . . . . . . . : MYLIB Owner . . . . . . . . . . . . . . . . . : PROGRAMMER Service program attribute . . . . . . . : RPGLE Detail . . . . . . . . . . . . . . . . . : *PROCEXP Procedure Exports: Procedure Name ARGOPT myproc *NO orderHeader *NO |
This service program contains two procedures: ‘myproc’ and ‘orderHeader’. Thus, to call the former, we’d supply array(‘func’=>’myproc’) in the PgmCall method. If we wanted to call the second procedure, we’d use array(‘func’=>’orderHeader’), observing case sensitivity, which often matters (a topic for another day).