cancel
Showing results for 
Search instead for 
Did you mean: 

Any more colors when using DateNavigator?

Former Member
0 Kudos

Hi Guys,

I need to build a calendar type application showing the leave on specific dates for an employee. There are different types of leave, and they need to be distinguished on the calendar by using different colors. The "Category" attribute of the DateNavigator under the "Markings" UI element only allows for 4 different colors... But I see there is also an attribute called daySymantics that have much more than 4 colors... But I have been unable to figgure out how this property works. I have bound it and tried to set the colors dynamically but I cannot seem to change it except for explicitly.

Please advise if this is the right route to go, or if I'm pretty much stuck with 4 colors.

Kind Regards,

Christiaan

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member

Got this figgured out!


* go through the leave context and paint the calendar accordingly
  types: begin of ty_marking,
*         category type WDUI_DATE_MARKING_CATEGORY,
         daySemantic TYPE WDUI_TABLE_CELL_DESIGN,
         tooltip  type string,
         date     type d,
         end of ty_marking.

  TYPES: BEGIN OF leave_types,
         type TYPE char2,
         description TYPE string,
         END OF leave_types.

  DATA lo_nd_t_zholdates TYPE REF TO if_wd_context_node.
  DATA lo_el_t_zholdates TYPE REF TO if_wd_context_element.
  DATA ls_t_zholdates TYPE wd_this->element_t_zholdates.
  DATA lt_t_zholdates TYPE STANDARD TABLE OF wd_this->element_t_zholdates.
  DATA lo_nd_t_zhrleaveplan TYPE REF TO if_wd_context_node.
  DATA lo_el_t_zhrleaveplan TYPE REF TO if_wd_context_element.
  DATA ls_t_zhrleaveplan TYPE wd_this->element_t_zhrleaveplan.
  DATA lt_t_zhrleaveplan TYPE STANDARD TABLE OF wd_this->element_t_zhrleaveplan.
  DATA lt_leave_types TYPE STANDARD TABLE OF leave_types.
  DATA ls_leave_types TYPE leave_types.
  DATA lo_nd_hrleave_t TYPE REF TO if_wd_context_node.
  DATA lo_el_hrleave_t TYPE REF TO if_wd_context_element.
  DATA ls_hrleave_t TYPE wd_this->element_hrleave_t.
  DATA lt_hrleave_t TYPE STANDARD TABLE OF wd_this->element_hrleave_t.
  DATA: marking type ty_marking,
        markings type standard table of ty_marking,
        node_datenav1     type ref to if_wd_context_node,
        node type ref to if_wd_context_node.
  DATA: lv_leave_type_desc TYPE string.
  DATA  lv_date TYPE d.
  DATA  lv_str_date TYPE string.
  DATA  lv_day TYPE char2.
  DATA  lv_month TYPE char2.
  DATA  lv_year TYPE char4.

  CONSTANTS: lc_annual_leave TYPE char2 VALUE 'B1',
             lc_sick_leave TYPE char2 VALUE   'B2',
             lc_maternity_leave TYPE char2 VALUE 'B3',
             lc_study_leave TYPE char2 VALUE 'B4',
             lc_other_leave TYPE char2 VALUE 'B5',
             lc_course_seminar TYPE char2 VALUE 'A1',
             lc_off_site_attendance TYPE char2 VALUE 'A2',
             "planned leave
             lc_pl_annual_leave TYPE char2 VALUE 'AL',
             lc_pl_sick_leave TYPE char2 VALUE 'SL',
             lc_pl_maternity_leave TYPE char2 VALUE 'MT',
             lc_pl_study_leave TYPE char2 VALUE 'ST',
             lc_pl_other_leave TYPE char2 VALUE 'OA',
             lc_pl_course_seminar TYPE char2 VALUE 'CS',
             lc_pl_off_site_attendance TYPE char2 VALUE 'OS'.

