Sunday, April 1, 2012
The following example program is a step by step guide to use ON_CLICK event to user actions for the Button UI element.
Procedure.
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.
- 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 specified.
- 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. "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. "configure_alv
- Call CONFIGURE_ALV method in WDDOINIT hook method.
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
- 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.
- 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.
- 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' ). * 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
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 ). 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 ). 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.
Followers
Popular Posts
- ABAP - ALV Report example with steps
- ABAP - Step by step tutorial on Smart Forms - Template Node
- ABAP - Sending email with pdf attachment
- SAP Adobe Form - Steps to create simple ADOBE Form and calling it from ABAP Program
- SAP ABAP - CL_ABAP_CHAR_UTILITIES class usage
- ABAP - Multiple value selection from F4 help for SELECT-OPTIONS
- Execute ABAP Report using SUBMIT statement
- ABAP - Select all or Deselect all in ALV or Check box handling in ALV
- Web Dynpro ABAP ALV - ON_CLICK event
- ABAP - Dynamic WHERE clause
0 comments:
Post a Comment
Your useful comments, suggestions are appreciated.Your comments are moderated.