Hi BI Gurus,
Currently, I need to display the records from 1st of the month to date entered by the user in the selection screen.
Eg,
User Entered Date : 23.06.2011
Report should display from: 01.06.2011 to 23.06.2011
I have created Customer Exit Variable "ZVAR_1ST_DAY" with Customer Exit (optional) for 0CALDAY inside the structure.
DATA:
l_s_range TYPE rrrangesid,
loc_var_range LIKE rrrangeexit,lv_month TYPE d,
lv_year(4) TYPE n,
lv_first_day TYPE sy-datum,
lv_last_day TYPE sy-datum.
*To Calculate First Day of the Month
CASE i_vnam.
WHEN 'ZVAR_1ST_DAY'.
IF i_step = 2.
LOOP AT i_t_var_range into loc_var_range WHERE vnam = 'ZVAR_1ST_DAY'.
lv_month = loc_var_range-low+4(2).
lv_year = loc_var_range-low+0(4).
CONCATENATE lv_year lv_month '01' INTO lv_first_day.
CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
day_in = lv_first_day
IMPORTING
last_day_of_month = lv_last_day.
l_s_range-low = lv_first_day.
l_s_range-high = lv_last_day.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
ENDIF.
ENDCASE.
Although there are no syntax error, but I am not sure is it working, I have limited knowledge in ABAP, can anyone please help me on this codes?
or any advice on how to change this would be great.
Many thanks,
Vince
The quick way to check the value for this variable is to execute the query in RSRT with HTML option. In the result screen click on the "Info" to view the variable values
hope this help
Thanks for the advice,
We are able to find out what is the cause.
The latest code seems to be okay in RSRT, however it displayed error:-
Error for variable in customer enhancement ZVAR_1ST_DAY
Message no. BRAIN649
Diagnosis
This internal error is an intended termination resulting from an illegal program status.
The error occuured for variable in customer enhancement ZVAR_1ST_DAY.
Procedure
Check your customer enhancement.
WHEN 'ZVAR_1ST_DAY'.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'CAL_DAY'.
lv_month = loc_var_range-low+4(2).
lv_year = loc_var_range-low+0(4).
CONCATENATE lv_year lv_month '01' INTO lv_first_day.
lv_last_day = loc_var_range-low.
l_s_range-low = lv_first_day.
l_s_range-high = lv_last_day.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
Any advice on what may be wrong in the codes above would be greatly appreciated.
Many thanks,
Vince
Hi
U have to create 2 variable . One variable with processing type manual entry ( let say the variable u defined is 'zvar_me' ) and the another variable with processing type customer exit ( let say the variable u created is ' zvar_ce') . Now replace the above code with
when 'zvar_ce'.' here u have to give the variable name with processing type customer exit.
if i_step = 2.
read table i_t_var_range into loc_var_range with key vnam = 'zvar_me'. " here u have to give the variablename with processing type manual entry.
...
...
...
..
endif.
AND THEN EXECUTE THE ABOVE CODE. it will display the output revert back in case of any queries.
Hope u got it,
Regard,
RaviChandra
Hi Ravi,
Thanks for the advice, I am not entirely understand what you explained.
But I have found out another way to get the first day of the month till the day User entered
Just to share to whoever need this in the future:-
In the BEx, create a Customer Exit Variables (ZVAR_1ST_DAY).
Then put the following code below in Customer Exit CMOD.
WHEN 'ZVAR_1ST_DAY'.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'CAL_DAY'.
lv_month = loc_var_range-low+4(2).
lv_year = loc_var_range-low+0(4).
CONCATENATE lv_year lv_month '01' INTO lv_first_day.
lv_last_day = loc_var_range-low.
l_s_range-low = lv_first_day.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
Then in Query Definition.
Under the Date, add Value Range for ZVAR_1ST_DAY - CALDAY.
Kind regards,
Vince
Hi
May i know in which step u did not get.
Regards,
RaviChandra
Hi Ravi,
Thanks for the kind offer to help, the part I am not sure of is as following:-
You mentioned that I should create 2 variables, right?
1. Manual Entry (ZVAR_ME)
2. Cust Exit (ZVAR_CE)
After I create ZVAR_ME, you mentioned that
when 'zvar_ce'.' here u have to give the variable name with processing type customer exit.
if i_step = 2.
I am not sure what "give the variable name with processing type customer exit means."
Kindly please elaborate further.
Many thanks,
Vince
Hi
In the when statement u have to give the variable name with processing type customer exit . Because the variable with processing type customer exit will be invoked during the execution of the query.
Because of that u have to pass the customer exit variable in the when statement.
Hope u got it,
Revert back in case of any query,
Regards,
RaviChandra
Hi Ravi,
If you have time to spare, can you please have a look on this issue that I have just raised?
http://scn.sap.com/message/13336269#13336269
Really appreciated any help at all.
Many thanks,
Vince