Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Calling Service Programs from Java

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

  • Calling Service Programs from Java

    llpind wrote: > ... > We have so many service programs which have character return values. Weíre now starting to do more java development in our shop, and would like to keep our business logic unchanged and centralized. Hence, we been writing wrapper programs to get around these issues, but as you may know these are hard to maintain. ... It would be somewhat easier to maintain wrapper procedures rather than wrapper programs. You could keep each wrapper procedure in the same module as the original procedure.

  • #2
    Calling Service Programs from Java

    Thanks for your response. I'm primarily a java programmer, and do not have much knowledge of RPG programming and the iSeries. What do you mean by "wrapper procedure"? Could you point me to a tutorial on how i can go about creating these procedures? I don't want to bother the RPG programmers for simple things such as calling existing business-logic. Most of which are just simple one input param and one output param. But also there are cases where I need ways to pass more than 7 params (the limit on calling service programs from java). Any help? Thank you.

    Comment


    • #3
      Calling Service Programs from Java

      llpind wrote: > > Thanks for your response. I'm primarily a java programmer, and do not have much knowledge of RPG programming and the iSeries. What do you mean by "wrapper procedure"? Could you point me to a tutorial on how i can go about creating these procedures? I don't want to bother the RPG programmers for simple things such as calling existing business-logic. Most of which are just simple one input param and one output param. But also there are cases where I need ways to pass more than 7 params (the limit on calling service programs from java). Any help? Thank you. I don't know of any tutorial. But the process to create a wrapper procedure is almost the same as a wrapper program. The benefit of using procedures is that you can have them all in one *SRVPGM object instead of having several *PGM objects. Say this is the prototype for the procedure you need to have a wrapper for: D myproc pr 10a D parm 10i 0 const D parm2 10a Write your RPG module like this. H nomain * The prototype for your wrapper procedure D myprocWrapper pr D retval 10a D parm 10i 0 value D parm2 10a ... add more wrapper prototypes here /copy the prototypes for the RPG procedures you want to wrap * The wrapper procedure P myprocWrapper b export D myprocWrapper pi D retval 10a D parm 10i 0 value D parm2 10a /free retval = myproc (parm : parm2); /end-free P myprocWrapper e ... add more procedures here

      Comment


      • #4
        Calling Service Programs from Java

        llpind wrote: > > ... But also there are cases where I need ways to pass more than 7 params (the limit on calling service programs from java). Any help? Thank you. For the cases where you have more than 7 parameters (or rather 6 parameters, since you'd need one for the return value), you could use a data structure for the wrapper. Say this is prototype for the problem procedure: D myproc2 pr 10a D parm1 10a D parm2 5p 0 D parm3 10a D parm4 10a D parm5 5p 0 D parm6 10a D parm7 10a D parm8 10a D parm9 10a Code your wrapper like this: * Data structure type definition D myproc2arms_t... D ds qualified D parm1 10a D parm2 5p 0 D parm3 10a D parm4 10a D parm5 5p 0 D parm6 10a D parm7 10a D parm8 10a D parm9 10a * Prototype for the wrapper D myproc2Wrapper... D pr D retval 10a D parms likeds(myprocParms_t) * The wrapper procedure P myproc2Wrapper... P b export D myproc2Wrapper... D pi D retval 10a D parms likeds(myprocParms_t) /free retval = myproc (parms.parm1 : parms.parm2 : parms.parm3 : parms.parm4 : parms.parm5 : parms.parm6 : parms.parm7 : parms.parm8 : parms.parm9); /end-free P e

        Comment


        • #5
          Calling Service Programs from Java

          hmm... ok. Thatís a good idea to add on to the existing module. Does it make a difference to how the existing procedures are binded in the module? Also, do you have any java code on passing a data structure using the java toolbox to the prototype youíve shown above? Thanks.

          Comment


          • #6
            Calling Service Programs from Java

            llpind wrote: > > hmm... ok. Thatís a good idea to add on to the existing module. Does it make a difference to how the existing procedures are binded in the module? I don't think so. But now I'm not sure it's a good idea to add them to the existing module. If you are using ProgramCallDocument to do your calls, and you are generating your PCML using the RPG compiler or a wizard in WDSC that doesn't require you to explicitly code each parameter, then the compiler or wizard would give an error when it tried to generate the PCML for the "illegal" procedure. Having all your ProgramCallDocument procedures in a separate module would be easier to manage since you'd only have to generate the PCML for the wrapper procedures. But I think it would be ok to package your module in the same service program with the other modules; having a separate service program would be ok too. > > Also, do you have any java code on passing a data structure using the java toolbox to the prototype youíve shown above? Thanks. Assuming you're using compiler-generated PCML, it would look something like this (untested) etc Your Java to call myproc2 would look something like this, assuming you had already created your ProgramCallDocument object, and had set the path to point to your service program. String myproc2 (String parm1, BigDecimal parm2, String parm3,.... String parm9) { pcd.setValue ("MYPROC2WRAPPER.PARMS.PARM1", parm1); pcd.setValue ("MYPROC2WRAPPER.PARMS.PARM2", parm2); ... more parms 3-8 pcd.setValue ("MYPROC2WRAPPER.PARMS.PARM9", parm9); pcd.setValue ("MYPROC2WRAPPER.RETVAL", " "); // must be set before the call because usage is "inputoutput" rc = pcd.callp ("MYPROC2WRAPPER"); return (String) pcd.getValue ("MYPROC2WRAPPER.RETVAL"); }

            Comment


            • #7
              Calling Service Programs from Java

              Hello, I have read and experimented with the following article on how to call RPG service programs from java: Calling Service Programs from java We have so many service programs which have character return values. Weíre now starting to do more java development in our shop, and would like to keep our business logic unchanged and centralized. Hence, we been writing wrapper programs to get around these issues, but as you may know these are hard to maintain. My current java project will require numerous calls to service programs and most of which have character return values. Have there been any recent developments in this area? I really donít understand why IBM would implement a toolbox which allows calling service programs, but only integer return values??? Itís very common for service programs to have non-numeric return values. Does anyone have any information on this subject? Thanks.

              Comment


              • #8
                Calling Service Programs from Java

                Actually I'm not using compiler-generated PCML. We are using Hibernate as our presistence layer and we use direct toolbox classes (ProgramCall or ServiceProgramCall) when we need to call RPG. I did use PCML early on, but since the switch to Hibernate we got various errors with conflicting xml parsers. I'm assuming i can do simliar things using ServiceProgramCall?

                Comment


                • #9
                  Calling Service Programs from Java

                  llpind wrote: > > Actually I'm not using compiler-generated PCML. We are using Hibernate as our presistence layer and we use direct toolbox classes (ProgramCall or ServiceProgramCall) when we need to call RPG. I did use PCML early on, but since the switch to Hibernate we got various errors with conflicting xml parsers. I'm assuming i can do simliar things using ServiceProgramCall? Yes, you can set up data structures using ServiceProgramCall. Look at this thread in the archives of the midrange.com java400 mailing list: http://archive.midrange.com/java400-.../msg00021.html - the thread starts out with a problematic Java example, and subsequent posts sort out the problem.

                  Comment

                  Working...
                  X