× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I don't want to prolong this any longer than necessary since 
Jeff appears to have found his solution.  However, I believe 
this example may be flawed.  I say maybe because it depends 
on how you number your level breaks.  If you sequence your 
breaks as L3 being the lower level break and L1 being the 
higher level break this will work but is the opposite of the 
cycle.  If you use the cycle ordering of L1 being the lower 
level and L3 being the higher level this example will execute 
higher level breaks when the break occurred at a lower level.

FWIW, I took one of the suggested skeletons, reversed the level breaks,
converted to freeform, prettied it up, and otherwise messed around with it
until it is unrecognizable from it's original state. <g>

Here it is:

 //
 // Example of manual level breaks
 //

 // Level 5 field:  Lev05 (highest, outer)
 // Level 4 field:  Lev04
 // Level 3 field:  Lev03
 // Level 2 field:  Lev02
 // Level 1 field:  Lev01 (lowest, inner)

 /FREE

  // Set position and process file
  Setll Key Filea;
  Dou %eof(Filea);
    Read Filea;
    If not %eof(Filea);
      Exsr ProcFilea;
    Endif;
  Enddo;

  // EOF, force all breaks and grand totals
  Exsr ProcLev05;
  Except GrdTotals;

  // Done
  *INLR = *on;
  Return;

 /EJECT
  Begsr Procfilea;

    // Increment record count
    RecsRead += 1;

    // Prevents level breaks first time through
    If RecsRead = 1;
      HldLev05 = Lev05;
      HldLev04 = Lev04;
      HldLev03 = Lev03;
      HldLev02 = Lev02;
      HldLev01 = Lev01;
    Endif;

    // Handle level breaks (before processing this record)
    Select;
      When HldLev05 <> Lev05;
        Exsr ProcLev05;
      When HldLev04 <> Lev04;
        Exsr ProcLev04;
      When HldLev03 <> Lev03;
        Exsr ProcLev03;
      When HldLev02 <> Lev02;
        Exsr ProcLev02;
      When HldLev01 <> Lev01;
        Exsr ProcLev01;
    Endsl;

    // Increment totals and whatever else
    TotLev05 += RcdDta;
    TotLev04 += RcdDta;
    TotLev03 += RcdDta;
    TotLev02 += RcdDta;
    TotLev01 += RcdDta;
    TotGrd += RcdDta;
    Except PrtDetail;

  Endsr;

 /EJECT
  //
  // Level 5 break
  //
  Begsr ProcLev05;

    Exsr ProcLev04;
    Except PrtLev05;
    TotLev05 = *Zero;
    HldLev05 = Lev05;

  Endsr;

 /EJECT
  //
  // Level 4 break
  //
  Begsr ProcLev04;

    Exsr ProcLev03;
    Except PrtLev04;
    TotLev04 = *Zero;
    HldLev04 = Lev04;

  Endsr;

 /EJECT
  //
  // Level 3 break
  //
  Begsr ProcLev03;

    Exsr ProcLev02;
    Except PrtLev03;
    TotLev03 = *Zero;
    HldLev03 = Lev03;

  Endsr;

 /EJECT
  //
  // Level 2 break
  //
  Begsr ProcLev02;

    Exsr ProcLev01;
    Except PrtLev02;
    TotLev02 = *Zero;
    HldLev02 = Lev02;

  Endsr;

 /EJECT
  //
  // Level 1 break
  //
  Begsr ProcLev01;

    Except PrtLev01;
    TotLev01 = *Zero;
    HldLev01 = Lev01;

  Endsr;

 /END-FREE 


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.