01-20-2008 11:43 AM
Hi all,
My problem is, i have calculated time in minutes i have to show output in terms of minute range. The minute range is defined in the selection screen by the user.
Eg If user has defined in selection screen the minute range as 10.
Now if the calculated minutes i have is 5 min then output = show range as 0-10
if i have 13 min then output = shoe range as 10-20 and so on.
Similarly if User enters 5 in selection screen, then
3 min output = show range as 0-5
13 min ouput = show range as 10-15 and so on.
Is there any FM which could help me, or nay other possible way.
Please help me out. Points will be rewarded.
Thanks
Vijay
01-20-2008 1:08 PM
Hi vijay,
no idea if there is a standard function but such a function module is written quite fast. Here an example. You have to adapt the data types perhaps if you have greater value ranges.
FUNCTION zrwe_range.
*"----
""Local Interface:
*" IMPORTING
*" REFERENCE(IV_VALUE) TYPE I
*" REFERENCE(IV_RANGE) TYPE I
*" EXPORTING
*" REFERENCE(EV_RANGE) TYPE CHAR10
*"----
local data definition
DATA:
lv_segment TYPE i,
lv_start TYPE i,
lv_end TYPE i,
lv_char_buff1 TYPE char4,
lv_char_buff2 TYPE char4,
lv_range TYPE char10.
clear the exporting parameter
CLEAR:
ev_range.
get the segment the value is in
lv_segment = ( iv_value DIV iv_range ) + 1.
get the start
lv_start = ( lv_segment - 1 ) * iv_range.
get the end
lv_end = ( lv_segment ) * iv_range.
build the result
WRITE lv_start TO lv_char_buff1.
WRITE lv_end TO lv_char_buff2.
CONDENSE lv_char_buff1.
CONDENSE lv_char_buff2.
CONCATENATE
lv_char_buff1
'-'
lv_char_buff2
INTO
ev_range.
ENDFUNCTION.
To sum up several entries just call such a function module in a loop and collect them into a table.
Best regards
Roman Weise