cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with dates, it is urgent

Former Member
0 Kudos

Hi,

Presently I am using function module

DAY_ATTRIBUTES_GET

Where I am passing two dates,

the first date pertains approval date of the document,

the next date is 3 days plus of approval date of the document

But I need to check whether the days between two dates does not fall under holidays or free days ,free days means Saturday and Sunday.

From this function module we can get the list of the holiday & free days,

if the days between two dates fall under holiday or free days we need not calculate holidays & free days instead we need to give 3 working days from the approval date.

Can some one help me with the logic.

Thanks in Advance,

Irfan Hussain

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

I have solved my problem using function module

RKE_SELECT_FACTDAYS_FOR_PERIOD

where i am jsut getting the list of the working dates

excluding holidays.

I am just picking up the third record ,

which is indiacating 3 working days,

I want to close this thread,

Please just let me know the procedure to close the thread.

Thanks & Regards

Irfan Hussain

Former Member
0 Kudos

HI IRFAN HUSSAIN

visit this link to know how to close the thread

<b>SPREAD LOVE: /people/mark.finnern/blog/2004/08/10/spread-the-love</b>

Cheers,

Vijay Raheja

Former Member
0 Kudos

Hi Irfan,

You can also use other function module

<b>'HOLIDAY_CHECK_AND_GET_INFO'</b>.

see the below code :

CALL FUNCTION 'HOLIDAY_CHECK_AND_GET_INFO'

EXPORTING DATE = Date

HOLIDAY_CALENDAR_ID = 'US'

IMPORTING HOLIDAY_FOUND = HOLIDAY

TABLES HOLIDAY_ATTRIBUTES = HOLIDAY_TAB.

This will tell you whether the given date is holiday or weekend day. Depending on that you can decide in betwwen the given dates any holidays exists.

Thanks & Regards,

Siri.

Former Member
0 Kudos

Hi,

You can use a similar code:

*first date

data l_date1 like sy-datum,

*last date

l_date2 like sy-datum,

  • factory calendar check TFACD table and find appropiate

l_fact_cal like SCAL-FCALID,

  • holiday calendar check THOCI table and find appropiate

l_fact_hol like SCAL-HCALID.

....

CALL FUNCTION 'DAY_ATTRIBUTES_GET'

  • EXPORTING

FACTORY_CALENDAR = l_fact_cal

HOLIDAY_CALENDAR = l_fact_hol

DATE_FROM = l_date1

DATE_TO = l_date2

LANGUAGE = SY-LANGU

  • IMPORTING

  • YEAR_OF_VALID_FROM =

  • YEAR_OF_VALID_TO =

  • RETURNCODE =

TABLES

day_attributes = it_day

EXCEPTIONS

FACTORY_CALENDAR_NOT_FOUND = 1

HOLIDAY_CALENDAR_NOT_FOUND = 2

DATE_HAS_INVALID_FORMAT = 3

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

  • Check the result table if there is a holiday/free day

clear: l_day, l_hol, l_free.

loop at it_table.

if it_table-holiday = 'X'.

l_hol = 'X'.

l_day = l_day + 1.

continue.

endif.

if it_table-freeday = 'X'.

l_free = 'X'.

l_day = l_day + 1.

continue.

endif.

ENDLOOP.

if l_free and l_hol is initial.

  • last day is ok and sum only 3 days -> l_day2 OK

ELSE.

  • Sum the number of holiday/free days

l_day2 = l_day2 + l_day.

  • check whether that day is OK

CALL FUNCTION 'DAY_ATTRIBUTES_GET'

  • EXPORTING

FACTORY_CALENDAR = l_fact_cal

HOLIDAY_CALENDAR = l_fact_hol

DATE_FROM = l_date2

DATE_TO = l_date2

LANGUAGE = SY-LANGU

  • IMPORTING

  • YEAR_OF_VALID_FROM =

  • YEAR_OF_VALID_TO =

  • RETURNCODE =

TABLES

day_attributes = it_day

EXCEPTIONS

FACTORY_CALENDAR_NOT_FOUND = 1

HOLIDAY_CALENDAR_NOT_FOUND = 2

DATE_HAS_INVALID_FORMAT = 3

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

READ TABLE IT_DAY INDEX 1.

IF IT_DAY-HOLIDAY IS INITIAL AND IT_DAY-FREE IS INITIAL.

  • The day is OK -> Finish

ELSE.

  • Sum a day and try...

ENDIF.

endif.

Hope it helps.

Cheers,

Mireia

Former Member
0 Kudos

Refer this link

http://www.sapdevelopment.co.uk/tips/date/date_daysadd.htm

FM 'DATE_CHECK_WORKINGDAY'

Also see 'DATE_CONVERT_TO_FACTORYDATE'

http://www.sapdevelopment.co.uk/tips/date/date_factorydat.htm

Hope this helps.

Reward poinst adn close the thread if u find helpful.

Former Member
0 Kudos

HI IRFAN HUSSAIN

USING FM 'DAY_ATTRIBUTES_GET'

You can easliy find out whether it is SATURDAY/SUNDAY ON A PARTICULAR DATE OR NOT.

AND TO FIND PUBLIC HOLIDAY.YOU NEED TO PASS PROPER CALENDER-ID TO

IMPORT PARAMETERS:

-FACTORY_CALENDAR

-HOLIDAY_CALENDAR

LIKE FOR INDIA IT IS 'IN'.

AND THIS FUNCTION MODULE WILL RETURN WHETHER A DATE IS HOLIDAY OR NOT IN THE INTERNAL TABLE VALUES.

CHEERS,

VIJAY RAHEJA