on 05-11-2010 7:14 AM
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
>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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
>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.
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.
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.
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.