0
I couldn’t find a suitable title for my doubt, but come on... Consider the code snippet below as an example:
def temp-table tt-test
field id as int
field customer as int
field added as char.
create tt-test.
assign tt-test.id = 1
tt-test.customer = 100
tt-test.added = "".
create tt-test.
assign tt-test.id = 2
tt-test.customer = 100
tt-test.added = "".
create tt-test.
assign tt-test.id = 3
tt-test.customer = 100
tt-test.added = "".
create tt-test.
assign tt-test.id = 4
tt-test.customer = 100
tt-test.added = "".
def buffer b-tt-test for tt-test.
for each tt-test
where tt-test.added <> "S"
break by tt-test.customer:
if tt-test.id = 2 then
for first b-tt-test
where b-tt-test.id = 4:
assign b-tt-test.added = "S".
end.
disp tt-test.id
tt-test.added
last-of(tt-test.customer).
end.
What problem I’m facing: the for each
continues to carry the record of id = 4
and this record had the field added
set to "S", and where
of for each
there is a condition tt-test.added <> "S"
, that is, by logic it should not appear.
What I need: in the case of the above code, I need the last-of(tt-test.customer)
be the record of id = 3
, since the record of id = 4
should no longer be read by for each
.
Out of curiosity: withdraw the clause break by
of for each
, then the record of id = 4
is not read, but in return without the break by
I can’t use the last-of
.
Thank you for your reply. I ended up discovering that to solve my situation just add an index in the temp-table with the Added or Customer field, so the number 4 record disappears and the last-of becomes the id record = 3.
– electus