on 04-09-2007 6:18 AM
Hello to all,
I intend to bind a table dynamically for which i am following these steps:
1. Created the context node dynamically in WDINIT.
2. Filled the context node (made a select query and then using bind_table)
3. In WDDOModify, used the following code
CALL METHOD VIEW->GET_ROOT_ELEMENT
RECEIVING
ROOT_VIEW_ELEMENT = LR_ROOT_ELEMENT .
"DOWNCAST IT
LR_CONTAINER ?= LR_ROOT_ELEMENT.
4. Created an UI elemnt and bound the data source
CALL METHOD CL_WD_TABLE=>NEW_TABLE
EXPORTING
BIND_DATA_SOURCE = 'SFLIGHTS_CONTEXT'
ID = 'TABLE_SFLIGHT'
RECEIVING
CONTROL = LR_TABLE
.
5. CALL METHOD LR_CONTAINER->ADD_CHILD
EXPORTING
THE_CHILD = LR_TABLE
6 CALL METHOD CL_WD_FLOW_DATA=>NEW_FLOW_DATA
EXPORTING
ELEMENT = LR_TABLE
RECEIVING
CONTROL = LR_FLOW_DATA
With this all i am getting in the browser is an empty table. Well i have used the <b>bind_data_source</b> parameter = the context, and this context is very much filled in the WDDOINIT method but can't understand this behavior of getting an empty table.
Please help me with this
Hi Abhishek,
I am putting the Exaple code which will help you to solve the problem. Here the logic in my example are the User enters TABLENAME into the Input field and he want to display the information about that Table with data.
DATA: lr_root_info TYPE REF TO if_wd_context_node_info,
lr_node_info TYPE REF TO if_wd_context_node_info,
lr_context_node TYPE REF TO if_wd_context_node,
lr_context_elem TYPE REF TO if_wd_context_element,
lv_tabname TYPE string,
lr_db_tab TYPE REF TO data.
FIELD-SYMBOLS: <lfs_db_tab> TYPE ANY TABLE.
read db table name from context
lr_context_node = wd_context->get_child_node( name = 'TABLE_NAME' ).
lr_context_elem = lr_context_node->get_element( ).
lr_context_elem->get_attribute(
EXPORTING name = 'TABLENAME'
IMPORTING value = lv_tabname ).
TRANSLATE lv_tabname TO UPPER CASE.
get meta data info of root context node
lr_root_info = wd_context->get_node_info( ).
create context structure
CALL METHOD lr_root_info->add_new_child_node
EXPORTING
STATIC_ELEMENT_TYPE = lv_tabname
name = 'DB_TABLE'
receiving
child_node_info = lr_node_info.
create data object of correct type and assign field symbol
CREATE DATA lr_db_tab TYPE TABLE OF (lv_tabname).
ASSIGN lr_db_tab->* TO <lfs_db_tab>.
read DB content
SELECT * FROM (lv_tabname)
INTO CORRESPONDING FIELDS OF TABLE <lfs_db_tab>
UP TO 100 ROWS.
bind table to context
lr_context_node = wd_context->get_child_node( name = 'DB_TABLE' ).
CALL METHOD lr_context_node->bind_table
EXPORTING
new_items = <lfs_db_tab>.
Best Regards,
Vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vijaya,
As i mentioned previously the context node has already been created (using add_new_child_node).
The question here is : "How do i create a 'TABLE' UI element dynamically and fill it with a data source ?
I am getting an empty view when i go for
DATA: LR_LABEL TYPE REF TO CL_WD_LABEL,
LR_CARRIER_ID TYPE REF TO CL_WD_INPUT_FIELD,
LR_FLOW_DATA TYPE REF TO CL_WD_FLOW_DATA,
LR_TABLE TYPE REF TO CL_WD_TABLE.
CALL METHOD CL_WD_TABLE=>NEW_TABLE
EXPORTING
BIND_DATA_SOURCE = 'SFLIGHTS_CONTEXT'
ENABLED = ABAP_TRUE
ID = 'TABLE_SFLIGHT'
RECEIVING
CONTROL = LR_TABLE
hope i made myself clear this time.
Hi Abhishek,
Here in my example GROUP_1 is a transaparent conatainer which is already created in my View. If you don't want this directly you can pass ROOTUIELEMENTCONTAINER instead of GROUP_1.
<b>See the Code Below:</b>
Check, whether this method has been processed before
IF first_time = abap_true.
Get reference to group, which shall be modified
DATA: lr_group TYPE REF TO cl_wd_group.
lr_group ?= view->get_element( id = 'GROUP_1' ).
************************************************************************
Define table bound to node DB_TABLE
************************************************************************
DATA: lr_table TYPE REF TO cl_wd_table,
lr_context_node TYPE REF TO if_wd_context_node.
lr_context_node = wd_context->get_child_node( name = 'DB_TABLE' ).
CALL METHOD cl_wd_dynamic_tool=>create_table_from_node
EXPORTING
ui_parent = lr_group
table_id = 'TABLE'
node = lr_context_node
RECEIVING
table = lr_table.
endif.
Warm Regards,
Vijay
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.