ml-connector
SAP S/4HANAGoogle Sheets

SAP S/4HANA and Google Sheets integration

SAP S/4HANA is your system of record for procurement and finance. Google Sheets is where your team builds reports, checklists, and dashboards. Connecting them means your invoice approvers and procurement analysts work from current data without manual exports. Supplier master records, purchase orders, and invoice headers flow from SAP into Sheets on a schedule you control, keeping your team's working data fresh.

How SAP S/4HANA works

SAP S/4HANA exposes suppliers, purchase orders, supplier invoices, GL accounts, and cost centers through OData V2 and OData V4 REST APIs, with endpoint URLs unique to each tenant. The cloud product authenticates with OAuth 2.0 client credentials issued against a Communication System and Communication Arrangement set up by your SAP admin. Tokens are short-lived (typically 12 hours) and must be refreshed before expiry. SAP S/4HANA has no native webhook system for cloud connectors, so records are read by polling with filters on the LastChangeDateTime field or delta tokens for incremental sync.

How Google Sheets works

Google Sheets is a cloud-based spreadsheet application where data is stored in spreadsheets divided into sheet tabs. You define the schema through column headers; there are no pre-built procurement or ERP entities. Data is read and written via the REST API (v4) using either OAuth 2.0 Service Account credentials (recommended for server-to-server integration) or user-delegated authorization. Polling is the recommended sync method, with watch channels available but unreliable due to short TTL and frequent expiry. Cells are addressed using A1 notation ranges or named ranges.

What moves between them

The primary data flow is from SAP S/4HANA into Google Sheets. Supplier invoices, purchase orders, and vendor master records are polled from SAP on your chosen schedule (daily, weekly, or in response to a calendar event) and written into named sheets within your spreadsheet, mapped to columns your team has defined. Each write includes the SAP record ID so invoice approvers can trace data back to SAP. Cost center and GL account reference data can also flow into separate sheets for reporting joins. No data flows back from Sheets into SAP; Sheets is the reporting and analysis layer.

How ml-connector handles it

ml-connector manages both credential sets: SAP OAuth tokens and Google Service Account credentials. When polling SAP, it submits OData requests with the LastChangeDateTime filter to retrieve only records changed since the last run, refreshing the SAP bearer token before expiry to avoid request failures. Supplier invoices (A_SupplierInvoice) and purchase order items (A_PurchaseOrderItem) are mapped to columns in your designated sheet tabs; you define the mapping once, and every poll writes new and updated records into the correct columns. Google Sheets rows are inserted or updated by matching on the SAP document ID to avoid duplicate rows. ml-connector tracks the last successful poll timestamp, so the next run picks up where the previous one stopped. If a write to Google Sheets fails, the job is retried with exponential backoff; all polling and write activity is logged to an audit sheet you can inspect.

A real-world example

A mid-market distribution company uses SAP S/4HANA to manage procurement across multiple regional warehouses and suppliers. The finance team approves supplier invoices in SAP but also maintains a Google Sheet for month-end invoice reconciliation and aging analysis. Before the integration, the accounts payable team exported invoices from SAP every few days and pasted them into the Google Sheet by hand, leading to stale data and reconciliation delays. With SAP S/4HANA and Google Sheets connected, invoices are automatically pushed to the sheet daily, updated with their approval status from SAP, and the finance team can monitor aging and totals in real time without manual exports.

What you can do

  • Poll supplier invoices and purchase orders from SAP S/4HANA on a schedule and write them to Google Sheets in columns you define.
  • Map SAP OData entities (A_SupplierInvoice, A_PurchaseOrderItem, A_Supplier) to sheet columns so your team works with familiar layouts.
  • Handle SAP OAuth 2.0 token refresh and Google Service Account authentication on every poll.
  • Deduplicate rows in Google Sheets by matching on SAP document IDs to prevent duplicate invoices and POs.
  • Retry writes to Google Sheets with exponential backoff and maintain a complete audit trail on a separate sheet.

Questions

How does the integration handle SAP S/4HANA's short-lived OAuth tokens?
ml-connector caches the SAP OAuth token and monitors its remaining TTL. Before the token expires (typically within 12 hours), it requests a fresh token from the SAP token endpoint to prevent mid-polling failures. The token endpoint URL is read from your SAP Communication Arrangement, not constructed, to ensure compatibility with your specific tenant.
What if my Google Sheet layout changes or I want to add a new column?
You define the column mapping once when you set up the integration. If you add a new column, you update the mapping to include it, and the next poll will populate the new column alongside existing ones. ml-connector will not erase unmapped columns, so your manual annotations in Sheets are preserved.
Does this integration write data back into SAP S/4HANA?
No. This integration is read from SAP into Sheets only. SAP S/4HANA is your system of record; Google Sheets is the reporting and analysis layer. All changes to invoices, POs, and vendors happen in SAP, and Sheets reflects those changes on the next poll.

Related integrations

Connect SAP S/4HANA and Google Sheets

Free to use. Add your credentials, ping your real systems, and see if we fit.

Get started