You are here to learn the ABAP field routine to convert 0CALMONTH to ZFISQRT.
We have a 0CALMONTH2 (01, 02, 03.…..12) & 0CALYEAR (2014, 2016, 2017, 2020, etc.) in the DSO from this we have to calculate the 0FISCPER (Fiscal Period) in our Infocube then we write that code in field routine of transformation. Check the below transformation between DSO to Infocube.
Step 1 : Map 0CALMONTH2 & 0CALYEAR from source to target with 0FISCPER in transformation.
Then, Right Click on 0FISCPER in target of transformation and select the Rule details option.
Step 2 : Select Rule Type as Routine as mentioned in above screen.
Step 3 : Write the below code to convert 0CALMONTH2 & 0CALYEAR to 0FISCPER in field routine as –
Kod:
DATA : MONTH(2) TYPE N,
YEAR(4) TYPE N,
YEAR1(4) TYPE N.
MONTH = SOURCE_FIELDS-CALMONTH2.
YEAR = SOURCE_FIELDS-CALYEAR.
YEAR = YEAR - 1.
YEAR1 = SOURCE_FIELDS-CALYEAR.
IF MONTH EQ 01.
CONCATENATE YEAR '010' into RESULT.
ELSEIF MONTH EQ 02.
CONCATENATE YEAR '011' into RESULT.
ELSEIF MONTH EQ 03.
CONCATENATE YEAR '012' into RESULT.
ELSEIF MONTH EQ 04.
CONCATENATE YEAR1 '001' into RESULT.
ELSEIF MONTH EQ 05.
CONCATENATE YEAR1 '002' into RESULT.
ELSEIF MONTH EQ 06.
CONCATENATE YEAR1 '003' into RESULT.
ELSEIF MONTH EQ 07.
CONCATENATE YEAR1 '004' into RESULT.
ELSEIF MONTH EQ 08.
CONCATENATE YEAR1 '005' into RESULT.
ELSEIF MONTH EQ 09.
CONCATENATE YEAR1 '006' into RESULT.
ELSEIF MONTH EQ 10.
CONCATENATE YEAR1 '007' into RESULT.
ELSEIF MONTH EQ 11.
CONCATENATE YEAR1 '008' into RESULT.
ELSEIF MONTH EQ 12.
CONCATENATE YEAR1 '009' into RESULT.
ENDIF.
0CALMONTH (INPUT) | 0CALYEAR (INPUT) | 0FISCPER (OUTPUT) |
12 | 2014 | 2014009 |
1 | 2015 | 2014010 |
4 | 2016 | 2016001 |
10 | 2017 | 2017007 |
Step 4 : Save the routine and transformation. Run your DTP and check the above table from Input data to Output data.
Conclusion : In the above blog post you have learned about the ABAP field routine code to convert 0CALMONTH2 (Calendar month) & 0CALYEAR (Calendar Year) to 0FISCPER (Fiscal Period). It’s a complete customization to convert Calendar Month and Year to Fiscal Period. In next some blogs you will get so many routine code for time characteristics conversion.
Okumaya devam et...