JRussell
9th January 2003, 12:47
Hi

I need to write an algorithm to remember previous values of records.

I want to read a record and store the value of the item field.

I have the following code but I am a bit lost as to what to do next:

if first_flag = false then
firstitem = wawti601.item
first_flag = true
endif

if first_flag = true then
curritem = wawti601.item
endif

if first_flag = true then
previtem =


I want to suppress printing of a record if the previous value is the same as the current value.....

Can anyone advise......?

Thanks

JRussell
9th January 2003, 14:33
Hi

This is the algorithm I have written to remember the values etc...

lattr.print = false
if first_flag = false then
firstitem = wawti601.item
firstwc = wawti601.wkcentre
first_flag = true
endif

if first_flag = true then
curritem = wawti601.item
currwc = wawti601.wkcentre

if (curritem = firstitem) and (currwc = firstwc) then
lattr.print = false |suppress print
endif

if (curritem <> firstitem) and (currwc = firstwc) then
lattr.print = true
firstitem = curritem
firstwc = currwc
endif

if (curritem <> firstitem) and (currwc <> firstwc) then
lattr.print = true
firstitem = curritem
firstwc = currwc
endif

if (curritem = firstitem) and (currwc <> firstwc) then
lattr.print = true
firstitem = curritem
firstwc = currwc
endif
endif



This works fine however I have a problem with the first records read.

Eg.

Product Code, Machine Code, rest of file...
D3774 E01 .......
D3774 E02 .......
D3774 E01 .......
D3774 E01 .......
K5501 E11 ......
M9016 E10 etc......

The above algorithm works, whereas it suppresses the printing of similar records that have the same product code and machine code. But the first records come out twice. By the code this should happen, but my problem is that I don't want it to happen. It is the way Baan reads the records.

Can anyone advise on a way of selecting the records once?

Any help would be great!!!
thanks
:(

OmeLuuk
9th January 2003, 14:46
Better use standard functions to do this... there are several. You can store records via rcd.(tablename):
if table ttiitm001 is declared also a string is declared: rcd.ttiitm001 which is a record buffer of the table. This buffer can be copied (temprarily stored).string buffer(128)

buffer=rcd.ttiitm001
select tiitm001.* from tiitm001 where tiitm001
selectdo endselect
rcd.tiitm001=bufferPart from our course material "Advanced Programming".

ulrich.fuchs
11th January 2003, 12:47
declaration:
domain tcitem hold.item
domain tccwoc hold.wkcenter

before.report:
hold.item = ""
hold.wkcenter = ""

before.<layoutname>:
before.layout:

if hold.item = wawti601.item
and hold.wkcenter = wawti601.wkcenter then

lattr.print = true

else

lattr.print = false

endif

hold.item = wawti601.item
hold.wkcenter = wawti601.wkcenter


_--------------------------------

But keep in mind that this will only work if the rport you are using reports already sorts by item and workcenter (input field subsession!).
But, in that case, probably using an after.field layout for the field wawti601.wkcenter will be the simpler way to achieve your goal.