Hi John,
Actually Zend finally did get back to me with the solution late yesterday.
In order to work with the individual elements of a data structure array from
RPG, you have to do it like this.
First, given the following PCML:
<struct name="OUT_ARRAY">
      <data name="OUT_NAME1" type="char" length="30" usage="inherit" />
      <data name="OUT_TICKET1" type="char" length="14" usage="inherit" />
   </struct>
   <program name="ATESTX1" path="/QSYS.LIB/ALIB.LIB/ATESTX1.PGM">
      <data name="KSOCKCN" type="char" length="2" usage="inputoutput" />
      <data name="KSOCKYR" type="char" length="2" usage="inputoutput" />
      <data name="KSOCKTY" type="char" length="2" usage="inputoutput" />
      <data name="KSOCKNO" type="char" length="7" usage="inputoutput" />
      <data name="OUT_NAME" type="char" length="30" usage="inputoutput" />
      <data name="OUT_TICKET" type="char" length="14" usage="inputoutput" />
      <data name="OUT_ARRAY" type="struct" struct="OUT_ARRAY" count="5"
usage="inputoutput" />
   </program>
And given that you want to access the individual elements within OUT_ARRAY,
the data structure array,  you define it in PHP like this:
    $out_parameters = array( 
                          "OUT_NAME"=>"OUT_NAME", 
                          "OUT_TICKET"=>"OUT_TICKET",
                          "OUT_ARRAY"=>"OUT_ARRAY");
Rather than defining it like a normal multidimensional PHP array which would
have been like this:
    $out_parameters = array( 
                          "OUT_NAME"=>"OUT_NAME", 
                          "OUT_TICKET"=>"OUT_TICKET",
                          "OUT_ARRAY"=>array("OUT_NAME1"=>"OUT_NAME1",
                                             "OUT_TICKET1"=>"OUT_TICKET1"));
Then to get to the results after the I5_Program_Call you would do this:
print "The value of Out_NAME1 is: ".$OUT_ARRAY[0]["OUT_NAME1"];
print "The value of Out_NAME1 is: ".$OUT_ARRAY[0]["OUT_TICKET1"];
print "The value of Out_NAME1 is: ".$OUT_ARRAY[1]["OUT_NAME1"];
print "The value of Out_NAME1 is: ".$OUT_ARRAY[1]["OUT_TICKET1"];
etc...
I would have never thought of that particular combination to make this work,
but work it does.  Very slick actually and makes passing a large number of
records in a single I5_Program_Call really simple.
Thanks for you suggestion too!
Shannon O'Donnell
-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On
Behalf Of Jon Paris
Sent: Friday, February 27, 2009 7:09 PM
To: web400@xxxxxxxxxxxx
Subject: Re: [WEB400] PHP Syntax Question
On 27-Feb-09, at 1:00 PM, web400-request@xxxxxxxxxxxx wrote:
I am having trouble understanding why I cannot print the contents of a
returned PHP array from an I5_Program_Call.
Shannon,
The example below works - it is not as complex a situation as yours (I  
always work from simple - it suits my brain!) but you should be able  
to adapt.  I'm also going to copy my Zend contacts on this because  
there are no examples of using an array that I can find and there are  
things like countref that are available in the interface that I can  
find nothing about at all.
Anyway - here's the PHP:
<?php
include("conn.php");
/* connection step  */
$Hdlcon = i5_connect($connect,$user, $pass,  
array(I5_OPTIONS_JOBNAME=>"I5JOB"));
$description = file_get_contents("/www/zendcore/htdocs/ARRAY.pcml")
     or trigger_error("Error while opening PCML file", E_USER_ERROR);
// Prepare the program
($hdlPgm = i5_program_prepare_PCML($description))
     or trigger_error("Error while parsing PCML: " . i5_errormsg(),  
E_USER_ERROR);
// Define input values
$in_parameters = Array("IOARRAY"=>array("One","Two","Three","Four"));
// And output variables
$out_parameters = array("IOARRAY"=>"IOARRAY");
echo "<br>Here's the input parms: ";
var_dump($in_parameters);
// Make the call
i5_program_call($hdlPgm, $in_parameters, $out_parameters)
or trigger_error("Error while executing program: " . i5_errormsg(),  
E_USER_ERROR);
echo "<br><br>And here's the resulting output: ";
var_dump($IOARRAY);
?>
And here's the RPG program.  The Printer part was introduced because I  
couldn't tell where the failures were occurring.
      FQprint    O    F  132        Printer
      D Array           Pr                  ExtPgm('ARRAY/PARTNER400')
      D  IOArray                       5a   Dim(4)
      D Array           PI
      D  IOArray                       5a   Dim(4)
      D x               S              5i 0
       /Free
        except info;
        For x = 1 to %Elem(IOArray);
          IOArray(x) = %Char(x);
        EndFor;
        except info;
        *InLR = *On;
        /End-Free
      OQprint    E            info        2
      O                       IOArray(1)          12
      O                       IOArray(2)          24
Hope this helps.
We could certainly do with a few more examples of this type of program  
call.
Jon Paris
www.Partner400.com
www.SystemiDeveloper.com
As an Amazon Associate we earn from qualifying purchases.