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: 

Regarding Working days

Former Member
0 Kudos

hi all,

How to calculate no of working days in a month.

I Used FM "RKE_SELECT_FACTDAYS_FOR_PERIOD"

with this i am getting all the days in a month.

but with that i am not getting working days.

Please suggest what will be the problem.

Regards

Reddy.

5 REPLIES 5

Former Member
0 Kudos

check this link

0 Kudos

Good one KPN....

Former Member
0 Kudos

use FMs

DATE_CHECK_WORKINGDAY

HR_E_GET_SI_DAYS_TO_WORK

WLB3_GET_NUMBER_OF_WORKDAYS

Regarding your code, do this:

DATA: it_days LIKE STANDARD TABLE OF rke_dat .

SELECT SINGLE fabkl INTO calendar_code FROM t001w CLIENT

SPECIFIED WHERE mandt = sy-mandt AND werks = plant.

CALL FUNCTION 'RKE_SELECT_FACTDAYS_FOR_PERIOD'

EXPORTING

i_datab = first_date

i_datbi = last_date

i_factid = calendar_code

TABLES

eth_dats = it_days

EXCEPTIONS

date_conversion_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.

ENDIF.

DESCRIBE TABLE it_days LINES working_days.

kesavadas_thekkillath
Active Contributor
0 Kudos

This is a duplicate post...which was answered by u itself....

Whatz going on.....

and dear jeet..

Do indicate the therad link here instead of copying others code...

link:

Former Member
0 Kudos

Hi ,

I have created a program to find out no of working days .Please check this may help you .

&----


*& Report Z_NO_WORKING_DAYS

*&

&----


*&

*&

&----


REPORT Z_NO_WORKING_DAYS.

Parameters : GV_GJAHR like T009B-BDATJ,

GV_PERIV LIKE T009B-PERIV,

GV_POPER LIKE T009B-POPER.

DATA : I_DATAB LIKE SY-DATUM.

DATA : I_DATBI LIKE SY-DATUM.

DATA : L_V_AKTDAT LIKE SCAL-DATE.

DATA : L_V_INDICATOR LIKE SCAL-INDICATOR.

DATA: BEGIN OF DATS,

PERIODAT TYPE SY-DATUM,

END OF DATS.

DATA: ETH_DATS LIKE TABLE OF DATS WITH HEADER LINE.

DATA : GV_COUNT TYPE INT2.

CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'

EXPORTING

I_GJAHR = GV_GJAHR

  • I_MONMIT = 00

I_PERIV = GV_PERIV

I_POPER = GV_POPER

IMPORTING

E_DATE = I_DATAB

  • EXCEPTIONS

  • INPUT_FALSE = 1

  • T009_NOTFOUND = 2

  • T009B_NOTFOUND = 3

  • OTHERS = 4

.

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 'LAST_DAY_IN_PERIOD_GET'

EXPORTING

I_GJAHR = GV_GJAHR

  • I_MONMIT = 00

I_PERIV = GV_PERIV

I_POPER = GV_POPER

IMPORTING

E_DATE = I_DATBI

  • EXCEPTIONS

  • INPUT_FALSE = 1

  • T009_NOTFOUND = 2

  • T009B_NOTFOUND = 3

  • OTHERS = 4

.

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 : ETH_DATS.

REFRESH: ETH_DATS.

L_V_AKTDAT = I_DATAB.

  • do it for all days in space of time

WHILE L_V_AKTDAT <= I_DATBI.

CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'

EXPORTING

DATE = L_V_AKTDAT

FACTORY_CALENDAR_ID = 'Z1'

IMPORTING

WORKINGDAY_INDICATOR = L_V_INDICATOR

EXCEPTIONS

CALENDAR_BUFFER_NOT_LOADABLE = 1

CORRECT_OPTION_INVALID = 2

DATE_AFTER_RANGE = 3

DATE_BEFORE_RANGE = 4

DATE_INVALID = 5

FACTORY_CALENDAR_NOT_FOUND = 6

OTHERS = 7.

IF SY-SUBRC NE 0.

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

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4

RAISING DATE_CONVERSION_ERROR.

ENDIF.

  • indicator is space if actual day is a working day

  • if indicator is not space the actual day isn't a working day

IF L_V_INDICATOR EQ SPACE.

CLEAR ETH_DATS.

ETH_DATS-PERIODAT = L_V_AKTDAT.

APPEND ETH_DATS.

ENDIF.

L_V_AKTDAT = L_V_AKTDAT + 1.

ENDWHILE.

DESCRIBE TABLE ETH_DATS LINES GV_COUNT.

WRITE 😕 GV_COUNT.

Regards

Sachin Saboo