I am modifing some code I found, and trying to add multiple 'or' statement. I have tried several different way to get the code to compile, but I always get errors. Can someone please tell me the proper syntax for the following statement below??
if Jobbstatus = 'MSGW' and SubShort = 'QBATCH' or +
Jobbstatus = 'MSGW' and SubShort = 'QPGMR' or +
Jobbstatus = 'MSGW' and SubShort = 'QPGMR1';
What I'm trying to test is, if Jobbstatus is MSGW, and if SubShort is any of the following subsystems, QBATCH, QPGMR, QPGMR1.
Also, how about if Jobbstatus was either 'MSGW' or 'RUN'? I have a second if statement, but it would be nice if I could test both MSGW and RUN along with the different subsystems as well. That would eliminate the need for 2 if statements.
if Jobbstatus = 'MSGW' or 'RUN' and SubShort = 'QBATCH' or +
SubShort = 'QPGMR' or +
SubShort = 'QPGMR1';
Thanks.
Software/Hardware used:
AS400 - 570
ASKED:
May 17, 2010 1:41 PM
UPDATED:
May 19, 2010 2:53 PM
Parentheses are your friend:
For the more complex statement, either of Tom’s examples would work – well, with the addition of a parenthesis at the end of the second example
.
I would suggest you keep in mind those that will come after you: readability is oft times more important than loading everything into a single statement.