Choose Your Path
There are three ways to use Atscript OData. Start with the first, and go further when you need to. Your screens come with you on every step; Switching to another path says which code changes.
| You need | Path |
|---|---|
| The quickest start | 1, a browser app |
| Your users already sign in to an SAP® ABAP® system | 1, hosted in that system as a BSP app |
| The user's own authorizations at the service, on every call | 1 |
| Your own users and rules, and hooks on every read and write (for an audit log, say) | 2, your Moost server |
| The service's host and credentials kept away from the browser | 2 |
| An action on all the rows a filter matches | 2 |
| Scripts and jobs that read and write the service | 2 |
| Tables of your own database next to the OData sets | 2, or 1 with a server of yours for those tables |
| To move a service your team owns, such as an SAP CAP app, off its stack | 3, the open stack |
Path 1: a browser app on your service
browser (your Vue app, Atscript UI) ──OData──► your serviceWhat you get
- Tables, forms and value helps over the service, and typed calls in your code:
odata.client(type),odata.call(handle, …)(Browser Client, Type Safety). - Each user's own login. The service sees the real user and applies their authorizations.
- The service's operations, offered and called from the page: on rows, in the toolbar, with a form for their parameters (Operations in the browser).
- Columns the service doesn't have, computed in the page as the signed-in user (Views and computed columns).
- A screen's calls grouped into one
$batch(Batching).
What it needs
The page and the service on one origin. There are two ways to get it:
- upload the app into your SAP ABAP system as a BSP app. It's served from the same host as the services, with the user's logon: no proxy, and no server of your own (Deploy into an SAP system);
- put a reverse proxy on your own host in front of both.
In development, Vite's proxy does it. Calls to another origin work only where the service allows them (CORS), and most SAP® Gateway systems don't (Reaching the service).
Users who can sign in to the service.
When not to use it
- You need rules of your own on top of the service's, or the service hidden from the browser.
- You need an action on all the rows a filter matches. The browser runs an action on the rows you pick, and calls every row it is given: the service decides (what differs).
Start here: Installation · Quick Start, 5a · Browser Client · Deploy into an SAP system
Path 2: your Moost server in front
browser ──REST──► your Moost server ──OData──► your serviceWhat you get
- Your own users and rules. The server signs in its users, with Aooth or any Moost auth, and decides who reads and writes what before the service is called (Your own base class).
- One technical account toward the service. The service sees the server, never the end users (Credentials and Sessions).
- Actions on all matching rows. Rows an action doesn't apply to, as the service says, are skipped before the call (what differs).
- Columns computed with the server's credentials (Views and computed columns).
- Scripts and jobs that read and write through the same models (From scripts and jobs).
- Tables of your own database in the same server, next to the OData sets (Your own models next to OData sets).
- No OData in the page. It talks REST to your server.
Your SAP licensing still applies
A technical user is a choice of architecture, not a way to save SAP user licenses. It doesn't change who needs an SAP license: check your SAP contract.
What it needs
- A Node.js host (22.12 or newer) for the server.
- A technical user with the rights of everything the server serves.
When not to use it
- You don't want to run a server.
- Every call must carry the end user's own authorizations at the service: here the service sees only the technical user.
Start here: Quick Start, 5b · Moost Server · Credentials and Sessions
Path 3: move to the open stack
┌──► Atscript DB ──► PostgreSQL, MySQL, SQLite or MongoDB (what you moved)
browser ──REST──► your Moost server ──┤
└──OData──► your service (the rest)For a service your team owns, you can move its data and logic to Atscript DB, one group of related collections at a time, behind the Moost server of path 2. The screens keep their URLs. When nothing is left on the service, you can retire it.
The honest scope
- Only for services your team owns: an SAP CAP app or a custom service. Standard SAP S/4HANA® and SAP Gateway services stay where they are.
- One group of related collections at a time. A relation between a moved set and one still on the service isn't supported, so related sets move together (What moves together).
- You copy the data, and rewrite the actions and handlers as controller code of your own.
- REST, not OData. Anything else that reads the OData service, such as an SAP Fiori® elements app or an integration, still needs it.
- No drafts.
Migrating from SAP CAP has the steps, around an example repo you can run. It is written for SAP CAP apps; a custom service of yours moves the same way, without the SAP CAP parts. Why teams look at it: SAP CAP's license, quoted from SAP's own page.
Start here: Migrating from SAP CAP · Replace SAP CAP with Atscript DB · The example repo
Switching to another path
When you switch from the browser app to a Moost server, or from a Moost server to the open stack, the generated models, your annotate blocks and the Atscript UI screens come with you: a table or a form reads whatever URL you give it. The code around them changes in a few places.
Switching from a browser app to a Moost server
| Browser app (path 1) | Moost server (path 2), from its page | |
|---|---|---|
| A set's URL | odata.urlOf(type), such as /odata/sales/OrderSet | your controller's path, such as /api/sales/OrderSet |
| Typed reads and writes | odata.client(type) | Client<typeof Type> of @atscript/db-client, at that path |
| Operations in code | odata.call(ops.X, { params }), bound ones with row | unbound: operationsClient(url).call(ops.X, params); bound: db actions of the set's controller |
| Computed columns | odata.computeHost(view, …) | the controller's computeHost |
| Views | thin views only | projection views too, filtered ones included |
| New code | none | the space, one controller per entity set, the technical user |
See Type Safety on a Moost page and From a Moost page. Every behavior that differs between the two hosts is in Host differences and, for operations, What differs from the Moost server.
Switching from a Moost server to the open stack
- The same URLs. For each group you move, the controller behind the URL changes from an OData one (
ODataTableController) to an Atscript DB one (AsDbController). The screens don't notice. - Your own model. Copy the generated types of the sets you move into a
.asfile of yours, and change a few lines: they become tables of your own. - Your own logic. Operations become controller actions; the service's handlers become controller hooks.
- Your own data. You copy the rows into the new database.
Replace SAP CAP with Atscript DB walks through each of these.
From the browser app you can go straight to the open stack as well: the browser client's fallback gives every URL that isn't OData a plain Atscript DB client, so a Moost server can serve the moved sets next to the page. Those screens then get the new URLs (Keep the URLs in one file).
See both paths in the live demo
Same screens, two data paths: the page of the browser app talks OData to the service, the page of the Moost server app talks REST to its own server. Code: src/odata.ts; src/server/space.ts and src/ui/api.ts. The Demo Apps page walks through both.
See also
- Why Atscript OData: the pains, our answers, and what we don't do.
- Host differences: every difference between paths 1 and 2, in one table.
- Limitations: what isn't supported, by design or not yet.