Trouble calling *SRVPGM with PHP Toolkit

Discussion in 'PHP Toolkit' started by John Taylor, Oct 31, 2017.

  1. John Taylor

    John Taylor New Member

    I'm trying to use the PHP Toolkit to call a function in a service program. I thought it was calling the program fine but after resetting my call I discovered this message:

    Error calling program. Code: UNEXPECTED Msg: XML run loop failed (p(54)

    Has anyone experienced this message?

    Here is my PHP code:

    $tkobj = $sm->get('tkconn');
    $parms[] = $tkobj->AddParameterChar('both', 10, 'dept', 'department', 'MEMBERS');
    $parms[] = $tkobj->AddParameterChar('both', 10, 'app', 'application', 'ELECTDOCS');
    $parms[] = $tkobj->AddParameterChar('both', 10, 'comp', 'company', 'UPR');
    $parms[] = $tkobj->AddParameterChar('both', 10, 'group', 'group', 'IFSDIR');
    $parms[] = $tkobj->AddParameterChar('both', 25, 'code', 'code', 'CAMPAIGNLOCATION');
    $retParms[] = $tkobj->AddParameterChar('both', 128, 'codeValue', 'codeValue', '');
    $result = $tkobj->PgmCall('CONTROL', '*LIBL',$parms, $retParms, array('func' => 'CONTROL_getCodeAlpha'));
    if (!$result) {
    die('Error calling program. Code: '.$tkobj->getErrorCode() . ' Msg: '. $tkobj->getErrorMsg());
    $outparms = $result['io_param'];
    echo "<p>CONTROL RESULTS:</p> ";
    echo "Parms: <pre>";print_r($parms);echo "</pre>";

    foreach ($retParms as $retParm) :
    echo "RetParms: <pre>";print_r($retParm);echo "</pre>";

    echo "Result: <pre>";print_r($result);echo "</pre>";

    echo "OutParms: <pre>";print_r($outparms);echo "</pre>";

    Attached is my log file.

    Attached Files:

    Last edited: Oct 31, 2017
  2. Alan

    Alan Administrator Staff Member

  3. John Taylor

    John Taylor New Member

    Hi Alan,
    I added the stateless but I am still receiving the same error. Attached is the new debug log.

    Attached Files:

  4. John Taylor

    John Taylor New Member

    This has been fixed. There were three issues:
    1) Function names are case sensitive. We were using CONTROL_getCodeAlpha and the function was CONTROL_GetCodeAlpha
    2) As Alan commented above the stateless option was not set ($tkobj->setOptions(array('stateless' => true)))
    3) In the function we were using the built-in function %Parms = %ParmNum. %Parms was equal to -1 rather than the actual number of parms passed. %ParmNum was equal to 5 which is the actual number of parms. I found this statement "The value returned by %PARMS will be -1 if the system can determine that the operational descriptor was not passed, but in some cases when the system cannot detect this, the value returned by %PARMS may be an incorrect value that is zero or greater." at the IBM website.

    I hope this helps others. Thank you Alan for your assistance.
    Last edited: Oct 31, 2017
  5. Alan

    Alan Administrator Staff Member

    John, what action did you take to resolve 3) above with the %Parms function?
  6. John Taylor

    John Taylor New Member

    We just took the edit check out for %Parms. Since all of the functions in our service program are SQL statements, if someone doesn't pass a parameter it will just not return what they were looking for. We considered checking for -1 or %Parms = %ParmNum but we opted to just remove the edit.

Share This Page