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.

13

SAPUI5

ENDIF.

IF <ls_tech_order>-property = 'NAME' OR

<ls_tech_order>-property = 'COLOR' OR

<ls_tech_order>-property = 'STRENGTH'.

<ls_sort_order>-astext = abap_true.

ENDIF.

ENDLOOP. "Sort Order from Incoming Request

SORT lt_result BY (lt_sortorder).

* Query the incoming URL to see if we have to start from

* a specific point, and how many rows to display

DATA: ld_start_row TYPE sy-tabix,

ld_end_row TYPE sy-tabix.

"The URL may contain text like "$skip=5"

IF is_paging-skip IS NOT INITIAL.

ld_start_row = is_paging-skip + 1.

ELSE.

ld_start_row = 1.

ENDIF.

"The URL may contain text like "$top=10"

IF is_paging-top IS NOT INITIAL.

ld_end_row = is_paging-skip + is_paging-top.

ELSE.

ld_end_row = lines( lt_result ).

ENDIF.

* Export the final result

FIELD-SYMBOLS : <ls_entity_set> LIKE LINE OF et_entityset,

<ls_result> LIKE LINE OF lt_result.

LOOP AT lt_result FROM ld_start_row TO ld_end_row

ASSIGNING <ls_result>.

APPEND INITIAL LINE TO et_entityset

ASSIGNING <ls_entity_set>.

MOVE-CORRESPONDING <ls_result> TO <ls_entity_set>.

ENDLOOP.

* In development only change security settings to allow local testing

* http://scn.sap.com/community/gateway/blog/2014/09/23/solve-cors-withgateway-and-chrome

DATA: ls TYPE ihttpnvp.

ls-name = 'Access-Control-Allow-Origin'.

ls-value = '*'.

/iwbep/if_mgw_conv_srv_runtime~set_header( is_header = ls ).

ENDMETHOD. "Monster Set - GET_ENTITY_SET

Listing 13.2 Coding the Monster GET_ENTITY_SET

586

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

Saved successfully!

Ooh no, something went wrong!