ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Tell me about service programs

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

  • Tell me about service programs

    Hi All:

    I'm trying to figure out why I should use a service program instead of using a regular rpg program. This is what I've figured out so far....please tell me where I'm going wrong.

    Advantages to using a service program.
    1. can be called when using the eval statement
    2. gets loaded when the main program gets loaded therefore will save nano-seconds if called as a program

    Disadvantages to using a service program
    1. requires signature maintenance
    2. makes the main program larger even if the service program isn't used

    Thanks
    gls
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

  • #2
    Re: Tell me about service programs

    I really havent used service programs very often.
    I do however use modules more and more each day.

    The one good thing about service programs / modules is that
    you change code in one place and one place only.
    then you can do a updpgm across all programs that use
    the module. If say you have a hunk of code that calculates tax rates
    How many programs is this calculation going to be re-written in?

    welcome to code400


    jamie

    Ps... I went to sub school in connecticut ...you dont know me do you
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Tell me about service programs

      Hi,

      Advantages;
      1. Promotes modular use of code and re-use.
      2. Change of logic only needed in the one service program verus numerious of other programs.

      Disadvantages;
      1. Sometimes a real pain in the arse to debug the logic.

      If I was doing maintenance I would not go with a new service program. If I was going with new then the whole ILE is the way to go. The biggest thing is that your company has to be behind it or you just end up makeing funcitons and procedures just for yourself.
      Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

      Comment


      • #4
        Re: Tell me about service programs

        Hi Jamie:

        Thanks for the quick reply. I still don't understand the advantage.

        I do understand that breaking out code into seperate modules is a major advantage. What I don't understand is what the advantage to binding the smaller program to the master program as opposed to calling the smaller program from the master program. In your reply you mentioned updpgm.....in a called program there is no need.

        Thanks
        GLS

        PS never been to the sub base
        The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

        Comment


        • #5
          Re: Tell me about service programs

          To be truely honest ......... The only real iseries advantage is that source code is in one place. but that said the advantage to us as developers is huge....when you get used to modules it helps with other languages php C+ blah blah blah.....
          Also there are a bunch of shops out there using modules...service programs ...SQL ...CGIDEV2 the list goes on..we as developers learn whats available to allow us to adapt to a multitude of environments.

          The time argument is always interesting and I really dont want to start a debate here...but how important is a second here or there????
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: Tell me about service programs

            GLS400,

            Go here:



            Scroll all the way to the bottom and read this:

            Who Knew You Could Do That with RPG IV? A Sorcerer's Guide to System Access and More

            It is a PDF you can download and read. It taught me A LOT about the subject. At that same site you will find the ILE Concepts manual. Between the two you should find the answers to all of lifes questions

            HTH,
            MdnghtPgmr
            "Tis better to be thought a fool then to open one's mouth and remove all doubt." - Benjamin Franklin

            Comment


            • #7
              Re: Tell me about service programs

              We use Service programs a lot.

              Reporting from our ERP system and before service programs we had problems keeping derived data reported by various programs in step.

              For example the cost of an item for any given date depends on the production method and production plant.
              For each item both the production method and production plant have effective dates against them.
              Before service programs when we needed to create a new program accessing this information we tended to copy the code that works out what the actual cost was from one source to another.
              This works fine until one of the accountants decides to change the way that a calculation is derived, you are then faced with the task of tracking down and changing every source that contains the code that has been copied and needs to be modified ( Yes I know we should have used /COPY ) You then have to recompile and test all of the changed sources.
              With a service program you create a function that returns the value you need to the calling program. Provided that you don't change the call interface (the number and sequence of parameters and the format of the returned value) when something changes you only need to recompile the service program and only test one of the many programs using the function. You don't need to recompile each program because nothing structural has changed and provided the function returns the correct value to one of the calling programs it will return the correct value to any.

              Hope this is clear
              Life is a constant struggle against maturity

              Comment


              • #8
                Re: Tell me about service programs

                Ditto what Tony said.

                I've written a few service programs here full of useful procedures. Dates, UPC logic, Validations, etc.

                I use BNDDIR now instead of compiling modules with Opt. 15 and it's taken a lot of the work out of the maintenance.

                We had the same "ship to" logic in 400 programs here not long ago, well we still do! We had to change it and had to touch every one of those programs!

                Here are examples of procedures I have in Service Programs that we use all over the place. I sometimes wonder if I should even create a Service Program for a specific process. I'm in EDI right now and wonder if I should have an 850 Purchase Order Service Program. It's all up to the shop.

                Code:
                c                   eval      beginDate = #getPrvWkStart( jobDate )    
                c                   eval      endDate = #getPrvWkEnd( jobDate )        
                
                c                   eval      st02# = #getNextSeq#( mcwhse : '940' ) 
                
                c                   eval      dwcitm = #getPO1value( po1ds : 'CB' )

                One thing I've found I'm not clear about is the recompile because it seems to work the opposite of what I've believed ... or maybe it's how Aldon handles them. When I change just the code in a service program and I don't add a procedure or change the input/output parameters I thought I could use UPDSRVPGM ... lately I'm not sure of that and have just been using CRTSRVPGM to be safe and recompiling all that it touched.
                Your friends list is empty!

                Comment


                • #9
                  Re: Tell me about service programs

                  Hi All:

                  I'm still not getting it.

                  What you all seem to be explaining to me is the benefit of breaking code into component code which has a massive benefit of re-use. I understand that point.


                  The point that isn't sinking in is what is the benefit of binding the programs together If I create the "service program" as a "program" and do not bind it to anything.....you know a stand alone program..... Logic changes do not require me to do anything but the logic changes.

                  Updpgm, updsrvpgm, signature maint and tracking are no longer needed.

                  The point brought up that seem to have sunk in is the ability to do inter-language calling

                  Thanks
                  gls400
                  The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                  Comment


                  • #10
                    Re: Tell me about service programs

                    If you leave the routine in a normal program, every time its called it has to be intitialised. If you use a service program the initialisation is only done once.
                    Repeated calls to the routine(s) will give you a significant performance hit while the system loads and unloads the program from memory.
                    In one case changing to a service program saved an hour on an overnight batch program.
                    Life is a constant struggle against maturity

                    Comment


                    • #11
                      Re: Tell me about service programs

                      You mean why call a procedure in a Service Program when you could just as well call a program that does the same thing?

                      For one (as far as I understand it) any call to a procedure is a Static call and a call to a program is a dynamic call.

                      A static call means that the name of the procedure is resolved to an address during binding. As a result run time performance is faster.

                      Also the static calls allow for many more parameters (about 399 i think), and the ability to use omiited parameters etc.

                      IMHO Service Programs are the way to go, not just because of the ease of maitenance as stated in other posts but also because it lends itself towards a multi language environment.

                      Mike
                      You don't stop playing games because you get old, You get old because you stop playing games!

                      Comment


                      • #12
                        Re: Tell me about service programs

                        Tony sneaked in in front of me while I was writing my reply..lol
                        You don't stop playing games because you get old, You get old because you stop playing games!

                        Comment


                        • #13
                          Re: Tell me about service programs

                          Think of it this way: If you change the logic inside a subprocedure, those changes will only be used by the programs that are "rebound" (is that a word?) to the service program that contains the subprocedure. You have the option, through signature management, to allow some of your programs to continue to use the original subprocedure from the previous version of the service program. You can then have more control over your rollout schedule for changes.

                          Here's an example (although kind of lame):

                          Suppose you had a subprocedure in a service program that calculated the current fiscal period based on the date and your companies fiscal calendar. Say, your fiscal year ends on September 30 each year, then today would be within your fiscal period 8, not 5 (for May).

                          Now suppose your wanted to change the fiscal year end. If you change the service program to use a different date, that would change the results you get back. But what if you didn't want some programs to use the new date (like, maybe, your month-end processing) until next month? If you used a program, you would now have to have two copies of that program, and juggle your library list to call the right one. Or you have to have a second program with a different name, and change all the programs that called the old one to now call the new one. Major headache!

                          With a service program, your can have a *CURRENT and a *PREVIOUS version, both with the same name. The programs that you want to call the *CURRENT version, you "rebind" them after updating the service program. The others you just leave them be. They will still use the *PREVIOUS version until recompiled.
                          "Time passes, but sometimes it beats the <crap> out of you as it goes."

                          Comment


                          • #14
                            Re: Tell me about service programs

                            If anyone is interested I just got this from Iseries network

                            Code:
                            Tommy Holden has written a utility to assist with the creation of service programs 
                            from RPG modules. He has released the source code and made it publicly 
                            available to anyone interested.
                            
                            Here's the message that Tommy posted on the iSeries Network forums:
                            
                            
                                I'm by nature a lazy person (I hear that makes for good programmers! LOL) 
                            so I created a "juiced up" version of CRTSRVPGM, and it allows recompilation 
                            of all modules and so forth and creates the service program in a single command.
                            
                            
                                In the interest of helping others who might be as lazy as I am, I'm making 
                            it available for download. The source currently compiles on V5R2 and higher. 
                            (Note that the CRTSVPGM RPGLE source could be modified to compile down 
                            to V5R1, but I'm too lazy to do so!)
                            
                                
                               I (Tommy Holden) have the ZIP file exported from the WDSc project posted 
                            there as well (the source is also in the save file.) The save file was created 
                            to be able to restore onto V5R1. To create the application, compile the 
                            CRTAPP program in the QCLSRC file and execute it.
                            
                            
                                I hope someone gets some use from this utility!
                            
                            [URL="http://www.code400.com/downloads/service.zip"]
                            Here's a link to where you can download the source:[/URL]
                            All my answers were extracted from the "Big Dummy's Guide to the As400"
                            and I take no responsibility for any of them.

                            www.code400.com

                            Comment


                            • #15
                              Re: Tell me about service programs

                              Thanks All:

                              I think it finally sunk in, although I'm not crazy about having any program in production without supporting source code.

                              Thanks to all
                              GLS
                              The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                              Comment

                              Working...
                              X