Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata


The below example shows, design of a database utility which displays data of any database table present in SAP system. User has to input the database table name and hit enter on keyboard. On user action the data will be displayed in Webdynpro ALV.

Below are the steps

Step 1: Declare usage of ALV component (SALV_WD_TABLE) in Consumer Component (Our Component: YDEMO_DYNPRO1) in the properties tab.


Step 2: Declare the usage of ALV in the properties tab of COMPONENTCONTROLLER of consumer component.


Step 3: Create proxy object of ALV in the DOINIT of COMPONENT CONTROLLER.

Code snippet

  data lo_cmp_usage type ref to if_wd_component_usage.
  lo_cmp_usage =   wd_this->wd_cpuse_dynmaic_alv( ).
  if lo_cmp_usage->has_active_component( ) is initial.
    lo_cmp_usage->create_component( ).



Step 4: Go to main view and create context attribute TABNAME (type : TABNAME) under Root context node.



Step 5: Go to layout tab of the MAIN view and create below UI elements

  • An input field which is data bind to TABNAME attribute of the context




Step 6: Create Enter action for the input field



Step 7: Go to properties of MAIN view and add usage of INTERFACECONTROLLER of the ALV.




Step 8: Go to ONACTIONENTER method of MAIN view and add below code


The code is built by using following concepts

Dynamic Internal table – OOPS ABAP

Context Programming – Webdynpro ABAP

Component Usage Concept – Webdynpro ABAP

Dynamic Programming – Webdynpro ABAP


Code Snippet



**Step 1: Find the table name from the screen
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->Element_context.
DATA lv_tabname TYPE wd_this->Element_context-tabname.
lo_el_context = wd_context->get_element( ).
    name =  `TABNAME`
    value = lv_tabname ).

**Step 2: Dynamic Internal table to hold data which comes from DB
data : dyntab type REF TO data.

CREATE DATA dyntab type TABLE OF (lv_tabname).
ASSIGN dyntab->* TO <table>.

SELECT * UP TO 20 ROWS FROM (lv_tabname) INTO TABLE <table>.

**Step 3: Dynamic context node
data : lv_table type string.
lv_table = lv_tabname.
wd_context->get_node_info( )->ADD_NEW_CHILD_NODE(
    STATIC_ELEMENT_TYPE          = lv_table
    NAME                         = lv_table
wd_context->get_child_node( lv_table )->BIND_TABLE(
    NEW_ITEMS            = <table>
*    INDEX                =
**Step 4: Assign this context to ALV
lo_INTERFACECONTROLLER =   wd_this->wd_cpifc_dynmaic_alv( ).

*   only_if_new_descr =                 " wdy_boolean
    r_node_data = wd_context->get_child_node( lv_table )   " ref to if_wd_context_node





Step 9: Go to display mode and activate all the entities together. Select Activate at component level.




Finally we have made a short and simple yet powerful application. J





  • No labels