OVS (Object Value Selector) Search Help
Steps to implement OVS search help
1.
Create a new web dynpro component ‘zsimple_ovs’
2.Give Description and Press Enter
3.
Save (Ctrl + S)
4.
Ensure change mode (Ctrl + F1)
5.
Add a component ‘WDR_OVS’ in the used components tab and Save.
6.
Double click on the ‘Main’ in the tree ‘Views’.
7.
Go to ‘Properties’ tab and click on ‘Create Controller Usage’.
8.
Select the OVS component from the list and Save.
9.
Go to ‘Context’ tab and Right click the context node to create the attribute ‘MATNR’ for which we are going to implement search help.
10.
Provide Attribute name, Type and select ‘Object Value Selector’ as Input Help Mode.
11.
Select the OVS component as OVS Component Usage from the F4 Help Option and Save.
12.
Go to ‘Layout’ Tab , Right click ‘ROOTUIELEMENTCONTAINER’ and
Select ‘Insert Element’ to insert a new UI Element.
13.
Enter the ‘ID and Type as 'Label'(for Label) and press Enter. Provide label text and select 'Label for' values in its property bar.
14.
Similarly create an input field.
15.
Bind the context attribute ‘MATNR’ to the value of the created input field and Save.
16.
Go to ‘Methods’ Tab and Enter the method name as ‘ON_OVS’ (Predefined Method), method type as ‘Event Handler’, description and select the component ‘OVS’ in the F4 help option of the ‘Component Use’.
17.
Double click on method ‘on_ovs’. Then the following default coding would have been generated in this method.
18.
Try to understand the purpose of these codes as explained below.
Search Help Window will look below,
So let us explain the code using Search Help Window.
* If we want to use multiple fields for selection criteria, we can define those fields here, which will be shown in the screen.
Ex.
types
:
begin
of
lty_stru_input,
* add fields for the display of your search input here
matnr
type
mara-matnr,
end
of
lty_stru_input.
(Note : Here the label text will be automatically assigned from the data element which we have referred for the field.)
* This structure contains the fields for the internal table in which we store the data using select query depending on the data entered in the above fields.
Ex.
types
:
begin
of
lty_stru_list,
* add fields for the selection list here
matnr
type
mara-matnr,
mtart
type
mara-mtart,
end
of
lty_stru_list.
* If you want to use your own label text rather than from data element, we can specify here.
Ex.
ls_text-name =
`MATNR`
.
"must match a field name of search
ls_text-
value
=
`My Material Number`
.
"wd_assist->get_text( `001` ).
insert
ls_text
into
table
lt_label_texts.
* Below diagram shows which data the work area or table stores.
* Select query is used to retrieve the data for search help
Ex.
"variable
data
: lv_matnr
type
string.
"assigning input text (Ex. 400* ) to variable
lv_matnr = -matnr.
if not lv_matnr is initial.
"replacing last character '*' with '%' to use with select query
replace
all
occurrences
of
'*'
in
lv_matnr
with
'%'
.
else.
lv_matnr = '%'.
endif.
"Select query to retrieve data based on the input data
select
matnr mtart
from
mara
into
corresponding
fields
of
table
lt_select_list
where
matnr
like
lv_matnr.
* Finally uncomment the following code and replace the name with the context attribute ‘MATNR’ and the value with -matnr.
Ex.
ovs_callback_object->context_element->set_attribute(
name =
`MATNR`
value
= -matnr ).
Save and Activate.
Create Web Dynpro Application and save it.
Output :
Test the application