‎2009 Feb 05 11:06 AM
Hi Friends,
Is it possible to restrict some of the dates for the date field while selecting from calendar. Is there any mechanism through which we can disable some of the days in calendar?
For eg. If I need just Saturdays to be populated, so calendar will disable all other days.
‎2009 Feb 05 2:31 PM
Hello Sumit,
Here are a bunch of calender related Function Modules,
make a bash at each to fix your problem.
All function modules are contained in the function group SCAL.
DATE_COMPUTE_DAY
This function module returns the day of the week for the date passed.
DATE_GET_WEEK
This function module returns the week for the date passed.
WEEK_GET_FIRST_DAY
This function module returns the first day of the week passed. (This is always a Monday, regardless of whether it is a working day or a holiday.)
EASTER_GET_DATE
This function module returns the date of Easter Sunday for the year passed.
FACTORYDATE_CONVERT_TO_DATE
This function module returns the calendar date for the factory date and the factory calendar passed.
DATE_CONVERT_TO_FACTORYDATE
This function module returns the factory date for the date and factory calendar passed. You can specify with a parameter whether the next or the previous working day is returned if the day is not a working day.
HOLIDAY_CHECK_AND_GET_INFO
With this function module, you test whether a particular date in the holiday calendar passed is a holiday. If so, the definition of the holiday is returned.Thankyou,
Zahack
‎2009 Feb 05 12:11 PM
Hi,
Use this function module to get your requirement.
It will tell u the day of a week as word like sunday,monday,tuesday........etc and whether the day is holiday or not....
Based on this u can perform logic ast selection-screen output or in a function module...
DAY_ATTRIBUTES_GET
I hope it will helpful to u.......
REgards
Kiran
‎2009 Feb 05 12:23 PM
Hi,
Or else u can try out this one also...
FM:
DATE_COMPUTE_DAY
Returns a number indicating what day of the week the date falls on. Monday is returned as a 1, Tuesday as 2, etc.
and u can write your own logic....
Regards
Kiran
‎2009 Feb 05 12:27 PM
Thanks for the reply, But I was looking for something which can disable days in calendar while selecting.
‎2009 Feb 05 12:31 PM
You could create your own dropdown, not in calendar form, but populate the dropdown with only days
you want to allow.
‎2009 Feb 05 1:25 PM
Hi,
Check out the below code.
Here you can view only Public Holidays , Saturdays and Sundays.
As said above i had used the FM 'DAY_ATTRIBUTES_GET'.
You just gothrough the FM import and export parameters and Tables.
DATA : h_facid TYPE scal-fcalid,
h_hocid TYPE scal-hcalid.
DATA : it_day_attr_tab TYPE STANDARD TABLE OF casdayattr INITIAL SIZE 0,
wa_day_attr_tab TYPE casdayattr.
DATA : l_datum TYPE scdatum,
l_datum1 TYPE scdatum,
l_langu TYPE sylangu.
l_datum = sy-datum - 37.
l_datum1 = sy-datum.
h_facid = '01'.
h_hocid = '01'.
START-OF-SELECTION.
CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
factory_calendar = h_facid
holiday_calendar = h_hocid
date_from = l_datum
date_to = l_datum1
language = l_langu
IMPORTING
YEAR_OF_VALID_FROM =
YEAR_OF_VALID_TO =
RETURNCODE =
TABLES
day_attributes = it_day_attr_tab
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.
LOOP AT it_day_attr_tab INTO wa_day_attr_tab.
IF wa_day_attr_tab-freeday = 'X' or wa_day_attr_tab-holiday = 'X'.
WRITE 😕 wa_day_attr_tab-date,
wa_day_attr_tab-txt_short,
wa_day_attr_tab-txt_long,
wa_day_attr_tab-weekday_l,
wa_day_attr_tab-day_string.
ENDIF.
ENDLOOP.
Regards.
‎2009 Feb 05 2:31 PM
Hello Sumit,
Here are a bunch of calender related Function Modules,
make a bash at each to fix your problem.
All function modules are contained in the function group SCAL.
DATE_COMPUTE_DAY
This function module returns the day of the week for the date passed.
DATE_GET_WEEK
This function module returns the week for the date passed.
WEEK_GET_FIRST_DAY
This function module returns the first day of the week passed. (This is always a Monday, regardless of whether it is a working day or a holiday.)
EASTER_GET_DATE
This function module returns the date of Easter Sunday for the year passed.
FACTORYDATE_CONVERT_TO_DATE
This function module returns the calendar date for the factory date and the factory calendar passed.
DATE_CONVERT_TO_FACTORYDATE
This function module returns the factory date for the date and factory calendar passed. You can specify with a parameter whether the next or the previous working day is returned if the day is not a working day.
HOLIDAY_CHECK_AND_GET_INFO
With this function module, you test whether a particular date in the holiday calendar passed is a holiday. If so, the definition of the holiday is returned.Thankyou,
Zahack
‎2009 Feb 05 2:47 PM
Hi,
Another thing what you can do is that when the entered date is not saturday then throw a error message,
ex.
DATA: w_day TYPE scal-indicator.
SELECT-OPTIONS: so_date FOR sy-datum.
AT SELECTION-SCREEN.
CALL FUNCTION 'DATE_COMPUTE_DAY' "To get the day of a date
EXPORTING
date = so_date-low
IMPORTING
day = w_day.
IF w_day NE '6'. "6 is for saturday
MESSAGE e000 WITH 'Not saturday'.
ENDIF.Regards,
Manoj Kumar P