on 06-10-2009 4:27 PM
hi everyone
is it possible to create an ALV or a table dynamically?
if possible, please tell me stepwise
thanks
method WDDOMODIFYVIEW .
data: wd_node_info type ref to if_wd_context_node_info,
wd_node type ref to if_wd_context_node,
lr_container type ref to cl_wd_uielement_container,
lv_tablename type string,
lt_db_data type ref to data,
lr_table type ref to cl_wd_table.
field-symbols: <lt_data> type any table.
wd_node_info = wd_context->get_node_info( ).
wd_node = wd_context->get_child_node( name = 'INPUT' ).
wd_node->get_attribute( exporting name = 'TABLE_NAME'
importing value = lv_tablename ).
" If TABLE_NAME is not equal to '' then it must be having the table name entered by the user
" Please keep in mind that am not validating the name entered by the user as of now in here..
check lv_tablename NE ''.
create data lt_db_data type table of (lv_tablename).
assign lt_db_data->* to <lt_data>.
" Creating the node with structure same as the tablename entered by user
" for binding to the table ui element dynamically
CALL METHOD WD_NODE_INFO->ADD_NEW_CHILD_NODE
EXPORTING
STATIC_ELEMENT_TYPE = lv_tablename
NAME = 'MY_NODE'
IS_MULTIPLE = ABAP_TRUE
IS_INITIALIZE_LEAD_SELECTION = ABAP_FALSE
RECEIVING
CHILD_NODE_INFO = wd_node_info.
wd_node = wd_context->get_child_node( name = 'MY_NODE' ).
" Fetch data from the table name entered by the user
select * from (lv_tablename) into corresponding fields of table <lt_data> up to 20 rows.
wd_node->bind_table( new_items = <lt_data> ).
lr_container ?= view->get_root_element( ).
cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).
" Creating internal table with the same structure as our dynamic context node
CALL METHOD CL_WD_DYNAMIC_TOOL=>CREATE_TABLE_FROM_NODE
EXPORTING
UI_PARENT = lr_container
TABLE_ID = 'MY_TABLE'
NODE = wd_node
RECEIVING
TABLE = lr_table.
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_table ).
lr_table->bind_data_source( path = 'MY_NODE' ).
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anjali,
Please try going through my code below. I have an input field on my screen where the user enters a table name of his choice. I would need to fetch and display the data from the database in the underlying table below.
I hope that this would help serve your cause.
I have a context node by name INPUT which has just 1 attribute TABLE_NAME of type STRING which am using to hold the table name entered by the user. The user enters a table name and presses on a pushbutton. I dont have any code within my buttons action handler. Within the WDDOMODIFYVIEW am just checking if the TABLE_NAME attribute is not blank & then going ahead with the dynamic node & table creation.
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anjali,
It is possible to create both an table & ALV dynamically. Regarding the ALV you can go through this excellent [blog |https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4c70444a-0801-0010-7688-9e4bd844b783]by Claudia Dangers.
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.