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: 

Abap Programming

Former Member
0 Kudos

I need to fine the difference between two dates in which i need to exclude saturdays,sunday & public holidays.

Regards

Suchithra

19 REPLIES 19

Former Member
0 Kudos

Hi,

Check FM HR_BE_SRD_PUBLIC_HOLIDAY.

Thanks,

Sriram Ponna.

Former Member
0 Kudos

Hi,

Use FM FIMA_DAYS_BETWEEN_TWO_DATES_2. In Field I_SKALID give the factory calender. It will give you diff between two dates in working days.

Regards,

Lalit

0 Kudos

hi Lalit

Thnks for ur reply

I tried to use this function module but i could not get any values for this .

secondly we haven't specified the factory calender as we use public calesnder

0 Kudos

Hi Suchitra

Find out with ur FC, which calender u need to use.. bcoz there are 2 or 3 types of calenders... Factory calender ,,,.

The factory day is a number assigned to each working day in plant calendar. The functions are FACTORYDATE_CONVERT_TO_DATE and DATE_CONVERT_TO_FACTORYDATE and they are documented directly in SAP

http://abaplog.wordpress.com/2007/03/15/working-with-sap-plant-calendars/

0 Kudos

Hi

I spoke to FC

We are using holiday calender

HEnce we need to use holiday calender.

Regards,

Suchithra

0 Kudos

http://help.sap.com/saphelp_nw04/helpdata/en/e1/52e9c8f7cb11d2a2b000a0c943858e/content.htm

DAY_ATTRIBUTES_GET Return useful information about a day. Will tell you the day of the week as a word (Tuesday), the day of the week (2 would be Tuedsay), whether the day is a holiday, and more.

HOLIDAY_CHECK_AND_GET_INFO Useful for determining whether or not a date is a holiday. Give the function a date, and a holiday calendar, and you can determine if the date is a holiday by checking the parameter HOLIDAY_FOUND.

Example:

data: ld_date like scal-datum default sy-datum,

lc_holiday_cal_id like scal-hcalid default 'CA',

ltab_holiday_attributes like thol occurs 0 with header line,

lc_holiday_found like scal-indicator.

CALL FUNCTION 'HOLIDAY_CHECK_AND_GET_INFO'

EXPORTING

date = ld_date

holiday_calendar_id = lc_holiday_cal_id

WITH_HOLIDAY_ATTRIBUTES = 'X'

IMPORTING

HOLIDAY_FOUND = lc_holiday_found

tables

holiday_attributes = ltab_holiday_attributes

EXCEPTIONS

CALENDAR_BUFFER_NOT_LOADABLE = 1

DATE_AFTER_RANGE = 2

DATE_BEFORE_RANGE = 3

DATE_INVALID = 4

HOLIDAY_CALENDAR_ID_MISSING = 5

HOLIDAY_CALENDAR_NOT_FOUND = 6

OTHERS = 7.

if sy-subrc = 0 and

lc_holiday_found = 'X'.

write: / ld_date, 'is a holiday'.

else.

write: / ld_date, 'is not a holiday, or there was an error calling the function'.

endif.

HOLIDAY_GET Provides a table of all the holidays based upon a Factory Calendar &/ Holiday Calendar.

HR_DISPLAY_BASIC_LIST is an HR function, but can be used for any data. You pass it data, and column headers, and it provides a table control with the ability to manipulate the data, and send it to Word or Excel. Also see the additional documentation here.

HR_GET_LEAVE_DATA Get all leave information (includes leave entitlement, used holidays/paid out holidays)

0 Kudos

Hi,

There is a Table TFACD which stores the Factory Calender.

You can know the value of the factory calender from this table.

If the FM which I have is not working try using the FMs given by our other friends. Meanwhile Let me serach if I can find some thing,

Regards.

Lalit

Former Member
0 Kudos

Check these programs

RWSAF0001_FORM_PUB_HOLIDAYS (include program)

SAPLHRSEN00CRULE_CALE_DAYS (Functional Pool)

MM61MF78_DELTA_WORKINGDAYS (include Program)

RPTHRT01_EVALUATE_DAYS (include Program)

Reward Points if useful.

Former Member
0 Kudos

Check the Function Modules

HR_SGPBS_YRS_MTHS_DAYS Calculate years, months, days & calender days between 2 given dates

