Array Screen Fields

RPG
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: