Q: I have a display screen which consists of input/output fields for 18 part numbers and quantities, a single field for a warehouse number, and a function key. I defined a portion of the screen input/output buffer as an array of quantities in the RPG program that controls the display file. The code I'm using looks similar to the code in 1.
Q: I have a display screen which consists of input/output fields for 18 part numbers and quantities, a single field for a warehouse number, and a function key. I defined a portion of the screen input/output buffer as an array of quantities in the RPG program that controls the display file. The code I'm using looks similar to the code in Figure 1.
When I compile the RPG program, I get a compile-time error that says the field *IN03 is not valid for a data structure because the compiler repeats the "fields" from the file the data structure is referring to. For screens, the indicators are part of the I/O buffer and are therefore being included. I'd like to be able to manipulate my screen input to the program using array logic, if there is a means of doing so. Is there a way I can accomplish this?
A: There is a way to do what you want, but you can't use an external data structure. You have to rename the fields from the display file to array elements. For example, look at the RPG code in 2. In this example the quantity fields in the display file are named QTY01, QTY02, QTY03, and so on. The RPG program first defines an array called QTY. It then renames each of the quantity fields in the display file to a corresponding element of the QTY array. From that point on, the program can perform calculations or output by specifying the QTY array instead of the individual screen field names.
A: There is a way to do what you want, but you can't use an external data structure. You have to rename the fields from the display file to array elements. For example, look at the RPG code in Figure 2. In this example the quantity fields in the display file are named QTY01, QTY02, QTY03, and so on. The RPG program first defines an array called QTY. It then renames each of the quantity fields in the display file to a corresponding element of the QTY array. From that point on, the program can perform calculations or output by specifying the QTY array instead of the individual screen field names.
Array Screen Fields
Figure 1 Defining the I/O Buffer as an Array
*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 FSFC351DFCF E WORKSTN E QTY 18 3 0 IEXTDS1 E DSSFC351DF I 2 55 QTY
Array Screen Fields
Figure 2 Renaming Screen Fields to Array Elements
*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 FSFC351DFCF E WORKSTN E QTY 18 3 0 ISFC351FM I QTY01 QTY,01 I QTY02 QTY,02 I QTY03 QTY,03 . . . I QTY16 QTY,16 I QTY17 QTY,17 I QTY18 QTY,18
LATEST COMMENTS
MC Press Online