on 10-30-2015 4:55 AM
Hi, Below given is my Istep 2 code used, where as after given user input as CALDAY showing error as 'No value could be determined for variable ZCALMONTH2'.
CASE i_vnam.
WHEN 'ZCALMONTH2'. "Substitute your Variable name here. e.g. ZPLANYEAR
CASE i_step. "Check for step number
WHEN 2.
DATA: loc_var_range Type rrrangeexit.
DATA: l_lastmth TYPE sy-datum.
DATA: lastmth(10) TYPE c,
LV_YEAR(4) TYPE C,
L_MONTH(2) TYPE C.
CLEAR l_s_range.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZCAL_DAY'.
lv_year = l_lastmth+0(4).
l_month = l_lastmth+4(2).
l_month = l_month - 1.
CONCATENATE lv_year l_month INTO lastmth.
l_s_range-low = lastmth .
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
exit.
CLEAR: lastmth.
endloop.
ENDCASE. "(I_STEP)
ENDCASE. "(I_VNAM) ENDFORM.
use the sequence...
if i_step =2....
case...
when var...
declare variable...
loop...
concatenate..
clear...
append...
endloop.
endcase.
endif.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try changing the BOLD ones:
CASE i_vnam.
WHEN 'ZCALMONTH2'.
CASE i_step.
WHEN 2.
DATA: loc_var_range Type rrrangeexit.
DATA: l_lastmth TYPE sy-datum.
DATA: lastmth(6) TYPE c,
LV_YEAR(4) TYPE C,
L_MONTH(2) TYPE C.
CLEAR l_s_range.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZCAL_DAY'.
lv_year = loc_var_range-low+0(4).
l_month = loc_var_range-low+4(2).
l_month = l_month - 1.
CONCATENATE lv_year l_month INTO lastmth.
l_s_range-low = lastmth .
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
exit.
CLEAR: lastmth.
endloop.
ENDCASE. "(I_STEP)
ENDCASE. "(I_VNAM) ENDFORM.
But I think the code won't work for month of JANUARY of any year..
Just this revised code:
CASE i_vnam.
WHEN 'ZCALMONTH2'.
CASE i_step.
WHEN 2.
DATA: loc_var_range Type rrrangeexit,
temp_day type d,
temp_calmonth(6) type c.
CLEAR l_s_range.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZCAL_DAY'.
concatenate loc_var_range-low(6) '01' into temp_day.
temp_day = temp_day - 1.
temp_calmonth = temp_day(6).
l_s_range-low = temp_calmonth.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
exit.
CLEAR: lastmth.
endloop.
ENDCASE. "(I_STEP)
ENDCASE. "(I_VNAM) ENDFORM.
RESULT of the revised code will give you the PREVIOUS MONTH based on the entered CALDAY..
So if you entered 10/30/2015 you will have value of ZCALMONTH2 = 201509.
Regards,
Loed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Then use this:
DATA: loc_var_range Type rrrangeexit,
temp_day type d,
temp_calmonth(6) type c.
CASE i_vnam.
WHEN 'ZCALMONTH2'.
if i_step = 2.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZCAL_DAY'.
CLEAR l_s_range.
concatenate loc_var_range-low(6) '01' into temp_day.
temp_day = temp_day - 1.
temp_calmonth = temp_day(6).
l_s_range-low = temp_calmonth.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
exit.
endloop.
endif.
ENDCASE.
Regards,
Loed
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.