Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
ramakrishnappa
Active Contributor

Purpose:

Demonstrate the scenario of providing custom search help for the fields in standard webdynpro application.

Scenario:

Here I consider the scenario to attach OVS search help for an attribute FIRSTNAME in context node PERSONALDATA of component HRRCF_C_PERSONL_DATA_UI

Pre-requisite:

Basic knowledge of Webdynpro ABAP & OVS search help

The existing output screen of standard application

Step1:

Open the standard application HRRCF_C_PERSONL_DATA_UI in t-code SE80 and click on Enhance ( Ctrl + f4 ) button to creation enhancement implementation as below

Step2:

A dialog box appears for creating enhancement implementation and provide the name and description as below

Step 3:

Create the component usage OVS_HELP by using standard ovs component WDR_OVS as shown below

Step 4:

Open view VW_PERSONALDATA and click on enhance ( ctrl + f4 ) button as show below

Step 5:

Chose the enhancement implementation YDEMO_OVS_HELP as shown below

Step 6:

Click on the Create component usage button to create component usage OVS_HELP in view as shown below

Step 7:

Choose the OVS_HELP component from the list as below

Step 8:

We are going to consider the attribute FIRSTNAME of context node PERSONALDATA for attaching  OVS value help as shown below

Step 9:

Go to methods tab of view and create event handler by using OVS_HELP as show below

Step 10:

Use F4 key to open list of components available as below

Step 11:

Select the OVS_HELP and event OVS and the event handler is successfully registerd for an event OVS as below

Please refer the below  sample code to populate the value list

ovs_firstname

METHOD ovs_firstname .
* 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
      firstname TYPE bu_namep_f,
      secondname TYPE bu_namep_l,
    END OF lty_stru_input.
  TYPES:
    BEGIN OF lty_stru_list,
*   add fields for the selection list here
      firstname TYPE bu_namep_f,
      secondname TYPE bu_namep_l,
    END OF lty_stru_list.

  DATA: ls_search_input  TYPE lty_stru_input,
        lt_select_list   TYPE STANDARD TABLE OF lty_stru_list,
        ls_select_list   LIKE LINE OF lt_select_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_table_header  TYPE string.

  FIELD-SYMBOLS: <ls_query_params> TYPE lty_stru_input,
                 <ls_selection>    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 = `FIRSTNAME`. "must match a field in list structure
      ls_text-value = `First Name`.
      INSERT ls_text INTO TABLE lt_column_texts.

      ls_text-name = `SECONDNAME`.
      ls_text-value = `Second Name`.
      INSERT ls_text INTO TABLE lt_column_texts.

      APPEND LINES OF lt_column_texts TO lt_label_texts.


      ovs_callback_object->set_configuration(
                label_texts  = lt_label_texts
                column_texts = lt_column_texts
                window_title = lv_window_title
                table_header = lv_table_header ).


    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 <ls_query_params>.
      IF NOT <ls_query_params> IS ASSIGNED.
******** TODO exception handling
      ENDIF.

*     call business logic for a table of possible values
*     lt_select_list = ???

      "=============================================
      "Prepare sample list for value list
      "=============================================
      CLEAR lt_select_list.

      CLEAR ls_select_list.
      ls_select_list-firstname = 'Ramakrishnappa'.
      ls_select_list-secondname = 'Gangappa'.

      APPEND ls_select_list TO lt_select_list.

      CLEAR ls_select_list.
      ls_select_list-firstname = 'Abc_First'.
      ls_select_list-secondname = 'Abc_Second'.

      APPEND ls_select_list TO 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 <ls_selection>.
      IF <ls_selection> IS ASSIGNED.

        ovs_callback_object->context_element->set_static_attributes(
                               static_attributes = <ls_selection> ).

      ENDIF.
  ENDCASE.

ENDMETHOD.

Step 12:

Now we need to create POST EXIT for method WDDOMODIFYVEW as shown below

Step 13:

Write the code in post exit of method WDDOMODIFYVIEW as shown below

Please refer the below sample code

POST_EXIT

METHOD _pst_dqxnmttuzezeszudlnztqzh4u .
  "Exit of WDDOMODIFYVIEW (in YDEMO_OVS_HELP )
  DATA lo_node TYPE REF TO if_wd_context_node.


  DATA lo_node_info  TYPE REF TO if_wd_context_node_info.

  CHECK first_time EQ abap_true.

  " Get node ref
  "==========================
  lo_node = wd_context->get_child_node( name =
wd_this->wdctx_personaldata ).

  " get node info reference
  "=============================
  IF lo_node IS BOUND.
    lo_node_info = lo_node->get_node_info( ).
  ENDIF.
  " Rerurn the control if lo_nod_info is not bound
  "==========================
  IF lo_node_info IS NOT BOUND.
    RETURN.
  ENDIF.
  " set the value help for attribute: firstname
  "==========================
  lo_node_info->set_attribute_value_help(
    EXPORTING
      name            = 'FIRSTNAME'
   value_help_mode = if_wd_context_node_info=>c_value_help_mode-ovs
      value_help      = 'OVS_HELP'
  ).
ENDMETHOD.

Output:

Use F4 key to get the value help for field FIRST NAME as below

Chose the record from value list and value of field FIRSTNAME is getting filled as below

6 Comments
Labels in this area