• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Don’t Clone That Printer File!

    February 6, 2013 Hey, Ted

    I have a program that uses an externally described printer file to create a report. I need to change the program so that it writes some information to one spooled file and the remaining information to a separate spooled file. I could clone the printer file, but that would mean I’d have to change two files instead of one when I modify the report file in the future. Do I have to clone the printer file?

    –Mark

    No, Mark, you can build two or more reports from one printer file definition. Here’s how it’s done.

    Let’s start with a printer file, QAD001P.

    A                                      REF(QCUSTCDT)
    A          R HEADER                    SKIPB(1) SPACEA(1)
    A            TITLE         40         1
    A          R DETAIL                    SPACEB(1)
    A            CUSNUM    R              1
    A            LSTNAM    R            + 1
    A            INIT      R            + 1
    A            CITY      R            + 1
    A            STATE     R            + 1
    A          R FOOTER                    SPACEB(2)
    A                                     1'** End of report **'
    

    Here’s program QAD001R, which uses the printer file to build a report.

    Fqcustcdt  if   e           k disk
    Fqad001p   o    e             printer
    
     /free
         *inlr = *on;
         title = 'Customers';
         write header;
         dow '1';
            read cusrec;
            if %eof();
               leave;
            endif;
            write detail;
         enddo;
         write footer;
         return;
    

    Let’s modify the program to put Texas customers on one report and everybody else on another one. Here’s what we do:

    1. Define the report twice in the program. You can use any name that suits you. I’ve used the clever names REPORT1 and REPORT2.

    2. Since two files cannot have a record format of the same name, rename the report formats for all but one of the files. In this example, I chose to rename the formats in both printer files, even though renaming the formats of one file would have sufficed.

    3. Change the program to reference the new record formats as required.

    Here’s the modified program.

    Fqcustcdt  if   e           k disk
    Freport1   o    e             printer
    F                                     rename(header: header1)
    F                                     rename(detail: detail1)
    F                                     rename(footer: footer1)
    Freport2   o    e             printer
    F                                     rename(header: header2)
    F                                     rename(detail: detail2)
    F                                     rename(footer: footer2)
     /free
         *inlr = *on;
         title = 'Texas only';
         write header1;
         title = 'All but Texas';
         write header2;
         dow '1';
            read cusrec;
            if %eof();
               leave;
            endif;
            if state = 'TX';
               write detail1;
            else;
               write detail2;
            endif;
         enddo;
         write footer1;
         write footer2;
         return;
    

    To compile the program, override both printer files to the original printer file.

    ovrprtf report1 tofile(qad001p)
    ovrprtf report2 tofile(qad001p)
    crtbndrpg pgm(qad001r) srcfile(mylib/qrpglesrc)
    

    You must also override the files at run time. Use the Spool File Name (SPLFNAME) parameter to distinguish the two reports.

    pgm
       ovrprtf report1 tofile(qad001p) splfname(Texas)
       ovrprtf report2 tofile(qad001p) splfname(NoTexas)
       call qad001r
    endpgm
    

    RELATED STORY

    Dynamic Spool File Names



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    BCD:  IBM i Webinar - Feb 14th. Web GUI for Green Screens: Modernize Faster with New Presto 4.5
    New Generation Software:  Get the Recipe for easy IBM i Query/Reporting/Analytics - NGS-IQ
    COMMON:  Join us at the 2013 Conference & Expo, April 7 -10 in Austin, TX

    More IT Jungle Resources:

    System i PTF Guide: Weekly PTF Updates
    IBM i Events Calendar: National Conferences, Local Events, and Webinars
    Breaking News: News Hot Off The Press
    TPM @ The Reg: More News From ITJ EIC Timothy Prickett Morgan

    Quantum Launches ‘Pay As You Grow’ Dedupe Boxes Invader II: New Power7+ Machines Take On Entry X86 Iron

    Leave a Reply Cancel reply

Volume 13, Number 3 -- February 6, 2013
THIS ISSUE SPONSORED BY:

ProData Computer Services
Bug Busters Software Engineering
WorksRight Software

Table of Contents

  • What’s That Name, Again?
  • Don’t Clone That Printer File!
  • Admin Alert: When Was The Last Time That Library Got Backed Up And More

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24
  • Big Blue Raises IBM i License Transfer Fees, Other Prices
  • Keep The IBM i Youth Movement Going With More Training, Better Tools
  • Remain Begins Migrating DevOps Tools To VS Code
  • IBM Readies LTO-10 Tape Drives And Libraries
  • IBM i PTF Guide, Volume 27, Number 23

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle