Administration & Troubleshooting

Gateway Metadata Cache Cleanup

Gateway metadata cache cleanup is the procedure that clears cached OData service models in SAP Gateway: /IWFND/CACHE_CLEANUP clears the cache on the hub, and /IWBEP/CACHE_CLEANUP clears it in the backend. Gateway metadata cache cleanup is needed when an SAP Fiori app keeps showing old fields, labels or annotations after a service change.

Quick facts

Type
SAP Gateway administration procedure
Layer
Services & APIs
Hub cache
Metadata model, annotation model, annotation texts; /IWFND/CACHE_CLEANUP
Backend cache
Metadata and annotation model; /IWBEP/CACHE_CLEANUP
Also in
SAP Gateway Client, Metadata menu (cleanup or rebuild)
Who runs it
Basis administrators, SAP Fiori and ABAP developers
Applies to
SAP S/4HANA on-premise and Private Edition, SAP ERP (ECC)
Layer: Services & APIsWhere it sits ▾
Where it sits: L4 · Services & APIsLayer: Services & APIs.L1L2L3L4L5L6BTP

Layer: Services & APIs

Open the architecture map →

How does the SAP Gateway metadata cache work?

SAP Gateway caches the metadata of each OData service so that it does not rebuild the model on every request:

  • On the hub, it caches the metadata model, the annotation model and the annotation texts.
  • In the backend, it caches the metadata model and the annotation model.
  • In an embedded deployment, hub and backend are one system, and caching happens once.

For services built with the OData Channel model, a changed model provider class triggers an automatic refresh: on each request for the service document or the $metadata document, the cache compares timestamps and reloads outdated metadata. The SAP Gateway metadata cache therefore refreshes itself in the common case and needs manual cleanup only when that check cannot see the change.

When do you need to clear the metadata cache?

Clear the cache when:

  • an ABAP Dictionary change, such as a new field type in a structure, alters the model without changing the model provider class, because no hook detects it;
  • a changed model provider class was imported into a production system, where SAP recommends a cleanup after every such import;
  • support packages were imported, which SAP lists among the launchpad caching fixes;
  • an SAP Fiori app shows old properties, labels or annotations although the service in the backend is correct.

In development systems the hub cache is deactivated by default, so stale metadata there usually comes from the browser or the backend cache. Gateway metadata cache cleanup is a targeted fix for model changes the automatic check misses.

How do you clear the metadata cache step by step?

Alder Manufacturing transports a new field into its supplier service, and the app still does not show it:

  1. In the hub system, run /IWFND/CACHE_CLEANUP. Select Cleanup Cache for all Models, or restrict it to the affected model, and execute.
  2. In the backend system, run /IWBEP/CACHE_CLEANUP the same way. In an embedded deployment, both run in the same system.
  3. Alternatively, open /IWFND/GW_CLIENT, call the service and use the Metadata menu to clean up the hub, the backend or both, or to rebuild the cache for the current service.
  4. Request $metadata in the SAP Gateway Client and confirm that the new field is there.
  5. Reload the app; if the browser still shows the old model, clear the browser cache.

Both cleanups are also available as IMG activities in SPRO. Verifying $metadata before testing the app separates a Gateway metadata cache problem from a browser cache problem.

How does the browser cache OData metadata?

The SAP Fiori launchpad also caches OData metadata and annotations in the web browser, protected by cache buster tokens. The front-end server collects these tokens from the SAP Gateway hubs through the report /UI5/UPD_ODATA_METADATA_CACHE, which SAP recommends scheduling periodically in production but not in development systems. When the tokens change, browsers load the new metadata.

If that report has not run since a change, users can still see old metadata after a Gateway cleanup. /UI2/INVALIDATE_GLOBAL_CACHES clears launchpad caches, not OData metadata, so it does not replace this step. Gateway metadata cache cleanup and the browser-side token update together make a model change visible end to end.

/IWFND/CACHE_CLEANUP vs. /IWBEP/CACHE_CLEANUP vs. /UI2/INVALIDATE_GLOBAL_CACHES: what is the difference?

/IWFND/CACHE_CLEANUP/IWBEP/CACHE_CLEANUP/UI2/INVALIDATE_GLOBAL_CACHES
Runs onSAP Gateway hubBackend systemSAP Fiori front-end server
ClearsHub metadata, annotation models and textsBackend metadata and annotation modelsLaunchpad (UI2) service caches
Typical triggerOld metadata after a service changeDictionary change not detected by the modelTransported launchpad content not visible

The two Gateway cleanups refresh OData models; the UI2 report refreshes launchpad content.

FAQ

Do I need both /IWFND/CACHE_CLEANUP and /IWBEP/CACHE_CLEANUP?

In a hub deployment, yes, when you are not sure where the stale model sits: run /IWFND/CACHE_CLEANUP on the hub and /IWBEP/CACHE_CLEANUP in the backend. In an embedded deployment both run in the same system, which SAP documents as caching the model only once; if old metadata persists after one cleanup, run the other as well.

Can I switch off the SAP Gateway metadata cache?

For OData V2, the hub cache can be activated or deactivated in SPRO; SAP recommends deactivating it in development and keeping it active in production and performance test systems. For OData V4, SAP Gateway offers no option to disable metadata caching.

Is clearing the metadata cache risky in production?

Clearing is not destructive: the next request rebuilds the model from the service implementation. The first calls after a full cleanup are slower, so restricting the cleanup to the affected models limits the impact.

Why does the app still show old annotations after the cleanup?

The browser may still hold the previous metadata. Check $metadata in the SAP Gateway Client first; if it is correct there, the problem is client-side, and the scheduled token update or a browser cache reset resolves it.

Sources

Applies to
SAP S/4HANA on-premise · SAP S/4HANA Cloud Private Edition · SAP ERP (ECC)
Last reviewed

SAP, SAP Fiori, SAPUI5, SAP S/4HANA, SAP BTP and other SAP products and services mentioned are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. This guide is independent and is not affiliated with, sponsored or endorsed by SAP SE.