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: 

weekends

Former Member
0 Kudos

hi guyz,

i wanna calculate the number of days an employee absent for ina given period time...here i am getting the right days with in that period ...but within that days i have to exclude the weekends..how can i do that...plz advise...

my code :

lv_days = lv_end_date - lv_strt_date + 1.

lv_strt_day = lv_begda - lv_strt_date .

lv_days = lv_days - lv_strt_day.

lv_hrs = p2001-stdaz / p2001-abrtg.

lv_time = lv_days * lv_hrs.

ADD lv_time TO employee_struct-absence_hours .

plz advise..

regards

4 REPLIES 4

S0025444845
Active Participant
0 Kudos

Hi,

Use Function module.

give start date and date and in i_factid give factory calender like IN,GB,You will get all the working days in l_it_dat.describe table to get no of days.

DATA : l_it_dat TYPE STANDARD TABLE OF rke_dat .

CALL FUNCTION 'RKE_SELECT_FACTDAYS_FOR_PERIOD'

EXPORTING

i_datab = l_docdate "start date

i_datbi = l_sysdate "enddate

i_factid = c_gb

TABLES

eth_dats = l_it_dat.

  • EXCEPTIONS

  • DATE_CONVERSION_ERROR = 1

  • OTHERS = 2

DESCRIBE TABLE l_it_dat LINES l_count.

reward points if useful.

Regards,

sudha

Former Member
0 Kudos

Hi Sudheer,

If you have factory Calender you can try these:

You can get holidays between 2 dates using function module HOLIDAY_GET

With that you can derive number of working days.

Otherwise,

refer FM RKE_SELECT_FACTDAYS_FOR_PERIOD : Gives working days for a period

Also try this code:

CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'

EXPORTING

DATE = fDay

FACTORY_CALENDAR_ID = 'YD'

IMPORTING

WORKINGDAY_INDICATOR = FLAG.

If you don't have factory Calender then try this:

Check the following code:

REPORT ZDATEDIFF.

DATA: EDAYS LIKE VTBBEWE-ATAGE,

EMONTHS LIKE VTBBEWE-ATAGE,

EYEARS LIKE VTBBEWE-ATAGE.

PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,

TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.

call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

exporting

i_date_from = FROMDATE

i_date_to = TODATE

I_FLG_SEPARATE = ' '

IMPORTING

E_DAYS = EDAYS

E_MONTHS = EMONTHS

E_YEARS = EYEARS.

WRITE:/ 'Difference in Days ', EDAYS.

WRITE:/ 'Difference in Months ', EMONTHS.

WRITE:/ 'Difference in Years ', EYEARS.

INITIALIZATION.

FROMDATE = SY-DATUM - 60.

Reward Points if found helpfull..

Cheers,

Chandra Sekhar.

Sm1tje
Active Contributor
0 Kudos

try and find a function module with weekday*, or factorycalen*. Should be something like this.

Former Member
0 Kudos

Hi,

try this short example:

DATA: BEG_DATE LIKE SY-DATUM VALUE '20080101'.

DATA: END_DATE LIKE SY-DATUM VALUE '20083112'.

DATA: CHK_DATE LIKE SY-DATUM.

*

DATA: DAYS TYPE I.

DATA: WEEK_DAYS TYPE I.

DATA: WORK_DAYS TYPE I.

DATA: WOTNR TYPE P.

*

CHK_DATE = BEG_DATE.

*

WHILE CHK_DATE < END_DATE.

*

DAYS = DAYS + 1.

CALL FUNCTION 'DAY_IN_WEEK'

EXPORTING

DATUM = CHK_DATE

IMPORTING

WOTNR = WOTNR.

*

IF WOTNR < 6.

ADD 1 TO WORK_DAYS.

ELSE.

ADD 1 TO WEEK_DAYS.

ENDIF.

ADD 1 TO CHK_DATE.

*

ENDWHILE.

*

WRITE: DAYS, WEEK_DAYS, WORK_DAYS, BEG_DATE, END_DATE.

*

Regards, Dieter