DAYS_BETWEEN_TWO_DATES

LEAP_DAYS_BETWEEN_TWO_DATES

HRWPC_PCR_CHECK_WORKINGDAYS

K_ABC_WORKDAYS_FOR_PERIODS_GET

RH_REQUEST_ON_WORKINGDAYS

WLB3_GET_NUMBER_OF_WORKDAYS

Former Member
0 Kudos

Use the FM RS_VARI_V_WDAYS_UP_TO_NOW....

Vinodh Balakrishnan

Former Member
0 Kudos

Hi all

I need to calculate the SLA.

Start date _100 working days .

Please help me how to calculate this date

Suchithra

Former Member
0 Kudos

Hi

Staring date + 100 working days

How to calculate this date

suchithra

kesavadas_thekkillath
Active Contributor
0 Kudos

Is this related to your factory calendar.....

0 Kudos

data: it_days like standard table of rke_dat .

call function 'RKE_SELECT_FACTDAYS_FOR_PERIOD'

exporting

i_datab = first_date

i_datbi = last_date

i_factid = p_v_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 p_v_working_days.

P_v_working _days will have the number of working days.

Former Member
0 Kudos

yes it is related to factory calender

Suchithra

0 Kudos

Check my last post...is it helping you ???

You pass the dates it will tell u the working days for the date range...

Former Member
0 Kudos

I need to get the date by adding the number of workingdays to the start date

for ex

19.01.2008 + 100 working days = date ? i need to calculate this date

suchithra

0 Kudos

Create A Functional Module ..Place the below code in it.

Import parameters:
PLANT		TYPE	T001W-WERKS
I_STARTTIME	TYPE	T
I_STARTDATE	TYPE	D
I_ADDTIME	TYPE	T
I_ADDDAYS	TYPE	I

Export Parameters:
E_ENDTIME	TYPE	T
E_ENDDATE	TYPE	D

Exceptions:
CALENDAR_BUFFER_NOT_LOADABLE	Factory calendar could not be buffered
CORRECT_OPTION_INVALID		CORRECT_OPTION is not '+' or '-'
DATE_AFTER_RANGE		Date is later than factory calendar definition
DATE_BEFORE_RANGE		Date is earlier than factory calendar definition
DATE_INVALID			Invalid date format
FACTORY_CALENDAR_NOT_FOUND	Factory calendar is not in buffer

Just copy the above things and paste it as your FM Parameters.


 

Then in the source code area paste this code

data : differenz type i,
         wk_adddays type i,
         wk_workingday type i,
         wk_fabkl like t001w-fabkl.

  data : wk_factorydt type dats.

  clear wk_fabkl.

  select single fabkl into wk_fabkl from t001w client specified
   where mandt = sy-mandt
     and werks = plant.

  e_enddate = i_startdate.

  if i_adddays > 1.

    wk_adddays = i_adddays.
  else.
    wk_adddays = i_adddays.

  endif.

  wk_workingday = 0.

  while  ( wk_adddays ge 0 ).


    call function 'DATE_CONVERT_TO_FACTORYDATE'
         exporting
              date                = e_enddate
              factory_calendar_id = wk_fabkl
         importing
              date                = wk_factorydt.

    .
    if wk_factorydt eq e_enddate.

      wk_adddays = wk_adddays - 1.

    endif.

    if wk_adddays ge 0.

      e_enddate = e_enddate + 1.

    endif.

  endwhile.

*** This clause will add time to the end date and display
*** the final end date and end time.

  e_endtime = i_starttime + i_addtime.
  differenz = e_endtime - i_starttime.

  if differenz < 0.
    e_enddate = e_enddate + 1.
  else.
    e_enddate = e_enddate.
  endif.

  wk_workingday = 0.

  while ( wk_workingday <> 1 ).
    call function 'DATE_CONVERT_TO_FACTORYDATE'
         exporting
              date                = e_enddate
              factory_calendar_id = wk_fabkl
         importing
              date                = wk_factorydt.

    if e_enddate eq wk_factorydt.
      wk_workingday = 1.
    else.
      wk_workingday = 0.
    endif.

    e_enddate = wk_factorydt.

  endwhile.

When executing : provide the startdate and days = 100.

It will give u the output date as u needed.



or if u need just apply this as u r coding...

any doubt revert.....:-)

Former Member