Hello Everyone,
Actually i want to calculate the retirement time left of each employee. Can anyone tell how would i calculate?
Say my field which will have the calculated result will be RAGE and CAGE is the current age of employee.
And say 60 years would be the retirement age and say table will be zemp.
Then i should do something like this:
ZEMP-RAGE = 60 - (ZEMP-CAGE).
But how will i display with exactly months, years and day's left on screen? Please guide.
Thanks for writing back,
Regards,
Lucky
Follow these steps-
1) Firstly add 60 years(in your case) to the birth date of the employee using FM--"HR_99S_DATE_PLUS_TIME_UNIT"
This gives you the exact retirement date of the employee, say RDATE
What you want is the time left for his retirement. So,
2) Subtract the current date(sy-datum) FROM RDATE. Use these Fms for that--
FIMA_DAYS_AND_MONTHS_AND_YEARS
FIMA_DECIMAL_MONTHS_AND_YEARS
or /SDF/CMO_DATETIME_DIFFERENCE
So you finally have the time for employee to retire.
Hope this helps,
Regards,
Sumit Nene.
Edited by: Sumit Nene on Aug 6, 2009 12:30 PM
Actually i have added 21900 instead of addin 60.
I was adding like
zemp-rdate = 60+zemp-bdate.
It was just adding 60 days instead of "years".
Then i thought i should make use of 60 in terms of yyyymmdd form then i tried 00600000 so as to add 60 as an year and nothing as a month or a day. But it hasn't worked it either.
Then i finally calculated it:
365 days in an year Multiplied by 60 years = 21900 and i added that to birthdate and then got the final answer but i haven't excluded leap years yet if i do then it will need some more mathematics into it but that's enough i guess.
Thanks everyone for writing back,
Regards,
Lucky
Add a comment