A few years ago, while employed by a furniture manufacturer, I was asked to develop a report program to print a detailed list of inventory transactions. Contrary to most inventory transaction reports, this one would be costed, breaking down each transaction into its material, labor and overhead costs for each work center--and sometimes there were eight work centers. This report never ran for less than 1,500 pages, and was usually much longer.
This company was relatively small. It occurred to me that, in a much larger organization (with a correspondingly larger volume of transactions), the report might exceed 9,999 pages. I wondered what would happen--after all, the PAGE field in RPG is implicitly defined as holding a maximum of four digits. So I wrote the program shown in 9 (page 104) and ran it as follows:
This company was relatively small. It occurred to me that, in a much larger organization (with a correspondingly larger volume of transactions), the report might exceed 9,999 pages. I wondered what would happen--after all, the PAGE field in RPG is implicitly defined as holding a maximum of four digits. So I wrote the program shown in Figure 9 (page 104) and ran it as follows:
SBMJOB CMD(CALL XEM004RG) + JOB(TEST-PAGE) + PRTTXT(*BLANK) + OUTQ(QPRINT)
It quickly produced 10,009 pages in QPRINT. I selected the QPRINT output queue because it wasn't attached to any printers, so this huge report wouldn't kill any trees. Using option 5 of the Work with Spool Files (WRKSPLF) command, I displayed the report and went to the bottom (using "B" in the control field). Not good! The page number was reset to 0 after reaching 9999, and kept increasing as 1, 2, and so on.
The trick here is that RPG allows you to define the PAGE field (including PAGE1 to PAGE7) with the width you want. In the *INZSR, simply Z-ADD *ZERO to PAGE, specifying the number of digits you want in columns 49-51, making sure the number of decimal places is zero (0 in column 52). 10 shows a similar program using this technique. I ran this program with the following command:
The trick here is that RPG allows you to define the PAGE field (including PAGE1 to PAGE7) with the width you want. In the *INZSR, simply Z-ADD *ZERO to PAGE, specifying the number of digits you want in columns 49-51, making sure the number of decimal places is zero (0 in column 52). Figure 10 shows a similar program using this technique. I ran this program with the following command:
SBMJOB CMD(CALL XEM005RG) + JOB(PAGE-OK) + PRTTXT(*BLANK) + OUTQ(QPRINT)
This produced the result that I wanted: I got page number 10,000 and higher. This technique can be used on a S/36, too. Now, if I could only find a way to redefine the PAGNBR DDS keyword....
TechTalk: Don't Recycle Page Numbers!
Figure 9 RPG Program XEM004RG
FQSYSPRT O F 132 OA PRINTER * C COUNT DOUEQ10010 C EXCPTHEADER C ADD 1 COUNT C ENDDO C MOVE *ON *INLR * C *INZSR BEGSR C Z-ADD1 COUNT 50 C ENDSR * OQSYSPRT E 306 HEADER O 4 'PAGE' O PAGE 1 + 1
TechTalk: Don't Recycle Page Numbers!
Figure 10 RPG Program XEM005RG
FQSYSPRT O F 132 OA PRINTER * C COUNT DOUEQ10010 C EXCPTHEADER C ADD 1 COUNT C ENDDO C MOVE *ON *INLR * C *INZSR BEGSR C Z-ADD1 COUNT 50 C ENDSR * OQSYSPRT E 306 HEADER O 4 'PAGE' O PAGE 1 + 1
LATEST COMMENTS
MC Press Online