This was rather disappointing as RPGLE is over 21 years old , free format calculations 14 years old, even free format definitions RPG is in its third year. All of the examples I found looked overly complicated for a beginner, so I decided to create this post showing a simple subfile program written in modern RPG. The examples in this post are the way I would write a simple subfile program using totally free RPG. I am sure that my examples are not the way all other IBM i developers would write theirs. There are probably as many ways to write a subfile program as there are programmers who write them, each with his or her own coding peccadillos.
|Country:||Turks & Caicos Islands|
|Published (Last):||23 April 2017|
|PDF File Size:||7.55 Mb|
|ePub File Size:||13.33 Mb|
|Price:||Free* [*Free Regsitration Required]|
Wednesday, January 10, Displaying more than one subfile at a time I decided to write the post after being asked if I had an example of having two subfiles on the same screen. I did a quick search using Google and was unable to find what I considered a good example I felt comfortable sharing. In this example I am going to show two subfiles horizontally i. I could have shown them vertically next to one another , or even had more than two. The principals I show here can easily be adapted to fit either of those other scenarios.
The most important thing to remember is that each set of subfile and subfile control record format cannot overlap another. To reduce the size of the display file source code, shown here, I have removed all unnecessary color and display attributes codes that I use in the screens I build. I am going to show my display source in multiple parts to make it easier to understand what each record format is for.
Let me start with the file level keywords. The display file controls it without any extra programming. Line 4: By using the indicator area I can give the display file indicators meaningful names in my RPG program rather than use the number. The examples I did find for more than one subfile on a screen, put the page headings in a separate record format. Rest assured it is not, most of the code is for the screen headings.
Lines 13 — I am using indicators 30 and 31 to condition the display of SFL Lines 17 — The rest of the this record format is for the screen headings. The second subfile is just about the same as the first. Lines 37 — I could have used the same indication to display the subfile control as I did for SFL01, but I decided that this subfile deserves its own indicators.
The last record format of the display file is the footer section, which I use to display the available function keys. I have mine externally defined to make it easier to include into many different programs. Lines 5 and 6: This is the definition of my display file. Line 6 contains the definitions for the subfiles.
Lines 7 — Having just mentioned the indicator data structure here it is. Here I define variable names that I will be using instead of the indicator numbers. Line I am making the screen name from the program name retrieved from the program data structure.
Line In this procedure the subfiles are loaded. I will show its content below. Lines 16 — Within this Do loop the screen is displayed.
Lines 17 — These are the record formats being written to the screen. The footer record needs to be first. The procedure to load the subfiles is a breeze. Lines 27 — Initializing the subfile SFL01 and setting on the indicators to display it. I am just writing a string to each subfile record until the maximum is reached. I like the More The changes to the display would be. This article was written for IBM i 7. Written by.
Interview Question and Answer – AS400 Subfiles
Using Subfiles Subfiles can be specified in the DDS for a display-device file to allow you to handle multiple records of the same type on the display. See Figure 1. A subfile is a group of records that is read from or written to a display-device file. For example, a program reads records from a database file and creates a subfile of output records. When the entire subfile has been written, the program sends the entire subfile to the display device in one write operation.
Problem solve Get help with specific problems with your technologies, process and projects. I have purchased several books on the subject, but none seem to help me learn the basics of subfiles. Do you have any recommendations? A subfile usually consists of three parts record formats in your DDS but it really only has to have two. Typically they flow this way. The top of the screen contains the subfile control record -- this controls the subfile display subfile, clear subfile, etc.
Single Page Subfiles
Wednesday, January 10, Displaying more than one subfile at a time I decided to write the post after being asked if I had an example of having two subfiles on the same screen. I did a quick search using Google and was unable to find what I considered a good example I felt comfortable sharing. In this example I am going to show two subfiles horizontally i. I could have shown them vertically next to one another , or even had more than two. The principals I show here can easily be adapted to fit either of those other scenarios. The most important thing to remember is that each set of subfile and subfile control record format cannot overlap another.
PROGRAMMING IN COBOL/400: 2nd Edition by James Cooper, Nancy Stern, Robert A. Stern