Newsletters   Subscriptions  Forums  Store  Media Kit  About Us  Contact  Search   Home 
fhg
Volume 4, Number 25 -- July 28, 2004

Control Break Programs, Version 2

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



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
E-mail: software@worksright.com
Web site: www.worksright.com


Editors: Howard Arner, Joe Hertvik, Ted Holt,
Shannon O'Donnell, Kevin Vandever
Managing Editor: Shannon Pastore
Contributing Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.


THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
WorksRight Software
Guild Companies


BACK ISSUES

TABLE OF
CONTENTS
Backup and Recovery Just Got Easier with BRMS V5R3

Control Break Programs, Version 2

Auditing Users with All-Object Authority


The Four Hundred
IBM Rejiggers eServer i5 Pricing

IBM Keeps the Wheels Turning on Express

CIOs Sure About Cost Cutting, Unsure of Future

Four Hundred Stuff
DB2/400: The Heart of a Supercomputer Cluster?

Support for SIP Expands Messaging Options for Stalker

Affirmative Launches Ethernet-Based Twinax Controllers

Four Hundred Monitor


Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, 50 Park Terrace East, Suite 8F, New York, NY 10034
Privacy Statement