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: 

To calculate Service as on date

former_member383741
Participant
0 Kudos
143

Hi,

I want to calculate the service as on date.

Employee No                     Employee Name                                  Date of joining                                      Service as on date
1000                                    XXXXXXX                                        01.06.2004                                            5 Years 3 months
2000                                  yyyyyyyyyyyyy                                01.08.2008                                            1 year 1 month


Is there any function module.
can you help me.

Regards,

K.Karthikeyan.

Edited by: Karthikeyan Krishnan on Sep 8, 2009 5:31 PM

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos
90

In your case just pass the employee join date and current date.

I think this is what you want


data:wa_output type PSEN_DURATION_DEC.

CALL FUNCTION 'HR_SEN_CRULE_0100_DURATION'
  EXPORTING
    id_begda                       = dat1  "service join data
    id_endda                       = sy-datum  "current date
 IMPORTING
   ES_DURATION                     = wa_output
 EXCEPTIONS
   CONVERSION_NOT_SPECIFIED       = 1
   CONVERSION_NOT_POSSIBLE        = 2
   OTHERS                         = 3
          .
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
else.
  write:/ 'Years', wa_output-CALYY  DECIMALS 0,
        / 'Months',wa_output-CALMM  DECIMALS 0,
        /'Days', wa_output-CALDD    DECIMALS 0.
ENDIF. 

Edited by: Keshu Thekkillam on Sep 8, 2009 5:42 PM

4 REPLIES 4

Former Member
0 Kudos
90

Hi,

Use FM : FIMA_DAYS_AND_MONTHS_AND_YEARS

Example:

I_DATE_FROM 01.06.2004

I_DATE_TO 08.09.2009

I_FLG_SEPARATE X

Export parameters Value

E_DAYS 7

E_MONTHS 3

E_YEARS 5

Regds,

Anil

kesavadas_thekkillath
Active Contributor
0 Kudos
91

In your case just pass the employee join date and current date.

I think this is what you want


data:wa_output type PSEN_DURATION_DEC.

CALL FUNCTION 'HR_SEN_CRULE_0100_DURATION'
  EXPORTING
    id_begda                       = dat1  "service join data
    id_endda                       = sy-datum  "current date
 IMPORTING
   ES_DURATION                     = wa_output
 EXCEPTIONS
   CONVERSION_NOT_SPECIFIED       = 1
   CONVERSION_NOT_POSSIBLE        = 2
   OTHERS                         = 3
          .
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
else.
  write:/ 'Years', wa_output-CALYY  DECIMALS 0,
        / 'Months',wa_output-CALMM  DECIMALS 0,
        /'Days', wa_output-CALDD    DECIMALS 0.
ENDIF. 

Edited by: Keshu Thekkillam on Sep 8, 2009 5:42 PM

Former Member
0 Kudos
90

Hi Karthikayan,

use this FM.

HR_99S_INTERVAL_BETWEEN_DATES

I hope this will help you.

Regards,

Vijay

Former Member
0 Kudos
90

CALL FUNCTION 'HR_SGPBS_YRS_MTHS_DAYS'

EXPORTING

beg_da = wa_mara_month-mstde

end_da = wa_mara_month-ersda

IMPORTING

no_cal_day = l_days

EXCEPTIONS

dateint_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.