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 condition

Former Member
0 Likes
614

Hello Every one..

I want to compare a value of a filed in a internal table with a set of values. can u suggest e , how to achieve that.

Ex: i hav val filed in internal table itab.

i want to check all entries of val filed in internal table , wether that value is between 1 to 99 or not.

In the loop of internal table how can i compare wether that valus is between the range or not.

Thanks in advance

Ravi

6 REPLIES 6
Read only

Former Member
0 Likes
595

Hi,

loop at itab.

if itab-val between 1 and 99.

do some thing.

endif.

endloop.

Regards,

madan.

Read only

Former Member
0 Likes
595

Hye Ravi,

suppose u have an internal table with fields A and B

loop at itab into wa.

if wa-A between 1 and 99.

Do ur processing.

endif.

if wa-B > 1 and wa-B < 100.

Do ur processing.

endif.

endloop.

These are the two ways you can do this.

Post the exact requirement so that i can explain u in clarity.

Pls reward if helpful.

Thanks,

Imran.

Read only

Former Member
0 Likes
595

declare a range r_range and populate the values as

r_range-sign = 'I'.

r_range-option = 'BT'.

r_range-low = '1'. <-- example

r_range-high = '99'. <-- example

append r_range.

loop at itab.

if itab-field1 in r_range.

else .

endif.

endloop.

Read only

Former Member
0 Likes
595

IF wa_tab-price BETWEEN 1 AND 99.

.................

ELSE.

.................

endif.

Regards,

Read only

Former Member
0 Likes
595

Hello,

Put all values into an internal table of type range and compare the values using the operator IN.


  DATA itab_comparison TYPE RANGE OF itab-field.

  itab_comparison-sign = 'I'.
  itab_comparison-option = 'EQ'.
  itab_comparison-low = 'Value 1'.
  APPEND itab_comparison.

  itab_comparison-low = 'Value 2'.
  APPEND itab_comparison.

  ...

  LOOP AT itab.
    IF itab IN itab_comparison.
    ENDIF.
  ENDLOOP.

Regards,

Read only

Former Member
0 Likes
595

Thanks a lot every one,