cancel
Showing results for 
Search instead for 
Did you mean: 

Changing column headers in a dynamic table from a dynamic node

former_member498918
Participant
0 Kudos

I am creating a dynamic table from a dynamic node using the below code.

comp-name = fieldname.
comp-type ?= cl_abap_datadescr=>describe_by_name( MYDOMAIN ).

append comp to comp_tab.

comp-name = fieldname2.

comp-type ?= cl_abap_datadescr=>describe_by_name( MYDOMAIN ).

append comp to comp_tab.

struct_type = cl_abap_srtructdescr=>create( comp_tab ).

call method get_node_info

  receiving

      node_info = node_info.

call method node_info->add_new_child_node

     exporting

        name   = 'MY_NODE'

        static_element_rtti = struct_type

        is_static = abap_false

    receiving

        child_node_info    = node_info.

l_root ?= view->get_root_element( ).

l_node = wd_context->get_child_node( 'MY_NODE' ).

cl_wd_dynamic_tool=>create_table_from_node(

           ui_parent = l_root

           table_id   = 'MY_TABLE'

           node       = l_node ).

This is working fine. The problem I have is that the table column headings are all coming out as the description of MYDOMAIN. I want to set a different column heading for each column, even though the domain for each column is the same.

The dynamic table columns and node attributes are being created from a list of skillcodes in a ztable which may change from run to run. So there is no specific domain for each column. There are around 60 codes and therefore 60 different column headings required. So I can't set up domains for each column. I want to make the column heading the same name as the skillcode and node attribute name.

Can someone tell me how to set the column headings in a dynamic table created from a dynamic node in webdynpro ABAP please.

I have looked at captions, but can't see how to use them dynamically in the dynamic table.

Many thanks

Karen

Accepted Solutions (1)

Accepted Solutions (1)

nishantbansal91
Active Contributor
0 Kudos

Hi Karen,

Have you created the table?

are you create the table dynamically or static.


For this you have to take the table object from view in modify view method.

Get all the columns of table using class cl_wd_Table=GET_COLUMNS

Get all the columns loop at columns object and call the set header method, I have just copied the code.

loop at lt_Column into lr_column.    

lr_column->set_header(

            cl_wd_caption=>new_caption(

                text = 'Cal. year / month'

            )

thanks

Nishant

Answers (1)

Answers (1)

AbhishekSharma
Active Contributor
0 Kudos

Hi Karen,

You can set table header dynamically as follows


Data:

          lr_table        TYPE REF TO cl_wd_table,

          lr_column       TYPE REF TO cl_wd_table_column.


lr_column = cl_wd_table_column=>new_table_column(

             view = view

             fixed_position = cl_wd_table_column=>e_fixed_position-left

           ).

           lr_column->set_header(

            cl_wd_caption=>new_caption(

                text = 'Cal. year / month'

            )

           ).



Hope this will help.


Thanks-

Abhishek


.