Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Calling Service Programs from Java using Data Structures

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

  • Calling Service Programs from Java using Data Structures

    llpind wrote: > > Hello, > > I'm having trouble calling RPG service programs passing a data structure as input and output. I've posted my code, please review. I have two issues... > 1. The returned byte array is always null. > 2. %parms always returns -1 (We even walked the service program in debug and were able to see 3 parameters being passed with actual values in them) > > The parameters we're passing do actually return data, we tested it on the AS/400. Any help will be appreciated, Thanks. > 2. You can't use %PARMS when you are being called by the ProgramCall class. The %PARMS documentation says that when called by other languages, you have to ensure that a minimal operational-descriptor must be passed, but there is no way to request this for a Java toolbox call. If you want to call your procedure with a variable number of parameters, you will have to pass an extra parameter to say how many other parameters were passed.

  • #2
    Calling Service Programs from Java using Data Structures

    Barbara, Thanks for your response. Yeah, thats kind of what we figured as well. Any idea what im doing wrong for #1??

    Comment


    • #3
      Calling Service Programs from Java using Data Structures

      llpind wrote: > > Barbara, > > Thanks for your response. Yeah, thats kind of what we figured as well. > > Any idea what im doing wrong for #1?? At the top of the ProgramParameter class, it says this. "The ProgramParameter class is used with ProgramCall and ServiceProgramCall to pass parameter data to a program, from a program, or both. Input data is passed to a program as a byte array with setInputData. Output data is requested from a program by specifying the amount of data to return with setOutputDataLength. To get the output data once the program has run use getOutputData. These values may also be set on the constructor." Looks like you need to call setOutputDataLength(), or use this constructor: ProgramParameter(int parameterType, byte[] inputData, int outputDataLength) And then printing getOutputDataLength() would just return whatever you had set.

      Comment


      • #4
        Calling Service Programs from Java using Data Structures

        Thanks Barbara! Changed: parmlist[0] = new ProgramParameter(ProgramParameter.PASS_BY_REFERENC E,output); To: parmlist[0] = new ProgramParameter(ProgramParameter.PASS_BY_REFERENC E,output,60); ok now I'm getting 60 elements in my data byte array. Is there any easy way to get to each item in the structure, other than dividing the byte array into 4, and using the AS400PackDecimal converter on each group? Thanks.

        Comment


        • #5
          Calling Service Programs from Java using Data Structures

          llpind wrote: > > ok now I'm getting 60 elements in my data byte array. Is there any easy way to get to each item in the structure, other than dividing the byte array into 4, and using the AS400PackDecimal converter on each group? > I don't know those classes well enough to know. (But glancing at your code, I would have guessed that myConverter would be able to convert from the byte array to struct_ordered?)

          Comment


          • #6
            Calling Service Programs from Java using Data Structures

            Looks like this worked... Object [] a = (Object [] )myConverter.toObject(data); for (int i = 0 ; i < a.length ; ++i) { System.out.println((BigDecimal)a[i]); } It's not converting to struct_ordered when retrieving data, but in fact to the java types (BigDecimal in this case). Thanks for your help. :]

            Comment


            • #7
              Calling Service Programs from Java using Data Structures

              Hello, I'm having trouble calling RPG service programs passing a data structure as input and output. I've posted my code, please review. I have two issues... 1. The returned byte array is always null. 2. %parms always returns -1 (We even walked the service program in debug and were able to see 3 parameters being passed with actual values in them) The parameters we're passing do actually return data, we tested it on the AS/400. Any help will be appreciated, Thanks.
              Code

              Comment

              Working...
              X