Search code examples
ibm-midrangerpglerpgphp-toolkit

Now to structure return parameter to accept boolean values with XMLService?


I am trying to call an RPGLE service program from PHP using the PHP Toolkit. The procedure returns a data structure that includes an element of type N (indicator) and returns either *off or *on.

I am trying to figure out how to structure my return parameter in PHP to accept a value of this type and cannot find any information about sending or receiving boolean values with XMLService.


Solution

  • I contacted Alan Seiden with this question and his answer fixed my issue.

    You can use a 1-byte character parameter in place of a specialized indicator type. For example:

    Input

    $params[] = $toolkit->AddParameterChar('in', 1, 'My indicator', 'MYIND', '0');
    

    Output

    $retVal = $toolkit->AddParameterChar('out', 1, 'My indicator', 'MYIND');
    

    The XML (for an output param) will come back like:

    <return io='out' comment='My indicator'>
        <data var='MYIND' type='1A' ><![CDATA[0]]></data> 
    </return>
    

    Which yields PHP in the $result['retvals'] of:

    array(1) { ["MYIND"]=> string(1) "0" }
    

    Which will evaluate to true/false (1/0) correctly as long as you don't type check.

    Thank you very much Alan!