2014 Dec 11 3:55 PM
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
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
2014 Dec 11 4:02 PM
2014 Dec 11 4:17 PM
Hi.
Did you try something like :
LOOP AT range_table.
IF range_table-value IN sel_option.
ELSE.
ENDIF.
ENDLOOP.
Hope to help
Bye
2014 Dec 11 5:31 PM
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
2014 Dec 12 10:50 AM
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.
2014 Dec 12 11:59 AM
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.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |