• 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
    Maxava

    Migrating to New IBM i Hardware?

    Whether you are moving to POWER9, Power10, or a cloud hosted system MAXAVA HAS YOU COVERED!

    Learn More

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

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

    Leave a Reply Cancel reply

Content archive

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

Recent Posts

  • Unattended IBM i Operations Continue Upward Climb
  • VS Code Is The Full Stack IDE For IBM i
  • Domino Runs on IBM i 7.5, But HCL Still Working on Power10
  • Four Hundred Monitor, March 6
  • IBM i PTF Guide, Volume 25, Number 11
  • You Ought To Be Committed
  • Thoroughly Modern: What You Need to Know About IBM i Security
  • Spring Brings Events To IBM i Community, And More
  • As I See It: AI-AI-O
  • IBM i PTF Guide, Volume 25, Number 10

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