In the previous post we have seen how to set a OVS Search help for a select option field. The event handler method for event ovs will be called when the user presses the F4 help on the screen. Now suppose if we have more than one selection field and if you want ovs search help for all of them how do you do it and this is what is this post is all about.
Select options component only have one event on_ovs for ovs search help and the event handler method for this event will be called when the User presses the f4 help from any input field created using the select options component. You cannot create a select options component usage for each input field and it will be performance intensive.
Now let us see how to create a ovs search help for multiple fields in a select option.
For more information on how to set the OVS Search help for select option refer to the post
Before going through this document I strongly recommend you to go through the post OVS Search help for select options.
Assume that we have two fields on the screen PO document number and Vendor number and we want to provide OVS Search help for them.
Set the search help mode for the select options field as ovs search as shown in the previous post.
CODE: In doinit method for OVS.
data lo_cmp_usage type ref to if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_select( ).
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
DATA lo_INTERFACECONTROLLER TYPE REF TO IWCI_WDR_SELECT_OPTIONS .
lo_INTERFACECONTROLLER = wd_this->wd_cpifc_select( ).
DATA lv_r_helper_class TYPE ref to if_wd_select_options.
lv_r_helper_class = lo_interfacecontroller->init_selection_screen(
).
data : rt_ebeln TYPE REF TO data.
CALL METHOD lv_r_helper_class->CREATE_RANGE_TABLE
EXPORTING
I_TYPENAME = 'EBELN'
* I_LENGTH =
* I_DECIMALS =
RECEIVING
RT_RANGE_TABLE = rt_ebeln
.
CALL METHOD lv_r_helper_class->ADD_SELECTION_FIELD
EXPORTING
I_ID = 'EBELN'
IT_RESULT = rt_ebeln
I_VALUE_HELP_TYPE = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_OVS
.
data : rt_lifnr TYPE REF TO data.
CALL METHOD lv_r_helper_class->CREATE_RANGE_TABLE
EXPORTING
I_TYPENAME = 'LIFNR'
* I_LENGTH =
* I_DECIMALS =
RECEIVING
RT_RANGE_TABLE = rt_lifnr
.
CALL METHOD lv_r_helper_class->ADD_SELECTION_FIELD
EXPORTING
I_ID = 'LIFNR'
IT_RESULT = rt_lifnr
I_VALUE_HELP_TYPE = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_OVS
.
CALL METHOD lv_r_helper_class->SET_GLOBAL_OPTIONS
EXPORTING
I_DISPLAY_BTN_CANCEL = ABAP_FALSE
I_DISPLAY_BTN_CHECK = ABAP_FALSE
I_DISPLAY_BTN_RESET = ABAP_FALSE
I_DISPLAY_BTN_EXECUTE = ABAP_FALSE
.
Step 1: Create an event handler method for the OVS Event of Select options.
In the Event handler method for the OVS event. First identify the field from where the F4 help for the select option is triggered.
If you see the structure of the importing parameter I_OVS_DATA it contains a field called m_selection_field_id which will contain the field id from where the F4 help is triggered.
Now using this we will be able to identify the field from where the F4 help is triggered. Therefore we will create a individual methods for each field with the importing parameter I_OVS_DATA and call these method based on condition.
Create a method for EBELN input field.
Create an Importing parameter for the method.
Write the Coding for OVS Search help in that method.
Refer the following link for more information: <<>>
types:
begin of lty_stru_input,
ebeln type ebeln,
end of lty_stru_input.
types:
begin of lty_stru_list,
ebeln type ebeln,
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_table_header type string.
field-symbols: <ls_query_params> type lty_stru_input,
<ls_selection> type lty_stru_list.
case I_OVS_DATA-M_OVS_CALLBACK_OBJECT->phase_indicator.
when if_wd_ovs=>co_phase_0.
ls_text-name = `EBELN`.
ls_text-value = `PO NUMBER`.
insert ls_text into table lt_label_texts.
ls_text-name = `EBELN`.
ls_text-value = `PO NUMBER`.
insert ls_text into table lt_column_texts.
I_OVS_DATA-M_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.
when if_wd_ovs=>co_phase_2.
select ebeln
from ekko
INTO TABLE lt_select_list.
I_OVS_DATA-M_OVS_CALLBACK_OBJECT->set_output_table( output = lt_select_list ).
when if_wd_ovs=>co_phase_3.
FIELD-SYMBOLS : <LT_SEL_OPT_RESULT> TYPE STANDARD TABLE.
assign I_OVS_DATA-M_OVS_CALLBACK_OBJECT->selection->* to <ls_selection>.
if <ls_selection> is assigned.
ASSIGN I_OVS_DATA-MT_SELECTED_VALUES->* TO <LT_SEL_OPT_RESULT>.
INSERT <LS_SELECTION>-EBELN INTO TABLE <LT_SEL_OPT_RESULT>.
endif.
endcase.
Similarly create a method for the LIFNR.
Step 2: In the event handler method for the OVS event of select options do the following.
Code:
if i_ovs_data-m_selection_field_id = 'EBELN'.
WD_THIS->OVS_EBELN( I_OVS_DATA ).
ELSEIF i_ovs_data-m_selection_field_id = 'LIFNR'.
WD_THIS->OVS_LIFNR( I_OVS_DATA ).
ENDIF.
Save and activate the whole component. Test the application.
I am overwhelmed by your post with such a nice topic. Usually I visit your blogs and get updated through the information you include but today’s blog would be the most appreciable. Well done! energy drink
ReplyDelete