• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Adding New Parameters to RPG Programs

    July 21, 2004 Hey, Ted

    We have an RPG IV program that accepts one parameter. We need to add two more parameters. Our problem is that this program is called from several menus and many programs. Unless you have some trick up your sleeve, adding the new parameters will involve a lot of work outside of regular hours. Can you help?

    –Bo

    This is not a difficult situation to handle, Bo. There’s no trick to it, and this is a fundamental technique that everybody should know.

    As long as you do not reference a parameter that is not passed to the program, the RPG program will not cancel. You can use RPG IV’s %PARMS built-in function to determine how many parameters are passed to the program on the CALL command.

    Add the parameters the end of the parameter list. In this example, I call them PARM2 and PARM3. You’ll use more descriptive names, of course.

    C     *entry        plist                                        
    C                   parm                    parm1             5  
    C                   parm                    parm2             3 0
    C                   parm                    parm3            10
    

    Define two variables as you’ve defined the new parameters. I’ll call them WORK2 and WORK3.

    D work2           s                   like(parm2) 
    D work3           s                   like(parm3) 
    

    Use the %PARMS function to determine whether each parameter was passed. If a parameter was passed into the program, load its value into the corresponding work variable. If a parameter was not passed into the program, assign a default value to the work variable.

    Use the work variables, not the parameters, throughout the program.



    Using this technique lets you leave existing calls as they are, as long as the default values for the new parameters are acceptable. You will only need to modify the calls that need to pass other parameter values.

    You’re fortunate that the program you must change was written in RPG and not CL. When you call a CL program, you must pass exactly the number of expected parameters. You can work around this problem to an extent by creating commands to run CL programs, but that is a topic for some other day.

    –Ted

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    DRV Tech

    Get More Out of Your IBM i

    With soaring costs, operational data is more critical than ever. IBM shops need faster, easier ways to distribute IBM applications-based data to users more efficiently, no matter where they are.

    The Problem:

    For Users, IBM Data Can Be Difficult to Get To

    IBM Applications generate reports as spooled files, originally designed to be printed. Often those reports are packed together with so much data it makes them difficult to read. Add to that hardcopy is a pain to distribute. User-friendly formats like Excel and PDF are better, offering sorting, searching, and easy portability but getting IBM reports into these formats can be tricky without the right tools.

    The Solution:

    IBM i Reports can easily be converted to easy to read and share formats like Excel and PDF and Delivered by Email

    Converting IBM i, iSeries, and AS400 reports into Excel and PDF is now a lot easier with SpoolFlex software by DRV Tech.  If you or your users are still doing this manually, think how much time is wasted dragging and reformatting to make a report readable. How much time would be saved if they were automatically formatted correctly and delivered to one or multiple recipients.

    SpoolFlex converts spooled files to Excel and PDF, automatically emailing them, and saving copies to network shared folders. SpoolFlex converts complex reports to Excel, removing unwanted headers, splitting large reports out for individual recipients, and delivering to users whether they are at the office or working from home.

    Watch our 2-minute video and see DRV’s powerful SpoolFlex software can solve your file conversion challenges.

    Watch Video

    DRV Tech

    www.drvtech.com

    866.378.3366

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Dieselpoint Search Engine Optimized for OS/400 IBM Rejiggers eServer i5 Pricing

    Leave a Reply Cancel reply

Volume 4, Number 24 -- July 21, 2004
THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
T.L. Ashford
Guild Companies

Table of Contents

  • Encapsulating File Access in a Service Program
  • Adding New Parameters to RPG Programs
  • Admin Alert: Four Cool Things You Can Do with PC5250

Content archive

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

Recent Posts

  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24
  • Big Blue Raises IBM i License Transfer Fees, Other Prices
  • Keep The IBM i Youth Movement Going With More Training, Better Tools
  • Remain Begins Migrating DevOps Tools To VS Code
  • IBM Readies LTO-10 Tape Drives And Libraries
  • IBM i PTF Guide, Volume 27, Number 23

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 © 2025 IT Jungle