Hi Loed,
Thanks for the great explanation. I am indeed greateful. I ow you a treat
With the help of your previous explanation, i tried to write a code for another requirement also. Please see the below code and correct me if i am wrong.
Requirement: If user enters a date, he should get data of a month earlier (Month - 1) and month later (Month +1).
If he enters feb 15th 2014, he should get data from Jan and march also.
Data: Month type sy-datum
month1 type sy-datum
LT_VAR_PRE type i
LT_VAR_NEXT type i
When IT_VAR_MONTH "Our variable on month"
If I_STEP = 2
Loop at I_T_VAR_RANGE into I_S_VAR_RANGE where VNAME = ZVAR1_DAT "HERE I HAVE ENTERED DATE"
Month = I_S_VAR_RANGE + 4(2)
Month = Month -1 " Here Jan data would come"
Month1 = Month + 1 "Here March data would come"
Concatenate I_S_VAR_RANGE +0(4) MONTH INTO LT_VAR_PRE " For previous month i.e jan"
Concatenate I_s_VAR_RANGE + 0(4) MONTH1 Into LT_VAR_NEXT " For next month i.e march"
L_S_RANGE-LOW = LT_VAR_PRE
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
L_S_RANGE - High = I_S_VAR_RANGE
"By doing the above statement it will get current and previous month data"
L_S_RANGE-LOW = I_S_VAR_RANGE "Current month"
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
L_S_RANGE - High =LT_VAR_NEXT " Next month"
"By doing the above statement it will get current and next month data"
APPEND L_S_RANGE TO E_T_RANGE.
Thanks,
Karthik.