I?d like to update my RPG LE skills as far as subfiles are concerned. I have purchased several books on the subject, but none seem to help me learn the basics of subfiles. Do you have any recommendations?
I don't have any recommendations on books, but I can give you a high-level overview. 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. and these are controlled by indicators) and generally displays some sort of information about the subfile (screen headings, field headings, descriptive data, descriptions of options, position to's, etc.)
The middle of the screen is generally the subfile itself. This is the data that is in the list and will also contain an input field if you allow users to select options (drill down etc.) on the individual subfile records.
The bottom part of the screen contains command key text and error message line.
There are three primary techniques to build subfiles. I'll briefly list them with the pros and cons of each method.
1. Build the entire subfile and let OS/400 handle roll forward and roll back.
Advantage - Simplest technique to code.
Disadvantages - Least flexible, data can become stale since it is only current when the subfile was loaded, Position to's aren't easily done. This can be a huge performance hit if there are a lot of records in the file.
2. Build the first page of the subfile only. Add to the subfile when paging down but let OS/400 handle rolling back.
Advantage -- You eliminate the performance hit that you would have in technique number 1.
Disadvantages -- somewhat flexible, data can become stale since it is only current when the subfile records were written, Position to's aren't easily done.
3. Build the subfile one page at a time. This means that you load only one page of data into your subfile and you control roll up and roll back.
Advantage: Data is always real time, most user friendly, consistent performance whether the file has 100 or 100 million records, this is the most flexible from a user and programming point of view.
Disadvantages: By far, the most difficult technique of the three to learn to code. Programmer has to control roll forward and roll back as well as a saving the screen options from screen to screen and executing them at the appropriate time, not the most efficient choice for summary type data that is not changing.
If you're just starting out with subfiles, I would recommend doing a small program with option #1. Once you understand that, it's not a huge jump to go to option #2. Option #3, is my preference for subfiles 99% of the time, but it's also the hardest to code. Option #2 is probably the most common subfile technique used in iSeries shops.
MORE INFORMATION ON THIS TOPIC
The Best Web Links: tips, tutorials and more.
Ask your programming questions--or help out your peers by answering them--in our live discussion forums.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.