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.
Option 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.)
Option 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
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).
Option 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.