• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Control Break Programs, Version 2

    July 28, 2004 Hey, Ted

    Ken Orr taught me this one. Assuming an input file called SALES that contains the daily sales of all stores sorted by store number, department number, and, finally, sales person number. The file also contains item number and sales amounts.

    This example shows where to print headers and footers of a report (excluding page headers and page footers), where to accumulate totals, and where to reset totals. The basic structure is a set of nested loops.

    EVAL        CompanyTotal = 0
    EXCPT       REPORTHEADER
    
    READ        SALES
    
    DOW         not %eof(SALES)
    
    EXCEPT      STOREHDR
    EVAL        StoreTotal = 0
    EVAL        oldStoreNum = StoreNum
    
    DOW         not %eof(SALES) and 
                oldStoreNum = StoreNum
    
    EXCEPT      DEPTHDR
    EVAL        DepartmentTotal = 0
    EVAL        oldDepartmentNum = DepartmentNum
    
    DOW         not %eof(SALES) and 
                oldStoreNum = StoreNum and
                oldDepartmentNum = DepartmentNum
    
    EXCEPT      SPHDR
    EVAL        SalesPersonTotal = 0
    EVAL        oldSalesPersonNum = SalesPersomNum
    
    DOW         not %eof(SALES) and 
                oldStoreNum = StoreNum and
                oldDepartmentNum = DepartmentNum and
                oldSalesPersonNum = SalesPersomNum
    
    EXCEPT      DETAIL
    EVAL        SalesPersonTotal = SalesPersonTotal + SaleAmount
    READ        SALES
    
    ENDDO
    
    EXCEPT      SPFOOTER
    EVAL        DepartmentTotal = DepartmentTotal + SalesPersonTotal
    
    ENDDO
    
    EXCEPT      DEPTFOOTER
    EVAL        StoreTotal = StoreTotal + DepartmentTotal
    
    ENDDO
    
    EXCEPT      STOREFOOTER
    EVAL        CompanyTotal = CompanyTotal + StoreTotal
    
    ENDDO
    
    EXCEPT      REPORTFOOTER
    

    –Mike

    The method you present is similar in philosophy to the one I presented, Mike, but it has been implemented with less code. I notice that control totals are reset before each group, as I like to do. The redundant tests on the do-while loops ensure that major breaks force minor breaks. I notice that your code doesn’t account for null values, but those tests could easily be added.

    Thanks for sharing this example with other readers of Four Hundred Guru, Mike.

    –Ted



    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

    Mrc Christens New Java Development Tool: M-Power There’s a New iSeries General Manager in Town

    Leave a Reply Cancel reply

Volume 4, Number 25 -- July 28, 2004
THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
WorksRight Software
Guild Companies

Table of Contents

  • Backup and Recovery Just Got Easier with BRMS V5R3
  • Control Break Programs, Version 2
  • Auditing Users with All-Object Authority

Content archive

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

Recent Posts

  • Unattended IBM i Operations Continue Upward Climb
  • VS Code Is The Full Stack IDE For IBM i
  • Domino Runs on IBM i 7.5, But HCL Still Working on Power10
  • Four Hundred Monitor, March 6
  • IBM i PTF Guide, Volume 25, Number 11
  • You Ought To Be Committed
  • Thoroughly Modern: What You Need to Know About IBM i Security
  • Spring Brings Events To IBM i Community, And More
  • As I See It: AI-AI-O
  • IBM i PTF Guide, Volume 25, Number 10

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 © 2023 IT Jungle