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


Multiple INDDS data structures


Q. I am converting an existing application to use the INDDS data structure function. If I have multiple screens defined in a single DDS workstation file, the indicators on different screens might mean different things. Could be command keys or maybe different fields, subfiles... Can I have the data structure remapped for every screen or some way to remap over the indicator in indicator data structure?

A. There are several ways to accomplish this. Please note that I am not representing any of these methods as "best practices." In a perfect world each indicator would have only one meaning in the program.

1. Of course, if the screens are in different DDS files, you can specify a different data structure in the F-spec INDDS keyword for each file. (But your question specifically asked about multiple formats in the same file.)

2. You can have different subfields in the indicator data structure share the same space:
D
Indicators      DS              
D Exit 03 03N
D Sfldsp 03 03N
or:
D Indicators      DS                               
D Exit 03 03N
D Sfldsp N Overlay(Exit)
With this method, both Exit and Sfldsp would share indicator 03 from the display file. If you change one, you change the other, since they're both in the same memory space. You'd have to be careful about inadvertently changing indicator 03 for the wrong purpose (just like you have to be careful when you're using numbered indicators).

3. If the indicators cannot share the same space in the RPG program, you can declare a separate screen-specific data structure for each format. Then, use a pointer to point the Indicators data structure to the appropriate screen-specific data structure before you process that format:
FTestdspf  CF   E             Workstn Indds(Indicators)

D Indicators DS 99 Based(Ptr)

D Fmt01Indic DS 99
D Exit 03 03N

D Fmt02Indic DS 99
D Sfldsp 03 03N

D Ptr S * Inz(%Addr(Fmt01Indic))

/Free
// Currently using Fmt01Indic as INDDS (Ptr points to Fmt01Indic)
Exfmt Fmt01;
Ptr = %Addr(Fmt02Indic); // Point Indicators to Fmt02Indic
Exfmt Fmt02;
// Sfldsp now represents indicator 03 from display file
/End-free
In this example, when Ptr is pointing Indicators to Fmt01Indic, indicator 03 is mapped to Exit; when Ptr is pointing Indicators to Fmt02Indic, indicator 03 is mapped to Sfldsp.

When you use this method, the compiler will generate an RNF3530 warning ("Data structure has no valid subfields.") for the Indicators declaration, but the program will still work.


Log of Journal Entries

Use this scrollable blog map to view other journal entries:
Journal Home
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® System i is the latest member of the family of eServer iSeries. This site might refer to System i as System i5, 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
RPG IV Jump Start
Power Tips for RPG IV
Control Language Programming for the AS/400
VisualAge for RPG by Example
 
International visitors: click hereInternational visitors:
Click here!