cancel
Showing results for 
Search instead for 
Did you mean: 

Define condition from ValueHelp odata

former_member538929
Discoverer
0 Kudos

Hi Everyone,

Recently I have faced an issue where ValueHelp implemented using G/W Annotation in define method of mpc_ext,does not handle filter value having more than one Contains Value when passed from Define Conditions.Example,*AE*,*AG41-1S*.

Writing this as i searched several thread could not find perfect thread handling this issue.

Gateway provide the filter Value in lt_filter_select_option via lo_filter->get_filter_select_options( ).,handled in hashed table, due to which multiple values with Contain search with same Property is not handled.

So below is the code which can handle this situation.

"Data Declaration

data :lv_gstr type string,
lv_input type string,
lt_filter type table of string,
lit_filter type table of string,
lt_selopt type ddshselops,
ls_selopt like line of lt_selopt,
lv_split type string,
lv_split1 type string,
lv_split2 type string,
lv_split3 type string,
rt_select_options type /iwcor/if_odata_types=>edm_select_option_t,
lis_seloption like line of rt_select_options,
lt_seloption type table of /iwbep/s_cod_select_option,
ls_seloption type /iwbep/s_cod_select_option.


*Reading Input filter string.
lv_gstr = iv_filter_string.
*Split with condition and store in table
split lv_gstr at 'or' into table lt_filter.
lit_filter = lt_filter[].
* This code will read the table row and switch filter value and field serached for.
*Example: (substringof('AG41-1S',FuncLocation) to (substringof(FuncLocation,'AG41-1S')
loop at lit_filter assigning field-symbol(<fs>).
if <fs> cs 'substringof'.
lv_split = <fs>.
split lv_split at `'` into lv_split1 lv_split2.
split lv_split2 at `'` into lv_split2 lv_split3.
concatenate `'` lv_split2 `'` into lv_split2.
replace all occurrences of ',' in lv_split3 with ''.
replace all occurrences of ')' in lv_split3 with ''.
concatenate lv_split1 lv_split3 ',' lv_split2 ')' into <fs>.
endif.
endloop.
unassign <fs>.
clear lv_split .

lt_filter[] = lit_filter[].
*concatinating all rows of table in to one string.
loop at lt_filter assigning <fs>.
concatenate lv_split 'or' <fs> into lv_split.
endloop.
shift lv_split by 2 places left in character mode.
clear lv_gstr.
lv_gstr = lv_split.
* This Method convert the string into selection option table.
call method /iwcor/cl_odata_expr_utils=>get_filter_select_options
exporting
iv_expression = lv_gstr
receiving
rt_select_options = rt_select_options.

Pass the final output (rt_select_options.)to your select table of type /iwbep/t_mgw_select_option .

I hope this is useful , if yes than please do like and comment.

Thank You.

Suman Vyas.

Accepted Solutions (0)

Answers (0)