As Tom write, PGMA need to access PGMB result set values .
This is usually done by PGMB passing the result to PGMA by parameter or store the result in an object (workfile, data queue…) that PGMA can access.
Using parameters you have 2 choices : passing parameter by value or by reference.
In your example, passing by value, you pass the DS ResultSet (containing the values).
By reference you pass the address of the DS ResultSet, then in PGMA you set the DS address to the address received by parameter (you have lots of examples for this in this site)
Depending on what you want to achieve with PGMB, using DTAQ is a great for passing values between programs , because PGMA knows when “end of data” is reached (instead of having to read all DS dataset), can make subsequent requests to PGMB to retrieve more data …
From the <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/sqlp/rbafyresultsets.htm”>Returning result sets from stored procedures</a> topic (V5R4):
<li>The interfaces that can work with <i>stored procedure</i> <b>result sets</b> include JDBC, CLI, and ODBC.</li>
If you want PGMA to be RPG, then you will want to use the <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/cli/rzadpkickoff.htm”>SQL CLI</a> <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/apis/database2.htm”>APIs</a> to get it done. If you have, say, a Visual Basic ODBC function that accesses your stored proc, then you pretty much convert that to RPG. The ODBC APIs translate almost directly to SQL CLI.