14.01.2020 Views

ABAP_to_the_Future

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Backend Tasks: Creating the Model Using SAP Gateway 13.3

LIKE LINE OF it_filter_select_options,

ls_select_options

LIKE LINE OF ls_filter_select_options-select_options.

DATA: lt_selections TYPE /bobf/t_frw_query_selparam,

lt_result TYPE ztt_monster_header.

FIELD-SYMBOLS: <ls_selections> LIKE LINE OF lt_selections.

IF it_filter_select_options[] IS NOT INITIAL.

LOOP AT it_filter_select_options

INTO ls_filter_select_options.

APPEND INITIAL LINE TO lt_selections

ASSIGNING <ls_selections>.

<ls_selections>-attribute_name =

ls_filter_select_options-property.

LOOP AT ls_filter_select_options- select_options INTO ls_select_

options.

<ls_selections>-option = ls_select_options-option.

<ls_selections>-sign = ls_select_options-sign.

<ls_selections>-low = ls_select_options-low.

<ls_selections>-high = ls_select_options-high.

ENDLOOP. "Selection options for field being queried

ENDLOOP.

ELSE.

* No selection criteria have been passed in

* Set selection criteria so that all records are returned

APPEND INITIAL LINE TO lt_selections

ASSIGNING <ls_selections>.

<ls_selections>-attribute_name = 'MONSTER_NUMBER'.

<ls_selections>-option

= 'GT'.

<ls_selections>-sign

= 'I'.

<ls_selections>-low

= '0000000001'.

ENDIF. "Were any selection criterai passed in?

mo_monster_model->retrieve_headers_by_attribute(

EXPORTING

it_selections = lt_selections

IMPORTING

et_monster_headers = lt_result ).

* Now we build a dynamic table which we will then use to

* sort the result a la SORTCAT in the ALV

FIELD-SYMBOLS: <ls_tech_order> LIKE LINE OF lt_techorder,

<ls_sort_order> LIKE LINE OF lt_sortorder.

LOOP AT lt_techorder ASSIGNING <ls_tech_order>.

APPEND INITIAL LINE TO lt_sortorder

ASSIGNING <ls_sort_order>.

<ls_sort_order>-name = <ls_tech_order>-property.

IF <ls_tech_order>-order = 'desc'.

<ls_sort_order>-descending = abap_true.

585

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!