OVS Stands for Object value selection. One way of using the F4 input help can be done by using OVS in ABAP webdynpro, The other forms are dictionary search help and freely programmed search help. Now let us see the way the OVS search help works.
The SAP has provided us with a standard webdynpro component WDR_OVS for OVS Search help. Using this standard component we can provide ovs search help in our component.
This OVS Search help has four phases which you will be able to see from the case statement declared in the code consisting of four phases if_wd_ovs=>co_phase_0 to if_wd_ovs=>co_phase_3.
Phase 1 : if_wd_ovs=>co_phase_0.
It is a configuration phase. In this phase we set the lable for the subsearch, output table etc. For this purpose, the event parameter OVS_CALLBACK_OBJECT provides the method SET_CONFIGURATION.
Phase 2 : if_wd_ovs=>co_phase_1.
This method is used to set the input structure for the subsearch.
Phase 3 : if_wd_ovs=>co_phase_2.
The business logic for fetching the data's from the data base are written here. the values obtained are set to the output table so that it can be displayed on the screen.
Phase 4 : if_wd_ovs=>co_phase_3.
When user has selected one value from the above table. It has to go and sit in the place from where the F4 help is being triggered. This is done in this phase.
Lets take a look into an example of how to create a ovs search help.
Step 1:
Add the standard component WDR_OVS to the component framework ( HERE I have created a component ZCSK_WD_OVS in which I am going to include OVS Search help ).
Step 2: Add the interface controller of the OVS component to the View in the properties tab so that we will be able to access the Standard OVS component methods.
Step 3: Create the context node and add attributes to it. Set the input help mode of the attribute as Object value selector. And select the OVS usage Component using F4 help.s
Step 4: Create an event handler method. And select the event as OVS using F4 help.
Step 5: In the method created for the ovs help. Write your processing logic.
5.1 Create a structure to specify the search criteria.
The Types declaration lty_stru_input generated by the code is for setting the sub search in the search help. Declare the input structure here which you want to set as an sub search.
5.2 Create a structure to display the search result.
The Types declaration lty_stru_list generated by the code is for setting the output table i.e the column where the search result is being displayed in the search help popup.
5.3 Create label texts for the search criteria.
The internal table lt_label_text is used for setting the lable to the subsearch input fields.
5.4 Create label to be displayed for the search results.
The internal table lt_column_texts is used for displaying the label for the output table.
5.5 Write the processing logic to fetch the data from the database.
5.6 Set the attributes to the context nodes.
When an user selects an value in the search, it has to be displayed in the input field from where he triggers the f4 help. In order to do that the values which the user select in the screen will be captured in the field-symbol <ls_selection> by the sap system. From the field symbol set the selected value in the context attribute which we have binded to the input field, so that it will be displayed on the screen.
Output:
Press F4 you will get the below pop up.
Enter the search criteria and press start search.
Double click on the values or select the lead and click ok.
The selected value will sit on the appropriate fields.
Codes on the OVS Event Handler Method.
Note : The highlighted part has to be modified by us, rest of the code is system generated when you add the event OVS to the event handler method.
method OVS .
* 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
kunnr type kunnr,
name1 type name1_gp,
end of lty_stru_input.
types:
* add fields for the selection list here
Kunnr type kunnr,
name1 type name1_gp,
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: <ls_query_params> type lty_stru_input,
<ls_selection> type lty_stru_list.
* DATA : lv_kunnr TYPE kunnr,
* lv_name TYPE string.
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 = `KUNNR`. "must match a field name of search
ls_text-value = `Customer Number`. "wd_assist->get_text( `001` ).
insert ls_text into table lt_label_texts.
ls_text-name = `NAME1`. "must match a field name of search
ls_text-value = `Customer Name`. "wd_assist->get_text( `001` ).
insert ls_text into table lt_label_texts.
ls_text-name = `KUNNR`. "must match a field in list structure
ls_text-value = `Customer Number`. "wd_assist->get_text( `002` ).
insert ls_text into table lt_column_texts.
ls_text-name = `NAME1`. "must match a field in list structure
ls_text-value = `Customer Name`. "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 <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 = ???
select kunnr name1 from kna1 into table lt_select_list up to 10 rows.
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 = 'KUNNR'
value = <ls_selection>-KUNNR ).
ovs_callback_object->context_element->set_attribute(
name = 'CUSTOMER_NAME'
value = <ls_selection>-NAME1 ).
* or
* ovs_callback_object->context_element->set_static_attributes(
* static_attributes = <ls_selection> ).
endif.
endcase.
endmethod.
The Images are not appearing. Please do the needful. This is really a nice blog but i think the links related to images are not working
ReplyDelete