on ‎2022 Jun 28 12:57 AM
Hello,
I map Query to a function module that has range table as input parameter (method GetEntitySet is generated). Here is example of my call is I use filter=Material eq '51' or Material eq '52' or Material eq '35'
Generated code looks like this:
* Maps filter table lines to function module parameters
LOOP AT lt_filter_select_options INTO ls_filter.
LOOP AT ls_filter-select_options INTO ls_filter_range.
CASE ls_filter-property.
WHEN 'MATERIAL'. " Equivalent to 'Material' property in the service
lo_filter->convert_select_option(
EXPORTING
is_select_option = ls_filter
IMPORTING
et_select_option = lr_material ).
LOOP AT lr_material INTO ls_material.
ls_it_material-high = ls_material-high.
ls_it_material-low = ls_material-low.
ls_it_material-option = ls_material-option.
ls_it_material-sign = ls_material-sign.
APPEND ls_it_material TO it_material.
ENDLOOP.
Table IT_MATERIAL ends up with 9 entries (3 sets of same 3 materials) because it loops on the second loop three times since I have 3 materials and each time, adds three materials.
I know I can redefine method and delete duplicate entries but it seems like SAP should know NOT to do this. Is there a standard way of preventing this from happening?
Thanks in advance,
Natasha
Request clarification before answering.
Hi Nathalie,
please check your loop:
you loop over t_filter_select_options and in this loop over AT ls_filter-select_options into ls_filter_range,
but you never use ls_filter_range?
LOOP AT lt_filter_select_options INTO ls_filter.
LOOP AT ls_filter-select_options INTO ls_filter_range.
Proposal:
Maps filter table lines to function module parameters
LOOP AT lt_filter_select_options INTO ls_filter.
CASE ls_filter-property.
WHEN 'MATERIAL'. " Equivalent to 'Material' property in the service
lo_filter->convert_select_option(
EXPORTING
is_select_option = ls_filter
IMPORTING
et_select_option = lr_material ).
LOOP AT lr_material INTO ls_material.
ls_it_material-high = ls_material-high.
ls_it_material-low = ls_material-low.
ls_it_material-option = ls_material-option.
ls_it_material-sign = ls_material-sign.
APPEND ls_it_material TO it_material.
ENDLOOP.
ENDLOOP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.