on 2005 May 16 11:33 AM
Hi All,
In my sales report, I need to calculate % time.
The user inputs a date and I need to calculate %Time as:
%TIME= Days lapsed upto that selected date in the month in which the selected date is present/total No of days in that month.
This formula is valid if the selected date is in the current month. If the selected date is not in current month:
%TIME = 100%
Can anyone tell me how to achieve this?
Thanks in advance
Vinay
You could use a formula variable that is filled by a user exit. The coding could look like this:
...
CASE I_VNAM.
WHEN 'TIMEPRC'.
* Calculate Time percentage
check i_step = 2.
READ TABLE I_T_VAR_RANGE into l_s_var_range
WHERE VNAM = 'IDATE'. "Input Date variable
IF l_s_var_range-low(6) = sy-datlo(6).
* Same month
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
DATA: l_d_this_month type d,
l_d_next_month type d,
l_d_this_day type d.
l_d_this_day = l_s_var_range-low(8).
l_d_next_month = l_d_this_month = sy-datlo.
* The following three lines determine the first
* of the next month
l_d_next_month+6(2) = '28'.
l_d_next_month = l_d_next_month + 4.
l_d_next_month+6(2) = '01'.
* Set l_d_this_month
l_d_this_month+6(2) = '01'.
* Calculate formula
l_s_range-low = ( l_d_this_day - l_d_this_month
+ 1 ) /
( l_d_next_month - l_d_this_month )
* 100.
else.
* Other month
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
l_s_range-low = '100'.
endif.
endcase.
I hope this helps a bit.
Best regards
Dirk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
66 | |
10 | |
10 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.