Former Member

ABAP Logic in Transformations-Start or Field Routine ENHANCEMENT

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.

10|10000 characters needed characters exceeded

Related questions

Posted on Jun 17, 2008 at 03:53 PM

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.
```