on 12-08-2006 12:28 AM
I am trying to create a dynamic Context that the ALV will use to present the data.
We cannot use a structure as we have no idea now many columns will be required until the data is retrieved.
Context:
- Node: MATRIX_NODE
- Attribute: ORIG_ZONE Type CHAR30
We are adding tothe MATRIX_NODE node many addtional attributes using the ADD_ATTRIBUTE method.
When the ALV is displayed, it is showing all the columns we have added but when we populate the information, the ALV is not picking it up. We can see the data in the MATRIX_NODE context object under the DYNAMIC_ATTRIBUTES attribute and not in the Structure atttribute.
How can we get the ALV to display the data we want?
Glenn
Try adding the attributes as STATIC.
I know it sounds unusual, but you can nominate the dynamically
added attributes should behave as the static ones.
Useful when some code accessing data in the does so using
GET_STATIC_ATTRIBUTES.
The dynamic data is correctly ignored.
Check the parameters on if_wd_context_node_info->ADD_ATTRIBUTE ,
the structure has a field "IS_STATIC"
Set it to ABAP_TRUE
cheers
Phil.
regards
Phil.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Phil,
Sorry, but this will not work. This is_static is mainly used internally, and means that the attribute belongs to the data structure of the node. The data structure may be a DDIC structure, created by the framework from the declared attributes or created by coding during runtime. This is done via RTTI.
Please refer to the following coding (e.g. in WDDOINIT):
DATA: node_info type ref to if_wd_context_node_info,
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.
field-symbols: <table> type table,
<row> type data,
<flight> type sflight.
* build a structure description from the list of single fields
comp-name = 'CARRID'.
comp-type ?= cl_abap_datadescr=>describe_by_name( 'S_CARRID' ).
APPEND comp TO comp_tab.
comp-name = 'CONNID'.
comp-type ?= cl_abap_datadescr=>describe_by_name( 'S_CONNID' ).
APPEND comp TO comp_tab.
* not this structure contains the fields "CONNID" and "CARRID"
struct_type = cl_abap_structdescr=>get( 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_true
IS_MULTIPLE = ABAP_true
STATIC_ELEMENT_RTTI = struct_type
IS_STATIC = ABAP_false
).
* fill new node;
data: l_node type ref to if_wd_context_node,
l_flight type STANDARD TABLE OF sflight.
*
l_node = wd_context->get_child_node( 'MY_NODE' ).
select * from sflight into table l_flight.
*
* if you could create a local data type, would be fine, but if you have to do it dynamically ...
struct_type = node_info->GET_STATIC_ATTRIBUTES_TYPE( ).
* create tabledescriptor from structdescription (standard table, no keys)
table_type = cl_abap_tabledescr=>get( p_line_type = struct_type ).
create data my_table type handle table_type.
assign my_table->* to <table>.
loop at l_flight assigning <flight>.
create data my_row type handle struct_type.
assign my_row->* to <row>.
move-corresponding <flight> to <row>.
append <row> to <table>.
endloop.
l_node->bind_table( <table> ).
* it would be possible to use
* l_node->bind_table( l_sflight ).
* but this would not be much slower, because the node optimization cannot be used
Ciao, Regina
Regina:
I will try your example code out and see if it meets our needs. But the long and short of it is that to get the 'structure' to be filled in the dynamic node must be created with a structure, you cannot dynamically append attributes to a node and use the ALV...
That seems to be a bit of a short comming with this version. I would think that ALV would have had more smarts.
Glenn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
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.