enskill.com iSeries Training Onsite classes
DVD training
Books
Online e-Learning
Home
Resources
Contact
(c)2002-2008

This page is powered by Blogger. Isn't yours? Bryan's RPG IV Journal

 

Converting Legacy Code to Named Indicators

Q. While maintaining a large RPG IV program, I added an indicator data structure, using the INDDS keyword for the workstation file. I also added the INDARA keyword to the DDS, as required, and recompiled the file. But now the program doesn't work. What did I do wrong? (The program is over 3,000 lines, and I do not want to change everything to use the new indicator data structure.)

A. When you add the INDDS keyword to a file specification, you "break the connection" between the DDS file's numbered indicators and the RPG program's number indicators. To test or set the indicators in the file, you must use the names of the indicators defined in your indicator data structure. When you test or set the numbered indicators, you're not processing the same ones that the file uses.

Named indicators, indicator data structures, and built-in functions largely eliminate the need to use the familiar 99 numbered indicators in a new RPG IV program. But you may find it impractical and error-prone to upgrade legacy RPG code to replace numbered indicators with newer constructs. Fortunately, it's not an either/or issue; you can assign both numbered and named indicators for the same condition, allowing the program to use either a numbered indicator or its corresponding named indicator interchangeably. All it takes is a data structure and a pointer:
D PtrIndicators   S               *   Inz(%Addr(*In))
D Indicators DS Based(PtrIndicators)
D Exit 3 3N
D Cancel 12 12N
D Overflow 90 90N
D Sfldspctl 91 91N
D Sfldsp 92 92N
D Sflend 93 93N
D Sflclr 94 94N
Because the Indicators data structure points to the same address as the internal array *In, it shares the same memory as the numbered indicators. In this example, the program can refer to indicator 03 either by its number or by its name: Exit (in byte 3 of the Indicators data structure). The same is true of the other indicators in the data structure.


It is your responsibility to ensure procedures, techniques, and code used from this website are accurate and appropriate for your installation. No warranty or support is implied or expressed.
E-mail to Bryan Meyers
Privacy and Email Policy
 
AS/400®, eServer, i5/OS, IBM i, Integrated Language Environment®, iSeries, OS/400®, RPG/400®, System i5, VisualAge®, and WebSphere® are trademarks of IBM Corporation. Note: IBM® i is the operating system used by IBM's Power Systems and iSeries servers. This site might refer to these servers as System i, iSeries, or AS/400.
 

If you are having trouble navigating the menu at the top of this page, you may use the following scrollable site map instead:
 

Self-paced DVD Training
DVD: RPG IV for RPG Programmers
DVD: RPG IV Modules, Procedures, and Service Programs
 
In association with Amazon.com
Programming in RPG IV
Control Language Programming for IBM i
RPG IV Jump Start
Power Tips for RPG IV
VisualAge for RPG by Example
 
International visitors: click hereInternational visitors:
Click here!