pjohns
21st March 2012, 13:06
Hello,
I want to add some text to a report layout but want to apply a print condition. I would normally put this in the "Print Condition" box of the Maintain Report Field. My problem is that the syntax is too long. I'm not sure how to change the report script to make this work for me. I have attached screen shots as reference. Would somebody be able to help me?
Thanks in advance.
PJ
mark_h
21st March 2012, 13:26
Something like this should work in the report script - of course I assume you want to stop the complete layout from printing.
after.tdsls045.orno.60:
before.layout:
if tdsls040.cuno = "A84200" and tdsls040.comp = 203 and tdsls040.cotp <> "3TR" and tdsls040.cotp <> "3BS" and tdsls040.cotp <> "3SC" then
else
lattr.print = false
endif
pjohns
21st March 2012, 13:33
Thanks Mark!
That worked perfectly.
I had tried something like this but obvioulsy the syntax wasn't quite there.
Thanks again.
PJ
pjohns
21st March 2012, 13:52
Sorry......
Do I need to put any brackets in the 'if' statement?
if tdsls040.cuno = "A84200" and tdsls040.comp = 203 and tdsls040.cotp <> "3TR" and tdsls040.cotp <> "3BS" and tdsls040.cotp <> "3SC"
If I print an invoice out for customer "A84200" and finance company "203" and order type is "3SC" the layout is printed. As the order type is "3SC" I would expect it not to print??
Thanks
pjohns
21st March 2012, 14:12
resolved it.
The report did not have tdsls040.cotp as an input field.
mark_h
21st March 2012, 14:14
I would expect it not to print. Because the " and tdsls040.cotp <> "3SC"" would be false and it would kick it into the else statement which has lattr.print = false.
mark_h
21st March 2012, 14:18
You can also try this.
after.tdsls045.orno.60:
before.layout:
lattr.print = false
if tdsls040.cuno = "A84200" and tdsls040.comp = 203 and tdsls040.cotp <> "3TR" and tdsls040.cotp <> "3BS" and tdsls040.cotp <> "3SC" then
lattr.print = true
else
lattr.print = false
endif
Then put it in debug mode and make sure the tdsls040.cotp has the correct value for what it is printing. I can't see how one with 3SC would print.
pjohns
21st March 2012, 14:25
I tried to put the tdsls040.cotp field on the layout but got the error saying "field not defined as report input". So I added the field to "Input Field". After doing this your original solution worked. It was the fact the report did not know the value of tdsls040.cotp that the logic was failing.
Thanks for your help.
JaapJD
21st March 2012, 22:56
If you put the condition in the before.layout, your layout overview does not show the condition anymore (because that layout condition will be 1 or true). To have more visibility of conditions in the layout overview session, you can use the #define. In your report script you code:
#define SPECIAL.ORDER.FOR.CUSTOMER.A84200 (tdsls040.cuno = "A84200" and tdsls040.comp = 203 and tdsls040.cotp <> "3TR" and tdsls040.cotp <> "3BS" and tdsls040.cotp <> "3SC")
Then you can use SPECIAL.ORDER.FOR.CUSTOMER.A84200 as layout condition.