on 04-28-2015 11:28 PM
Hi Guys,
In the customer exit code for Fiscal week, I have written a code as below. However Could you please tell me what value should I use in 'VNAM' field in the below Loop statement.
I am creating a customer exit variable on characteristic 'ZFISCWEEK'. I think in the below loop statement, I am supposed to use 'ZFISCWEEK' for VNAM? but the I am getting null values in the BEx report.
But if I use '0DAT' in place of 'ZFISCWEEK' for VNAM below in the code.. it's working perfect . Isn't it strange? or am I wrong? We are on BW 7.4 version. Any comments will be appreciated.
WHEN 'ZFISCWEEK'.
IF i_step = 2.
_ _ _ _
_ _ _ _
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = '0DAT'.
loc_var_range-low = C_week.
l_s_range-low = loc_var_range-low.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
EXIT.
ENDLOOP.
ENDIF.
ENDCASE.
Hi Ricky,
What is your logic to calculate C_week?
The internal table 'i_t_var_range' will be used to read values from other variables in the query.
Does your logic need you to read values from other variables? If yes then, the variable name from which you will read values should be passed to VNAM.
e.g. derive fiscal week from user entered date
Assuming Date variable used in Query is VAR1. then
WHEN 'ZFISCWEEK'.
IF i_step = 2.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'VAR1'.
C_week = Derive_week_from_date ( loc_var_range-low).
loc_var_range-low = C_week.
l_s_range-low = loc_var_range-low.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
EXIT.
ENDLOOP.
ENDIF.
ENDCASE.
If you have a logic that is independant of any other variable of the query, then you do not need to use internal table 'i_t_var_range' at all.
e.g. derive fiscal week from system date.
WHEN 'ZFISCWEEK'.
IF i_step = 2.
C_week = Derive_week_from_date ( sy-datum).
l_s_range-low =C_week.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
EXIT.
ENDIF.
ENDCASE.
Table e_t_range will be applied to the Variable for which exit is written which is ZFISCWEEK.
Hope this is clear.
-Swati.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Swati,
I am just trying to get Current Fiscal week based on system date. Fiscal week doesn't have a standard infoobject so I created one and based on that I am creating a customer exit variable to get current fiscal week. Here is my complete code. I am not an abaper hence pls ignore the formatting .
WHEN 'ZC_FISCWEEK'.
IF i_step = 2.
REFRESH e_t_range.
CLEAR: l_s_range,loc_var_range.
** Data declaration for Fiscal Week variable
DATA: year(4) TYPE n,
date1 LIKE sy-datum,
date2 LIKE sy-datum,
days TYPE p,
weeks(2) TYPE n,
C_week(6) TYPE n,
number(2) TYPE n,
fiscv(2) TYPE c,
lv_buper TYPE t009b-poper.
CLEAR: year,
date1,
date2,
days,
weeks,
number,
fiscv.
date2 = sy-datum.
fiscv = 'Z4'.
**Get the Year from Date
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = date2
* I_MONMIT = 00
i_periv = fiscv
IMPORTING
e_buper = lv_buper
e_gjahr = year
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'FIRST_AND_LAST_DAY_IN_YEAR_GET'
EXPORTING
i_gjahr = year
i_periv = fiscv
IMPORTING
e_first_day = date1
* E_LAST_DAY = DATE2
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
IF sy-subrc <> 0.
ENDIF.
**Get the rounded off value to get the total number of weeks.
days = ( date2 - date1 ) + 1.
* days = days + 1.
weeks = days / 7.
number = days MOD 7.
IF number > 0 AND number < 4.
weeks = weeks + 1.
ENDIF.
**Get the Fiscal week for an input date by concatenating Year and Week
*found in above step
CONCATENATE year weeks INTO C_week.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = '0DAT'.
loc_var_range-low = C_week.
l_s_range-low = loc_var_range-low.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
EXIT.
ENDLOOP.
ENDIF.
Hi Ricky,
I understand that you are not an ABAPer so let me explain this to you.
'i_t_var_range' is an internal table which carries values and names of the variables that you are currently running. If your customer exit value depends on any of the values in those variables then and then only you need to read this table with variable name that you want to use.
e.g. Derive Age from Date of birth. When user enters the date of birth the selection screen and executes the query, the customer exit code (I_step = 2) will start executing. as the Age calculation depends on the Date of birth enetered by the user, we will need to read it from table 'i_t_var_range'. we DON'T NEED to read this table if our customer exit code is independent of values in the other variables of the query being executed.
as per me, all your code is correct. Only in the last 10 statements you need below change, because you do not need to read any variable value.
Current Code:
CONCATENATE year weeks INTO C_week.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = '0DAT'.
loc_var_range-low = C_week.
l_s_range-low = loc_var_range-low.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
EXIT.
ENDLOOP.
ENDIF.
Correct code:
CONCATENATE year weeks INTO C_week.
l_s_range-low = C_week.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
EXIT.
ENDLOOP.
ENDIF.
Please let me know if you face any issues.
-Swati.
Hi Ricky,
As I have said above, no need to use the LOOP statement since you derive your FISCAL WEEK based on SYSTEM DATE..
Follow the correction in your code by Swati..
You will use the LOC_VAR_RANGE-LOW and/or LOC_VAR_RANGE-HIGH when you want to derive something based on the input of the user..
Regards,
Loed
Hi Swati,
You are correct. I already figured out yesterday that I am not inputting any values in the variable and I am using system date to calculate current week. So in that case I don't need to read input values and use the loop statement as well. I had made the changes and it's working.
Thanks v much to all of you for your prompt responses.
Regards,
Ricky
Hi,
'0DAT' is not customer exit varaible and how you are passing the '0DAT'. into variable name.
create customer exit pass it there.
Thanks,
Phani.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's strange 0DAT is not even an infoobject in BW. When I use the original variable VNAM = 'ZC_FISCWEEK' I am getting short dump in RSRT and when I switch back to VNAM = 0DAT it working perfectly even for other YTD & QTD customer exit variables. What's going on here?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
But if I use '0DAT' in place of 'ZFISCWEEK' for VNAM below in the code.. it's working perfect . Isn't it strange? or am I wrong? We are on BW 7.4 version.
The processing type of 0DAT is manual input( not customer exit ) if that is the case means how it will work correctly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Your code.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = '0DAT'.
loc_var_range-low = C_week.
l_s_range-low = loc_var_range-low.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
EXIT.
ENDLOOP.
ENDIF.
ENDCASE.
With the loop statement you will get the values entered in 0DAT variable into loc_var_range.
loc_var_range-low = C_week. " this statement is not clear.
loc_var_range-low will gives the value entered for 0DAT.
then use this value to get the week.
C_week = Derive_week_from_date (loc_var_range-low ).
Then the code needs to be like below.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = '0DAT'.
C_week = Derive_week_from_date (loc_var_range-low ).
l_s_range-low = C_WEEK
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
EXIT.
ENDLOOP.
ENDIF.
ENDCASE.
Regards,
Sai
Hi Ricky,
The value in VNAM must be the variable where the user enters date..
ZFISCWEEK must be the customer exit type variable..
0DATA must be the user entry variable..
If that's the case, your code must work fine assuming that C_WEEK has the correct value..
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 Loed,
ZFISCWEEK is the customer exit variable which I am trying to create. I was trying to use it for VNAM but it's not working. That's why I tried 0DAT.
There is no user entry for this as I am trying to calculate Current Fiscal week based on the system date.
Do you think that due to system date it is accepting 0DAT as VNAM?
Thanks,
Ricky
User | Count |
---|---|
98 | |
11 | |
11 | |
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.