Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

DATE_SELECTED event of CL_GUI_CALENDAR not working

Hey folks,

I have created a several "view" classes to encapsulate all object oriented stuff related to my Dynpros.

In one of them I create a CL_GUI_CUSTOM_CONTAINER and a CL_GUI_CALENDAR inside of it.

Although I have followed all the guides and docs I have found on the web, I can't seem to get the event triggering working.

The view class looks as follows:

CLASS zcl_test_view_main DEFINITION

  PUBLIC

  FINAL

  CREATE PUBLIC.

  PUBLIC SECTION.

    METHODS constructor.

    METHODS on_date_selected FOR EVENT date_selected OF cl_gui_calendar

      IMPORTING date_begin

                date_end.

  PROTECTED SECTION.

  PRIVATE SECTION.

    DATA o_calendar           TYPE REF TO cl_gui_calendar.

    DATA o_calendar_container TYPE REF TO cl_gui_custom_container.

ENDCLASS.

CLASS zcl_test_view_main IMPLEMENTATION.

  METHOD constructor.

    IF me->o_calendar_container IS INITIAL.

      CREATE OBJECT me->o_calendar_container

        EXPORTING

          container_name = 'C_CALENDAR'.

    ENDIF.

    IF me->o_calendar_from IS INITIAL.

      DATA style    TYPE i.

      DATA events   TYPE cntl_simple_events.

      DATA event    LIKE LINE OF ievents.

      event-appl_event = 'X'.

      event-eventid = cl_gui_calendar=>m_id_date_selected.

      APPEND event TO events.

      style = cnca_sel_month.

      CREATE OBJECT me->o_calendar

        EXPORTING

          parent          = me->o_calendar_container

          selection_style = style

          view_style      = cnca_style_dtpicker

          dtpicker_format = 'yyy / MMMM'.

      me->o_calendar->set_registered_events( events = events ).

      SET HANDLER me->on_date_selected FOR me->o_calendar.

    ENDIF.

  ENDMETHOD.

  METHOD on_date_selected.

    MESSAGE 'TEST' TYPE 'I'.

    MESSAGE date_begin TYPE 'I'.

    MESSAGE date_end TYPE 'I'.

  ENDMETHOD.

ENDCLASS.

The month picker is being displayed correctly but the event just does not fire once i change the date. I have already changed the appl_event property but nothing changed.

I hope someone can find the mistake.

Thanks in advance!

Tags:
Not what you were looking for? View more on this topic or Ask a question