SAP Gateway Cache is new option to handle access to big amount of data. Because RFC call can take a long time to execute the different Operation CRUD ( Create, Read, Update and Delete). This new Caching functionality so-called Soft-State?enable caching the RFC returns and avoid a new call. A typical use for SAP Gateway Cache is Pricing calculation.?
Table of Contents
The so-called ?soft state? mode enables the SAP NetWeaver Gateway runtime to process several requests in one ABAP application server session, similar to stateful behavior. The only difference is the behavior of the application server after the session times out: Instead of breaking the request processing with a time-out exception the server creates a new session and processes the request as usual. For the consumer the change of the application server sessions is transparent and no data is lost on the client session.
The session that is held by the ICF framework results in session held in the backend system via RFC where the data provider class can cache data in member variables. The Data Provider Cache is highlighted in green in the following figure.
The following diagram explains how the Soft Caching works
The list of steps to do in your Gateway Service to enable the HTTP Caching ( Soft-Cache)
method DEFINE. super->define( ). model->set_soft_state_enabled( abap_true ). endmethod.
1. ?Add new?attribute with the following settings
2. Refine the Method?/IWBEP/IF_MGW_SOST_SRV_RUNTIME~OPERATION_START
method /IWBEP/IF_MGW_SOST_SRV_RUNTIME~OPERATION_START. mv_is_softstate = abap_true. endmethod.
3. Refine the Method?/IWBEP/IF_MGW_SOST_SRV_RUNTIME~OPERATION_END
Without adding any code. Actually, once the OPERATION_START method is defined, you have to define the OPERATION_END, else you will get an exeption.
Note, that /IWBEP/IF_MGW_SOST_SRV_RUNTIME~OPERATION_END?is where you can perform?action for example to handle persistance state of exchanged data.
4. Define a new Static Attribute GV_COUNT
5. Activate all the Changes
1. Launch the SAP Gateway Maintenance Service Transaction /IWFND/MAINT_SERVICE and confirm the Hub redirection warning if you got one
2. Click on Soft-State button.?You will probably get an error ( just confirm the error popup).
The service is shown as not Soft-State enable.
3. Load the metadata in order to retrieve the new information.
You will see that the service is Soft-State enable but the Soft-State is not active yet.
4. Change the session time out
In the ICC node, go to?ICF Node –> Configure (SICF).
Navigate to your service and set a Session Timeout a value > than 0.
5. Now, you can active the Soft-State by clicking on the button on /IWFND/MAIN_SERVICE
Confirm the warning and your service is Soft-State Active !!!
In order to implement the SAP Gateway Cache, you have to modify the DPC Method XXX_GET_ENTITYSET where you retrieve data.
Here a sample example, for SAP Gateway cache of PRODUCT
METHOD PRODUCTSET_GET_ENTITYSET. DATA lv_count_requested TYPE abap_bool. " Check if Count $Count is set to the Odata Call lv_count_requested = io_tech_request_context->has_count( ). IF lv_count_requested EQ abap_true. " Check if SAP Gateway Cache or Soft-State is active IF mv_is_softstate = abap_false. " if no, Calculate a new count SELECT COUNT( * ) INTO gv_count FROM SNWD_PD. ELSE. " If count is initial, calculate it IF gv_count is INITIAL. SELECT COUNT( * ) INTO gv_count FROM SNWD_PD. ELSE. " Else, increment the count gv_count = gv_count + 1. ENDIF. ENDIF. " Return The counter es_response_context-count = gv_count. ELSE. " Else, retrieve the whole data CALL FUNCTION 'BAPI_EPM_PRODUCT_GET_LIST' TABLES HEADERDATA = et_entityset. ENDIF. ENDMETHOD.
*Reference:?How to use Soft-State support for OData services
SAP ISU Tables for Technical master data, for Billing Master Data, Billing and invoicing Tables?…
SAP Fiori 3 UX and Design of SAP Fiori Apps for SAP S/4HANA, SAP TechEd…
Dunning is the business practice of informing a customer of past due payment. Dunning letters…
SAP AP Tcodes & SAP AR Tcodes: House Banks Tcodes, Advance Payments or Down Payments,…
What are the main SAP Payment Terms Tables ? What are the related Tables in…
Work center consists of master data related to routing of products. It contains data related…