940 pts.
 How to give If condition in CL/400 program
Hi, I want to give two If conditions in a cl program to make sure the value of field is between the Range. I am trying to write following line of code but syntax error is coming,any idea/suggestions How can I do comparison at a same time: IF COND(%SST(&ODOBNM 7 4) *LE %SST(&VAR1 7 4)) and IF COND(%SST(&ODOBNM 7 4) *GE %SST(&VAR2 7 4)) Thanks

Software/Hardware used:
AS400
ASKED: November 24, 2012  12:14 PM
UPDATED: November 26, 2012  1:29 PM

Answer Wiki:
Last Wiki Answer Submitted:  Be the first to answer this question.
All Answer Wiki Contributors:  Be the first to answer this question. Michael Tidmarsh   11,410 pts. , 6r   940 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

even if I want to use corrected condition like:-

IF COND(%SST(&ODOBNM 7 4) *LE %SST(&VAR1 7 4)) *AND IF COND(%SST(&ODOBNM 7 4) *GE %SST(&VAR2 7 4))
Then condition prompt is not enoough longer to give this command,I mean full condition can’t be typed because of lessser space in If condition prompt,any idea/suggestions,How o type this long condition in IF command in CL/400 PROGRAM.

Thanks

 940 pts.

 

Using your style, it would look something like this:
 
IF COND(%SST(&ODOBNM 7 4) *LE %SST(&VAR1 7 4) *AND +
        %SST(&ODOBNM 7 4) *GE %SST(&VAR2 7 4))  THEN( DO )
 …code goes here
ENDDO
 
I might use a style that looks something like this:
 
if ( %sst( &ODOBNM 7 4 ) *le %sst( &VAR1 7 4 ) *and +
     %sst( &ODOBNM 7 4 ) *ge %sst( &VAR2 7 4 ))   do
 …code goes here
enddo
 
The compound COND() doesn’t have another “IF” statement in the middle of it. Also, the “AND” connective is written “*AND”. When the two conditions are combined, you also must be careful about balancing the parentheses. Finally, notice the “+” after the “*AND” to indicate the continuation onto a new source line.
 
It’s hard to predict how the code is going to look after I post this comment. We can work out details if necessary.
 
Tom

 108,330 pts.