• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Adding Subprocedures to a Service Program

    August 30, 2002 Timothy Prickett Morgan

    Hey, Ted:

    I’m still new to ILE, procedures, and service programs. I thought you could add procedures to the end of a service program, then recreate the service program and use it without recreating any existing program that has it bound in. Is this true, or am I off track?

    — Tim

    You need to learn and use binder language, Tim.

    Here’s an example that I hope will help you get started.

    Once there was an RPG programmer named Dan D. Koder. Dan decided to create a service program for frequently used math routines.

    Here’s the source code:

    H nomain                                     
    
     /copy prototypes,math
                                                 
    P OneMoreThan     b                   export
    D                 pi            10i 0
    D   Number                      10i 0 value
    
    C                   return    Number + 1
                                                 
    P                 e
    

    Notice that there’s only one routine–OneMoreThan.

    Dan created a source member in which to store the procedure prototype:

    D OneMoreThan     pr            10i 0
    D   Number                      10i 0 value
    

    Dan used the following commands to create the service program:

    CRTRPGMOD MODULE(OURLIB/MATH) +
       SRCFILE(OURLIB/SRC) SRCMBR(MATH)
    CRTSRVPGM SRVPGM(OURLIB/MATH) EXPORT(*ALL)
    

    Notice EXPORT(*ALL) in the Create Service Program (CRTSRVPGM) command. This says that the service program is to have the same exports as those of the module. In this case, there is one export–a subprocedure named OneMoreThan.

    With the service program ready for action, Dan wrote a program that used the OneMoreThan subprocedure. He named the program SNAZZYPGM. Here is part of the source code for that program:

    /copy prototypes,math                                 
    C                   exfmt     fmt01
    C                   dow       not *in03
    C                   eval      num2 = OneMoreThan(num1)
    

    Dan compiled SNAZZYPGM using the following commands:

    CRTRPGMOD MODULE(OURLIB/SNAZZYPGM)
       SRCFILE(OURLIB/SRC)
       SRCMBR(SNAZZYPGM)
    CRTPGM PGM(OURLIB/SNAZZYPGM) BNDSRVPGM(MATH)
    

    Everything was copasetic.

    One day Dan decided to add a subprocedure called Twice to the math service program:

    H nomain
    
     /copy prototypes,math
    
    P OneMoreThan     b                   export
    D                 pi            10i 0
    D   Number                      10i 0 value
    C                   return    Number + 1
    P                 e
    
    P Twice           b                   export
    D                 pi            10i 0
    D   Number                      10i 0 value
    C                   return    Number * 2
    P                 e
    

    He also modified the prototype member:

    D OneMoreThan     pr            10i 0
    D   Number                      10i 0 value
    D Twice           pr            10i 0
    D   Number                      10i 0 value
    

    Dan recreated the service program using the same Create RPG Module (CRTRPGMOD) and Create Service Program (CRTSRVPGM) commands as before.

    When a user ran the SNAZZYPGM program, everything was no longer copasetic. The user got escape message MCH4431 (Program signature violation) followed by CPF0001 (Error found on CALL command).

    Here’s what caused the problem: The program SNAZZYPGM expected the MATH service program to have one export, but MATH had two!

    Now, let’s look at how Dan should have handled this project.

    Before creating the service program for the first time, Dan should have created another source physical file, called QSRVSRC. He should have added a member named MATH into it. He should have keyed the following into the member.

    STRPGMEXP PGMLVL(*CURRENT)
    EXPORT SYMBOL('ONEMORETHAN')
    ENDPGMEXP
    

    This is called binder language, which allows a programmer to tell the RPG compiler about the exports in the service program.

    Dan should have created the service program this way:

    CRTSRVPGM SRVPGM(OURLIB/MATH) +
       EXPORT(*SRCFILE) +
       SRCFILE(OURLIB/QSRVSRC)
    

    Notice that EXPORT(*ALL) has been replaced by EXPORT(*SRCFILE) and the SRCFILE parameter has been filled in. This tells the compiler to use the binder language to resolve the exports.

    Dan would have created SNAZZYPGM as before.

    Later, when Dan added the Twice routine to the RPG source member, he should have revised the binder language like this example:

    STRPGMEXP PGMLVL(*CURRENT)
    EXPORT SYMBOL('ONEMORETHAN')
    EXPORT SYMBOL('TWICE')
    ENDPGMEXP
    STRPGMEXP PGMLVL(*PRV)
    EXPORT SYMBOL('ONEMORETHAN')
    ENDPGMEXP
    

    When the service program was recreated using this revised binder language, the service program would have two signatures–a current one with two exports and a previous one with only one export. SNAZZYPGM would have continued to run as always.

    Dan learned his lesson. Later he added another subprocedure–OneThirdOf. He changed the binder language so that it had three signatures–a current signature with three exports and two previous signatures–and everything ran smoothly.

    STRPGMEXP PGMLVL(*CURRENT)
    EXPORT SYMBOL('ONEMORETHAN')
    EXPORT SYMBOL('TWICE')
    EXPORT SYMBOL('ONETHIRDOF')
    ENDPGMEXP
    STRPGMEXP PGMLVL(*PRV)
    EXPORT SYMBOL('ONEMORETHAN')
    EXPORT SYMBOL('TWICE')
    ENDPGMEXP
    STRPGMEXP PGMLVL(*PRV)
    EXPORT SYMBOL('ONEMORETHAN')
    ENDPGMEXP
    

    Here’s the moral of the story: Don’t EXPORT(*ALL) when creating a service program.

    — Ted

    Sponsored By
    WORTH CONSULTING

    Improve Legacy Programs with

    Super/Windows

    Summary:

    This newly released

    tool for the iSeries is used to improve user and programmer productivity and

    efficiency.

    Pop-up windows (or

    selection windows) are what users want to make their jobs easier and more accurate. They have

    been exposed to “list boxes” when on the Internet or when using a typical

    windows-based program. This feature makes it so that the user does not need those sticky notes

    and reference material at their grasp to know what value to key in entry fields.

    Programmers have been

    reluctant to put the selection window feature in entry programs because it takes substantial

    programming efforts to build the information and display it on the screen. It also requires

    major additions to the display files.

    Super/Windows easily

    enables pop-up selection windows to your application programs in an affordable manner. Very few

    changes are required to be made to your existing RPG, COBOL, and CL programs. Changes to your

    display files are not needed! Your existing code or table files are used to populate the

    information in the windows from which your users make selection. You can also use the codes file

    (and maintenance program) that is included with Super/Windows. One of Super/Windows’

    functions generates the program source for each file ID using a simple entry program where the

    file and descriptive information is recorded. The source can be modified to return additional

    fields.

    You do not have to make

    wholesale changes to your application software, can optimize your staff’s existing skills,

    and little user training is needed. They will welcome Super/Windows with open

    arms!

    Business Owner

    Benefits:

    • Low Investment /

      High ROI as compared to leading high investment solutions that generate application

      software.

    • Immediate observable

      results.

    • Efficiency in

      workforce.

    • Faster training of

      users and programmers by using existing skill sets.

    • Gradual

      implementation with control of the degree of application.

    • its your budget: no

      increase in personnel and no major software expense.

    • License fee is

      $1,500 for first system and $750 for each subsequent system, no matter how many users or system

      size!

    • Annual maintenance

      is $300, regardless of the number of installations.

    Programmer

    Benefits:

    • Installs in 5

      minutes. Free 30-day trial.

    • Values in windows

      are built from your existing code and table file…nothing is

      “hard-coded.”

    • The programs that

      retrieve the data for display are automatically generated after entry of file and key

      information.

    • Easily implemented.

      Only two copybook lines and 8 lines for each field to be enabled are added to each

      program.

    • No changes to

      display files are needed, so programs can be promoted when currently active.

    • Code validation

      routines and file definitions for the enabled codes are no longer needed in your

      programs.

    • New programs to

      allow users to input criteria for reports and extracts are a snap!

    • Examples in RPG,

      RPGLE, COBOL, and CLP are provided.

    • The system can also

      be used in batch environment to retrieve descriptive values to be included in reports and

      extract files.

    User

    Benefits:

    • Improved accuracy.

      Invalid keyed entry causes window to pop up allowing the user to select a valid

      entry.

    • Reliance on printed

      code lists and manuals is reduced.

    • Improved efficiency.

      Eyes remain on the screen and keyboard with no need to access the mouse to cause a list box to

      appear.

    • Selected values are

      always up to date from the code or table files.

    • Improved customer

      service as entries can be selected with customer consent when in phone contact.

    Click here to learn more about

    Super/Windows.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: mgo_rc, Volume 2, Number 66 -- August 30, 2002

    Sponsored by
    Racksquared

    It’s time for IBM Power in the Cloud!

    Stop buying hardware and make the move to the cloud. It’s easier and more cost effective than you might think.

    • IBM Power in the Cloud
    • IBM Power Backup Solutions
    • IBM Power High Availability and DR solutions
    • IBM Power Colocation with Management and Monitoring

    Let’s talk about your business needs.

    Call: 855-380-7225
    Email: Sales@racksquared.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Edit with Parentheses in Query/400 Reader Feedback and Insights: Odds and Ends Always Popular

    Leave a Reply Cancel reply

MGO Volume: 2 Issue: 66

This Issue Sponsored By

    Table of Contents

    • Reader Feedback and Insights: Splitting a Qshell Variable
    • Adding Subprocedures to a Service Program
    • A Fuzzy Search Algorithm

    Content archive

    • The Four Hundred
    • Four Hundred Stuff
    • Four Hundred Guru

    Recent Posts

    • IBM Tweaks Some Power Systems Prices Down, Others Up
    • Disaster Recovery: From OS/400 V5R3 To IBM i 7.4 In 36 Hours
    • The Disconnect In Modernization Planning And Execution
    • Superior Support: One Of The Reasons You Pay The Power Systems Premium
    • IBM i PTF Guide, Volume 25, Number 13
    • IBM i Has a Future ‘If Kept Up To Date,’ IDC Says
    • When You Need Us, We Are Ready To Do Grunt Work
    • Generative AI: Coming to an ERP Near You
    • Four Hundred Monitor, March 22
    • IBM i PTF Guide, Volume 25, Number 12

    Subscribe

    To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

    Pages

    • About Us
    • Contact
    • Contributors
    • Four Hundred Monitor
    • IBM i PTF Guide
    • Media Kit
    • Subscribe

    Search

    Copyright © 2023 IT Jungle