on 10-02-2012 7:21 PM
Hi Experts,
I have a requirement where I need to build a dynamic internal table with dynamic columns => structure of the internal table is also dynamic
Now I have to display it using ALV
I have written logic to build dynamic internal table and written logic to set data to ALV
Only part missing is creating dynamic node for this dynamic internal table
I have populated my final internal table i.e dynamic internal table <lt_dyntable> with data
( FIELD-SYMBOLS: <lt_dyntable> TYPE STANDARD TABLE )
I have used following code for creating dynamic node:
DATA rootnode_info TYPE REF TO if_wd_context_node_info.
DATA dyn_node TYPE REF TO if_wd_context_node.
DATA tablename TYPE string.
rootnode_info = wd_context->get_node_info( ).
cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
parent_info = rootnode_info
node_name = tablename
structure_name = tablename ?????
is_multiple = abap_true ).
dyn_node = wd_context->get_child_node( name = tablename ).
dyn_node->bind_table( <lt_dyntable> ). "use dyn_node to set data to ALV
But as the internal table is dynamic, I do not have structure_name for this dynamic internal table.
What should I pass to the structure_name which is mandatory parameter but I have a dynamic structure.
Please suggest.
Thanks!
Regards
Vasu
Hi Vasu,
cl_wd_dynamic_tool=>create_nodeinfo_from_struct
This method is Obsolete which i have checked in EHP6 instead of this you can use
lv_struct-name = 'mystruct'.
call method l_cntx_nd_info_self>add_new_child_node
exporting
* supply_method =
* supply_object =
* dispose_method =
* dispose_object =
static_element_type = lv_struct_name
name = `NODE_2`
* is_mandatory = ABAP_FALSE
* is_mandatory_selection = ABAP_FALSE
is_multiple = abap_true
* is_multiple_selection = ABAP_TRUE
* is_singleton = ABAP_FALSE
* is_initialize_lead_selection = ABAP_TRUE
* static_element_rtti = lv_struct_name
is_static = abap_false
* attributes =
receiving
child_node_info = lo_child_node_info
.
if not lo_child_node_info is initial.
l_cntx_nd_result = nodt->get_child_node( name = `NODE_2` ).
endif.
and also see these links.
http://scn.sap.com/docs/DOC-28458
Hope this help you.
Regards
Madhukiran.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Madhu,
That was a very useful link and finally I am able to bind the data to the node.
Now I have a dynamic node which has table with data binded to it.
Now the problem is when I use set_data method of salv_wd_table, the table is not shown like regular ALV but shown like a regular table with no ALV functionality. Also, field headings are lost.
What should I do to make it look like normal ALV output
Thanks!
Regards
Vasu
Hi Vasu,
For getting ALV functionality you need to integrate standard wedynpro component in your component
and the node you have created you need to do external mapping with SALV_WD_TABLE node i.e., DATA but by directly calling method set_data you can't achieve ALV functionality.
To do alv follow this link.
http://saptechnical.com/Tutorials/WebDynproABAP/ALV/page1.htm
http://saptechnical.com/Tutorials/WebDynproABAP/ALV/page1.htmhttp://scn.sap.com/docs/DOC-2208
Regards
Madhukiran.
Hi,
Try creating the structure using cl_abap_structdescr=>create( ) method.
First create component table of type cl_abap_structdescr=>component_table.
data: lt_component_table type cl_abap_structdescr=>component_table.
comp-name = 'Field1'.
comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
APPEND comp TO lt_component_table.
comp-name = 'Field2'.
comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
APPEND comp TO lt_component_table.
data: structure TYPE REF TO cl_abap_structdescr.
structure = cl_abap_structdescr=>create( lt_component_table ). "returns Structure
Also you can use add_new_child_node(
name = <node_name>
is_mandatory = abap_true
is_multiple = abap_true
static_element_rtti = structure ). from interface IF_WD_CONTEXT_NODE_INFO.
Regards,
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Rohit. I was able to create the structure dynamically (using
cl_abap_structdescr=>create( ) method ) and have created internal table dynamically and populated values into it. Also, using add_new_child_node, I have created dynamic node and added attributes using add_attribute method.
Now I have dynamical internal table i.e.
FIELD-SYMBOLS: <lt_dyntable> TYPE STANDARD TABLE
<lt_dyntable> is populated with records
and I have dynamic node i.e.
DATA dyn_node TYPE REF TO if_wd_context_node.
Now, when I do the following,
dyn_node->bind_table( <lt_dyntable> ).
and use dyn_node in ALV, output is shown blank.
ALV part is working correctly as I have checked using another node with data and it displays records.
In debug mode, <lt_dyntable> has values.
dynamic node is also created correctly and attributes are fine as I can see the structure of internal table in ALV output.
However, only problem is that data is not shown.
Please suggest me how to bind dynamic internal table to a dynamic node.
Thanks!
Hi Vasu,
The code to do binding is correct. Have you set_Data method.
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
lo_interfacecontroller = wd_this->wd_cpifc_alv( ). "alv is the name of ALV component usage
lo_interfacecontroller->set_data( dyn_node ).
You can try this order ...
1. lo_interfacecontroller->set_data( dyn_node ).
2. dyn_node->bind_table( <lt_dyntable> ).
Regards,
Rohit
User | Count |
---|---|
80 | |
24 | |
12 | |
9 | |
7 | |
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.