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: 

FM to get employee list who is having birthday on a given period

Former Member
0 Kudos

Hi  all,

I am inputting a period for example..

01.01.2013                   to                31.12.2013.

i need to display all employees having birthday in this month or between the given period.

Is there any FM to do this?

regards,

Alenlee MJ

1 ACCEPTED SOLUTION

Former Member
0 Kudos

I also tried but found no FM for this.

You can refer below code which we had used when we had a similar requirement.

   ****CALCULATE NO.OF DAYS BETWEEN START DATE AND END DATE
  CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
    EXPORTING
      BEGDA = LV_BEGDA
      ENDDA = LV_ENDDA
    IMPORTING
      DAYS  = LV_COUNT.

  LV_DATE = LV_BEGDA.


****POPULATE TABLE LT_DATE WITH THE ALL THE DATES BETWEEN START DATE AND END DATE
  DO LV_COUNT TIMES.
    LS_DATE-GBMON = LV_DATE+4(2).         " MONTH
    LS_DATE-GBTAG = LV_DATE+6(2).         " DATE
    APPEND LS_DATE TO LT_DATE.
    CLEAR  LS_DATE.
    LV_DATE = LV_DATE + 1.
  ENDDO.


****FETCH RECORDS OF EMPLOYEES WHOSE BIRTHDAY OCCUR IN THE DATES IN THE ABOVE POPULATED INTERNAL TABLE
  SELECT GBJHR
         GBMON
         GBTAG
         PERNR
         BEGDA_0002
         ENDDA_0002
    FROM M_PREMG
    INTO TABLE LT_PREMG
    FOR ALL ENTRIES IN LT_DATE
    WHERE GBMON = LT_DATE-GBMON AND
          GBTAG = LT_DATE-GBTAG AND
          ENDDA_0002 GE SY-DATUM AND
          BEGDA_0002 LE SY-DATUM.

2 REPLIES 2

former_member192023
Active Participant
0 Kudos

Hi Alenlen, It is not a FM. You may check field GBDAT(Birth date) of table pa0002 in tr-code se16. You can key in the period in this field. Regards.

Former Member
0 Kudos

I also tried but found no FM for this.

You can refer below code which we had used when we had a similar requirement.

   ****CALCULATE NO.OF DAYS BETWEEN START DATE AND END DATE
  CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
    EXPORTING
      BEGDA = LV_BEGDA
      ENDDA = LV_ENDDA
    IMPORTING
      DAYS  = LV_COUNT.

  LV_DATE = LV_BEGDA.


****POPULATE TABLE LT_DATE WITH THE ALL THE DATES BETWEEN START DATE AND END DATE
  DO LV_COUNT TIMES.
    LS_DATE-GBMON = LV_DATE+4(2).         " MONTH
    LS_DATE-GBTAG = LV_DATE+6(2).         " DATE
    APPEND LS_DATE TO LT_DATE.
    CLEAR  LS_DATE.
    LV_DATE = LV_DATE + 1.
  ENDDO.


****FETCH RECORDS OF EMPLOYEES WHOSE BIRTHDAY OCCUR IN THE DATES IN THE ABOVE POPULATED INTERNAL TABLE
  SELECT GBJHR
         GBMON
         GBTAG
         PERNR
         BEGDA_0002
         ENDDA_0002
    FROM M_PREMG
    INTO TABLE LT_PREMG
    FOR ALL ENTRIES IN LT_DATE
    WHERE GBMON = LT_DATE-GBMON AND
          GBTAG = LT_DATE-GBTAG AND
          ENDDA_0002 GE SY-DATUM AND
          BEGDA_0002 LE SY-DATUM.