cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in creating a dynamic tab with dynamic table in tabstrip ?

Former Member
0 Kudos

Hi Guys,

I have a requirement to create a dynamic tab in tab strip with a dynamic table in it.

Though i am managing to create the dynamic tab and dynamic table,

The position of the table is the one i am unable to control.

The table is even appearing beyond the tab strip.

Please help to solve the issue.

My code which is generating the Dynamic tab and table is as below. This is written in modify view hook method.

  data:  lo_tab      type ref to CL_WD_TAB,

           lo_table    TYPE REF TO CL_WD_table,

           lo_container TYPE REF TO cl_wd_uielement_container,

           lv_string type string,

           it_zf005 type zftt005,

           lo_text      TYPE REF TO cl_wd_caption.

      lo_tab = cl_wd_tab=>new_tab(  ).

      lo_text = cl_wd_caption=>new_caption( text = 'Test' ).

      lo_tab->set_header( the_header = lo_text ).

      lo_tab->register_to_view( i_view = view ).

**define a table

     lv_string = 'COR'.

     lo_container ?= view->get_root_element( ).

     lo_table = cl_wd_dynamic_tool=>create_table_from_node( ui_parent = lo_container

                                                             table_id =  lv_string

                                                                 node = lo_nd_mpr_table ).

     lo_tab->set_content( the_content = lo_table ).

     lo_el_tabstrip->add_tab( exporting the_tab = lo_tab ).

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Vamsi,


Vamshi Krishna wrote:

The position of the table is the one i am unable to control.

The table is even appearing beyond the tab strip.

Here the issue is with below statement :


     lo_table = cl_wd_dynamic_tool=>create_table_from_node( ui_parent = lo_container

                                                             table_id =  lv_string

                                                                 node = lo_nd_mpr_table ).

You are creating table in root ui element and also adding into tab. Hence its appearing beyond tabstrip element.

Hence, its required to create a transparent container in your TAB and pass that reference to method parameter UI_PARENT.

You can achieve you requirement as below

  • Here, I have created a node TEST with attribute first_name & last_name
  • Change your code as below

METHOD wddomodifyview .
  DATA:  lo_tab         TYPE REF TO cl_wd_tab,
           lo_table     TYPE REF TO cl_wd_table,
           lo_container TYPE REF TO cl_wd_uielement_container,
           lv_string    TYPE string,
           lo_node      TYPE REF TO if_wd_context_node,
           lo_tabstrip  TYPE REF TO cl_wd_tabstrip,
           lo_text      TYPE REF TO cl_wd_caption.


  CHECK first_time EQ abap_true.


  lo_container ?= view->get_root_element( ).

  cl_wd_tabstrip=>new_tabstrip(
  EXPORTING
      id                         = 'TABSTRIP1'
      view                       = view
    RECEIVING
      control                    = lo_tabstrip
  ).
  DATA lo_layout_data TYPE REF TO cl_wd_flow_data.

  cl_wd_flow_data=>new_flow_data(
    EXPORTING
      element     = lo_tabstrip
    RECEIVING
      control     = lo_layout_data
  ).

  lo_tabstrip->set_layout_data(
  the_layout_data = lo_layout_data ).
  lo_container->add_child( lo_tabstrip ).

  lo_tab = cl_wd_tab=>new_tab( id = 'TAB1' ).

  lo_text = cl_wd_caption=>new_caption( text = 'Test' ).

  lo_tab->set_header( the_header = lo_text ).

  lo_tabstrip->add_tab(
    EXPORTING
      the_tab = lo_tab
  ).

**define a table

  lo_tabstrip->set_selected_tab( value =  lo_tab->id ).

  " add a container to tab
  DATA lo_tc    TYPE REF TO cl_wd_transparent_container.
  cl_wd_transparent_container=>new_transparent_container(
    EXPORTING
      id                       = 'TC_1'    " ID
    RECEIVING
      control                  = lo_tc    " CONTROL
  ).
  DATA lo_flow_layout TYPE REF TO cl_wd_flow_layout.

  cl_wd_flow_layout=>new_flow_layout(
    EXPORTING
      container = lo_tc
    RECEIVING
      control   = lo_flow_layout
  ).
  lo_tc->set_layout( the_layout = lo_flow_layout ).
*
  lo_node = wd_context->get_child_node( name = wd_this->wdctx_test ).

  lo_tab->set_content( the_content = lo_tc ).

  FREE lo_container.


  lo_table = cl_wd_dynamic_tool=>create_table_from_node(
  ui_parent = lo_tc

   table_id =  wd_this->wdctx_test

   node = lo_node ).

ENDMETHOD.

Change the above code as per your requirement

Hope this resolves your issue.

Regards,

Rama

Former Member
0 Kudos

Hi Rama,

Thanks a lot for your reply. Now, I am able to create the dynamic table.

But when i tried to change the table properties such as the visibility of the column and row count,

it is not working.

i have added this after creating the table dynamically.

data lr_column type REF TO CL_WD_TABLE_COLUMN.

lr_column = lo_table->get_column( id = 'MANDT' ).

here i am getting lr_column as always initial.

Please  help.

Thanks,
Vamshi

ramakrishnappa
Active Contributor
0 Kudos

Hi Vamsi,

The name of column is not the same as your attribute name,  if you create table from context node by using method of class CL_WD_DYNAMIC_TOOL.

