RPG Tutorial: Advanced statement types (Extension/Line Counter)

The Extension and Line Counter specifications are both used to supply additional information about specific types of files to be processed by the RPG program.  

It is rare to have a printer file that will not require a Line Counter specification, but the specification is uncomplicated and will, for the most part, be the same for all programs.

The Extension specification is used for defining tables and establishing relationships to indexed-sequential files that are to be read "automatically" using chaining fields or Record Address Files.  Therefore, the need to code Extension specifications will occur less frequently.

If used, Extension and Line Counter specifications follow the File Description specifications in the source program.

  1. Line Counter
  2. Extension

Line Counter specification

When writing an output file to a physical printer, the printer relies upon carriage control tape punches (or the equivalent carriage control buffer) to control skipping and page overflow operations.  When such a file is first written to an intermediary storage device, such as happens under MVT spooling, the RPG program must count the number of output lines written and simulate the presence of a carriage control tape/buffer.

This functionality is provided with the Line Counter specification.  In a physical carriage control tape, a channel 12 punch is used to signal that the end of the physical page has been reached.  A channel 01 punch is used to advance the carriage to the top of the next physical page.  Punches in other channels are optionally used to specify stopping at intermediate points on the physical page.  Entries on the Line Counter specifications are used to provide the functional equivalent of the carriage control tape punches (or forms control buffer).

Column(s) Field Name Use
7 - 14 File Name name of the output file to which this line counter specification applies
15 - 17
20 - 22
25 - 27
30 - 32
35 - 37
40 - 42
45 - 47
50 - 52
55 - 57
60 - 62
65 - 67
70 - 72
Line Number the number of the line at which channel punches are to be simulated - as a minimum, the lines at which channel 01 and channel 12 punches occur must be defined to specify the top and bottom limits of the page
18 - 19
23 - 24
28 - 29
33 - 34
38 - 39
43 - 44
48 - 49
53 - 54
58 - 59
63 - 64
68 - 69
73 - 74
Channel Number the channel punch to simulate for the corresponding line number

File Extension specification

RPG programs which utilize Record Address Files, chained indexed-sequential files, and table files require that information specific to these files be specified in addition to the standard information contained on the File Description specification.  The File Extension specification is used to provide that information.  Because this specification is used to specify such a variety of dissimilar information, it can be confusing.  I have divided the information into three groups - the first for chained files, the second for record address files, and the third for tables.

Entries for chained files

 Column(s) Field Name Use
7 - 8 Record Sequence of chaining file enter the sequence entry (from column 15-16 of the input specification) for the input file which is the 'chained from' file
9 - 10 Number of the chaining field enter the number (C1 - C9) identifying the field used to link the chaining record with the chained record (from column 61-62 of the input specification)
11 - 18 From Filename enter the name of the chaining file 
19 - 26 To Filename enter the name of the chained file

Entries for Record Address Files

 Column(s) Field Name Use
11 - 18 From Filename enter the name of the record address file 
19 - 26 To Filename enter the name of the Indexed-Sequential file that contains the data records to be processed

Entries for tables

 Column(s) Field Name Use
11 - 18 From Filename enter the name of the file from which the table entries will be read
19 - 26 To Filename enter the name of the file to which the updated table will be written
27 - 32 Table Name enter the name of the table (the first three positions must be "TAB")
33 - 35 Entries per Record enter the number of table elements read from/written to each physical record (used only when table is read from or written to a file)
36 - 39 Entries per Table enter the number of elements to be contained in the table
40 - 42 Length of Entry enter the length of each element in the table
43 Packed enter "P" if the data in the table elements is in packed decimal format
44 Decimal Positions enter the number of decimal positions (0 - 9) if the data in the table elements are numeric - leave blank for alphanumeric data
45 Sequence enter "A" if the table elements are in ascending sequence; enter "D" if in descending sequence; leave blank if unsequenced - in tables consisting of alternating arguments and functions, the sequence refers to the order in which the arguments appear in the table
46 - 51 Table Name enter the name of the table to contain the function elements related to the argument table specified in columns 27-32 (the first three positions must be "TAB")
52 - 54 Length of Entry enter the length of each element in the function table
55 Packed enter "P" if the data in the table elements is in packed decimal format
56 Decimal Positions enter the number of decimal positions (0 - 9) if the data in the table element are numeric - leave blank for alphanumeric data
57 Sequence enter "A" if the table elements are in ascending sequence; enter "D" if in descending sequence; leave blank if unsequenced - in tables consisting of alternating arguments and functions, the sequence refers to the order in which the arguments appear in the table

   


Return to Site Home Page 


This page was last updated on January 17, 2015