Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

If Syntax

Former Member
0 Likes
1,159

hi frnd's.

Whether the IN condition can be used in the IF Statement.

Sample code is

IF W_data IN ('01', '02', '03', '04', '05', '15', '17', '20', '21', '22', '23' ).

I am getting an error incorrect logical expression.

9 REPLIES 9
Read only

FredericGirod
Active Contributor
0 Likes
1,080

Better is to play with ranges.


ranges : r_data for ... 

move : 'I' to r_data-sign ,
       'EQ' to r_data-option ,
       '01' to r_data-low.
append r_data.
...

if w_data in r_data ..

Read only

Former Member
0 Likes
1,080

If and in don't go together.

YOu have to use Or statements.

Read only

naimesh_patel
Active Contributor
0 Likes
1,080

Hello,

You can not use IF by this way..

simply fill one range by your values and then you can use this IF ...

IF w_data in R_data.

where r_data

r_data-sign = 'I'.

r_Data-options = 'EQ'.

r_data-low = '01'.

Regards,

Naimesh

PS: Reward points, if you find useful..!

Read only

Former Member
0 Likes
1,080

Hi Suganya,

I think you can't use IN statement like the way you have used.

But u can create "select options" variable and compare it using IN statement.

Eg:

SELECT-OPTIONS S_CARRID FOR WA-CARRID.

IF 'LH' IN S_CARRID.

WRITE 'LH was selected'.

ENDIF.

Regards,

Sylendra

Read only

Former Member
0 Likes
1,080

Hi

In condition can be used in IF statement but the statement where you want to use is worng.Check out the help of in in SAP help.I hope that will give your much idea to solve this problem.

Thanks

Mrutyunjaya Tripathy

Read only

Former Member
0 Likes
1,080

Hi,

IN cannot be used with if statement.

Read only

abdul_hakim
Active Contributor
0 Likes
1,080

Hi suganya

<b>You cannot use IN in IF variants.</b>

The correct code in your scenario would be

<b>IF WA_DATA EQ '01' OR

WA_DATA EQ '02' OR

WA_DATA EQ '03' OR

WA_DATA EQ '04' OR

WA_DATA EQ '05' OR

WA_DATA EQ '15' OR

WA_DATA EQ '17' OR

WA_DATA EQ '20' OR

WA_DATA EQ '21' OR

WA_DATA EQ '22' OR

WA_DATA EQ '23'.

ENDIF.</b>

Cheers,

Abdul Hakim

Read only

Former Member
0 Likes
1,080

HI,

You cannot use IF with IN statement, You can use either AND or OR with IF statement.

regards

-Rakesh