Build Apps data and logic — SAP Guided Tutorial
Free sample lesson · open to everyone
Connecting SAP Build Apps to data through BTP destinations and REST integrations, using data, page and app variables, and building logic flows that load, create and update records with proper error handling.
In this lessonShow sectionsHide sections
Visual overview
The situation: a real project scenario
A field-service app saved inspection results via a REST call with a hard-coded technical password visible in the app bundle. Moving to a BTP destination with principal propagation removed the secret and ensured the backend applied each user's authorizations.
Explanation
Data resources connect an SAP Build Apps app to backends: BTP destinations (for example, pointing at an OData service), direct REST APIs, or on-device storage. Data variables hold the records loaded from a data resource, while page and app variables hold pure UI state — a selected row, a filter value, whether a dialog is open.
Logic is built visually with flow functions: get records, create or update a record, set a variable, navigate to another page, and so on, triggered by events like a component tap or a page mounting.
Every flow that calls a backend should have an explicit error output path that informs the user, because a create or update call can fail for reasons entirely outside the app's control (network, validation, authorization), and a user who sees nothing happen has no way to know whether to retry or give up.
Calling backends directly with credentials stored inside the app exposes those secrets to every single user of the app, since the app bundle itself can be inspected.
Connecting data: BTP destinations keep backend URLs and authentication out of the app itself, which is why they're the recommended approach for SAP systems rather than hard-coding a URL and token; OData integrations read the service's entity metadata so its records and fields show up directly in the data panel; test a data resource in the editor before building pages on top of it, so you're not debugging data and UI problems at the same time.
Variables: a data variable is bound to a data resource and can auto-load records when a page opens; a page variable holds state local to one page (selected item, filter text); an app variable holds state that needs to persist across pages (current user context). Keep the number of variables minimal — each one is state you have to keep consistent.
Logic flows: an event (component tap, page mounted) triggers a chain of flow functions and produces outputs; use formulas for conditions and data transformation rather than duplicating logic across flows; reuse logic where the same steps are needed in more than one place.
Errors and feedback: connect the error output of create/update flow functions to a toast or dialog so the user actually sees that something went wrong; disable the save button while a save is in progress to prevent double submits; validate input before calling the backend at all, so obviously-bad data doesn't even generate a round trip.
Step by step: create a data resource using a BTP destination to an OData service; bind a list component to a data variable and display three fields; build a form that creates a record, with validation and an error toast wired up; then test with the backend offline and confirm the user actually sees a clear error message rather than a frozen screen. Checkpoint: the app should read and write only through a destination, never store credentials itself, and show a clear message whenever the backend call fails.
Watch out
Common mistakes
Hard-coding API keys or passwords directly in a data resource, instead of going through a BTP destination, exposes those credentials to every user of the app, since the app bundle can be inspected — this is exactly what happened in the real-project scenario below, where a technical password was visible in a field-service app's bundle.
Leaving no error path on a backend call means that when a create or update fails — which it eventually will, for reasons outside the app's control — the user sees nothing happen and has no idea whether to retry.
Creating too many app-level variables that duplicate the same data in different forms makes state hard to keep consistent and makes bugs (stale data showing in one place but not another) much harder to track down.
Allowing a save button to be tapped multiple times in a row, with no disable-while-saving guard, lets users accidentally create duplicate records simply because the UI didn't give feedback fast enough.
Do this
Best practices
Connect to SAP backends through BTP destinations with proper authentication (ideally principal propagation, so the backend applies each user's own authorizations) rather than embedding credentials or calling REST APIs directly from the app. Add an explicit error path on every flow that calls a backend, wired to a visible toast or dialog, so failures are never silent to the user. Keep logic flows short and clearly named, and keep the number of app-level variables minimal, so the app's state stays easy to reason about as it grows.
In the interview
Interview angle
An interviewer may ask: "How does a Build Apps app securely connect to an SAP backend, and what happens when that connection fails?" A weak answer says "you call the API from the app." A strong answer distinguishes data resources (BTP destination vs. direct REST vs. on-device storage) and explains why a BTP destination with proper authentication — ideally principal propagation — keeps credentials out of the app bundle and applies each user's own authorizations, unlike a hard-coded technical user.
It also covers the data/page/app variable distinction and insists that every backend-calling flow needs an explicit error path connected to visible user feedback, not a silent failure.
Practice this lesson
Original educational case studies for SAP consultants, not official SAP certification exam questions. Verify product edition and implementation details against the current SAP documentation.
Quick check
0 of 4 questions attempted
Question 1 of 4
What is the recommended way to connect SAP Build Apps to an S/4HANA OData service?
Question 2 of 4
Which variable type should hold the selected item on a single page?
Question 3 of 4
A create-record flow function fails. What should the app do?
Question 4 of 4
Why disable the save button while a request is running?
Practise this in an interview
Answer in your own words and get instant feedback, the way an interviewer would judge it.
1How do you build a Build Apps screen that lists and creates S/4HANA records safely?
2What are the risks of low-code apps calling backends, and how do you mitigate them?
Was this lesson helpful?
Keep exploring
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.