Hence your column MANDT is not found in table

You column name should be like this

Table name : T_TEST

Index of column : 1

your column name is : T_TEST_C1

You can see all your columns by using LO_TABLE->CH_COLUMNS

Hope this helps you.

Regards,

Rama

ramakrishnappa
Active Contributor
0 Kudos

Hi Vamsi,

Please mark the replies as helpful/correct if its helping you in resolving your issue.

So, that it helps others to refer to the all helpful and correct answers

Regards,

Rama

Former Member
0 Kudos

Hi Rama,

Thanks for your quick replies.

Sure i will mark the answers helpful and correct when i am closing the thread.

Also excuse for asking the basic questions, as this is my first development in Web dynpro.

Thanks the column is working now.

Please also help to my Final issue, now i have created two tabs and two tables. Two tables are binded to the same context node.

But i have to show a set of data in one tab table and another set in another tab table.

How can i achieve this.

Thanks,
Vamshi

ramakrishnappa
Active Contributor
0 Kudos

Hi Vamshi,

You can achieve by using event ON_SELECT of tabstrip as below


  • Go to ACTIONS tab of your view and create an action "SET_DATA"
  • While creating tabstrip usint method NEW_TABSTRIP, you pass parameter ON_SELECT = 'SET_DATA'.
  • Now, the event handler will be triggered on selection any tab.
  • Go to event handler method "SET_DATA' , get the tab id by using WDEVENT object reference as below

          wdevent->get_data( name = 'ID' value = lv_tab_id ).

  • Based on tab id, bind the data to your context node as per requirement

     case lv_tab_id.

     when 'TAB1'.

          set data1 to context node

     when 'TAB2'

          set data2 to context node

     endcase.

Hope this helps you.

Regards,

Rama

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Rama,

Thanks for all your replies. It helped me solve my issue and also got a good understanding of Dynamic programming.

I am closing the thread.

However, i would be more happy if you confirm my below understanding.

You mention to set data to context node, when each tab is selected.

I found only way to set data is to bind the internal table to context node.

Is it the only way to set the data to node each time?

Please confirm.

Thanks,
Vamshi

Former Member
0 Kudos

If you want to set the refreshed data every time on the tab selection then write the code in the on_selection event of the tab strip.  Otherwise write the code in the wddoinit method of the view..

ramakrishnappa
Active Contributor
0 Kudos

Hi Vamshi,

Its good to hear

Yes, we set the table data to context node by using method BIND_TABLE of interface if_wd_context_node.

Regards,

Rama

Former Member
0 Kudos

Hello Vamshi,

I am following your approach above to dynamically embed a table within tabstrip but I am coming across the problem you faced about not having a node's structure in the context. Since my table is created dynamically I cannot provide the node with attributes since they are known at runtime.

I dont know if I have to define a context's attribute type string , type ref to data?

Please could you share how you sorted it out?

Thanks a lot,

Javier

Former Member
0 Kudos

Hi Javier,

Are you creating your node also dynamically?

But anyhow, you can bind the Node with attributes to the table. 


In the example mentioned by Rama, dynamic Table is bounded to a Context node. This node can be with many attributes.

If my understanding of your issue is incorrect, please elaborate your issue?

Thanks,

Vamshi

Former Member
0 Kudos

Hi Vamshi and thanks for your quick answer.

After defining my dynamic tabstrip I create the dynamic table within the tabstrip using the code below.

   lo_node = wd_context->get_child_node( name = wd_this->wdctx_test ).

   lo_tab->set_content( the_content = lo_tc ).

   FREE lo_container.

   lo_table = cl_wd_dynamic_tool=>create_table_from_node(

   ui_parent = lo_tc

    table_id wd_this->wdctx_test

    node = lo_node ).

   lo_tab->set_content( the_content = lo_table ).




Please be aware that I had bound my dynamic table <tab> to the context node Test as shown below.

So <tab> structure is provided at runtime therefore I cannot provide the context node Test with attributes.


DATA LO_ND_TEST TYPE REF TO IF_WD_CONTEXT_NODE.

   DATA LT_TEST TYPE WD_THIS->ELEMENTS_TEST.


* navigate from <CONTEXT> to <TEST> via lead selection

   LO_ND_TEST = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_TEST ).

   LO_ND_TEST->BIND_TABLE( NEW_ITEMS = <tab>

                           SET_INITIAL_ELEMENTS = ABAP_TRUE ).



The context node Test has an attribute Type Ref to Data, but I have also tried with Type String.


At the end the outcome is a table without columns in the tabstrip with the message: TABLE DOES NOT CONTAIN VISIBLE COLUMNS.


Thanks again for your help.


Javier



Former Member
0 Kudos

If still you are facing some problem you can use following document ..

ramakrishnappa
Active Contributor
0 Kudos

Hi Vamsi,

Is your resolved? if so, please close the discussion.

Regards,

Rama

harsha_jalakam
Active Contributor
0 Kudos

HI Vamshi,

     Create Flow/Matrix data arrangement in the above code and add table into it, it would place the table in the correct form.

Regards,

Harsha

Former Member
0 Kudos

Hi Harsha,


Thanks for the reply.

But as per my understand, a table in the tab does not have any layout definition.

So, how to achieve this?

Can you provide the sample data.

Thanks,
vamshi