Skip to Content
author's profile photo Former Member
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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    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.
    

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.