0% found this document useful (0 votes)
81 views2 pages

'No - of - Tables': Get Element Via Lead Selection @TODO Handle Not Set Lead Selection

This method populates a drop down list with values from 1 to the number of tables and sets an attribute on the context node. It then gets the selected number of tables from the context, creates a sub-node with the table name, binds an internal table of table data to the sub-node, and displays the data in an ALV component.

Uploaded by

Robert Walls
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views2 pages

'No - of - Tables': Get Element Via Lead Selection @TODO Handle Not Set Lead Selection

This method populates a drop down list with values from 1 to the number of tables and sets an attribute on the context node. It then gets the selected number of tables from the context, creates a sub-node with the table name, binds an internal table of table data to the sub-node, and displays the data in an ALV component.

Uploaded by

Robert Walls
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

METHOD onactionpopulate_drop_down .

DATA drp_info
TYPE REF TO if_wd_context_node_info.
DATA drp_value_set TYPE wdr_context_attr_value.
DATA drp_value_list TYPE wdr_context_attr_value_list.
DATA index TYPE n.
drp_info = wd_context->get_node_info( ).
DO 4 TIMES.
index = sy-index .
drp_value_set-value = index.
drp_value_set-text = index.
INSERT drp_value_set INTO TABLE drp_value_list.
ENDDO.
drp_info->set_attribute_value_set(
EXPORTING
name = 'NO_OF_TABLES'
value_set = drp_value_list ).
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_no_of_tables TYPE wd_this->element_context-no_of_tables.
*
*

get element via lead selection


lo_el_context = wd_context->get_element( ).
@TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.
get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `NO_OF_TABLES`
IMPORTING
value = lv_no_of_tables ).

if lv_no_of_tables eq 1.

DATA:
*Node Info
rootnode_info type ref to if_wd_context_node_info,
*Context Nodes
dyn_node
type ref to if_wd_context_node,
tabname_node type ref to if_wd_context_node,
*String (for table name)
tablename type string.
*get node info of context root node
rootnode_info = wd_context->get_node_info( ).
*get the name of the table to be created.

tabname_node = wd_context->get_child_node( name = 'INPUT_TABLE' ).


* tabname_node->get_attribute( Exporting name = 'TABNAME'
*
Importing value = tablename ).
tablename = 'SFLIGHT'.
*create sub node named TEST1 of structure (tablename)
cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
parent_info = rootnode_info
node_name = tablename
structure_name = tablename
is_multiple = abap_true ).
DATA: stru_tab type ref to data.
field-symbols: <tab> type table.
*Create Internal Table
create data stru_tab type table of (tablename).
assign stru_tab->* to <tab>.
*Get table content
select * from (tablename) into corresponding fields of table <tab>.
*get instance of new node
dyn_node = wd_context->get_child_node( name = tablename ).
*Bind Internal table to context node.
dyn_node->bind_table( <tab> ).
*instantiate alv component
data: l_ref_cmp_usage type ref to if_wd_component_usage.
l_ref_cmp_usage =
wd_this->wd_cpuse_alv( ).
if l_ref_cmp_usage->has_active_component( ) is initial.
l_ref_cmp_usage->create_component( ).
endif.
*pass context node to alv
data: l_ref_interfacecontroller type ref to iwci_salv_wd_table .
l_ref_interfacecontroller =
wd_this->wd_cpifc_alv( ).
l_ref_interfacecontroller->set_data( dyn_node ).

endif.
ENDMETHOD

You might also like