cancel
Showing results for 
Search instead for 
Did you mean: 

Get the selected or active tab on a tabstrip to show different content

Former Member
0 Kudos

Hi All,

I have two tabs (TAB1 and TAB2) on a tabstrip. And on each of these tabs I have a table. Both tables are binded to the same context node.

The property selectedTab of the Tabstrip is binded to an attribute "TAB" of a context node "TABSTRIP".

I defined a supply function on this context node "TABSTRIP" in order to show the TAB1 by the first building up the view.

METHOD supply_tabstrip .


* local structure for the activ TAB
  DATA: stru_tabstrip TYPE if_componentcontroller=>element_tabstrip.
  CLEAR stru_tabstrip.

* set the default-value
* --> This is valid untill the user choose another Tab
  MOVE 'TAB1' TO stru_tabstrip-tab.

* bind the filled structure to the context
  node->bind_structure(
    new_item             = stru_tabstrip
    set_initial_elements = abap_true ).

ENDMETHOD.

I also definded a supply function on the context node of the table (which is mentioned above) to fill it with content.

Now i need to define a query to fill the table with two different content and for this I need to know which tab is selected by the user. How can i find which tab is selected or which tab is active?

Thank you for any help

Best regards

Haleh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I have a context attrinbute SELECTED to which the SelectedTab property of tabstrip is bound.

Implement action onSelect for Tabstrip - Use this code snippet -

***Variables
  DATA:
    lv_select_tab type string.          "Selected tab value
***Structure and internal table for the Events and messages
  DATA:
    lt_events type WDR_EVENT_PARAMETER_LIST,
    ls_events type WDR_EVENT_PARAMETER.

***Field symbols
  field-symbols: <fs_value> type any.   "Attribute value in events table

***Move the event table to lt_events
  lt_events = wdevent->parameters.

*"Set to 'TAB' in lt_events
  read table  lt_events into ls_events with key name = wd_assist->GC_TAB.  "TAB
  if sy-subrc eq 0.
    assign ls_events-value->* to <fs_value>.
    if sy-subrc eq 0.
      lv_select_tab = <fs_value>.
    endif.                 "IF sy-subrc eq 0.
  endif.                 "IF sy-subrc eq 0.

***Set the selected tab value
  CALL METHOD WD_CONTEXT->SET_ATTRIBUTE
    EXPORTING
      VALUE = lv_select_tab
      NAME  = wd_assist->GC_SELECT_TAB.  "Set the selected tab Id "SELECTED

**Call additional data if tab selected
  if lv_select_tab eq 'TAB1'.
*/Have your code here......
 else 
 endif.

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

thanks a lot for your prompt reply. I used your coding in the onSelect event of the tabstrip.

On this line:

read table  lt_events into ls_events with key name = wd_assist->GC_TAB.  "TAB

I get this syntaxerror:

Field "GC_TAB" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.

I tried to find the right phrase but couldn't.

Would you help me please?

thanks

Haleh

Former Member
0 Kudos

You hardcode it as 'TAB'.

read table  lt_events into ls_events with key name = 'TAB'.

Former Member
0 Kudos

Hi Lekha,

thanky you very much. I changed the phrase as you said and also with another small change in the coding it works now and i can show different content in the table on two tabs.

Have a nice and successful day

Regards, Haleh

Answers (0)