Skip to Content
0

Set calender color for fixed and flexi holidays

Dec 26, 2016 at 06:31 AM

100

avatar image
Former Member

Hi,

We have a requirement to set calender color of employees for fixed and flexi holidays.This is for letting employess know which are the date having flexi leaves.We have a custom developed for saving the flexi holidays based on location of employees.Currently colors are displayed based on approved or sent leaves only.Can anyone suggest how that can be acheived.

I have checked SPRO and the BASI PT_ABS_REQ method SET_CALENDER_COLOR but can anyone provide a code snippet how can this be done.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
avatar image
Former Member Feb 10, 2017 at 06:10 AM
0

Solved issue by using combination implicit enhacements in webdynpro application and BADI methods.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Dec 26, 2016 at 08:20 AM
0

MODULE select_data_0300 OUTPUT.


DATA: BEGIN OF wa_day_info,
color TYPE i,
date TYPE cnca_utc_date,
text TYPE text50,
END OF wa_day_info,
wa_holiday TYPE shol_disp,
lt_day_attributes TYPE TABLE OF casdayattr,
ls_day_attribute TYPE casdayattr,
l_date_from LIKE sy-datum,
l_date_to LIKE sy-datum,
l_date LIKE sy-datum,
l_feiertag TYPE cind,
lt_hol_attributes TYPE TABLE OF thol,
lt_thoc TYPE TABLE OF thoc,
ls_thoc TYPE thoc,
ls_tholt TYPE tholt,
ls_tfacd TYPE tfacd,
l_tabix TYPE sy-tabix.

CLEAR: working_days, non_working_days,
g_working_days, g_non_working_days,
gt_holidays, gt_day_info.

CONCATENATE: s_date-low(4) '0101' INTO l_date_from,
s_date-low(4) '1231' INTO l_date_to.

SELECT SINGLE *
INTO ls_tfacd
FROM tfacd
WHERE ident = 'SB'.

CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
factory_calendar = 'SB'
date_from = l_date_from
date_to = l_date_to
TABLES
day_attributes = lt_day_attributes
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 lt_day_attributes INTO ls_day_attribute.

CLEAR: wa_day_info, wa_holiday.

wa_day_info-date = ls_day_attribute-date.

IF NOT ls_day_attribute-holiday IS INITIAL AND
NOT ls_day_attribute-freeday IS INITIAL.

SELECT SINGLE *
FROM thoc
INTO ls_thoc
WHERE ident = 'OC' AND
datum = ls_day_attribute-date.

IF ls_thoc-garant = 'X' OR ls_thoc-garant = 'Y' OR
ls_thoc-garant = 'V' OR ls_thoc-garant = 'S' OR
ls_thoc-garant = 'D' OR ls_thoc-garant = 'E' OR
ls_thoc-garant = 'F' OR ls_thoc-garant = 'G' OR
ls_thoc-garant = 'Z' OR ls_thoc-garant = 'A'.

CONCATENATE ls_day_attribute-txt_long ',' text-300
INTO wa_day_info-text SEPARATED BY space.

ELSE.

wa_day_info-text = ls_day_attribute-txt_long.

ENDIF.

wa_day_info-color = cnca_color_5.
ADD 1 TO g_non_working_days.

MOVE-CORRESPONDING wa_day_info TO wa_holiday.
APPEND wa_holiday TO gt_holidays.

ELSEIF NOT ls_day_attribute-holiday IS INITIAL AND
ls_day_attribute-freeday IS INITIAL.

CONCATENATE ls_day_attribute-txt_long ',' text-907 ',' text-906
INTO wa_day_info-text SEPARATED BY space.

MOVE-CORRESPONDING wa_day_info TO wa_holiday.
APPEND wa_holiday TO gt_holidays.

ADD 1 TO g_working_days.

ELSEIF NOT ls_day_attribute-freeday IS INITIAL.

wa_day_info-text = text-905.
wa_day_info-color = cnca_color_2.
ADD 1 TO g_non_working_days.

ELSE.

wa_day_info-text = text-906.
* wa_day_info-color = cnca_color_5.
ADD 1 TO g_working_days.

ENDIF.

APPEND wa_day_info TO gt_day_info.

ENDLOOP.

ENDMODULE.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Wasim,

Thanks for the logic to retrieve public holidays.Can you please let me know how we can changes the color for holidays in leave request calendar based on the logic.

leave.png (22.7 kB)
0
Former Member
Former Member

You have to identify the leave days and using the "color" field of info day you can change color.

Below is sample code. You need to fill the Leave_day_first and leave_day_last

LOOP AT lt_day_attributes INTO ls_day_attribute.

CLEAR: wa_day_info, wa_holiday.

wa_day_info-date = ls_day_attribute-date.

IF ls_day_attribute-date BT Leave_day_first TO leave_day_last and

ls_day_attribute-holiday IS NOT INITIAL.

wa_day_info-text = "holiday during leave days".
wa_day_info-color = cnca_color_5.
ADD 1 TO g_total_leave_days.

endif.

APPEND wa_day_info TO gt_day_info.

ENDLOOP.

0