ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

please help how to get return array from rpg program on java code?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • please help how to get return array from rpg program on java code?

    Hi

    I have created a rpg program that returns 2 parameter 1 is the id and another one is list of array, when I called this program I passed two programparameter from my java code (see the code below) but when i checked what value would be return it is returned only first value of array. how will i get all array values ?

    please suggest me regarding this issues I amn't so much aware on java & AS400.


    try
    {

    ProgramParameter[] parmList = new ProgramParameter[2];

    AS400Text p1 = new AS400Text(10);
    AS400Text p2 = new AS400Text(30);
    try
    {
    parmList[0] = new ProgramParameter(10);
    parmList[1] = new ProgramParameter(30);
    parmList[0].setParameterType(ProgramParameter.PASS_BY_REFEREN CE);
    parmList[1].setParameterType(ProgramParameter.PASS_BY_REFEREN CE);

    parmList[0].setInputData(p1.toBytes("Pune"));
    parmList[1].setInputData(p2.toBytes(" "));

    }
    catch(Exception ex)
    {
    }

    ProgramCall pgm = new ProgramCall(o);
    pgm.setProgram("/QSYS.LIB/XXX/XXX.PGM",parmList);

    if (pgm.run())
    {

    byte s[] = parmList[1].getOutputData(); // HERE I got only first value of returning array.

    parmList[1].getOutputDataLength();

    //String sts = ((String) (new AS400Text(10,o).toBytes(s[0])));
    }
    else
    {
    AS400Message[] messageList = pgm.getMessageList();
    for (int msg = 0; msg < messageList.length; msg++) {

    }
    }


    }
    catch(Exception ex)
    {
    AS400Message[] messageList = null;
    }
    finally
    {
    o.disconnectAllServices();
    }
    }

  • #2
    Re: please help how to get return array from rpg program on java code?

    Are you currently getting any data back from the AS/400? Or can't you figure out how to get the values from RPG to Java? Just looking for some clarity on your issue..
    Your future President
    Bryce

    ---------------------------------------------
    http://www.bravobryce.com

    Comment


    • #3
      Re: please help how to get return array from rpg program on java code?

      hi bryce4president,

      Thank you very much for reply.

      Actually i am getting both the parameter in my java code but problem is that I wanted to fetch array as second parameter like
      parmList[0] = "XX"
      parmList[1] = Array()

      I got only first value of that array not all of them.
      Is it possible in java As400 I also attach RPG program with this message please suggest me.

      and also tell in my database there is a table for student record I need to retrieve all the records How can I do this thing which is the best thing to get the records easily?

      Comment


      • #4
        Re: please help how to get return array from rpg program on java code?

        Are you using servlets and JSP by chance? How are you displaying your data? Web browser? Desktop App?
        Your future President
        Bryce

        ---------------------------------------------
        http://www.bravobryce.com

        Comment


        • #5
          Re: please help how to get return array from rpg program on java code?

          Originally posted by bryce4president View Post
          Are you using servlets and JSP by chance? How are you displaying your data? Web browser? Desktop App?
          I am using servlet for this .......
          it is a Web App

          Comment


          • #6
            Re: please help how to get return array from rpg program on java code?

            You should look into CGIDev2 for this. I haven't done it, but if you want to run RPG programs in the form of a web app like this it would be a good place to start. I've never connected any of my java web apps to RPG programs. It can be done, I've just never done it. Is the RPG program complicated enough that it would take too long to reproduce in Java?
            Your future President
            Bryce

            ---------------------------------------------
            http://www.bravobryce.com

            Comment


            • #7
              Re: please help how to get return array from rpg program on java code?

              Wait, you're trying to pass an array from a Java app to an RPG program? wouldn't you have to put the entire array into a single variable and pass it as a parm.

              Comment


              • #8
                Re: please help how to get return array from rpg program on java code?

                I've just got back off holiday so I'm still getting into the flow of things. In your program call you don't define any parameter as an array. It's no surprise then that you don't get an array back. If I were you I would look into using PCML for this. It's basically the same but it looks a lot neater. You effectively "prototype" your program using XML in a .pcml file. The following article should tell you everything you need to know. In particular look at the "Count" attribute for the parameter definitions.

                Ben

                Comment

                Working...
                X