Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
You are here to learn the ABAP field routine to convert 0CALMONTH to ZFISQRT.

 

In this blog we are using Fiscal Variant as V3, means our Fiscal year will start from April to March.

Also ZFISQRT is the custom generated object as per the requirement.

 

We have a 0CALQUARTER value as (20141, 20142, 20143, 20154,20163, etc.) from this calendar

quarter we have to define the ZFISQRT (Fiscal Quarter) then we write that code in field routine.

 

0CALQUARTER -------------> filed routine ------------>  ZFISQRT

 

Step 1 : Map 0CALQUARTER from source to target with ZFISQRT in transformation.

Then, Right Click on ZFISQRT in target of transformation and select the Rule details option.

Rule Details -


 

Step 2 : Select Rule Type as Routine as mentioned in above screen.

Step 3 : Write the below code to convert 0CALMONTH to ZFISQRT in field routine as -

 
DATA: YEAR(4) TYPE N, //Declaring YEAR with length 4 of TYPE N.
QUARTER(1) TYPE N. //Declaring QUARTER with length 1 of TYPE N.

YEAR = SOURCE_FIELDS-CALQUARTER+0(4).

// Here we calculate YEAR from 0CALQUARTER.

QUARTER = SOURCE_FIELDS-CALQUARTER+4(1).

// Here we calculate only QUARTER from 0CALQUARTER.

// Below is the logic to calculate fiscal year quarter from calendar quarter.

IF QUARTER = 1.
RESULT = YEAR - 1.
CONCATENATE RESULT '4' into RESULT.

ELSEIF QUARTER = 2.
RESULT = YEAR.
CONCATENATE RESULT '1' into RESULT.

ELSEIF QUARTER = 3.
RESULT = YEAR.
CONCATENATE RESULT '2' into RESULT.

ELSEIF QUARTER = 4.
RESULT = YEAR.
CONCATENATE RESULT '3' into RESULT.
ENDIF.

 


 























0CALQUARTER (INPUT) ZFISCQRT (OUTPUT)
20142 20141
20143 20142
20144 20143
20141 20144


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 0CALMONTH (Calendar month) to ZFISQRT (Fiscal Quarter). It’s a complete customization to convert Calendar Month to Fiscal Quarter. In next some blogs you will get so many routine code for time characteristics conversion.

 

 
3 Comments