• 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
    ARCAD Software

    [Webinar] Synchronous IBM i and non-IBM i Deployments
    April 13 at 12 p.m. ET

    Do you need to automate and synchronize deployments across ALL your environments and applications?

    Many backend IBM i applications have off-platform components, such as an API layer, or Web front-end. To ensure your application stays reliable, artifacts must be deployed securely and in-sync.

    In our Webinar, learn how to orchestrate all your deployments, multi-platform and multi-cloud, using DROPS by ARCAD Software:

    – One single console to deploy across multiple endpoints – IBM i, Windows, Linux, IBM z, on prem or cloud

    – Real-time visibility of application status, from anywhere

    – Deployment plans and one-click-deploy

    – Rollback on error

    Simplify and secure your application delivery.

    Register Now

    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

Content archive

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

Recent Posts

  • LANSA Developing Business Intelligence Tool
  • Blazing The Trail For VTL In The Cloud
  • Data De-Dupe Gives VTL Customers More Options
  • Four Hundred Monitor, March 29
  • The Big Spending On IT Security Is Only Going To Get Bigger
  • IBM Tweaks Some Power Systems Prices Down, Others Up
  • Disaster Recovery: From OS/400 V5R3 To IBM i 7.4 In 36 Hours
  • The Disconnect In Modernization Planning And Execution
  • Superior Support: One Of The Reasons You Pay The Power Systems Premium
  • IBM i PTF Guide, Volume 25, Number 13

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