|
|
![]() |
|
|
Easy Display File Printing by Shannon O'Donnell [The code for this article is available for download.]
Here's a nifty technique for printing the contents of a display file every time a user does anything on the screen. There are hundreds of business uses for such a technique. How about using it to keep a printed, running total of a user's data entry? Or for printing the "tape" of a series of calculations in a calculator-like application? Whatever you use it for, you'll find that printing the contents of a display file is really quite simple! The Sample Application This is one of those concepts that is difficult to understand or appreciate until you see it actually working. With that in mind, download the source code and compile it on your AS/400. In the sample program, the user is prompted to enter an item number on a 5250 display screen. As each item is entered and the Enter key is pressed, the contents of the item number field are added to the printed report. In this case, the printed report is an external printer file defined using Report Layout Utility (RLU). However, you could just as easily use an internally defined output file. The Source Code The source code for our sample application is really pretty simple. The display file consists of a single data entry field and an indicator to allow the program to be cancelled. Notice in the external printer file that the field name on the DTL record format is the same as the field name in the DDS display. By keeping the fields you want to print the same as the display file, you can avoid having to handle all of the individual moves in the RPG program. And this helps to keep the printing in RPG simple. In the RPG program, a simple loop is set up to keep showing the display file until the user presses the F3 function key, which terminates the program. Every time the user enters something into the ITEM field on the display file, the program checks to see if Indicator *IN05 is on. If it is, the printer file is advanced to the next page; otherwise, the contents of the ITEM field are printed on the report. Keeping It Simple There are thousands of complex applications out there that you can study on (or "cipher on," as Jethro Bodine would say) and use to challenge your mind. The sample application shown here isn't one of them, but the technique can be quite useful! Use the sample code any time you need a way to quickly capture activity on a display file.
|
Editors
Contact the Editors |
|
Last Updated: 10/24/02 Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |