SAP S/4HANA

Send numeric KPIs from SAP S/4HANA (via its REST/OData APIs) into Metaplane so Metaplane can model trends and alert on anomalies for custom monitors.

Architecture (at a glance)

  1. Source: SAP S/4HANA exposes business objects via RESTful OData (V2/V4) endpoints on the SAP Business Accelerator Hub / S/4HANA system. You’ll authenticate (typically OAuth2) and query KPIs (e.g., open order count, invoice totals).

  2. Transformer: Lightweight job (Airflow, Dagster, Lambda, etc.) fetches values, aggregates to a single numeric datapoint per monitor.

  3. Sink: POST each value to Metaplane’s Ingest Datapoint endpoint for the target monitorId, authenticated with a bearer token.


Prerequisites

  • SAP: API access to your S/4HANA tenant (comm. arrangement / destination, OAuth client, and the specific API packages that surface your KPIs). References to “APIs for S/4HANA” and OData domain APIs describe where/how to find the endpoints.

  • Metaplane:

    • API token (Bearer) from your Metaplane account.

    • The monitor(s) you want to feed. Ingest Datapoint posts values into a monitor identified by monitorId


Data flow & mapping

  1. Identify KPI in SAP (example ideas):

    • Count of new sales orders today

    • Sum of invoice amounts last hour

    • Backlog quantity per plant (rolled up to a single value if needed) Use S/4HANA OData reads with $filter, $select, and server-side aggregates if available, or aggregate client-side.

  2. Normalize to a single numeric value per monitor per execution window (Metaplane models numeric series).

  3. POST to Metaplane Ingest Datapoint:

    • Endpoint: /v1/monitors/ingest-datapoint/{monitorId}

    • Auth: Authorization: Bearer <token>

    • Body: includes the value; timestamp defaults to “now” if omitted (per docs). (Endpoint is in private beta; confirm exact body shape with your Metaplane rep/docs.)

Skeleton example

# 1) Fetch from SAP (example) – do your OAuth2 first, then:
curl -s "https://<your-s4hana-host>/sap/opu/odata4/<package>/<entity>?$filter=PostingDate eq 2025-08-26" \
  -H "Authorization: Bearer $SAP_TOKEN" > sap.json

# 2) Transform to a single numeric (pseudo step in your job)
VALUE=$(jq '<your aggregation expression>' sap.json)

# 3) Send to Metaplane
curl -X POST "https://dev.api.metaplane.dev/v1/monitors/ingest-datapoint/$MONITOR_ID" \
  -H "Authorization: Bearer $METAPLANE_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"value\": $VALUE}"

Auth & security

  • SAP S/4HANA: typically OAuth2 client credentials via your communication arrangement; calls hit OData endpoints defined for the business domain.

  • Metaplane: Bearer token generated once in the app; keep secret, rotate via account settings.


Scheduling & reliability

  • Run the job on a schedule aligned with KPI granularity (e.g., 5–15 min for ops metrics; hourly/daily for finance).

  • Add basic idempotency (don’t double-send same period) and retry/backoff on 5xx/429.

  • Log both source fetch volume and Metaplane POST status for observability.


Monitoring & validation

  • In Metaplane, confirm the monitor receives points and begins modeling; outliers will trigger alerts according to your settings.

Risks & caveats

  • API rate limits & performance on SAP side can affect freshness; consider incremental filters and server-side aggregation where possible.

What to do next

  1. Confirm access to the Metaplane Ingest Datapoint beta + create target monitors and API token.

  2. Select 1–3 SAP KPIs with clear business value and OData availability. Use SAP API Hub/help to pinpoint endpoints.

  3. Stand up a small job (Airflow/Lambda) to: authenticate to SAP → query → aggregate → POST to Metaplane.

  4. Run for a week to let models learn baselines, then tune alert thresholds in Metaplane.