Before I start with example I should mention that you can find SAP standard demo in your SAP system DEMO_VALUE_HELP and WDR_TEST_OVS.
If standard search help does not fulfil your business requirement in web dynpro then you can implement OVS value help. OVS linked value help puts you in control of selection fields that search help will display, selection logic, and columns displayed in result and how to use value returned by user selection.
OVS value help is implemented using component WDR_OVS. The OVS value help is linked to the context attribute. Therefore, the value help is automatically available for each input field that is bound to this context attribute. WDR_OVS raises event OVS, this is where you will need to put all your coding. This event is triggered at four different times also known as phase, essentially when component expects data from used component or when selected data is available to consume. Instance attribute OVS_CALLBACK_OBJECT->PHASE_INDICATOR contains value for phase.
I will very briefly explain about what code should be included in each phase, more details about each phase is explained at link OVS Value Help .
Here you set configuration. Window title, Group header, table header, labels if they are different from data element labels.
Here you can specify any selection screen you want to issue before you display any result. Make sense if your result set is large as this will help user to narrow down selection. This is however optional, if you ignore this phase, PHASE_3 will be invoked. From user point of view they will get list when they take value help.
In this phase we write logic to create list. This can be a complex logic to a normal select. In case you have implemented phase 1 you will also get selection values entered by user which you can include in you logic.
This triggers when user has made selection from list. Typically used to fill returned value in input where user took value help.
I am going to create a simple Web Dynpro with input based on field SCARR-CARRID. Automatic search help on this field is based on search help S_CARRIER_ID
Using WDR_OVS component I will implement search to display values based on plane type. I will do this in steps to explain one thing at a time
Let gets started.
Create Web Dynpro ZPW_OVSDEMO1 with Window ZPW_DEMOOVS1 and view MAIN.
Now go to view context and create Node based on dictionary structure SCARR and ‘Add Attribute from Structure’ CARRID to screen.
We have context attribute, let add this to screen as input. Go to layout tab and right click on ROOTUIELEMENTCONTAINER and choose ‘Create Container Form’ option. On next screen press ‘Context’ button and choose node FLIGHT and press OK.
You should now have Airline input on screen. At this point create web dynro application and activate all objects. If you test web Dynpro and take value help on input Airline you will get SAP standard value help based on search help S_CARRIER_ID .
To implement OVS search help first step is to add component WDR_OVS to web Dynpro.
Navigate to view MAIN and define component usage for WDR_OVS using new button.
Next go to context of view and navigate to attribute CARRID. In property tab change ‘Input Help Mode’ to ‘Object Value Selector’ and in input ‘OVS Component Usage’ enter name of WDR_OVS component which is OVS in this case.
Finally go to methods tab and defined event handler method for event OVS of component used.
If you double click on method ON_OVS to open it code you will see system automatically put most of the code there including a CASE statement on OVS_CALLBACK_OBJECT->PHASE_INDICATOR. We just need to put code under right WHEN block. However I am going to delete this code and put just what I need to implement a simple value help without any selection screen. Little steps at a time.
In this simplest example I have defined structure lty_stru_list which is like report structure. An internal table lt_select_list of line type lty_stru_list will hold data that will be displayed to user. In phase 2 we have code which selects data from table sflight. Note that I have defined range type for planetype which I am using in select statement. In this case it blank but in coming example I will create selection screen and fill this range with what user has entered. In phase 3 based we assigned selected CARRID value to context element.
METHOD on_ovs . TYPES: BEGIN OF lty_stru_list, carrid TYPE sflight-carrid , planetype TYPE sflight-planetype , END OF lty_stru_list. DATA: lt_select_list TYPE STANDARD TABLE OF lty_stru_list. FIELD-SYMBOLS: <ls_selection> 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. TYPES : tr_planetype TYPE RANGE OF sflight-planetype . DATA : lt_planetype TYPE tr_planetype . SELECT carrid planetype INTO TABLE lt_select_list FROM sflight WHERE planetype IN lt_planetype . 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_attribute( name = 'CARRID' value = <ls_selection>-carrid ). ENDIF. ENDCASE.ENDMETHOD.
Hope this piece of code is clear to you. At this point you can activate the web dynpro and test it. What we demonstrated here is you have total control over column and rows.
Lets build on this and introduce selection screen to before displaying values. To display select screen first thing we need is a structure definition for fields being displayed as part of selection screen. We have defined type lty_stru_input and structure ls_search_input of this type. In plase 1 we will pass ls_search_input to ovs which will automatically build selection screen. In phase 2 we will extract value entered by user in selection screen and fill that in range. With these extra logic code look like this.
METHOD on_ovs . TYPES: BEGIN OF lty_stru_list, carrid TYPE sflight-carrid , planetype TYPE sflight-planetype , END OF lty_stru_list. TYPES: BEGIN OF lty_stru_input, planetype TYPE sflight-planetype , END OF lty_stru_input. DATA: lt_select_list TYPE STANDARD TABLE OF lty_stru_list, ls_search_input TYPE lty_stru_input . FIELD-SYMBOLS: <ls_selection> TYPE lty_stru_list , <ls_query_params> TYPE lty_stru_input. 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 ovs_callback_object->set_input_structure( input = ls_search_input ). WHEN if_wd_ovs=>co_phase_2. 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 ELSE. TYPES : tr_planetype TYPE RANGE OF sflight-planetype , ty_planetype TYPE LINE OF tr_planetype . DATA : lt_planetype TYPE tr_planetype , ls_planetype TYPE ty_planetype . IF <ls_query_params>-planetype IS NOT INITIAL . ls_planetype-sign = 'I' . ls_planetype-option = 'EQ' . ls_planetype-low = <ls_query_params>-planetype . APPEND ls_planetype TO lt_planetype . ENDIF. ENDIF. SELECT carrid planetype INTO TABLE lt_select_list FROM sflight WHERE planetype IN lt_planetype . 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_attribute( name = 'CARRID' value = <ls_selection>-carrid ). ENDIF. ENDCASE.ENDMETHOD.
This is screen shot of value help with selection screen.
Finally, I am going to add code under phase 0 to set various text.
WHEN if_wd_ovs=>co_phase_0. "configuration phase, may be omitted 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. ls_text-name = 'PLANETYPE'. ls_text-value = 'Enter plane type'. INSERT ls_text INTO TABLE lt_label_texts. ls_text-name = `CARRID`. "must match a field in list structure ls_text-value = 'Airline ID'. "wd_assist->get_text( `002` ). INSERT ls_text INTO TABLE lt_column_texts. lv_window_title = 'Window title' . lv_group_header = 'Group Header' . lv_table_header = 'Table Header' . 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 ).
OVS linked value help puts you in control of selection fields that search help will display, selection logic, and columns displayed in result and how to use value returned by user selection. OVS value help is implemented using component WDR_OVS. The OVS value help is linked to the context attribute.
- Step1: ...
- Step2: ...
- Create the component usage OVS_HELP by using standard ovs component WDR_OVS as shown below.
- Open view VW_PERSONALDATA and click on enhance ( ctrl + f4 ) button as show below.
- Chose the enhancement implementation YDEMO_OVS_HELP as shown below.
Go to the web dynpro component. We can provide the assistance class here. Maintain the class name here which is now treated as Assistance class. In the component controller, attribute tab we find an object WD_ASSIST is created which points to the assistance class.
To check fully qualified domain name, go to Web Dynpro explorer in the ABAP development environment use T-code − SE80 and select the Web Dynpro application from the navigation tree for your Web Dynpro component/interface and check the URL in the administration data.
- DATA lo_ovs TYPE REF TO iwci_wdr_ovs.
- DATA lo_context TYPE REF TO if_wd_context.
- DATA lo_context_node TYPE REF TO if_wd_context_node.
- DATA lo_el TYPE REF TO if_wd_context_element.
- ” get reference of ovs component usage.
- lo_ovs = wd_this->wd_cpifc_test_ovs( ).
There are 4 phases for an OVS ( 0, 1, 2, 3, 4 ). All the 4 phases will be called one after the other.
- Enter the transaction code as SE11 in the command field.
- Select the radio button for Search help and enter a name for the custom Search help. ...
- On the next screen select the option 'Elementary search help'.
- Give some description for the search help.
- F4IF_FIELD_VALUE_REQUEST if suitable SEARCHHELP already exists in system (SE11>Search help) ...
- F4IF_INT_TABLE_VALUE_REQUEST if select options can be provided in an itab table.
- Step 1 − Go to transaction SE11. ...
- Step 2 − The system will prompt for the search help type to be created. ...
- Step 3 − In the selection method, we need to indicate whether our source of data is a table or a view. ...
- Step 4 − After the selection method is entered, the next field is the Dialog type.
A web dynpro component will have only one assistance class and it is defined at the component level as per the screenshot below. The assistance class is automatically instantiated when a component is called.
SAP List Viewer is used to add an ALV component and provides a flexible environment to display lists and tabular structure. A standard output consists of header, toolbar, and an output table.
GET_ATTRIBUTE method of interface IF_WD_CONTEXT_NODE to retrieve value of context element. The GET_ATTRIBUTE method retrieves the value of an individual field/attribute of of context element. This is the simplest form of attribute to set as you can reference it directly using the WD_CONTEXT attribute.
Go to the Transaction Code SE93 and give the name of the transaction code that needs to be created and press the Create button. Give the Transaction WDYID and select the initial Skip Screen Button.
A Web Dynpro application for this simple Web Dynpro component, which can be run in the browser will be created. Step 1 − Go to T-Code − SE80 and select Web Dynpro component/intf from the list. Step 2 − Create a new component as the following. Step 3 − Enter the name of the new component and click on display.
Navigate in transaction SE80 to the required Web Dynpro application and open it. The application is started with URL parameter sap-config-mode=X. To start a Web Dynpro application in customizing mode on the SAP NetWeaver Portal, it is sufficient to start the application in preview mode.
Search help mechanism in Web Dynpro is tightly linked to ABAP dictionary. As long as you bind Input field to context which is defined with reference to dictionary, system will provide you standard search help, including values from check table, values table or domain fixed values.
- Step 1 - First create a basic web dynpro application. ...
- Step 2 - Create context node globally within component controller. ...
- Step 3 - Context node details. ...
- Step 4 - Choose node attributes. ...
- Step 5 - Assign COMPONENTCONTROLLER context to VIEW context.