Question

We use the com.ibm.as400.data.ProgramCallDocument class to interface with our RPG programs on the iSeries through Java. In most of the cases for our WebSphere applications we have fronted our RPG/Synon programs with CL's and used the PCML to interface with them. We also have not normally worked with structs as inputoutput.

This time one of our RPG developers created the program in RPG IV (not Synon) and gave us the PCML to interface with this program. We have three inputoutput parms as regular Strings. Not a big deal. We've done that before. Now the fourth parm as you can see is a struct of count 100 and it is inputoutput.

All we are getting back from the RPG program when we try to invoke it is tons of blanks (ie, hex 40). The String parms come back fine. But the struct does not. All indeces are nothing but blanks.

When we had the RPG programmer validate, he can see that his program does indeed return the array of structs. He also wrote up a quick and dirty CL to make sure his program was indeed returning values, and he said that the CL proved it was.

So now I'm stumped. I've even tried to find a way to pass in a value and see if that makes a difference. But no matter what I either make it unhappy (as I don't match the parms list), or I get back only blanks. Any idea on a direction to go?

Here is the PCML file

   <pcml version="4.0">
   <!-- RPG program: IL010S20  -->
   <!-- created: 2010-07-13-11.28.53 -->
   <!-- source: CPPGENL/QRPGLESRC(IL010S20) -->
   <!-- 2208 -->
   <struct name="ADDRINFO">
      <data name="PREDIRECTION" type="char" length="2" usage="inherit" />
      <data name="STREETNAME" type="char" length="30" usage="inherit" />
      <data name="POSTDIRECTION" type="char" length="2" usage="inherit" />
      <data name="STREETTYPE" type="char" length="4" usage="inherit" />
      <data name="LOWADDRESS" type="char" length="11" usage="inherit" />
      <data name="HIGHADDRESS" type="char" length="11" usage="inherit" />
      <data name="ODDEVEN" type="char" length="1" usage="inherit" />
      <data name="TERRID" type="char" length="2" usage="inherit" />
      <data name="TAXCODE" type="char" length="5" usage="inherit" />
      <data name="TERRNAME" type="char" length="30" usage="inherit" />
   </struct>
   <!-- 2226 -->
   <program name="program" path="/QSYS.LIB/DEVOBJL.LIB/IL010S20.PGM"> 
      <data name="STATE" type="char" length="2" usage="inputoutput" />
      <data name="ZIP" type="char" length="5" usage="inputoutput" />
      <data name="STREET" type="char" length="30" usage="inputoutput" />               
      <data name="RETURNADDR" type="struct" struct="ADDRINFO" count="100" usage="inputoutput" />
   </program>
</pcml>

And to load the ProgramCallDocument as follows:

//sys is our AS400 object and parameters is a HashMap.
ProgramCallDocument newPcml = new ProgramCallDocument( sys, pcmlfileName );
Iterator parametersKeysI = parameters.keySet().iterator();
StringBuffer loggingStatement = new StringBuffer();
while( parametersKeysI.hasNext() ) {
    String key = (String)parametersKeysI.next();

    if("program.RETURNADDR".equalsIgnoreCase(key)) {
      AS400Structure [] structure = (AS400Structure[]) parameters.get(key);
      int [] indeces = new int[1];
      indeces[0] = 0;
      for(int i = 0; i < structure.length; i++) {
        indeces[0] = i;
        Object paramValue = structure[i];
        loggingStatement.append(paramValue).append(", ");
        newPcml.setValue(key, indeces, paramValue);
      }
    }
    else {
      Object paramValue = parameters.get( key );
      loggingStatement.append( paramValue ).append( ", " );
      //set the value
      newPcml.setValue( key, paramValue );
    }
}

and then we invoke our program with newPcml.callProgram('program'); and from what we can see, the invocation is returning true. But when we go to read out the struct there is nothing. I've even used com.ibm.as400.data.PcmlMessageLog.setTraceEnabled(true); to try to see the parms and that is what puzzles me. We look like there is no issue, but we aren't getting what we are expecting.

Any help or direction would be appreciated. So far the Javadocs and examples online haven't been the most helpful.

Was it helpful?

Solution

Ok. This is stupid we didn't think to check this earlier. But the problem was case on our Strings/chars. Even though our iSeries here pretty much deals with upper cased letters when typing, because we are using jt400.jar I believe it reads our lower case letters in our Java app and sends the byte eqivalents of them into the iSeries and thus we didn't match on the DB reads in the RPG program. Our iSeries guy just modified this program to "to Upper" everything that comes in so we got around the problem. We just assumed it was ok, because of how most things automatically "to Upper" on the iSeries. Guess we were wrong.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top