09-12-2007 12:19 PM
Hi Experts,
I am working on Asset Management.I need to get current fiscal year.
I have to enter fiscal year on selections screen which i have to validate that it should not be greater than current fiscal year.
For above i have used following code snippet but i have hard coded variant as 'MK'.
To get variant i was using function '/IBS/RB_FI_GET_FISCAL_YEAR_VAR' but in my selection screen we have to enter multiple company codes. if i will keep this function inside loop then it may give multiple variants.
How to resolve this ?
DATA : l_year(4) type c,
l_date TYPE sy-datum.
CALL FUNCTION '/IBS/RB_FI_GET_FISCAL_YEAR_VAR'
EXPORTING
i_company_code =
IMPORTING
E_FISCAL_YEAR_VARIANT =
EXCEPTIONS
COMPANY_CODE_NOT_FOUND = 1
OTHERS = 2.
*
l_date = sy-datum - 700.
l_date = l_date + 1.
IF sy-subrc EQ 0.
CALL FUNCTION 'GM_GET_FISCAL_YEAR'
EXPORTING
I_DATE = l_date
i_fyv = 'MK'
IMPORTING
E_FY = l_year
EXCEPTIONS
FISCAL_YEAR_DOES_NOT_EXIST = 1
NOT_DEFINED_FOR_DATE = 2
OTHERS = 3.
IF sy-subrc EQ 0.
IF s_gjahr-low GT l_year.
PRINT Error Message "Entered fiscal year should not be greater than current fiscal year".
ENDIF.
ENDIF.
09-12-2007 12:22 PM
Hi,
Here is the function module which returns the Current Fiscal year
GET_CURRENT_YEAR
Regards
Sudheer
09-12-2007 12:22 PM
Fiscal year idepend on contry. So based on ur client , get the fiscal year info.
rewards if helpful.
09-12-2007 12:24 PM
CALL FUNCTION <b>'GET_CURRENT_YEAR'</b>
EXPORTING
BUKRS = '1000' " Company Code
DATE = SY-DATUM " Date to find fiscal year for
IMPORTING
CURRM = w_currm " Current Fiscal Month
CURRY = w_curry " Current Fiscal Year
PREVM = w_prevm " Previous Fiscal Month
PREVY = w_prevy. " Previous Fiscal Year
09-12-2007 12:35 PM
Hi,
Your observation is correct. Since the variant is stored in T001 whose key is the company code. Hence if your input has got say 5 different co codes, they as you rightly pointed out you may get 5 differrnt variants for co codes keyed in by the user. So you will have to do the validation 5 times, one for each company code with the corresponding variant.
I hope this helps,
Regards
Raju Chitale
09-12-2007 1:23 PM
make it simpler by using - DATE_TO_PERIOD_CONVERT
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
I_DATE = SY-DATUM
I_PERIV = L_VARI "Fiscal year Variant - refer to tab T009B
IMPORTING
E_BUPER = L_BUPER " Fiscal Period
E_GJAHR = L_GJAHR " Fiscal year
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4
Hope this will solve ur problem.