Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Logic in Transformations-Start or Field Routine ENHANCEMENT

Former Member
0 Kudos

Hi

Currently i am calculacting age of an employee in years and months using FM.

Source Object (DOB) is DATS and

Target object (age) is Char (6)

My requirment is to show age in YY.MM

If an employee age is 65Y,8M..then it shoud be displayed as 65.08.

If an employee age is 5Y,8M..then it shoud be displayed as 05.08

The below code is working fine for the above sceaniro...

BUT i need to enhance the code for

If an employee age is 100Y,8M..then it shoud be displayed as 100.08 and

If an employee age is 65Y,8M..then it shoud be displayed as 65.08.

Please update me how to proceed

DATA: YEARS TYPE TFMATAGE,

MONTHS TYPE TFMATAGE.

DATA: Y_NUM(4) TYPE N,

M_NUM(2) TYPE N.

IF NOT SOURCE_FIELDS-/BIC/ZDOB IS INITIAL.

CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

EXPORTING

I_DATE_FROM = SOURCE_FIELDS-/BIC/ZDOB

I_DATE_TO = SY-DATUM

I_FLG_SEPARATE = 'X'

IMPORTING

E_MONTHS = MONTHS

E_YEARS = YEARS.

Y_NUM = YEARS.

M_NUM = MONTHS.

CONCATENATE Y_NUM+2(2) '.' M_NUM INTO RESULT.

ENDIF.

1 ACCEPTED SOLUTION

franois_henrotte
Active Contributor
0 Kudos

piece of cake...

replace


CONCATENATE Y_NUM+2(2) '.' M_NUM INTO RESULT.

with


IF y_num GE 100.
  CONCATENATE Y_NUM+1(3) '.' M_NUM INTO RESULT.
ELSE.
  CONCATENATE Y_NUM+2(2) '.' M_NUM INTO RESULT.
ENDIF.

1 REPLY 1

franois_henrotte
Active Contributor
0 Kudos

piece of cake...

replace


CONCATENATE Y_NUM+2(2) '.' M_NUM INTO RESULT.

with


IF y_num GE 100.
  CONCATENATE Y_NUM+1(3) '.' M_NUM INTO RESULT.
ELSE.
  CONCATENATE Y_NUM+2(2) '.' M_NUM INTO RESULT.
ENDIF.