cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic context nodes

Former Member
0 Kudos

Hi all,

I want to create a dynamic context in this way. But in this example I always need a data element in the dictionary for the describe by name method --> here ZREMARK

I can use here describe_by_name( 'STRING' ) but then the column headerline is empty.

How can I set the column headerline when I use this coding?

comp-name = 'REMARK'.

comp-type ?= cl_abap_datadescr=>describe_by_name( 'ZREMARK' ).

APPEND comp TO comp_tab.

  • not this structure contains the fields "CONNID" and "CARRID"

struct_type = cl_abap_structdescr=>create( comp_tab ).

  • now the nodeinfo is created

node_info = wd_context->get_node_info( ).

node_info = node_info->add_new_child_node(

name = 'MY_NODE'

is_mandatory = abap_false

is_multiple = abap_true

static_element_rtti = struct_type

is_static = abap_false

).

regards

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>How can I set the column headerline when I use this coding?

What UI element are you binding the content to - ALV or Table? The process of filling in the column header description would be different for each.

Why do you need to fill in a column heading? If you use comp-type ?= cl_abap_datadescr=>describe_by_name( 'ZREMARK' ).

and ZREMARK is your DDic Data Element, the description should be pulled from the data dictionary. You mention using DESCRIBE_BY_NAME( 'STRING' ) in one place and then use a DDic element in the code - so I'm a little confused.

Former Member
0 Kudos

Hi,

I want to use the table control - no alv because I want to use grouped headers later on. (Later on I'm looking for a coding where I can create grouped headers dynamically)

My problem is that I have dynamic columns in my table which are not available in the dictionary. And it makes no sense to create a database table or structure in the DDic because the whole structure of the table is always different.

When I think of a normal ALV grid (not in web dynpro) I can create the fieldcatalog manually like that.

struct-fieldname = 'XYZ'.

struct-seltext = 'Material'.

struct-datatype = 'XZY'.

Is it possible to create the columns of the table control in a similar way?

The table should look like this -> grouped headers

Column1 Column2 .. ColumnX

Min Min Min Max Min Max

And Column1 - ColumnX are values from a database table and not the fields of a table.

regards

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>Is it possible to create the columns of the table control in a similar way?

Yes you can create the table and its columns dynamically in WDDOMODIFYVIEW. Here is a sample - I'm only creating one column, but it would be easy to adapt this logic to loop through some list of fields to create the columns.

DATA lr_container TYPE REF TO cl_wd_uielement_container.
  DATA lr_input TYPE REF TO cl_wd_input_field.
  DATA lr_table TYPE REF TO cl_wd_table.
  DATA lr_caption TYPE REF TO cl_wd_caption.
  DATA lr_table_column TYPE REF TO cl_wd_table_column.
  DATA lr_table_standard_cell TYPE REF TO cl_wd_table_standard_cell.

  IF first_time = abap_true.
    lr_container  ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

    cl_wd_table=>new_table(
      EXPORTING
        bind_data_source              = 'SFLIGHT.SFLIGHT'
        id                            = 'DYNTABLE'
      RECEIVING
         control                       = lr_table ).

    cl_wd_input_field=>new_input_field(
      EXPORTING
         bind_value             = 'SFLIGHT.SFLIGHT.CARRID'
         id                     = 'INPUT1'
      RECEIVING
        control                = lr_input ).

    lr_table_column = cl_wd_table_column=>new_table_column( ).
    lr_table_column->set_table_cell_editor( lr_input ).
    lr_caption = cl_wd_caption=>new_caption( ).
    lr_caption->set_text( 'Some text' ).

    lr_table_column->set_header( EXPORTING the_header = lr_caption ).
    lr_table->add_column( EXPORTING the_column = lr_table_column ).


*       create the layout data of the text view
    DATA lr_grid_data TYPE REF TO cl_wd_grid_data.
    lr_grid_data = cl_wd_grid_data=>new_grid_data( lr_table ).
    lr_table->set_layout_data( lr_grid_data ).
    lr_container->add_child(
      EXPORTING
        the_child = lr_table ).
  ENDIF.

Former Member
0 Kudos

Hi,

thanks for your coding.

Now it works fine. Do you have also an example for grouped headers?

regards

Edited by: Wolfgang Bauer on May 12, 2010 7:00 AM

Former Member
0 Kudos

To execute the functionality suggested by Thomas, please ensure the following things:

1) Make sure that the Layout type of the ROOTUIELEMENTCONTAINER is Grid Layout otherwise it will give you a error.

2) Make a Node SFLIGHT with attribute CARRID in the View context.

3) Use the below updated code for the Data source reference:

IF first_time = abap_true.

lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

cl_wd_table=>new_table(

EXPORTING

bind_data_source = 'SFLIGHT' " change 'SFLIGHT.SFLIGHT' to 'SFLIGHT'

id = 'DYNTABLE'

RECEIVING

control = lr_table ).

cl_wd_input_field=>new_input_field(

EXPORTING

bind_value = 'SFLIGHT.CARRID'

id = 'INPUT1'

RECEIVING

control = lr_input ).

Because we would not create another Node with the similar name in the same context.

Hope it helps you.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Why do you feel the need to "correct" the coding. There is nothing wrong here. This is a sample from a working applicaiton - of course the context names have to be adjusted to whatever your situation is.

>Because we would not create another Node with the similar name in the same context.

Why not? I did in my application.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Hi,

>

> thanks for your coding.

>

> Now it works fine. Do you have also an example for grouped headers?

>

> regards

>

> Edited by: Wolfgang Bauer on May 12, 2010 7:00 AM

I don't have a sample of grouped headers that I could shared, but the concpets for dynamic generation would be the same.

Former Member
0 Kudos

Hi Thomas,

1) I just want to pass my point to other users so that they don't face any issue while taking this thread as a reference for dynamic table creation.

2) For the second point, as you said:

Why not?

I am getting an error, when creating another node with the same name in the view context as below:

A node with the name SFLIGHT already exists in the context.

Please suggest, what will be the problem for such type of error?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>I am getting an error, when creating another node with the same name in the view context as below:

>A node with the name SFLIGHT already exists in the context.

If the node is created dynamically and mapped dynamically there there isn't any error when using repeating names.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

As I understand, you want to set header text of a column when column type is of type string.

Every table column will have a caption UI element included by default ( expand you table column ).

You can bind the captions text property to an attribute of type string, which can contain your table column header.

I guess this is what you are looking for ..

Regards

Manas Dua

Former Member
0 Kudos

Hi,

Check this [Thread|; . In this thread they are creating a dynamic table with structure of dynamic node.

Hope it helps you.

Former Member
0 Kudos

You answered not my question..