TechTalk: Don't Recycle Page Numbers!

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: