We'll give it a shot Sweetie
this bothers me a bit: sum(amount)
It implies to me that there is another group required based on CODE
First Structure your report this way
Group 1 header Unit (put the column headings)enable repeat group header
Group 2 header @Type (put the Value of @type)
Group 3 header CODE
Details (Suppressed)
Group 3 footer (suppressed)
Group 2 footer (put your Type data/summary calculations)
Group 1 (put your net calculations)
Re: @Type
You have no provision for data that does not fall into these 2 categories...there should be...so I would make the formula something like this
//@Type
IF {tab1.L2_ID} like 'IC*' AND RIGHT({tab1.L5_ID},2) = '01' THEN
'ASSETS'
ELSE IF {tab1.L2_ID} like 'IC*' AND RIGHT({tab1.L5_ID},2) = '02' THEN
'LIAB.'
ELSE
"OTHER";
Now you have a chance to catch data errors
Now to produce the data in the Group 3 footer you simply need to place your fields and do a summary operation on the "code" to get the count and "Amount" to get the sum
For the Group 2 footer summary You do another count of code based on your @Type group and Sum of Amount for the total amount for this grouping.
To get the Net summary in the Group 1 footer...you have to collect this data in arrays
In the Group 1 header place this formula
//@Init
WhilePrintingRecords;
//estimate the number of codes then add 50% to that total
//let us say there are 20 codes then dim the arrays for 30 elements
StringVar Array Code := ["","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","",""};
StringVar Array CodeDescr := ["","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","",""};
StringVar Array CodeCount := ["","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","",""};
StringVar Array CodeSum := ["","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","",""};
NumberVar pointer := 0;
StringVar Warning := "";
The arrays are strings for display reasons that will be obvious later.
Now in the Group 2 footer place this formula
//@CollectSummaryInfo
WhilePrintingRecords;
StringVar Array Code;
StringVar Array CodeDescr ;
StringVar Array CodeCount ;
StringVar Array CodeSum ;
NumberVar pointer ;
StringVar warning;
numberVar counter;
booleanVar flag := False;
if pointer = 0 then
(
pointer := pointer + 1;
Code[pointer] := {Table.code};
CodeDescr[pointer] := {Table.codeDescr};
CodeCount[pointer] := totext(count({Table.code,@Type),0,""

;
CodeAmount[pointer] := totext(sum({Table.amount,@Type),0,""

;
)
else
(
for counter := 1 to pointer do
(
if Code[counter] = {Table.code} then
(
CodeCount[counter] := totext(tonumber(CodeCount[counter]) + count({Table.code,@Type),0,""

;
CodeAmount[counter] := totext(tonumber(CodeAmount[counter]) + sum({Table.amount,@Type),0,""

;
flag := True;
)
if flag then Exit For;
);
if not flag then
(
if pointer + 1 > ubound(Code) then
warning := "warning report maintenance required: too many codes for the array"
else
(
pointer := pointer +1;
Code[pointer] := {Table.code};
CodeDescr[pointer] := {Table.codeDescr};
CodeCount[pointer] := totext(count({Table.code,@Type),0,""

;
CodeAmount[pointer] := totext(sum({Table.amount,@Type),0,""

;
warning := "";
);
);
);
Now you have your data.
The display of it depends n the size of your {Table.codeDescr} size. Let us say this is 25 char MAX...then a string formula can hold 254/25 or 10 {Table.codeDescr}'s
So each display of the footer variables will have a formula similar to this one
//@DisplayCode1
WhilePrintingRecords;
stringVar array Code;
numberVar pointer;
StringVar result := "";
for pointer := 1 to 10 do
(
result := result + Code[pointer] + chr(13);
)
result;
now you see the benefits of the string array
For each group of 10 results make a new subsection of the footer and Enable "Suppress BLank Section"
the formula is very similar except for the range.
//@DisplayCode1
WhilePrintingRecords;
stringVar array Code;
numberVar pointer;
StringVar result := "";
for pointer := 11 to 20 do
(
result := result + Code[pointer] + chr(13);
)
result;
add one more the footer section place and a warning formula
(Make sure this has Suppress Blank Section Enabled)
//@Warning
WhilePrintingRecords;
StringVar Warning;
Warning;
There that is how it is done...it may not be 100% error free but you get the idea
Jim Broadbent
The quality of the answer is directly proportional to the quality of the problem statement!