Bogdan
15th February 2002, 13:50
Hi,

It is possible to reevalute a previous layout within a report script?
For example, I have :
Before.field
Detail
After.field

I want to reevaluate Before.field layout based on certain conditions met in After.field layout.

Is this possible?

Thanks a lot
Bogdan

evesely
15th February 2002, 16:09
If you put layout.again() in your after.layout subsection, it should re-execute the layout and all of its subsections. I have used it several times before when I have an array and want to do one detail line for each item in the array. Try something like this:
before.layout:
do.your.code()
after.layout:
if condition.is.ok then
layout.again()
endif

mark_h
15th February 2002, 16:25
Hi Bogdan!

I know you can do it like Ed suggested, but I do not think you can call another before.field event. At least I could not figure out how. If you find out how, please the solution here.

Mark

evesely
15th February 2002, 19:16
Sorry! I posetd a response to what I wanted to read rather than what you wanted.

I have never tried it, but if you are feeling adventurous, you could give this a shot. Let's say field in question is xx. When you compile the report, Baan creates external functions r.s.before.xx() and r.s.after.xx() (assuming you have before and after layouts for that field) plus external functions like r.s.before.xx.yy.bef.lay() (which is the before.layout code for the before.field.xx.yy layout) for each section of code you write.

The r.s.before.xx() function will run through all of the before.field layouts for field xx. So if there was more than one but you only wanted to evaluate one, you could set a flag in the after.field section you discussed and check that flag in the before.layout sections of each of the before.field layouts for that field. [Does that read as confusing as it sounds typing it :confused: ?)

For example if field suno had two before layouts (10 and 20) and I only wanted to re-run 10, I could do:

calling function:
rerun.flag=1

before.field.suno.20:
before.layout:
if rerun.flag = 1 then
lattr.print = false
endif


Again, I haven't run this, so I can't say that it will work. In theory, I think it might ;) .

Bogdan
18th February 2002, 08:21
Hi,

I'm sure your solution will work, but my problem is a litlle bit different:

I'm testing the condition in After.field and because the Before.field was allready evaluated ....
So I was wondering if it is possible to reevaluate a field allready evaluate and send to "printer".

By the way, if I'm not using lattr.print, but a particular variable, I cannot control the printing of a layout. This variable is, of course, present in Output expr. field in Maintain report layouts. The result is something like this:
|**** condition = false (no print)
OK, nothing is sent to printer
|**** condition = true (print)
OK, layout is sent to printer
|**** condition = false (no print)
WRONG, layout IS SENT TO PRINTER

It looks like the variable has wrong value. Maybe I shoud give a layout.again()? I'll try this.

Thanks for the tip with those functions.

Best regards,
Bogdan

jroberts
18th February 2002, 17:57
If you are using an array,
use the array to evaluate the next value in your array before your
layout.again()

before.layout:
if q = 1 then
skip.to(spool.pg.length - 12)
endif

after.layout:
if q < 8 then
if array.frcl(1,q+1) <> "ZZZZ" then
layout.again()
q = q + 1
endif
endif

The current record gets printed, and based on the value of the next record array.frcl(1,q+1) in the array
layout.again() is called.

Hope this helps,
John

evesely
18th February 2002, 21:04
For Bogdan's post:

If you have an expression in the "output expression" field of the Maintain Layouts subsession, you can always change it to 1 and bring the actual condition inside your script and set lattr.print based upon that value. The only real change in doing so is that now your before.layout script will get executed each time. However, you can easily program around any potential problems that might arise because of that.