Skip to content

Overview ​

Atscript OData turns the $metadata of an OData v2 or v4 service into typed Atscript models, and serves the service to Atscript UI the way an Atscript DB backend is served. Tables, filters, value-help pickers and forms then work against the service you already run.

It works with services of SAP S/4HANA®, SAP Gateway®, the ABAP® RESTful Application Programming Model (RAP) and the SAP Cloud Application Programming Model® (SAP CAP), and with any other OData v2 or v4 service.

Preview release

The packages are a preview (0.0.x): their APIs may still change between releases.

What it does, and what it leaves to others ​

Atscript OData owns the OData side:

  • reading $metadata (v2 and v4) into one version-neutral service model;
  • generating .as models from it: entity sets, keys, labels, relations, value helps, texts, fixed values, version tokens (ETags);
  • reading the live $metadata at runtime and running on it, the generated types included;
  • translating Atscript DB queries and writes into OData requests, and the answers back;
  • the transport: CSRF tokens, ETags, sessions, paging links, error bodies.

It does not render anything, and it does not run a database. Screens come from Atscript UI; the server, when you have one, is Moost with the controllers of Atscript DB.

Two hosts, one core ​

                        ┌─ @atscript/odata-client ──────────────── browser ──────┐
  $metadata ─► @atscript/odata (models, query, codec, transport)                 ├─► Atscript UI
                        └─ @atscript/db-odata ─► @atscript/moost-odata ─ server ─┘
PackageRuns inRole
@atscript/odatabrowser, NodeThe core: metadata parser, generator and build plugin, query engine, transport, CLI
@atscript/odata-clientbrowserA client Atscript UI uses like the Client of @atscript/db-client, talking OData
@atscript/db-odataNodeAn Atscript DB adapter: each entity set becomes a table
@atscript/moost-odataNodeBase classes for the Moost controllers you declare, operations, credentials, sessions

Both hosts share the core, so they build the same requests and agree on what a service can do. Their limits differ only where the host is the reason (see Limitations).

Which host to choose ​

The browser client talks to the service directly. There is no server of yours in between.

A Moost server of your own serves each entity set through Atscript DB's REST controllers. The browser sees a plain Atscript DB backend and never talks to the service.

You needBrowser clientServer
The fastest start, no serveryesno
The service reachable from the browser (same origin, or a proxy)requirednot needed
The end user's own login at the service (single sign-on cookies)the browser's ownno: the service sees a technical user
One technical account for every callernoyes
Your own authorization, scopes, hooks on reads and writesnoyes, as on any Atscript DB controller
OData entity sets next to tables of your own databaseyes, other URLs go to your serveryes, one server
The service's host, credentials and texts kept away from the browsernoyes

Start with the browser client when the service is reachable from your origin and the users already have a session with it. Choose a Moost server when you need your own authorization, a technical user, server-side hooks, or a stable API in front of the service: the server signs in its own users, and calls the service with credentials of its own. Both read the same generated models, and the screens do not change when you move from one to the other: only the URL of each entity set does.

See it live

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 80% path ​

Generate the models once, register the service, connect, and point a table at it:

ts
// src/main.ts (browser client)
import { createODataClientFactory } from "@atscript/odata-client";
import { setDefaultClientFactory } from "@atscript/ui";
import { createApp } from "vue";
import App from "./App.vue";
import * as sales from "./odata/sales.as";
import { model } from "./odata/sales.model.gen";

const odata = createODataClientFactory({
  services: [{ baseUrl: "/sap/opu/odata/sap/ZDEMO_ORDERS_SRV", model, types: sales }],
});
setDefaultClientFactory(odata);
odata.connect().then(() => createApp(App).mount("#app"), showStartError);
vue
<AsTableRoot url="/odata/sales/OrderSet" :types="cellTypes">
  <AsTable />
</AsTableRoot>

The Quick Start walks through it, and through the same screen behind a Moost server.

What each page covers ​

Getting started

  • Installation: the packages of each setup, and the toolchain.
  • Quick Start: from $metadata to a table and a form, in the browser and behind a Moost server.
  • Demo Apps: two apps over one OData v4 service, one per host, with a walkthrough of each repo.
  • AI Agent Skill: the skill that walks a coding agent through the same path.

Models

  • Generating Models: atscript-odata fetch, the build plugin and its options, what is generated, and what is listed as not expressed.
  • Live Metadata: the live $metadata at runtime, the language, the browser on a changed service, the Moost server's drift report, and the limits.
  • Value Helps: value lists, value-help services, fills, texts, columns and dropdowns.
  • Relations: navigations as relations, $with as $expand.

Hosts

  • Browser Client: the client factory, connecting, runtime mode, sessions and locale.
  • Moost Server: the space, connecting before app.init(), declaring the controllers, value-help targets, your own base class.
  • Type Safety: what the compiler checks when you pass the generated types and handles, per host, typed screen configs, and what it does not check.
  • Credentials and Sessions: the server's technical user, the strategies, and the sessions the space keeps.

Reading and writing

  • Writes and Concurrency: what a write sends, version tokens, CSRF.
  • Operations: function imports and actions on a Moost server (the generated bases) and in the browser (db actions of the sets, odata.call), and what happens when the service changes them.
  • Aggregation: grouped reads as $apply.
  • Errors: what each host throws or answers, and why.

Reference

Conventions used across these pages ​

  • Typed at build time, live at runtime. The saved $metadata gives the models and the TypeScript types; at runtime the hosts read the live $metadata and run on it, and the generated classes become the live declarations. See Live Metadata.
  • Service name. The name you give a service in the plugin (sales). It is written into every generated type as @db.space, the name a Moost server registers the service's space under (provideDbSpace(space, "sales")); the hosts take it from the model module, and it is the URL segment of the browser client.
  • An SAP service is one whose $metadata came from SAP Gateway or RAP. The core recognizes it by itself and picks the sap dialect for it; SAP CAP and every other service get standard. See Dialects and Vendors.
  • Version token. An entity set with optimistic concurrency gets a field __etag in its type that carries the entity's ETag. It is never sent to the service as data.
  • Fail closed. What OData or the service cannot do is refused with a clear error before any request, and left out of /meta where /meta can say so. Nothing is emulated in silence.
  • Examples use a synthetic Gateway v2 service ZDEMO_ORDERS_SRV with the entity sets OrderSet, OrderItemSet and CustomerSet, generated as the interfaces Order, OrderItem and Customer of src/odata/sales.as.

SAP, SAP S/4HANA, SAP Fiori, SAPUI5, SAP BTP and other SAP products and services mentioned herein, as well as their respective logos, are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. Atscript OData is an independent open-source project and is not affiliated with, sponsored or endorsed by SAP SE.
Released under the MIT License.