Thursday, March 22, 2012
Steps to achieve functionality
  • Create Web Dynpro Component with Window and View(Automatically View is embedded into Window). 
  • Define Component Use OVS_PERNR for the Used component WDR_OVS under Used Components tab of Web Dynpro Component.
  • Go to View OVS_V->Properties tab->Define or Include Used Controllers/ Components of OVS.
  • Go to View OVS_V->Context tab
    • Create node N1.
    • Create one attribute PERNR of type NUM8(NUMC -8)
    • Select Input Help mode as  Object Value Selector
    • Select OVS Component usage OVS_PERNR from F4 help. 
  • Go to View OVS_V->Layout tab->Create one input and bind it with node N1 attribute PERNR. 
  • Go to View OVS_V->Methods tab->Give method name as OVS_ON_FIELD, method type Event Handler and Select Event OVS of Component Usage OVS_PERNR from F4 help as shown in the figure. 
  • Double click on OVS_ON_FIELD method->Below code is auto generated. 
  • Auto Generated code
  • method OVS_SS .
    * declare data structures for the fields to be displayed and
    * for the table columns of the selection list, if necessary
      types:
        begin of lty_stru_input,
    *   add fields for the display of your search input here
          field1 type string,
        end of lty_stru_input.
      types:
        begin of lty_stru_list,
    *   add fields for the selection list here
          column1 type string,
        end of lty_stru_list.
    
      data: ls_search_input  type lty_stru_input,
            lt_select_list   type standard table of lty_stru_list,
            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:  type lty_stru_input,
                         type lty_stru_list.
    
      case ovs_callback_object->phase_indicator.
    
        when if_wd_ovs=>co_phase_0.  "configuration phase, may be omitted
    *   in this phase you have the possibility to define the texts,
    *   if you do not want to use the defaults (DDIC-texts)
    
          ls_text-name = `FIELD1`.  "must match a field name of search
          ls_text-value = `MYTEXT`. "wd_assist->get_text( `001` ).
          insert ls_text into table lt_label_texts.
    
          ls_text-name = `COLUMN1`.  "must match a field in list structure
          ls_text-value = `MYTEXT2`. "wd_assist->get_text( `002` ).
          insert ls_text into table lt_column_texts.
    
    *      lv_window_title = wd_assist->get_text( `003` ).
    *      lv_group_header = wd_assist->get_text( `004` ).
    *      lv_table_header = wd_assist->get_text( `005` ).
    
          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 ).
    
    
        when if_wd_ovs=>co_phase_1.  "set search structure and defaults
    *   In this phase you can set the structure and default values
    *   of the search structure. If this phase is omitted, the search
    *   fields will not be displayed, but the selection table is
    *   displayed directly.
    *   Read values of the original context (not necessary, but you
    *   may set these as the defaults). A reference to the context
    *   element is available in the callback object.
    
          ovs_callback_object->context_element->get_static_attributes(
              importing static_attributes = ls_search_input ).
    *     pass the values to the OVS component
          ovs_callback_object->set_input_structure(
              input = ls_search_input ).
    
    
        when if_wd_ovs=>co_phase_2.
    *   If phase 1 is implemented, use the field input for the
    *   selection of the table.
    *   If phase 1 is omitted, use values from your own context.
    
          if ovs_callback_object->query_parameters is not bound.
    ******** TODO exception handling
          endif.
          assign ovs_callback_object->query_parameters->*
                                  to .
          if not  is assigned.
    ******** TODO exception handling
          endif.
    
    *     call business logic for a table of possible values
    *     lt_select_list = ???
    
          ovs_callback_object->set_output_table( output = lt_select_list ).
    
    
        when if_wd_ovs=>co_phase_3.
    *   apply result
    
          if ovs_callback_object->selection is not bound.
    ******** TODO exception handling
          endif.
    
          assign ovs_callback_object->selection->* to .
          if  is assigned.
    *        ovs_callback_object->context_element->set_attribute(
    *                               name  = `COLUMN1`
    *                               value = -column1 ).
    *      or
    *        ovs_callback_object->context_element->set_static_attributes(
    *                               static_attributes =  ).
    
          endif.
      endcase.
    
    endmethod.
    
  • Change the code according to our requirement and make it workable.
  • METHOD ovs_on_field .
      TYPES:
        BEGIN OF lty_stru_list,
    *   add fields for the selection list here
              pernr TYPE pa0002-pernr,
              nachn TYPE pa0002-nachn,
              vorna TYPE pa0002-vorna,
        END OF lty_stru_list.
    
      DATA: lt_select_list   TYPE STANDARD TABLE OF lty_stru_list,
            ls_text          TYPE wdr_name_value,
            lt_label_texts   TYPE wdr_name_value_list,
            lt_column_texts  TYPE wdr_name_value_list.
    
      FIELD-SYMBOLS:     TYPE lty_stru_list.
    
      CASE ovs_callback_object->phase_indicator.
        WHEN if_wd_ovs=>co_phase_0.  "configuration phase, may be omitted
        WHEN if_wd_ovs=>co_phase_1.  "set search structure and defaults
        WHEN if_wd_ovs=>co_phase_2.
    *   If phase 1 is implemented, use the field input for the
    *   selection of the table.
    *   If phase 1 is omitted, use values from your own context.
    *     call business logic for a table of possible values
          SELECT pernr
                 nachn
                 vorna
            FROM pa0002
            INTO CORRESPONDING FIELDS OF TABLE lt_select_list
            UP TO 200 ROWS.
          ovs_callback_object->set_output_table( output = lt_select_list ).
        WHEN if_wd_ovs=>co_phase_3.
    *   apply result
          ASSIGN ovs_callback_object->selection->* TO .
          IF  IS ASSIGNED.
            ovs_callback_object->context_element->set_static_attributes(
                                   static_attributes =  ).
          ENDIF.
      ENDCASE.
    
    ENDMETHOD.
    
  • Activate Web Dynpro Component 
  • Create Web Dynpro Application and Save it as local object. 
  • Run the Web Dynpro Application. 

1 comment:

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.