* init
  node_datenav1 = wd_context->get_child_node( name = `DATENAV1` ).
  node = node_datenav1->get_child_node( name = 'MARKINGS' ).
  ls_leave_types-type = 'B1'.
  ls_leave_types-description = 'Annual Leave'.
  APPEND ls_leave_types TO lt_leave_types.
  ls_leave_types-type = 'B2'.
  ls_leave_types-description = 'Sick Leave'.
  APPEND ls_leave_types TO lt_leave_types.
  ls_leave_types-type = 'B3'.
  ls_leave_types-description = 'Maternity Leave'.
  APPEND ls_leave_types TO lt_leave_types.
  ls_leave_types-type = 'B4'.
  ls_leave_types-description = 'Study Leave'.
  APPEND ls_leave_types TO lt_leave_types.
  ls_leave_types-type = 'B5'.
  ls_leave_types-description = 'Other Leave'.
  APPEND ls_leave_types TO lt_leave_types.
  ls_leave_types-type = 'A1'.
  ls_leave_types-description = 'Course/Seminar'.
  APPEND ls_leave_types TO lt_leave_types.
  ls_leave_types-type = 'A2'.
  ls_leave_types-description = 'Off Site Course Attendance'.
  APPEND ls_leave_types TO lt_leave_types.

* planned leave
* navigate from <CONTEXT> to <T_ZHRLEAVEPLAN> via lead selection
  lo_nd_t_zhrleaveplan = wd_context->get_child_node( name = wd_this->wdctx_t_zhrleaveplan ).
  CHECK lo_nd_t_zhrleaveplan IS NOT INITIAL.
* get element via lead selection
  lo_el_t_zhrleaveplan = lo_nd_t_zhrleaveplan->get_element(  ).
  IF lo_el_t_zhrleaveplan IS NOT INITIAL.

    lo_nd_t_zhrleaveplan->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING table = lt_t_zhrleaveplan ).

    LOOP AT lt_t_zhrleaveplan INTO ls_t_zhrleaveplan.
* compose date
      CHECK ls_t_zhrleaveplan-zday IS NOT INITIAL.
      CHECK ls_t_zhrleaveplan-zmonth IS NOT INITIAL.
      CHECK ls_t_zhrleaveplan-zyear IS NOT INITIAL.
      lv_day = ls_t_zhrleaveplan-zday.
      IF strlen( lv_day ) = 1.
        CONCATENATE '0' lv_day INTO lv_day.
      ENDIF.
      lv_month = ls_t_zhrleaveplan-zmonth.
      IF strlen( lv_month ) = 1.
        CONCATENATE '0' lv_month INTO lv_month.
      ENDIF.
      lv_year = ls_t_zhrleaveplan-zyear.
      CONCATENATE lv_year lv_month lv_day
                  INTO lv_str_date.
      MOVE lv_str_date TO lv_date.
      IF ls_t_zhrleaveplan-ztype = lc_pl_annual_leave. "planned leave
*        marking-category = CL_WD_DATE_NAV_LEGEND=>E_CATEGORY-TWO.
        marking-daySemantic = CL_WD_DATE_NAV_MARKING=>E_DAY_SEMANTICS-BADVALUE_DARK.
        marking-tooltip  = 'Planned Annual Leave'.
        marking-date     = lv_date.

        append marking to markings.
      ELSEIF ls_t_zhrleaveplan-ztype EQ lc_pl_sick_leave
              OR ls_t_zhrleaveplan-ztype EQ lc_pl_maternity_leave
              OR ls_t_zhrleaveplan-ztype EQ  lc_pl_study_leave
              OR ls_t_zhrleaveplan-ztype EQ  lc_pl_other_leave
              OR ls_t_zhrleaveplan-ztype EQ  lc_pl_course_seminar
              OR ls_t_zhrleaveplan-ztype EQ  lc_pl_off_site_attendance.

*        marking-category = CL_WD_DATE_NAV_LEGEND=>E_CATEGORY-ONE.
        marking-daySemantic = CL_WD_DATE_NAV_MARKING=>E_DAY_SEMANTICS-BADVALUE_LIGHT.
        marking-tooltip  = 'Planned Leave Other. Click to see more details.'.
        marking-date     = lv_date.
        append marking to markings.
*      ELSEIF ls_t_zhrleaveplan-ztype EQ  lc_pl_course_seminar
*             OR ls_t_zhrleaveplan-ztype EQ  lc_pl_off_site_attendance.
*
*        marking-category = CL_WD_DATE_NAV_LEGEND=>E_CATEGORY-ONE.
*        marking-tooltip  = 'Planned Leave Course/Seminar and Off Site Attendance'.
*        marking-date     = lv_date.
        append marking to markings.
      ENDIF.
    ENDLOOP.
  ENDIF.

*  approved leave
*   navigate from <CONTEXT> to <HRLEAVE_T> via lead selection
  lo_nd_hrleave_t = wd_context->get_child_node( name = wd_this->wdctx_hrleave_t ).
  CHECK lo_nd_hrleave_t IS NOT INITIAL.
