Skip to Content
  • Create pointer to model<br>

  model ?= get_model( ‘mf’ ).

  • Data definitions<br>

  data: sdnlinks type ZFAQSDNRSSLINKTAB.

clear sdnlinks.

clear lt_data.

sdnlinks = model->GET_FAQ_RSSLINKS( ).

if selected IS INITIAL.

lt_data = model->GET_SDN_WEBLOG_BY_URL( ).

else.

lt_data = model->GET_SDN_WEBLOG_BY_URL( url = selected ).

endif.

if selectedRowIndex IS INITIAL.

selectedRowIndex = -1.

endif.

  • Data definitions<br>

  data: default_view type ref to if_bsp_page.

  • Create view<br>

  default_view = create_view( view_name = ‘obj/sdn.htm’ ).

default_view->set_attribute( name = ‘lv_data’

value = lt_data ).

default_view->set_attribute( name = ‘iterator’

value = me ).

default_view->set_attribute( name = ‘sri’

value = selectedRowIndex ).

default_view->set_attribute( name = ‘selected’

value = selected ).

default_view->set_attribute( name = ‘sdnlinks’

value = sdnlinks ).

  • Call view<br>

  call_view( default_view ).

endmethod.

 

DO_HANDLE_EVENT

>
method DO_HANDLE_EVENT .

  • Table Types<br>

  data: wa TYPE ZFAQ_DATA.

data: witab TYPE ZFAQ_SDNRSS.

  • Object definitions<br>

  data: lt_event TYPE REF TO if_htmlb_data.

data: table TYPE REF TO CL_HTMLB_TABLEVIEW.

data: table_event TYPE REF TO cl_htmlb_event_tableview.

data: ddlb TYPE REF TO CL_HTMLB_DROPDOWNLISTBOX.

lt_event = cl_htmlb_manager=>get_event_ex( request ).

if lt_event IS NOT INITIAL.

table ?= CL_HTMLB_MANAGER=>GET_DATA( request = request

name = ‘tableView’

id = ‘sdn_sdnblogs’ ).

if table IS NOT INITIAL.

table_event = table->data.

selectedRowIndex = table_event->SELECTEDROWINDEX.

endif.

  • Check if the user selected a different link.<br>

    ddlb ?= CL_HTMLB_MANAGER=>GET_DATA(

method DO_REQUEST .

  • Create pointer to model

  model ?= get_model( ‘mf’ ).

  • Data definitions

  data: sdnlinks type ZFAQSDNRSSLINKTAB.

  clear sdnlinks.

  clear lt_data.

  sdnlinks = model->GET_FAQ_RSSLINKS( ).

  if selected IS INITIAL.

    lt_data = model->GET_SDN_WEBLOG_BY_URL( ).

  else.

    lt_data = model->GET_SDN_WEBLOG_BY_URL( url = selected ).

  endif.

  if selectedRowIndex IS INITIAL.

    selectedRowIndex = -1.

  endif.

  • Data definitions

  data: default_view type ref to if_bsp_page.

  • Create view

  default_view = create_view( view_name = ‘obj/sdn.htm’ ).

  default_view->set_attribute( name = ‘lv_data’

                               value = lt_data ).

  default_view->set_attribute( name = ‘iterator’

                               value = me ).

  default_view->set_attribute( name = ‘sri’

                               value = selectedRowIndex ).

  default_view->set_attribute( name = ‘selected’

                               value = selected ).

  default_view->set_attribute( name = ‘sdnlinks’

                               value = sdnlinks ).

  • Call view

  call_view( default_view ).

endmethod.

method DO_HANDLE_EVENT .

  • Table Types

  data: wa TYPE ZFAQ_DATA.

  data: witab TYPE ZFAQ_SDNRSS.

  • Object definitions

  data: lt_event TYPE REF TO if_htmlb_data.

  data: table TYPE REF TO CL_HTMLB_TABLEVIEW.

  data: table_event TYPE REF TO cl_htmlb_event_tableview.

  data: ddlb TYPE REF TO CL_HTMLB_DROPDOWNLISTBOX.

  lt_event = cl_htmlb_manager=>get_event_ex( request ).

  if lt_event IS NOT INITIAL.

    table ?= CL_HTMLB_MANAGER=>GET_DATA( request = request

                                  name    = ‘tableView’

                                  id      = ‘sdn_sdnblogs’ ).

    if table IS NOT INITIAL.

      table_event = table->data.

      selectedRowIndex = table_event->SELECTEDROWINDEX.

    endif.

  • Check if the user selected a different link.

    ddlb ?= CL_HTMLB_MANAGER=>GET_DATA(

                      request = request

                      id = ‘sdn_sdnlinks’

                      name = ‘dropdownListBox’ ).

    IF ddlb->selection IS NOT INITIAL.

      selected = ddlb->selection.

      lt_data = model->GET_SDN_WEBLOG_BY_URL( url = selected ).

    ENDIF.

    CASE event.

      WHEN ‘edit’.

        model->SET_TAB( tab = ‘sdnlinks’ ).

        navigation->goto_page( ‘faq.do?faq_tabs=sdnlinks’ ).

      WHEN ‘add’.

        IF selectedRowIndex NE 0.

          READ TABLE lt_data INTO witab index selectedRowIndex.

          CLEAR wa.

          “* Assign automatic Category ID 1 –

          “* SDN Weblog Category

          wa-CAT_ID = 1.

          “* Assign automatic ID for the next DATA entry

          wa-ID = model->GET_NEXT_DATA_ID( table = ‘ZFAQ_DATA’ ).

          wa-AUTHOR = witab-creator.

          wa-CDATE = witab-pdate.

          wa-SUBJECT = witab-subject.

          wa-TITLE = witab-title.

          wa-SHORT_DESC = witab-description.

          wa-URL = witab-link.

          INSERT INTO ZFAQ_DATA VALUES wa.

          selectedRowIndex = 0.

        ENDIF.

    ENDCASE.

  endif.

endmethod.

Earilier I stated that we should define our global tab variable, and if you noticed we’ve now used the idea of that variable to forward our navigation to another tab from this controller. Check the ‘edit’ case statement.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Gregor Wolf
    Hi Craig,

    I think you build in some bugs to see if somebody use your tutorial. I’ve found that the Attribute definitions are not correct. Hope that the HTML PRE Tag works here I post the correct (Class get’s compiled) here

    LT_DATA     Instance Attribute     Protected     Type     ZFAQSDNRSSTAB
    M_ROW_REF     Instance Attribute     Protected     Type Ref To     ZFAQ_SDNRSS
    SELECTEDROWINDEX     Instance Attribute     Protected     Type     I
    SELECTED     Instance Attribute     Protected     Type     STRING
    MODEL     Instance Attribute     Private     Type Ref To     ZFAQ_CL_M

    Regards
    Gregor

    (0) 

Leave a Reply