on 06-01-2010 12:41 PM
Hi,
I have a ALV table with tree in one column (reccuring context value).
I would like dynamically to add new columns. I know the method of IF_WD_CONTEXT_NODE_INFO->ADD_NEW_CHILD_NODE, but this is used in another posts/blogs where whole table is generated dynamically. I have a table already and just want to add a new column.
Is that possible?
Thank you on advance, cheers.
Under normal circumstances you could use the Context API method ADD_ATTRIBUTE to create a dynamic attirubte:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/af/cb744176cb127de10000000a155106/frameset.htm
Unfortunately this is not compatible with the ALV. The ALV only supports static attributes. Therefore you will need to build up an entire RTTI based structure in memory and then dynamically re-create the entire context. This is a similar example:
data:
rootnode_info type ref to if_wd_context_node_info,
dyn_node type ref to if_wd_context_node,
dyn_node_info type ref to if_wd_context_node_info,
tabname_node type ref to if_wd_context_node,
current_tablename type string,
tablename type string,
struct_type type ref to cl_abap_structdescr,
table_type type ref to cl_abap_tabledescr,
comp_tab type cl_abap_structdescr=>component_table,
comp like line of comp_tab,
my_table type ref to data,
my_row type ref to data.
loop at field_details assigning <wa_detail>.
* build a structure description from the list of single fields
comp-name = <wa_detail>-field_code.
comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ). "Replace with your dataType
append comp to comp_tab.
endloop.
struct_type = cl_abap_structdescr=>create( comp_tab ).
dyn_node_info = rootnode_info->add_new_child_node(
name = 'MDM_DATA'
is_mandatory = abap_false
is_mandatory_selection = abap_false
static_element_rtti = struct_type
is_multiple = abap_true
is_static = abap_false ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.