pjohns
23rd July 2013, 10:07
Hello,

Can somebody please help me a syntax for a print condtion?

I am printing a report label which currently has the following condition -

tdsls040.comp = xxx and tdsls040.cuno = "A12345"

I want to add two more customers to the logic and I'm not quite sure on what the syntax should be. Is the following correct?

tdsls040.comp = xxx and (tdsls040.cuno = "A12345" or tdsls040.cuno = "B12345" or tdsls040.cuno = "C12345")

Thanks in advance

bhushanchanda
23rd July 2013, 11:18
Yes,

It works the same way. Make sure that if there are any spaces after the code, you need to put it in you condintion like if cuno = "A112" then you need to add cuno = "A112 ".

Here's a simple query:-

select
tdsls400.ofbp, | Sold-to Business Partner
tdsls400.orno | Sales Order

from
tdsls400 | Sales Orders
where (tdsls400.ofbp = "CN0000162" or tdsls400.ofbp = "CN0000017" or
tdsls400.ofbp = "CN0000338")

And, if you are using it in print expression, make sure if you set the used fields in report input fields.

pjohns
23rd July 2013, 12:06
Thanks for your reply.

What if I wanted to move this logic to the report script?

My thinking is that the syntax will be too long to fit in the print condtion box. Therefore I thought I could set a variable in the report script that would determine if this report field is printed. I have tried the following in the before.program section but I think it must be wrong as it is not working.

before.program:

swiss = "n"

select tdsls040.comp, tdsls040.cuno
from tdsls040
where tdsls040.orno = :tdsls040.orno
selectdo
endselect

If tdsls040.comp = 203 and tdsls040.cuno = "E34000"
then swiss = "y"
endif

I have dropped a form field on my report for the "print" variable above and printed a report which meets the logic above but the "print" is displayed as "n"

My coding skills are very basic and I don't very often have to do it so I'm sorry for these simple questions.

vamsi_gujjula
23rd July 2013, 12:11
Will it fit in the print expression.... i doubt

it should be handled in report script using a flag (if it does not fit in the print expression)

vamsi_gujjula
23rd July 2013, 12:14
pjohns

nobody is good they just get used to it..:P

anyway i dont think before.program is a good layout i would suggest just before the layout where these fields are printing

bhushanchanda
23rd July 2013, 12:33
Hi,

What are you trying to do with this loop?

select tdsls040.comp, tdsls040.cuno
from tdsls040
where tdsls040.orno = :tdsls040.orno | you are comparing its own orno which will cause problems
selectdo

endselect
 If tdsls040.comp = 203 and tdsls040.cuno = "E34000"
then swiss = "y"
endif


Anyway, it can be like this:-


long flag
flag = 0
swiss = "n"
select tdsls040.comp, tdsls040.cuno
from tdsls040
where tdsls040.orno = :tdsls040.orno | you are comparing its own orno which will cause problems
and tdsls040.comp = 203 and tdsls040.cuno = "E34000"
selectdo
flag = 1
endselect

if flag = 1 then
swiss = "y"
else
swiss = "n"
endif

My second question is, is this in the program script of report script?

If its in program script, you should put it in

choice.print.data:

after.choice:


If its in report script:-

You can use in:-

layout_name: | e.g. detail.1:

before.layout:



I am not sure what are you trying to do. Please post the snapshots of the form and the program and report scripts. That will be helpful to analyse the problem in better way.

mark_h
23rd July 2013, 16:17
Actually your code looks correct to me for going into a print condition. The quest I have is it just a report field or is it a whole layout? If it does not fit then yes it can go in the report script. The key will be figuring out where to put it in the script. Not exactly sure if you are just trying to print a field or a whole layout. I am usually turning off and on whole layouts.

pjohns
23rd July 2013, 16:59
Thank you for everyones help.

I now have it working by setting a flag from within the report script in the before.layout section Then using the flag for my report field print condition.

Thanks again!

bhushanchanda
23rd July 2013, 17:04
Well done! Can you post the code snipplet? That would help others facing same problem.

pjohns
19th September 2013, 12:12
A bit late, but working code I used is below. Very simple to most of you but could help somebody.

before.layout:
select tccom010.cuno, tccom010.refa
from tccom010
where tccom010.cuno = :tdsls040.cuno
selectdo
endselect

swiss = "n" | Added PJ 23-07-2013 Swiss VAT Exempt

select tdsls040.comp, tdsls040.cuno
from tdsls040
where tdsls040.orno = :tdsls040.orno
selectdo
endselect

If tdsls040.comp = 203 and (tdsls040.cuno = "E34000" or tdsls040.cuno = "NV9700" or tdsls040.cuno = "A05900")
then swiss = "y"
endif