FileRelay
Documentation
Try our Sandbox

SAP OData Setup

Pull invoices and attachments from released S/4HANA Cloud OData APIs (API_CV_ATTACHMENT_SRV and friends), route them to SharePoint, S3, and 15+ destinations, and read SAP records and files on demand through the Data API. No ABAP, no BTP DMS.

SAP OData Setup

S/4HANA Cloud exposes released OData APIs for business-object attachments. FileRelay queries the attachment lists, fetches binaries, and routes them.

Use OData when you're on S/4HANA Cloud (Public or Private/RISE), want released, future-proof endpoints, and your document model is attachment-centric (FI invoices, MM POs, HR records). If SAP should store documents in FileRelay as its content repository, use ArchiveLink or CMIS instead. Decision matrix: protocol comparison.

Data API: read records and files on demand

Besides routing attachments as they arrive, an OData repository can serve live reads to your own applications through the Data API: list SAP records, read one by key, and download its file, all with a FileRelay API key instead of SAP credentials.

In the repository's details, under Data API:

  1. Add each entity set to expose, with its key, the fields the API may return, and where the file is (if any).
  2. Test against SAP to see sample rows before saving.
  3. Switch the Data API on. The endpoints for each entity set appear, ready to copy.

Only mapped entity sets and fields are reachable, reads are audited, and switching it off stops access at once. Self-hosted operators can instead route reads through the connector (ODATA_ACCESS_ROUTES_JSON); see docs/connector-odata-read.md in the deployment repository.

Which OData APIs?

Pick by business object. The most common:

API What it exposes
API_CV_ATTACHMENT_SRV Generic attachments on any business object
I_AttachmentForBusinessObject (CDS) Read-only view of every attachment with its parent object key
API_SUPPLIERINVOICE_PROCESS_SRV Supplier invoice attachments (FI)
API_PURCHASEORDER_PROCESS_SRV Purchase order attachments (MM)
API_OUTBOUND_DELIVERY_SRV Delivery note attachments (SD)

Any released v2 or v4 service that exposes attachments works. Full catalog at api.sap.com.

SAP-side setup

Communication Arrangement

In SAP Fiori → Communication Arrangements, create one using the template matching your target API.

Template Use case
SAP_COM_0204 Generic OData attachment access
SAP_COM_0276 Document Management integration
SAP_COM_0008 Supplier invoice integration
SAP_COM_0053 Purchase order integration

Each arrangement needs a Communication System (logical SAP-side rep of FileRelay), a Communication User (FileRelay's identity, inbound), and an auth method — OAuth 2.0 with X.509 client certificate or OAuth 2.0 with client credentials. Both are supported.

Once saved, the arrangement exposes a Service URL plus OAuth credentials.

Attachment events (required)

FileRelay receives documents through attachment events, so S/4HANA must send them: subscribe the connector's webhook URL (below) to the attachment-created event (sap.s4.beh.attachment.v1.Attachment.Created.v1) through Enterprise Event Enablement or SAP Event Mesh, with the repository's webhook signing secret. On systems without either, a small ABAP hook (an SM59 HTTP destination plus an HTTP client call) can post the same event.

Configure the source

  1. Repositories → Add Source → OData.
  2. Fill in: name, service URL, OData version (v2 for most S/4HANA APIs), entity set (e.g. AttachmentContentSet), OAuth token URL, client ID/secret, auth method (client-credentials or client-certificate).
  3. Test connection — FileRelay mints a token, fetches $metadata, validates the entity set, returns a sample result.
  4. Save.

For X.509 auth, upload the cert + private key under Certificates; FileRelay attaches them on every token request.

How fetching works

FileRelay fetches on SAP's event. When an attachment is created, S/4HANA (Enterprise Event Enablement, or a custom ABAP hook) posts a signed CloudEvent to:

https://<connector-host>/<userSlug>/<workspaceSlug>/events/odata?contRep=<Repository ID>

FileRelay then:

  1. Checks the HMAC-SHA256 signature in X-Sap-Webhook-Signature against the repository's webhook signing secret (401 if it does not match).
  2. Answers 202 Duplicate straight away if it already holds that attachmentId, so SAP's redeliveries never create a second document.
  3. Downloads the attachment from the event's contentHref (OAuth client credentials or Basic auth, with sap-client when set), up to 512 MB.
  4. Stores it and answers 202, or 503 if SAP's download or FileRelay's storage failed, so SAP retries.

The document then goes through your connections like any other source. There is no scheduled polling: a document reaches FileRelay only through an event.

Authentication + rotation

OAuth tokens are ~12 h. FileRelay refreshes on demand.

  • Client secret rotation — paste the new secret; next token request uses it.
  • Certificate rotation (X.509) — upload the new cert before the old one expires; overlap is supported, no downtime.
  • Communication User password — not used directly (OAuth, not basic), but the user record must stay active.

Forwarded metadata

OData property Forwarded as
BusinessObjectTypeName parent object type (e.g. BUS2032)
BusinessObjectKey / LinkedSAPObjectKey parent object key (PO number, invoice ID)
FileName filename
MimeType MIME type
CreatedByUser / CreationDateTime provenance
ArchiveDocumentID original SAP archive ID for traceability

Per-connection mapping in Document Routing.

Gotchas

  • Released APIs only on Public Edition — no custom CDS / OData. On Private/RISE you can roll your own, but released APIs survive upgrades; custom ones are yours to maintain forever.
  • Entity set ≠ entity type — FileRelay needs the entity set name (URL-addressable collection). If $metadata lists multiple sets per type, pick the one that returns binary via $value.
  • $value returns raw bytes — that's normal.
  • Per-user rate limits — for many concurrent sources, use a dedicated Communication User per source so one busy stream doesn't starve the others.
  • UTC in filters — timestamps are UTC; format as datetime'YYYY-MM-DDTHH:MM:SS' with no zone suffix.

Troubleshooting

Symptom Likely cause
401 from token URL Communication User isn't bound as inbound, or wrong scope
403 on $value but 200 on the list Principal has list access but not download — fix the Communication Scenario role
404 on the entity set Typo, or the scenario doesn't expose that set (check <service-url>/$metadata)
Events arrive but answer 503 SAP answered HTTP 403 The download user lacks access to $value, or a proxy refuses the call
Events arrive but answer 401 Invalid webhook signature The signing secret in S/4HANA and on the repository differ
Events configured but never fire Wrong event type, or inbound endpoint unreachable from SAP egress

Raw request/response captures: Request Viewer.

Next steps