0

In my webdynpro, when I click a button, I wan't to get the tooltip of the button and use it as the title of the pop-up window.

method WDDOMODIFYVIEW .
  "write view to attribute so it can be accessed from other methods.
  wd_this->DETAILVIEW = view.
endmethod.

.

method ONACTIONOPENDIALOG .
  data lv_title type string.
  data lv_buttonID type string.
  data lv_button type ref to if_wd_view_element.
  buttonID = wdevent->get_string( name = 'ID' ).
  button = wd_this->detailview->get_element( lv_buttonid ).

  call method cl_fitv_wd_util=>UI_GET_PROPERTY(
    exporting
      io_view = wd_this->detailview
      io_view_element = lv_button
      iv_id = buttonid
      iv_property_name = 'TOOLTIP'
      importing
      ev_value = lv_title ).

  wd_this->dopopup( title = lv_title ).
endmethod.

The method UI_GET_PROPERTY fails to get the tooltip. Probably because it's trying to call the method GET_TOOLTIP on if_wd_view_element and not on cl_wd_button. Is this a bug in this method? Is there a way to convert if_wd_view_element to cl_wd_button?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Peter
  • 850
  • 5
  • 16

1 Answers1

1

ref to if_wd_view_element can be downcasted to ref to cl_wd_uielement. Downcasting to cl_wd_button works aswell for buttons, but not for toolbar buttons. cl_wd_uielement works for probably all uielements.

method ONACTIONOPENDIALOG .
  data lv_title type string.
  data lv_buttonID type string.
  data lv_button type ref to if_wd_view_element.
  data lv_realbutton type ref to cl_wd_uielement.

  lv_buttonID = wdevent->get_string( name = 'ID' ).
  lv_button = wd_this->detailview->get_element( lv_buttonid ).

  "downcast view_element to uielement
  lv_realbutton ?= lv_button.
  lv_title = lv_realbutton->get_tooltip( ).

  selectbuttonrow( exporting actionevent = wdevent ).
  wd_this->dopopup( title = lv_title ).
endmethod.

I found an article about downcasting here: https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapmove_cast.htm

Peter
  • 850
  • 5
  • 16