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

IN operator

Former Member
0 Likes
1,482

Guys,

I want to check the following condition.But the IN operator is giving error.Can any one help with this?

IF iest1-material(4) IN ('GH39' 'GH43' 'GH44' 'GH6' '6001').

12 REPLIES 12
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,445

...

Read only

Former Member
0 Likes
1,445

Hi,

Give the IF condition as

IF iest1-material0(4) = 'GH39' OR iest1-material0(4) = 'GH43' OR iest1-material0(4) = 'GH44' OR iest1-material0(4) = '6001' .

Hope this helps you.

Read only

Former Member
0 Likes
1,445

Hi,

Check the below Thread,

Hope this helps.

Regards,

Anki Reddy

Read only

Former Member
0 Likes
1,445

Hi

U can't use that control in a IF condition, u need to use a RANGE instead of an explicit range:

DATA: BEGIN OF MY_RANGE OCCURS 0,
        SIGN(1)   TYPE C,
        OPTION(2) TYPE C,
        LOW(4)    TYPE C,
        HIGH(4)   TYPE C, 
      END   OF MY_RANGE. 

MY_RANGE(3) = 'IEQ'.
MY_RANGE-LOW = 'GH39'.
APPEND MY_RANGE.

MY_RANGE-LOW = 'GH43'.
APPEND MY_RANGE.

MY_RANGE-LOW = 'GH44'.
APPEND MY_RANGE.

MY_RANGE-LOW = 'GH6'.
APPEND MY_RANGE.

MY_RANGE-LOW = '6001'.
APPEND MY_RANGE.

IF iest1-material(4) IN MY_RANGE.
ENDIF.

Max

Read only

Former Member
0 Likes
1,445

Take a range , fill all the values and check ..

Read only

Former Member
0 Likes
1,445

hi,

if this is not working, try insert into one range table.then do IN rabge table.this will defenitely work

Read only

faisalatsap
Active Contributor
0 Likes
1,445

Hi, Alka

Test the following code i am using Range here insted of if, i have tested it is working fine.

TYPES: BEGIN OF t_it,
  mat(6),
END OF t_it.

DATA: it TYPE STANDARD TABLE OF t_it WITH HEADER LINE,
      number TYPE i VALUE '1001'.

RANGES: rtest FOR it-mat.

rtest-sign = 'I'.
rtest-option = 'EQ'.
rtest-low = '1001'.
APPEND rtest TO rtest.
rtest-low = '1002'.
APPEND rtest TO rtest.
rtest-low = '1003'.
APPEND rtest TO rtest.

DO 10 TIMES.
  it-mat+0(4) = number.
  ADD: 1 TO number.
  APPEND it TO it.
ENDDO.

LOOP AT it INTO it.

  IF it-mat+0(4) IN rtest.
    WRITE: / 'In the Range ', it-mat.
  ELSE.
    WRITE: / 'Not In the Range ', it-mat.
  ENDIF.

ENDLOOP.

Please Reply if any thing else,

Kind Regards,

Faisal

Read only

Former Member
0 Likes
1,445

guys ,

I am declaring Ranges as follows: It go into dump and shows error at:

IF NOT iest1-material(temp_len) IN MAT_RANGE.

Code:

RANGES MAT_RANGE FOR ZEST1-MATERIAL.

MAT_RANGE-LOW = '04'.

APPEND MAT_RANGE.

MAT_RANGE-LOW = '05'.

APPEND MAT_RANGE.

MAT_RANGE-LOW = '06'.

APPEND MAT_RANGE.

LOOP AT itab_zwst43.

CLEAR : temp_len.

temp_len = strlen( itab_zwst43-material ).

IF iest1-material(temp_len) EQ itab_zwst43-material.

IF temp_type_parts IS INITIAL OR

itab_zwst43-lab_type1(1) > temp_type_parts1(1).

MOVE itab_zwst43-lab_type TO temp_type_parts.

ENDIF.

EXIT.

ELSE.

IF NOT iest1-material(temp_len) IN MAT_RANGE.

IF temp_type_parts IS INITIAL.

temp_type_parts = 'L1'.

ENDIF.

EXIT.

ENDIF.

ENDIF.

ENDLOOP.

Please guide

Read only

0 Likes
1,445

Use

IF iest1-material(temp_len) NOT IN MAT_RANGE.

Regards,

Prashant

Read only

0 Likes
1,445

Hi, Alka,

Just try to replace the following line of code in my above code.

IF it-mat+0(4) IN rtest. " Now you have to writ like this IF it-mat+0(4) NOT IN rtest.

Please Reply if any Problem,

Kind Regards,

Faisal

Read only

0 Likes
1,445

Hi,

You also need to assign the values for the sign and option fields of the range.


mat_range-sign = 'I'.
mat_range-option = 'NE'.  " Use Not equal to operator

MAT_RANGE-LOW = '04'.
APPEND MAT_RANGE.

MAT_RANGE-LOW = '05'.
APPEND MAT_RANGE.

MAT_RANGE-LOW = '06'.
APPEND MAT_RANGE.

.....

IF iest1-material(temp_len) IN MAT_RANGE.  " Use this line.

regards,

Advait

Read only

Former Member
0 Likes
1,445

Hi Alka,

Hope this should be helpful.

IF iest1-material+0(4) = 'GH39'

OR iest1-material+0(4) = 'GH43'

OR iest1-material+0(4) = 'GH44'

OR iest1-material+0(4) = '6001' .

-


ENDIF.

Regards

Sravan