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

Compare range tables

Former Member
0 Likes
2,205

Hi,

I have two range tables and want to compare them. That means, I need to check, if the values, selected in one range table

are also selected in the other one.

Example:

I have range table lt_range_1 & lt_range_2.

In table lt_range_2 I have some single values and in lt_range_1 I have a range defined. No I want to know, if the single values fo lt_range_2 are in the selected range of lt_range_1.

Thank you for your help!

1 ACCEPTED SOLUTION
Read only

vinod_vemuru2
Active Contributor
0 Likes
1,367

Hi,

Check below logic.



LOOP AT lt_range_2 .
IF lt_range_2-low IN lt_range_1.
"Value exist
ELSE.
"not exist.
ENDIF.
ENDLOOP.

Please note that ranges works similar to select options. Check F1 help for more details.

Thanks,

Vinod.

3 REPLIES 3
Read only

vinod_vemuru2
Active Contributor
0 Likes
1,368

Hi,

Check below logic.



LOOP AT lt_range_2 .
IF lt_range_2-low IN lt_range_1.
"Value exist
ELSE.
"not exist.
ENDIF.
ENDLOOP.

Please note that ranges works similar to select options. Check F1 help for more details.

Thanks,

Vinod.

Read only

0 Likes
1,367
LOOP AT lt_range_2 .
IF lt_range_2-low IN lt_range_1.
"Value exist
ELSE.
"not exist.
ENDIF.
ENDLOOP.

This would imply that you only have -low filled.

How about (at least for a small tab):

SELECT from tab into tab1 where key in lt_range1.
SELECT from tab into tab2 where key in lt_range2.
IF tab2[] = tab1[].
" hurray!
ELSE.
" ahum...
ENDIF.

Read only

0 Likes
1,367

Hello,

Welcome to SCN!!!.

Here question is about comparing the single values in one range variable (always has it in low) with the range of values in another range variable. Direct comparison won't work here.


In table lt_range_2 I have some single values and in lt_range_1 I have a range defined. Now I want to know, if the single values fo lt_range_2 are in the selected range of lt_range_1.

Thanks,

Vinod.