Break by on multiple fields

Kalan

Member
Greetings,

I am having a problem using "break by" feature to consolidate 9 columns on the report. My code is similar to below template,
FOR EACH < Table Name> Break by Col1 by Col2 by Col3 by Col4 by Col5 by Col6 by Col7 By Col8 by Col9:

IF First-of(Col1) AND ....First-of(Col9) THEN DO:
Initialize variables.
END.
Calculation part.
IF Last-of(Col1) AND ....Last-of(Col9) THEN DO:
Printing the report row.
END.

The problem here, Grouping works mainly to column specified with BREAK BY keyword, rest of the 8 columns not effective on grouping. i.e. Its not recognizing the distinct value appears in Col8, incorrectly it combines with non-identical column values. Is there any limitation on using Break by option for multiple fields? Could someone pls suggest the correct approach for the above example? - Thanks.
 

TomBascom

Curmudgeon
BREAK BY works as I expect it to when I do things that I believe are similar to what you have described.

For instance:
Code:
define variable d as logical no-undo.
define variable r as logical no-undo.

for each customer no-lock break by salesrep by discount:

  d = first-of( discount ).
  r = first-of( salesrep ).

  display r d salesrep discount name.

end.

You should provide a real example with real fields and real data. I suggest that you base it on the sports2000 database (as above) and perhaps use a few less groupings (unless you think the problem is purely due to the number of groups). That way we can all try it.
 

tamhas

ProgressTalk.com Sponsor
Did you try just

Break by Col1 by Col9

Why are you breaking on all of those columns?
 

Kalan

Member
Thanks Tom/Tamhas,

Its an existing code for an enhancement to consolidate around 9 number of columns. Managed to go with workaround of grouping these identical columns while creating/updating into temp-table. I will come up with an example when its failed to apply break by function on multiple columns. Thanks again.
 
Try only checking the last field:
Code:
FOR EACH < Table Name> Break by Col1 by Col2 by Col3 by Col4 by Col5 by Col6 by Col7 By Col8 by Col9:

 IF First-of(Col9) THEN DO:
    Initialize variables.
 END.
 Calculation part.
 IF Last-of(Col9) THEN DO:
    Printing the report row.
 END.
 
Top