1 H 2 H* 3 H* READ ADDRESS CARDS AND PRINT ADDRESS LIST 4 H* 5 FINCARDS IPE F 80 80 READ40 6 FOUTLIST O F 132 132 OF LPRINTER 7 LOUTLIST 0010106012 8 IINCARDS AA 01 9 I 1 25 NAME 10 I 26 50 ADDR1 11 I 51 75 ADDR2 12 OOUTLIST H 201 1P 13 O OR OF 14 O PAGE Z 40 15 O 36 'PAGE' 16 O 23 'ADDRESS LIST' 17 O UDATE 8 ' 0/ / ' 18 O D 1 01 19 O NAME 30 20 O D 1 01 21 O ADDR1 30 22 O D 2 01 23 O ADDR2 30 24 O T 3 01 LR 25 O 24 '*** END OF LIST ***'
Statements 2-4 are comments, however the first statement read by the compiler must be a valid Header Specification and not a comment. Therefore the Header Specification must come before the comments describing the program.
Statements 5-6 are the File Description Specifications for the card input (INCARDS) and the printer output (OUTLIST) files.
Statement 7 is a Line Counter Specification defining where the Channel 01 and Channel 12 punch should be simulated for the printer file. Since MVT is spooling the output, no physical printer carriage tape is available to signal where these channel punches exist. Therefore it is necessary to use a Line Counter specification for any files destined for a printer.
Statement 8 defines the input file INCARDS. The alphabetic entry in sequence (column 15-16 = AA) designates that the records occur in the file in no particular grouping - each record is unique. Since no record identification codes were specified (columns 21-41), indicator 01 will be turned on for each record read from the file.
Statements 9-11 define three fields to appear on each input record - NAME, ADDR1, and ADDR2.
Statements 12-13 specify the conditions under which the heading information line will be produced on the output file. The 1P (first page) indicator is turned on at the beginning of program execution and is set off at the end of the first detail cycle. Since I wanted the heading to be produced on the first page and any time the page is filled (page overflow), I used a second output specification in an OR relationship to specify that the line is also to be produced when the OF indicator is on. OF is the overflow indicator associated with the file in the File Description specification for the file (see statement 6, column 33). The spacing for the line is also specified here - the page will be advanced to channel 01 before the fields are printed (column 19 = 01) and one blank line will be printed after the fields (column 18 = 2).
Statements 14-17 specify the fields to print on the heading information line. PAGE is a field that is automatically maintained to count pages. It is initialized at zero and will be incremented by one each time it is printed. The edit code Z (column 38) suppresses leading zeros when the page number is printed. Statement 17 uses the special field UDATE to print the system current date. An edit word is used in column 45 to insert slashes ('/') in between the subfields of the date. The '0' preceding the first slash stops zero suppression at that position. Zero suppression is provided automatically whenever an edit word is applied to a numeric field. If a zero does not appear in the edit word to stop zero suppression, all zeros in the numeric value will be replaced by blanks. It is my personal convention to specify the fields in an output record in order from right to left, so the fields have been specified in the order that they appear on the line from right to left.
Statements 18-23 define the three detail lines which print for each input record read. Each field in the input record will appear on a separate line, one beneath the previous. The printer will advance a single line after printing the first two fields (column 18 = 1 in statements 18 and 20), and it will advance two lines after printing the third field (column 18 = 2 in statement 22).
Statements 24-25 define a message line to print at the end of the input file. The line is produced at total time when the last record (LR) indicator is on. The page will be advanced three lines before printing (column 17 = 3) and the page will be advanced to channel 01 after printing (column 21 = 01).
The compiler listing and program output is available for viewing here: Example 1 SYSOUT.
The jobstream, complete with JCL, RPG source, and input data are available for download here: Example 1 jobstream.
Return to Site Home Page
This page was last updated on January 17, 2015.