Newsletters   Subscriptions  Forums  Store  Media Kit  About Us  Contact  Search   Home 
fhg
Volume 4, Number 27 -- August 11, 2004

Control Break Programs, Version 3

Dear Readers:


Faithful reader Doug Eckersley sent me an example of how he would write a control break program like the one I presented in the May 12 issue. Doug mentions two things he likes about his method. First, it uses subroutines, which makes the program modular, and, second, he uses no hold fields. Here's his code.

D K1              C                   1
D K2              C                   2
D K3              C                   3
D Key           E DS                  extname(SALES:*key)

     Begsr $Main;

       NewPage = *on;
       CompanyTotal = 0;
       Except REPORTHEADER;
       Setll *start SALES;
       Read SALES;  
                 
       Dow not %eof(SALES);    
          Exsr $Level1;    
          Read SALES;
       Enddo;
       
       Except REPORTFOOTER;

     Endsr;
     
     Begsr $Level1;

       // Store
       StoreTotal = 0;  
       Except STOREHDR;   
       
       Dow not %eof(SALES);
          Exsr $Level2;
          Reade %kds(Key:K1) SALES;
       Enddo; 
       
       Except STOREFOOTER;
       CompanyTotal += StoreTotal;
       Setgt %kds(Key:K1) SALES;

     Endsr;
     
     Begsr $Level2

        // Department  
        DepartmentTotal = 0;  
        Except DEPTHDR;
     
        Dow not %eof(SALES);
           Exsr $Level3;
           Reade %kds(Key:K2) SALES;
        Enddo; 
     
        Except DEPTFOOTER;
        StoreTotal += DepartmentTotal;
        Setgt %kds(Key:K2) SALES;

     Endsr; 
     
     Begsr $Level3;

        // SalesPerson  
        SalesPersonTotal = 0;
        Except SPHDR;
     
        Dow not %eof(SALES);
          Exsr $Detail;
          Reade %kds(Key:K3) SALES;
        Enddo;
     
        Except SPFOOTER;
        DepartmentTotal += SalesPersonTotal;
        Setgt %kds(Key:K3) SALES;

     Endsr;
     
     Begsr $Detail;

        Exsr $NewPage
        Except DETAIL;
        SalesPersonTotal += SaleAmount;

     Endsr;
     

I'd like to add an observation or three. It's true that Doug's method doesn't require hold fields, but it does require random I/O (that is, SETGT), which may hamper performance. The fact that Doug uses a keyed file means that he has to have an access path over the data, at least at compile time. Also, this method doesn't work with embedded SQL.

But I sound more critical than I mean to be. Both Doug and Mike (in the July 28 issue) have presented techniques that are well thought out, and I am grateful to have learned other ways to handle a common task.

--Ted

Sponsored By
DAMON TECHNOLOGIES

RSP is the Evolution of RPG

RSP (RPG Server Pages) is the best way to develop Web applications with RPG.

· Developers use their existing RPG skills.
· More robust than CGI with greater flexibility and speed.
· RSP is not just visual development. It is an application server built specifically for the iSeries.
· Full debug capabilities.
· Session Handling with a built in garbage collector.
· Use WDSc to develop your web content.
· Priced Right.

With RSP, Web content is developed with the Ease, Speed, and Reliability of RPG.

In today's fast paced business world, there is not enough time or resources to convert RPG developers into Java developers. The logical step to bring your business critical applications to the Web is with RSP. RSP gives the developer the tools necessary to create fast and reliable Web applications.

Download your free copy of RSP today!

www.damontech.com
Evolve


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:

T.L. Ashford
WorksRight Software
Damon Technologies


BACK ISSUES

TABLE OF
CONTENTS
Listing Spool Files

Optional Parameters and CL Procedures

Control Break Programs, Version 3


The Four Hundred
IBM Launches New IxA Cards to Link to Nocona Servers

Novell Takes On Red Hat with SuSE Enterprise Server 9

IBM Changes More iSeries, i5 Prices

Four Hundred Stuff
Thin Clients Making Advances in a PC World

Positive Pay Yields Positive Results At Stimson Lumber

Initech Debuts with Low-Cost iTool Suite

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