Home / SAP Joule Guide / Building Agents

Connect S/4HANA OData APIs to a Joule Agent (Actions Guide)

Turn an S/4HANA OData service into a clean, tested action your custom Joule agent can rely on, using one shared destination.

Building Agents9 min readUpdated Dec 2026
TL;DR
  • An action in SAP Build wraps an API (for example an S/4HANA OData service) so Joule agents and workflows can call it.
  • Use one existing S/4HANA destination across all your actions. Don’t create one per scenario.
  • Expose only the operations and fields the agent needs. Smaller responses mean better answers and fewer AI Units.

A Joule agent can only act on what its tools let it see and do. On S/4HANA those tools are almost always OData APIs. This guide shows how to turn an OData service into a clean, tested action that a custom Joule agent can use.

Step 1: Pick the API

Start on SAP Business Accelerator Hub and search for the business object, for example API_SALES_ORDER_SRV, API_BUSINESS_PARTNER or API_PURCHASEORDER_PROCESS_SRV. Check that:

  • The API is released for your edition (Public Cloud, Private Cloud or on-premise).
  • The communication scenario or service is activated in your S/4HANA system.
  • It returns the fields your use case needs. If not, build a custom RAP service that returns exactly what the agent needs (a clean-core extension).

Step 2: Create the action project

  1. Create a new Actions projectIn the SAP Build lobby, create an action project and import the API (from the Hub or an uploaded spec).
  2. Select operationsPick only what the agent needs, for example GET sales order by ID and GET items. Leave out create, update and delete unless the use case needs them.
  3. Trim the outputRemove fields the agent won’t use. Use $select and $expand deliberately.
  4. Name things for humansGive each action and parameter a clear description. The agent reads these to decide which tool to use.

Step 3: Reuse one destination

Bind the action to your existing S/4HANA destination in the BTP subaccount. One well-configured destination is easier to secure, monitor and move between environments than dozens of near-copies.

For agents that act on behalf of a user, the destination should use principal propagation, so S/4HANA checks that user’s own authorizations. Setup guide: Joule agent authentication.

Step 4: Test the action

Test inside the action editor with real keys before any agent touches it:

GET /sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrder('1234567')
    ?$select=SalesOrder,SoldToParty,TotalNetAmount,
             TransactionCurrency,OverallSDProcessStatus,
             TotalCreditCheckStatus
  • 200 with data: good. Check that the field values make sense.
  • 401/403: a destination or authorization problem, not an AI problem.
  • 404: a wrong key format or service path, or the service isn’t activated.
  • Big payload: trim the fields further.

Step 5: Bind it to the agent

Release the action project, then in your Joule agent add the action as a tool. In the agent’s instructions, say when to use it:

Use "Get Sales Order" first to read header and credit status.
Use "Get Customer Open Items" only if credit status is blocked.

Test the agent with the same document numbers you used for the action, so you know any new error comes from the agent layer.

Common errors and fixes

SymptomLikely causeFix
Agent says it can’t find the orderWrong key format (leading zeros)Describe the format in the parameter, or pad it in the action
Works for you, fails for usersTechnical user vs user contextSwitch to principal propagation and check user roles
Slow or vague answersResponse too largeTrim fields and split into smaller actions
Agent calls the wrong toolVague action descriptionsRewrite descriptions and add “when to use” in the instructions

Frequently asked questions

What is an action in SAP Build?

An action wraps an API, such as an S/4HANA OData service, so it can be reused by Joule agents, workflows and apps in SAP Build.

Should I create a new BTP destination for each agent?

No. Reusing one well-configured S/4HANA destination is simpler to secure, monitor and transport.

Can I use custom RAP services as actions?

Yes. If standard APIs do not return what you need, a custom RAP service is a clean-core way to expose exactly the right data.

Keep reading

Want this built in your landscape?

We design and ship Joule agents on S/4HANA, from API layer to production.

Book a Discovery Call
© 2026 erpai.blogSAP, S/4HANA and Joule are trademarks of SAP SE. Screens show illustrative sample data.