*   get element via lead selection
  lo_el_hrleave_t = lo_nd_hrleave_t->get_element(  ).
  IF lo_el_hrleave_t IS NOT INITIAL.

    lo_nd_hrleave_t->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING table = lt_hrleave_t ).

    LOOP AT lt_hrleave_t INTO ls_hrleave_t.
      IF ls_hrleave_t-TYPE_005 EQ lc_annual_leave
         OR ls_hrleave_t-TYPE_005 EQ lc_sick_leave
         OR ls_hrleave_t-TYPE_005 EQ lc_maternity_leave
         OR ls_hrleave_t-TYPE_005 EQ lc_study_leave
         OR ls_hrleave_t-TYPE_005 EQ lc_other_leave
         OR ls_hrleave_t-TYPE_005 EQ lc_course_seminar
         OR ls_hrleave_t-TYPE_005 EQ lc_off_site_attendance.
* approved leave
        CLEAR ls_leave_types.
        READ TABLE lt_leave_types INTO ls_leave_types
          WITH KEY type = ls_hrleave_t-TYPE_005.
        IF sy-subrc = 0.
          CONCATENATE 'Approved Leave: '
                      ls_leave_types-description
                      INTO lv_leave_type_desc RESPECTING BLANKS.
        ENDIF.
*        marking-category = CL_WD_DATE_NAV_LEGEND=>E_CATEGORY-THREE.
        marking-daySemantic = CL_WD_DATE_NAV_MARKING=>E_DAY_SEMANTICS-GOODVALUE_DARK.
        marking-tooltip  = lv_leave_type_desc.
        marking-date     = ls_hrleave_t-BEGDA_004.
        append marking to markings.
      ENDIF.
    ENDLOOP.
  ENDIF.

* public holidays
*   navigate from <CONTEXT> to <T_ZHOLDATES> via lead selection
  lo_nd_t_zholdates = wd_context->get_child_node( name = wd_this->wdctx_t_zholdates ).

*   @TODO handle not set lead selection
  IF lo_nd_t_zholdates IS NOT INITIAL.
    lo_nd_t_zholdates->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING table = lt_t_zholdates ).
    IF lt_t_zholdates[] IS NOT INITIAL.
      LOOP AT lt_t_zholdates[] INTO ls_t_zholdates.
*        marking-category = CL_WD_DATE_NAV_LEGEND=>E_CATEGORY-FOUR.
        marking-daySemantic = CL_WD_DATE_NAV_MARKING=>E_DAY_SEMANTICS-GOODVALUE_LIGHT.
        marking-tooltip  = 'Public Holiday'.
        marking-date     = ls_t_zholdates-holdate.
        append marking to markings.
      ENDLOOP.
    ENDIF.
  ENDIF.

  node->bind_table( markings ).

Edited by: christiaan69 on Jan 20, 2011 1:06 PM

sahai
Contributor
0 Kudos

hi dear,

check this link i hope this may help you

[link|https://cw.sdn.sap.com/cw/docs/DOC-25638]

regards,

sahai.s

Edited by: sahai.s on Jan 20, 2011 12:47 PM

Former Member
0 Kudos

Hi There,

I have already come across this piece of information, thank you. But I still havent been able to get it to work... here is some of my code if it helps... In my layout, the "marking-daySemantic" property is bound to the daySemantics value of my DateNavigator Marking UI Element.

 * go through the leave context and paint the calendar accordingly
  types: begin of ty_marking,
         category type WDUI_DATE_MARKING_CATEGORY,
         daySemantic TYPE WDUI_TABLE_CELL_DESIGN,
         tooltip  type string,
         date     type d,
         end of ty_marking.

*   @TODO handle not set lead selection
  IF lo_nd_t_zholdates IS NOT INITIAL.
    lo_nd_t_zholdates->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING table = lt_t_zholdates ).
    IF lt_t_zholdates[] IS NOT INITIAL.
      LOOP AT lt_t_zholdates[] INTO ls_t_zholdates.
*       marking-category = CL_WD_DATE_NAV_LEGEND=>E_CATEGORY-FOUR.
        marking-daySemantic = CL_WD_DATE_NAV_MARKING=>E_DAY_SEMANTICS-GOODVALUE_LIGHT.
        marking-tooltip  = 'Public Holiday'.
        marking-date     = ls_t_zholdates-holdate.
        append marking to markings.
      ENDLOOP.
    ENDIF.
  ENDIF.

  node->bind_table( markings ).

Edited by: christiaan69 on Jan 20, 2011 12:59 PM