Did you ever have the need for more than eight printer files in an RPG program? If so, you probably learned that you are limited to a maximum of eight. So, what to do?
Here is a solution. Create a disk file of a length equal to the maximum required printer output line length, plus six (e.g., a 132-column printer file will have a disk file length of 138 bytes).
Code your program to output your formatted print data to this disk file instead of a printer file. For each line, place the printer control values for space before, space after, skip before and skip after in the extra six bytes of this disk file. Simply code these as literals in the output specs.
For example, if your printer file statements are as shown in 6a, on page 66, then your disk file statements will be as shown in 6b, on page 70.
For example, if your printer file statements are as shown in Figure 6a, on page 66, then your disk file statements will be as shown in Figure 6b, on page 70.
If the printer file in this example had a skip after value, then that value would have replaced the two blank bytes in positions 137-138 in the disk file.
Your next step is to write a short RPG program like the one below to read this disk file and print each line. But how can you control the line spacing? Easily. Just use the PRTCTL option by specifying it as a continuation line on the printer file F-spec and include the LINE data structure as shown in 7, on page 70.
Your next step is to write a short RPG program like the one below to read this disk file and print each line. But how can you control the line spacing? Easily. Just use the PRTCTL option by specifying it as a continuation line on the printer file F-spec and include the LINE data structure as shown in Figure 7, on page 70.
Each time you read a record of your disk file, move the spacing and skipping control values from the last six bytes of the record into the data structure fields. Use one output line with no spacing or skipping control values, since the PRTCTL option will take care of this for you.
There you have it. Your printed output should look exactly as it would have printed in the original program.
Editor's Note: When you write any numeric variables to DISKFILE, be sure not to pack them (leave column 44 blank). You should act as though you're writing directly to the PRINTER file. This means that you should also use edit codes or edit words if appropriate.
TechTalk: More Than Eight PRINTER Files in RPG!
Figure 6A Printer file statement
Figure 6a: Printer File Statement OQSYSPRT E 1201 PRINT O FIELD1 12 O FIELD2 37 O FIELD3 59 O 110 'Literal 1'
TechTalk: More Than Eight PRINTER Files in RPG!
Figure 6B Disk file statement
Figure 6b: Disk File Statement ODISKFILEE PRINT O FIELD1 12 O FIELD2 37 O FIELD3 59 O 110 'Literal 1' O 138 '1201'
TechTalk: More Than Eight PRINTER Files in RPG!
Figure 7 RPG program using PRTCTL
Figure 7: RPG Program Using PRTCTL FDISKFILEIF F 138 DISK FQSYSPRT O F 132 PRINTER KPRTCTLLINE * IDISKFILENS I 1 132 DATA I 133 133 SBF I 134 134 SAF I 135 136 SKBF I 137 138 SKAF * ILINE DS I 1 1 SPBEFR I 2 2 SPAFTR I 3 4 SKBEFR I 5 6 SKAFTR I 7 90CURLIN * C *INLR DOUEQ '1' C READ DISKFILE LR C *INLR IFEQ '0' C MOVE SBF SPBEFR C MOVE SAF SPAFTR C MOVE SKBF SKBEFR C MOVE SKAF SKAFTR C EXCPTPRINT C END C END * OQSYSPRT E PRINT O DATA 132
LATEST COMMENTS
MC Press Online