SAP Sync

Internal integration. The SAP puller runs inside Treedis — it is not a public API and is intentionally not part of the API Reference. This page documents how to set it up and how it behaves for operators and support.

The SAP integration is a passive puller: on a schedule you choose, Treedis authenticates to your SAP OData service (S/4HANA or BTP), pulls rows from the equipment / functional-location entity sets you map, and upserts them into your Connected-Workers asset tables. Nothing is pushed back to SAP — it is read-only against your SAP instance.

It is configured per workspace from Workspace → Settings → Integrations → SAP.

1. Authenticate

SAP authenticates with the OAuth2 client-credentials grant against your SAP/BTP token endpoint. Copy these values into the integration form:

Treedis field What it is
tokenEndpoint OAuth2 token URL (client-credentials grant).
clientId OAuth2 client id.
clientSecret OAuth2 client secret.
odataBaseUrl OData service root, e.g. https://host/sap/opu/odata/sap/API_EQUIPMENT.
scope (optional) OAuth2 scope, if your auth server requires one.

clientSecret is a secret — once saved it is never shown again (the form only indicates whether it is set). Treedis exchanges the client id/secret for a short-lived bearer token (sent as a Basic auth header, the S/4 default), caches it until just before expiry, and sends it on every OData request.

2. Choose how often it syncs

Once authenticated, open Configure and pick a sync frequency: every 1 hour, 6 hours, 12 hours, or 24 hours (default: 24h).

A single background job ticks hourly and runs a workspace only when its chosen interval has elapsed since the last successful run. Use Sync now in the Configure dialog to run an out-of-band sync immediately; the dialog shows the last sync time and status (and the error, if the last run failed).

3. Map SAP fields to your asset columns

Mapping is configured per asset table from the SAP Mapping item on that table's toolbar menu (available on workspace-level asset tables once the integration is enabled). For each table you set:

  • SAP entity — the OData entity set to pull from (e.g. an equipment or functional-location entity set). Treedis probes that entity's field names to pick from; you can also type a field name directly.
  • Field → column rows — each maps one SAP field to one of your asset columns. Only the columns you map are written; everything else on the row is ignored.
  • Primary-key column — the column Treedis uses to recognise an existing row. Defaults to the table's title column.

Treedis reads OData server pages ($top/$skip) and accepts both OData v2 (d.results) and v4 (value) response shapes.

4. Upsert behaviour — no duplicates

Every sync upserts keyed on the primary-key column: a row whose primary-key value already exists is updated in place (only the mapped columns are touched; other columns are left alone), and a new value is inserted. Re-running a sync over unchanged SAP data is a no-op. A row whose primary-key value is empty in SAP is skipped. If no primary-key column is set, the table's title column is used.

This means syncing the same entity repeatedly never creates duplicate rows — it keeps your asset table in step with SAP.

5. Sync status & troubleshooting

The integration records, per workspace, the last sync time, a status (idle / running / success / failed), and the last error when a run fails. A failed run does not block the next scheduled run.

Common things to check when a sync fails:

  • Auth errors → confirm the tokenEndpoint, clientId/clientSecret, and any required scope.
  • No rows / wrong rows → verify the SAP entity (entity set) name and the field → column mapping; confirm the odataBaseUrl points at the right OData service.
  • Rows updated but a value didn't change → confirm that field is actually mapped and that the primary-key column matches the unique key in SAP.