Saturday, July 7, 2012

on Leave a Comment

sample

hi

on Leave a Comment

OVS multiple value selection

OVS multiple value selection (WebDynpro for ABAP)

Step1: Creating a WD Component

clip_image001

Step2: Reuse the System component “WDR_OVS”

clip_image002

Step3: Create the required Node Structure in the Context of Component Controller

  • Emp_no , Type PERNR_D
  • Emp_Name, Type EMNAM

clip_image003

Step4:  Define Mapping between View context and Component controller context

clip_image004

Step5: Designing the Layout

clip_image005

clip_image006

clip_image007

 

Step6: Data mapping for the Input fields and the Table

clip_image008

clip_image009

clip_image010

Step7: Reuse the Used Component from the Component controller

clip_image011

clip_image012

clip_image013

Step8: Create an Event handler by using the System component

clip_image014

clip_image015

clip_image016

Step9: Change the System generated code from the Event handler method

clip_image017

 

Changed code as per our requirement:

METHOD ovs_employeeid.
TYPES : BEGIN OF ty_emp_data,
        pernr TYPE pernr_d,
        ename TYPE emnam,
END OF ty_emp_data,
        tt_emp_data TYPE TABLE OF ty_emp_data.
DATA :  lo_nd_employee_details  TYPE REF TO if_wd_context_node,
        lo_el_employee_details  TYPE REF TO if_wd_context_element,
        ls_employee_details     TYPE wd_this->element_employee_details,
        lt_employee_details     TYPE wd_this->elements_employee_details.
DATA: ls_search_input  TYPE ty_emp_data,
        lt_select_list   TYPE TABLE OF ty_emp_data,
        ls_text          TYPE wdr_name_value,
        lt_label_texts   TYPE wdr_name_value_list,
        lt_column_texts  TYPE wdr_name_value_list,
        lv_window_title  TYPE string,
        lv_group_header  TYPE string,
        lv_table_header  TYPE string.
FIELD-SYMBOLS: <ls_selection>    TYPE ty_emp_data,
                 <lt_selection>    TYPE tt_emp_data.
* navigate from <CONTEXT> to <EMPLOYEE_DETAILS> via lead selection
  lo_nd_employee_details = wd_context->get_child_node( name =
  wd_this->wdctx_employee_details ).
SELECT  pernr ename
FROM pa0001
INTO TABLE lt_select_list
UP TO 50 ROWS.
CASE ovs_callback_object->phase_indicator.
WHEN if_wd_ovs=>co_phase_0.
      ovs_callback_object->set_configuration(
                label_texts         = lt_label_texts
                column_texts        = lt_column_texts
                group_header        = lv_group_header
                window_title        = lv_window_title
                table_header        = lv_table_header
                col_count           = 2
                row_count           = 20
                table_multi_select  = 'X').
WHEN if_wd_ovs=>co_phase_1.
* No Action
WHEN if_wd_ovs=>co_phase_2.
      ovs_callback_object->set_output_table( output = lt_select_list ).
WHEN if_wd_ovs=>co_phase_3.
ASSIGN ovs_callback_object->selection->* TO <lt_selection>.
IF <lt_selection> IS ASSIGNED.
LOOP AT <lt_selection> ASSIGNING <ls_selection>.
APPEND <ls_selection> TO lt_employee_details.
ENDLOOP.
        lo_nd_employee_details->bind_table( lt_employee_details ).
* Visibility
DATA :  lo_el_context   TYPE REF TO if_wd_context_element,
          ls_context      TYPE wd_this->element_context,
          lv_visible_grp1 TYPE wd_this->element_context-visible_grp1,
          lv_visible_grp2 TYPE wd_this->element_context-visible_grp2.
* get element via lead selection
  lo_el_context = wd_context->get_element( ).
* @TODO fill attribute
lv_visible_grp1 = ' '.
lv_visible_grp2 = 'X'.
* set single attribute
  lo_el_context->set_attribute(
    name =  `VISIBLE_GRP1`
value = lv_visible_grp1 ).
* set single attribute
  lo_el_context->set_attribute(
    name =  `VISIBLE_GRP2`
value = lv_visible_grp2 ).
ENDIF.
ENDCASE.
ENDMETHOD.

Step10: Create a WD Application for the component, save it and test it

clip_image018

Result:

clip_image019

clip_image020

clip_image021

Powered by Blogger.

Comments