I want to use sub-total to get information based on a part number.
It's not working, so I built very basic code for debugging, this basic code is sort of like I have it below.
My "for each" has the "break by <...>"
I have added
1: "accumulate <...>( sub-total ).
2: if last-of(<...>) then
message (accum sub-total <...>) view-as alert-box.
This is just giving a running total. It uses the sub-total from the last group and totals it onto the sub-total of the current group.
Imagine
A 1
A 2
A 3
A 4
---
10 Total
B 1
B 2
B 2
B 3
------
8 Total.
Instead and getting 8 total, I get 18. That's 8 added onto the 10 before it.
define temp-table tt
field cc as char
field ii as int
.
create tt. assign tt.cc = "A" tt.ii = 1.
create tt. assign tt.cc = "A" tt.ii = 2.
create tt. assign tt.cc = "A" tt.ii = 3.
create tt. assign tt.cc = "A" tt.ii = 4.
create tt. assign tt.cc = "B" tt.ii = 1.
create tt. assign tt.cc = "B" tt.ii = 2.
create tt. assign tt.cc = "B" tt.ii = 2.
create tt. assign tt.cc = "B" tt.ii = 3.
for each tt break by tt.cc:
accumulate tt.ii ( sub-total by tt.cc ).
display
tt.cc
tt.ii
.
if last-of( tt.cc ) then
display accum sub-total by tt.cc( tt.ii ).
end.from the top of my head you should use
message (accum sub-total by xxx)
define temp-table tt
field cc as char
field ii as int
.
create tt. assign tt.cc = "A" tt.ii = 1.
create tt. assign tt.cc = "A" tt.ii = 2.
create tt. assign tt.cc = "A" tt.ii = 3.
create tt. assign tt.cc = "A" tt.ii = 4.
create tt. assign tt.cc = "B" tt.ii = 1.
create tt. assign tt.cc = "B" tt.ii = 2.
create tt. assign tt.cc = "B" tt.ii = 2.
create tt. assign tt.cc = "B" tt.ii = 3.
for each tt break by tt.cc:
accumulate tt.ii ( sub-total by tt.cc ).
display
tt.cc
tt.ii
.
if last-of( tt.cc ) then
display accum sub-total by tt.cc( tt.ii ).
end.Thanks Stefan Drissen. That's worked, now hopefully I can implement this into the real project.