cancel
Showing results for 
Search instead for 
Did you mean: 

Problem involving dynamic table columns in ECM

Former Member
0 Kudos

Hi,

In my current project I have got a requirement whose solution I am not able to figure out.

My requirement is this:

I will have a table containig budget owners name(since its compensation management in HR).There will be a table popin inside this table on the click of the personal number of the budget owner. Now the table popin will have another table with all employees name under that particular budget owner.

The problem is that the table inside the popin will not be having fixed columns.

Actually the columns will be coming from a function module(HRWPC_RFC_OADP_EVAL_DATAVIEW ) in the form of an internal table .

My requirement is this how can this be handled?

How to create the table with dynamic columns?Mind it,the data inside the table also have to binded and some of the columns will also be editable.

Experts please help!

Thanks and Regards,

Saikat.

Accepted Solutions (1)

Accepted Solutions (1)

saravanan_narayanan
Active Contributor
0 Kudos

Hello Saikat,

Refer this blog /people/bjorn-henrik.zink/blog/2010/03/26/web-dynpro-abap-dynamic-table-in-table-popin to understand how to dynamically create a table in the table popin.

And regarding the data binding, based on the output from HRWPC_RFC_OADP_EVAL_DATAVIEW FM, you need to dynamically create the context node and context attribute and the same has to bound to the table and table columns.

there are lot of blogs available in SDN which explains about how to dynamically create the context node and dynamically binding it to table. If you are not able to find let us know.

BR, Saravanan

Former Member
0 Kudos

Hi,

Thanks for the reply.The table i would like to keep in design time binding it to some other node.The node on the other hand will be created dynamically adding custom attributes that i get from that function module.After the node is created i will have to overwrite the binding for the table(we bound it to a node at desigh time remember) to this node.

Can you please share the code specially the part where i assign the newly created node to the already existing table which is created in desigh time.

Many thanks,

Saikat.

saravanan_narayanan
Active Contributor
0 Kudos

Hello Saikat,

I didnt understand why you want to create the table at design and change it runtime. you as well create the table at runtime. Because the table columns defined in the design time will not match number of table columns required at runtime. this depends on the outpur of your function module.

Anyway here is the solution for your requirement

1. create a attribute in the view controller (say MR_VIEW) of TYPE REF TO if_wd_view.

2. in the doModifyview method write the following code


if first_time = abap_true.
   wd_this->mr_view = view.
endif.

3. after calling you function module write the following code to change the biniding of the table and table columns


  data lo_table type ref to cl_wd_table.
  lo_table ?= wd_this->mr_view->get_element( id = 'TABLE'  ). "Pass the ID of the table that is created at design time

  data lo_nd_table2 type ref to if_wd_context_node.
  data lo_ndi_table2 type ref to if_wd_context_node_info.
  data lv_node_path type string.
  data lv_attribute_path type string.

  data lt_attributes type wdr_context_attr_info_map.
  data ls_attribute like line of lt_attributes.
  data lo_column type ref to cl_wd_table_column.
  data lo_text_view type ref to cl_wd_text_view.
  data lo_header type ref to cl_wd_caption.


  lo_nd_table2 = wd_context->get_child_node( 'TABLE2' ). "dynamically create context node name

  lv_node_path = lo_nd_table2->get_meta_path( abap_true ). "Get the path of this node

  lo_table->bind_data_source( path =  lv_node_path ). "change the ata 
  lo_table->remove_all_columns( ). "remove all the design time columns
  lo_table->remove_all_grouped_columns( ).

  lo_ndi_table2 = lo_nd_table2->get_node_info( ).
  lt_attributes = lo_ndi_table2->get_attributes( ). "get the attributes in the context node
"if you already have the list of attributes then you can just loop through them

  loop at lt_attributes into ls_attribute.

    concatenate lv_node_path '.' ls_attribute-name into lv_attribute_path.

    "Creating Table column
    lo_column = cl_wd_table_column=>new_table_column( view = wd_this->mr_view   ).
    "Creating table cell editor
    lo_text_view = cl_wd_text_view=>new_text_view(
          bind_text = lv_attribute_path "Path of the context attribute
          view      = wd_this->mr_view ).
    "creating header for the table column
    lo_header = cl_wd_caption=>new_caption(
        text  = ls_attribute-name
        view  = wd_this->mr_view  ).
    "Setting cell editor and header for the column
    lo_column->set_table_cell_editor( lo_text_view ).
    lo_column->set_header( lo_header ).

    "Adding the column to the table
    lo_table->add_column( the_column = lo_column  ).

  endloop.

BR, Saravanan

Former Member
0 Kudos

Thank you very much Saravanan.I will try this solution and will inform in this thread.

Thanks again,

Saikat.

Answers (0)