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

Comparing select options and range table

Former Member
0 Likes
1,969


Hi All,

I have a requirement like following senario:

I have a range table with 10 records: 1, 3, 9, 12, 15, 18, 21, 24, 27, 30 and in select option if i give low = 3 and high = 14, then i need to fetch records from range table which are in select option range (i.e 3, 9, 12) into another range table.

Any suggestion will be highly appreciated.

Regards,

Sharan

5 REPLIES 5
Read only

Former Member
0 Likes
946

What have you coded so far?

Rob

Read only

roberto_vacca2
Active Contributor
0 Likes
946

Hi.

Did you try something like :

LOOP AT range_table.

IF range_table-value IN sel_option.

ELSE.

ENDIF.

ENDLOOP.

Hope to help

Bye

Read only

Former Member
0 Likes
946

Hi Sharanabasappa,

So my understanding is this first range table with all the data is single selection row records.

So all of them will be stored as I EQ 1, I EQ 3 etc..

In which case if your first range table with all individual records are r_1, your select option is so_1 and the final range is r_2.

Then you can do the following:

MOVE r_1[] TO r_2[].

DELETE r_2 WHERE low NOT IN so_1.

Regards,

Nabarko

Read only

VenkatRamesh_V
Active Contributor
0 Likes
946

Hi Sharanabappa,

Hope it helpful.

loop at  range.

if range-num between so_num-low and so_num-high.

else.

delete range index sy-tabix.

endif.

endloop.

Regards,

Venkat.

Read only

Former Member
0 Likes
946

hi sharan,

I have coded and tried to get the result as per your requirement.

Have a look at the following code.

REPORT  ZR_RANGE_TABLE.

DATA: num1 type I.

TYPES: range_type TYPE RANGE OF fieldname.

DATA: range_table1 TYPE range_type,
range_wa1
TYPE LINE of range_type,
range_table2
TYPE range_type,
range_wa2
TYPE LINE of range_type.
DATA: counter TYPE I VALUE 1.

range_wa1
-sign = 'I'.
range_wa1
-option = 'EQ'.
range_wa1
-low = 1.
APPEND range_wa1 to range_table1.

DO 10 TIMES.      
range_wa1
-sign = 'I'.
range_wa1
-option = 'EQ'.
range_wa1
-low = 3 * counter.
APPEND range_wa1 to range_table1.
counter
= counter + 1.
ENDDO.

SELECT-OPTIONS: val FOR NUM1.

START-OF-SELECTION.

loop at range_table1 into range_wa1.
write: / range_wa1-low.
If range_wa1-low BETWEEN val-low AND val-high.
APPEND range_wa1 to range_table2.
ENDIF.
ENDLOOP.      


write: / 'Final result in range table2'.

loop at range_table2 into range_wa1.
write: / range_wa1-low
ENDLOOP.      



INITIALIZATION.
val
-sign = 'I'.
val
-option = 'BT'.
val
-low = 3.
val
-high = 14.
append val.