Connect SAP S/4HANA🔗
Lightrun reads the S/4HANA records behind a ticket, such as purchase orders, supplier invoices, sales orders, deliveries, production orders, stock, warehouse tasks, WBS elements and application logs. With optional ABAP Development Tools (ADT) access, it can also read ABAP short dumps, ABAP source and IDoc status. It only reads.
Lightrun connects to S/4HANA through a read-only MCP server. The MCP server signs in to S/4HANA with a dedicated display-only technical user. It reads business records through SAP's OData APIs, and ABAP and IDoc details through ADT.
Lightrun ──HTTPS──▶ Read-only S/4HANA MCP server ──▶ S/4HANA OData and ADT APIs
(bearer token or OAuth) (display-only technical user)
Talk to your Lightrun team first
Your Lightrun team helps you choose where the MCP server runs: in SAP Integration Suite on your BTP, or on a host that can reach S/4HANA. They'll also agree the list of APIs with you.
Who does it: your SAP Basis team, with your Lightrun team.
Prerequisites🔗
- SAP S/4HANA with SAP Gateway, and the system and client Lightrun should read, for example system
S4H, client100. - A Basis admin who can create users and roles (
SU01,PFCG) and publish OData services (/IWFND/MAINT_SERVICE,/IWFND/V4_ADMIN). - An agreed list of S/4HANA APIs, and the company codes, plants and organizational units in scope.
- A place to run the MCP server that can reach S/4HANA over HTTPS with a trusted SAP certificate. For example, SAP Integration Suite with MCP Server, reaching S/4HANA through SAP Cloud Connector.
- HTTPS access from Lightrun to the MCP server URL.
- One or two known records, such as a purchase order item, to verify the setup.
Step 1: Create the technical user and roles🔗
- In
SU01, create a dedicated technical user for the MCP server, for exampleLIGHTRUN_MCP_RD. - In
PFCG, give it display-only roles (ACTVT=03) for the agreed business areas, limited to your company codes, plants and organizational units. Generate each profile and run User Comparison.
Two kinds of permission work together:
- Gateway start access lets the user call a service. For an OData V2 service, use
S_SERVICEwithSRV_TYPE=HT, and maintain both the Gateway registration (IWSG) and the backend service (IWSV). For an OData V4 service group, useS_STARTwithAUTHPGMID=R3TR,AUTHOBJTYP=G4BAandAUTHOBJNAMset to the service group. - Business display permissions decide which records SAP returns, for example
M_BEST_*for purchase orders orV_VBAK_*for sales orders.
Step 2: Publish the agreed APIs🔗
Register the OData V2 services in /IWFND/MAINT_SERVICE, and publish the OData V4 service groups in /IWFND/V4_ADMIN. A typical starting set:
| Area | S/4HANA services |
|---|---|
| Purchasing, invoicing and finance | API_PURCHASEORDER_PROCESS_SRV, API_SUPPLIERINVOICE_PROCESS_SRV, API_OPLACCTGDOCITEMCUBE_SRV, API_COSTCENTER_SRV |
| Sales, shipping and billing | API_SALESORDER (V4), API_OUTBOUND_DELIVERY_SRV;v=0002, API_BILLINGDOCUMENT (V4) |
| Manufacturing | API_PRODUCTION_ORDER_2_SRV, API_PROCESS_ORDER_2_SRV, API_PROD_ORDER_CONFIRMATION_2_SRV |
| Inventory and products | API_MATERIAL_DOCUMENT_SRV, API_MATERIAL_STOCK_SRV, API_PRODUCT_SRV |
| Warehouse (EWM) | API_WHSE_INB_DELIVERY_2 (V4), API_WAREHOUSE_ORDER_TASK_2 (V4) |
| Project System | API_PROJECT_V3 (V4) |
| Application logs | APL_LOG_MANAGEMENT_SRV |
OData V2 services are served under /sap/opu/odata/sap/<service>. OData V4 services are served under /sap/opu/odata4/sap/<service group>/srvd_a2x/sap/<service>/0001.
Optional: ABAP, short dumps and IDocs🔗
To let Lightrun read ABAP source, short dumps and IDoc status, add a display role with:
| Purpose | Authorization |
|---|---|
| ADT routes | S_ADT_RES for /sap/bc/adt/programs/programs/*, /sap/bc/adt/repository/information*, /sap/bc/adt/runtime/dump* and /sap/bc/adt/datapreview/freestyle |
| ABAP source | S_DEVELOP with ACTVT=03, limited to the packages and programs in scope |
| Short dumps | S_ABAPDUMP with ACTVT=03 |
| IDoc status | S_TABU_NAM with ACTVT=03 and TABLE=EDIDC,EDIDS only |
Step 3: Run the MCP server🔗
Configure the MCP server with:
- the S/4HANA endpoint and client number
- the trusted SAP certificate
- the technical user's credentials
Keep the SAP password and the MCP token in a secret store. The MCP server must expose a Streamable HTTP endpoint over HTTPS.
Step 4: Connect in Lightrun🔗
- Go to Connectors and click Add custom MCP.
- Enter the MCP server's HTTPS URL.
- Under credentials, choose API key and paste the MCP server's read-scope bearer token.
- Click Test connection. Lightrun lists the MCP server's tools. Keep only the read tools, then click Add.
- Add the connector to your workflow's agent.
MCP server in SAP Integration Suite with OAuth
If your MCP server runs in SAP Integration Suite and uses OAuth client credentials, connect it with Connectors → SAP S4HANA (Integration Suite) instead. Enter the URL, Client ID, Client secret and Token endpoint from a SAP Process Integration Runtime integration-flow key with the API.invoke role.
Step 5: Network🔗
- Lightrun → MCP server: HTTPS to the MCP server URL. If you restrict it by IP address, allowlist Lightrun's IP addresses.
- MCP server → S/4HANA: HTTPS with a trusted certificate. If the MCP server runs in SAP BTP, use SAP Cloud Connector and allow only the agreed API paths. Cloud Connector connects outbound, so S/4HANA isn't exposed to the internet.
Check it works🔗
- Confirm that Lightrun lists the MCP server's tools.
- Ask about a known record, for example "Show purchase order 4500001234, item 10." Keep document numbers as text so leading zeros are kept.
- If you enabled IDoc access, ask about a known outbound IDoc and check its status against
WE02.
An empty result can be a permission problem
An HTTP 200 with an empty list can mean the technical user isn't allowed to see the record. Compare the same query for a known record under the technical user. Run an authorization trace (STAUTHTRACE) for that user only, and switch it off after the read.
Troubleshooting🔗
| What you see | What to check |
|---|---|
| The service call is refused | The service is published, and the user has Gateway start access (S_SERVICE or S_START). |
| A known record is missing | The user's business display permissions cover that record's organizational units. Compare the exact document and item keys. |
| An ADT route returns HTTP 403 | The user has S_ADT_RES for that route. Some routes, such as system information and transport requests, need more authorization. |
| A table read is refused | S_TABU_NAM limits the user to the listed tables. This is expected for tables outside the agreed scope. |