0% found this document useful (0 votes)
283 views

Web Dynpro ABAP ALV - ON - CLICK Event: Procedure

The document provides steps to configure an ALV component in a Web Dynpro ABAP application to use the ON_CLICK event. It describes how to: 1) Create a Web Dynpro ALV program using the SALV_WD_TABLE component and configure it to include buttons for columns. 2) Define an ON_CLICK event handler method to identify clicks in ALV cells. 3) Use WDDOMODIFYVIEW to populate context nodes with click details and load associated data to display in the application.

Uploaded by

raju
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
283 views

Web Dynpro ABAP ALV - ON - CLICK Event: Procedure

The document provides steps to configure an ALV component in a Web Dynpro ABAP application to use the ON_CLICK event. It describes how to: 1) Create a Web Dynpro ALV program using the SALV_WD_TABLE component and configure it to include buttons for columns. 2) Define an ON_CLICK event handler method to identify clicks in ALV cells. 3) Use WDDOMODIFYVIEW to populate context nodes with click details and load associated data to display in the application.

Uploaded by

raju
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Web Dynpro ABAP ALV - ON_CLICK event

The following example program is a step by step guide to use ON_CLICK event to user
actions for the Button UI element.
Procedure.

Create Web dynpro alv program by using ALV component SALV_WD_TABLE.

Configure the ALV to get button for column

Define one event handler method ON_CLICK in view controller for ON_CLICK
event of SALV_WD_TABLE interface controller.

Identify Click in a Cell of ALV Output in event handler method ON_CLICK.

Implement WDDOMODIFYVIEW to set data based on click in a Cell.


Program steps

Create One Web Dynpro application for ALV output. Click here to check on
how to create.

Go to Component controller of web dynpro component


Methods tab ->Define CONFIGURE_ALV method and write the code as

o
specified.

o
o
o
o
o
o
o
o

CONFIGURE_ALV method code


METHOD configure_alv .
"Instantiate Used Component
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
lo_cmp_usage =
wd_this->wd_cpuse_alv( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

"Create an instance of ALV Interface Controller


DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
lo_interfacecontroller =
wd_this->wd_cpifc_alv( ).
"Configuration of the ALV Output
DATA lv_value TYPE REF TO cl_salv_wd_config_table.
lv_value = lo_interfacecontroller->get_model( ).
DATA:
lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lt_columns
TYPE salv_wd_t_column_ref,
ls_columns
LIKE LINE OF lt_columns.
lr_column_settings ?= lv_value.
lt_columns = lr_column_settings->get_columns( ).
LOOP AT lt_columns INTO ls_columns.
CASE ls_columns-id.
WHEN 'PERNR'.
DATA:lr_button TYPE REF TO cl_salv_wd_uie_button.
CREATE OBJECT lr_button.
lr_button->set_text_fieldname( ls_columns-id ).
ls_columns-r_column->set_cell_editor( lr_button ).
ENDCASE.
ENDLOOP.
ENDMETHOD.

Call CONFIGURE_ALV method in WDDOINIT hook method.

o
o
o
o
o

"configure_alv

METHOD wddoinit .
wd_this->get_data( ).
wd_this->configure_alv( ).
ENDMETHOD.

Activate web dynpro component and run application. The output would be like
below.

Go to view ALV_EVENTS_V
o

Properties tab->Define or Include Used Controllers/ Components of ALV.

Context tab->Create node PA0006 with cardinality 0..n and another node

EVENT_PROPERTIES(beneath NAME and VALUE are attributes) with cardinality


0..n.
o

Context node EVENT_PROPERTIES is needed to hold the information on


the last event.

Layout tab->Create one table UI element->Bind Context node PA0006


with table UI element.

Method tab->Define ON_CLICK event handler method for ON_CLICK


event of ALV Interface controller.

ON_CLICK event handler method code.Here EVENT_PROPERTIES


context node will be populated with details like column id, column index, column
attributes and value of column.

o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

Bind the internal table to context node EVENT_PROPERTIES.


METHOD ON_CLICK .
DATA: lr_node
TYPE REF TO if_wd_context_node,
lt_event_properties TYPE wd_this->elements_event_properties,
ls_event_properties TYPE wd_this->element_event_properties.
FIELD-SYMBOLS: TYPE ANY.
* fill internal table
ls_event_properties-name = 'COLUMN_ID'.
ls_event_properties-value = r_param->column.
APPEND ls_event_properties TO lt_event_properties.
ls_event_properties-name = 'INDEX'.
ls_event_properties-value = r_param->index.
APPEND ls_event_properties TO lt_event_properties.
ls_event_properties-name = 'ATTRIBUTE'.
ls_event_properties-value = r_param->attribute.
APPEND ls_event_properties TO lt_event_properties.
ASSIGN r_param->value->* TO <l_value>.
ls_event_properties-name = 'VALUE'.
ls_event_properties-value = <l_value>.
APPEND ls_event_properties TO lt_event_properties.
* navigate to context node EVENT_PROPERTIES
lr_node = wd_context->get_child_node( 'EVENT_PROPERTIES' ).

o
o
o
o

* bind internal table to context node


lr_node->bind_table( lt_event_properties ).
ENDMETHOD.

Populate context node PA0006 based on context EVENT_PROPERTIES.

For that use WDDOMODIFYVIEW hook method.


WDDOMODIFYVIEW method code

o
o
o
o
o
o
o
o

METHOD wddomodifyview .
DATA lo_nd_event_properties TYPE REF TO if_wd_context_node.
DATA: lt_event_properties TYPE wd_this->elements_event_properties,
ls_event_properties LIKE LINE OF lt_event_properties.
" Navigate from to via lead selection
lo_nd_event_properties = wd_context->get_child_node( name = wd_this>wdctx_event_properties ).
lo_nd_event_properties->get_static_attributes_table( IMPORTING table =
lt_event_properties ).

o
o
o
o
o
o

DATA lo_nd_pa0006 TYPE REF TO if_wd_context_node.


DATA lt_pa0006 TYPE wd_this->elements_pa0006.
" Navigate from <CONTEXT> to <PA0006> via lead selection
lo_nd_pa0006 = wd_context->get_child_node( name = wd_this->wdctx_pa0006
).

o
o
o
o
o
o
o
o

READ TABLE lt_event_properties INTO ls_event_properties WITH KEY name =


'VALUE'.
SELECT *
FROM pa0006
INTO CORRESPONDING FIELDS OF TABLE lt_pa0006
WHERE pernr EQ ls_event_properties-value.
lo_nd_pa0006->bind_table( new_items = lt_pa0006 set_initial_elements =
abap_true ).
ENDMETHOD.

Activate Web dynpro component.

Run web dynpro application.

You might also like