Show TOC

Implementation ExampleLocate this document in the navigation structure

In this simplified example a GET_ENTITYSET implementation is adapted to support the Last-Modified and cache control functionality.

METHOD products_get_entityset.
    DATA:  lv_if_modified_since TYPE tzntstmps.
**   Set the max-age for the cache
    es_response_context-max_age = 3600.

**   Set the last-modified time stamp. This is only a very simplified example - in reality the last-modified time stamp must reflect the last change of the business data
    es_response_context-last_modified = 20121127094140. "Year 2012 Nov 27 09:41:40

**   Get time stamp of if-modified-since request header
    lv_if_modified_since = io_tech_request_context->get_if_modified_since( ).

**  Calculate the value for is-not-modified
es_response_context-is_not_modified =    /iwbep/if_mgw_conv_srv_runtime~check_if_is_not_modified(
                      iv_if_modified_since = lv_if_modified_since
                      iv_last_modified = es_response_context-last_modified ).

**  Entity set data does not need to be returned if is-not-modified is ABAP_TRUE
IF es_response_context-is_not_modified <> /iwbep/if_mgw_appl_types=>gcs_modification_status-is_not_modified.
          headerdata = et_entityset.