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: 

#Working day count

Former Member
0 Kudos

Hi All,

I need some help from u all.

when user enter any date , i.e. 2 April 2007 output should be 1.

Means count of working days .

If 9 april 2007 then output should be 6.

Dont worry about Points

3 REPLIES 3

kostas_tsioubris
Contributor
0 Kudos

Hi,

you want to count the working days between 2 dates right? I had created a FM a few time ago for this reason. Check it out if it helps you.


FUNCTION Z_COMPUTE_WORKING_DAYS.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     VALUE(I_DATE1) TYPE  DATUM
*"     VALUE(I_DATE2) TYPE  DATUM
*"     VALUE(I_FACTORY_CALENDAR_ID) LIKE  SCAL-FCALID DEFAULT 'ZG'
*"  EXPORTING
*"     VALUE(E_DAYS) TYPE  I
*"----------------------------------------------------------------------
  DATA : LV_WORKING_DAY TYPE DATUM,
         LV_INDICATOR LIKE SCAL-INDICATOR.

  CHECK I_DATE1 GT I_DATE2.
  LV_WORKING_DAY = I_DATE2.
  CLEAR E_DAYS.

  WHILE LV_WORKING_DAY NE I_DATE1.

    CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
      EXPORTING
        DATE                 = LV_WORKING_DAY
        FACTORY_CALENDAR_ID  = I_FACTORY_CALENDAR_ID
      IMPORTING
        WORKINGDAY_INDICATOR = LV_INDICATOR
      EXCEPTIONS
        OTHERS               = 1.

    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    CASE LV_INDICATOR.
      WHEN ' '.
        ADD 1 TO E_DAYS.
        ADD 1 TO LV_WORKING_DAY.
      WHEN '+'.
        ADD 1 TO LV_WORKING_DAY.
    ENDCASE.

  ENDWHILE.


ENDFUNCTION.

Kostas

0 Kudos

GR8, THANSK

points r given

Former Member
0 Kudos

Hi,

there is a stanadard function module

RKE_SELECT_FACTDAYS_FOR_PERIOD.

for this you need to pass

I_DATAB(start date)

I_DATBI(enddate)

I_FACTID(country code like 'US','IN')

then this will give the number of working days in ETH_DATS( table) ....

i hope this will be useful..

reward points if helpful