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: 

HR Calendar

Former Member
0 Kudos
89

hi can any one tell me how to find No. of working days between 2 dates using HR CALENDAR ??

Eg:

DATE 1 - 21/03/2007

DATE 2 - 29/11/2007

Country - TH (Thailand)

No of working days ?

Title was edited by:

Alvaro Tejada Galindo

3 REPLIES 3

Former Member
0 Kudos
52

hi

good

HR_IE_NUM_PRSI_WEEKS Return the number of weeks between two dates.

RP_CALC_DATE_IN_INTERVAL Add/subtract years/months/days from a date

SD_DATETIME_DIFFERENCE Give the difference in Days and Time for 2 dates

<b><REMOVED BY MODERATOR></b>

thanks

mrutyun^

Message was edited by:

Alvaro Tejada Galindo

Former Member
0 Kudos
52

HI,

You will find the Holiday calendar --> SCA2 and Factory calendar --> SCA3 transaction code, there find the Factory calender for Thailand, then use the below function module to find the number of working days

WDKAL_DATE_ADD_FKDAYS.

Regards

Sudheer

Former Member
0 Kudos
52

Hi,

Use the below code.

DATA: v_week1 LIKE scal-week,

v_week2 LIKE scal-week.

DATA: v_work_days like MDCAL-ANZFD,

v_total_work_days like MDCAL-ANZFD,

v_wotnr type p.

CALL FUNCTION 'DATE_GET_WEEK'

EXPORTING

date = '20070321'

IMPORTING

week = v_week1

EXCEPTIONS

date_invalid = 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.

ENDIF.

CALL FUNCTION 'DATE_GET_WEEK'

EXPORTING

date = '20071129'

IMPORTING

week = v_week2

EXCEPTIONS

date_invalid = 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.

ENDIF.

clear v_wotnr.

CALL FUNCTION 'DAY_IN_WEEK'

EXPORTING

datum = '20070321'

IMPORTING

WOTNR = v_wotnr.

if v_wotnr le 5.

v_total_work_days = v_total_work_days + ( 5 - v_wotnr ) + 1.

endif.

clear v_wotnr.

CALL FUNCTION 'DAY_IN_WEEK'

EXPORTING

datum = '20071129'

IMPORTING

WOTNR = v_wotnr.

if v_wotnr le 5.

v_total_work_days = v_total_work_days + v_wotnr.

endif.

v_week1 = v_week1 + 1.

v_week2 = v_week2 - 1.

while v_week1 le v_week2.

clear v_work_days.

CALL FUNCTION 'WEEK_GET_NR_OF_WORKDAYS'

EXPORTING

WEEK = v_week1

  • DAY = DAY

fabkl = 'US' "Give Thailand ID here

  • REST_OF_WEEK = REST_OF_WEEK

IMPORTING

NR_OF_WORKDAYS = v_work_days

EXCEPTIONS

WEEK_INVALID = 1

DAY_INVALID = 2

FABKL_INVALID = 3

FABKL_EMPTY = 4

OTHERS = 5

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

v_total_work_days = v_total_work_days + v_work_days.

v_week1 = v_week1 + 1.

endwhile.

write:/ 'Number of working days = ', v_total_work_days.