Newsletters   Subscriptions  Forums  Store  Media Kit  About Us  Contact  Search   Home 
fhg
Volume 4, Number 24 -- July 21, 2004

Adding New Parameters to RPG Programs

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

Sponsored By
T.L. ASHFORD

BARCODE400 by T.L. Ashford is the easiest
and fastest way to create and print Compliance
Labels directly from the AS/400 and iSeries.

Ashford's comprehensive library of Compliance formats is available to Barcode400 users. AIAG labels for Ford and Motorcraft, GM, and many more are available. BARCODE400 is backed by the best Technical Support Team in the industry.

FREE Guide to Bar Code Labeling

www.tlashford.com or call 800.541.4893


Editors: Howard Arner, Joe Hertvik, Ted Holt,
Shannon O'Donnell, Kevin Vandever
Managing Editor: Shannon Pastore
Contributing Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.


THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
T.L. Ashford
Guild Companies


BACK ISSUES

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


The Four Hundred
More on the July 13 i5 Announcements

IBM Boosts Earnings As Sales Come In a Bit Shy

Dubious Achievement: iSeries Gets Some Attention From Hackers

Four Hundred Stuff
Tracking SQL: Tango/04 Keeps Watch for Malicious Queries

App Development Gains Speed, Visual Characteristics with WebSphere Tools

IBM Targets Exchange Again with New E-Mail Software

Four Hundred Monitor


Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, 50 Park Terrace East, Suite 8F, New York, NY 10034
Privacy Statement