Skip to content

Operations ​

The function imports, actions and functions of a service, on both hosts. On a Moost server, ask the OData plugin for a controllers module: it writes base classes whose methods are Moost DB db actions and routes, one per operation. You extend them, as you extend ODataReadableController, and declare, guard and register every controller yourself. In the browser there is nothing to declare: the clients of the factory list the operations of their sets as db actions, and odata.call calls any operation (see In the browser).

ts
// atscript.config.ts
odataPlugin({
  services: [
    {
      name: "sales",
      metadata: "odata/sales.xml",
      language: "EN",
      controllers: { writable: ["OrderSet"] },
    },
  ],
});
ts
// server/main.ts
import { TableController, provideDbSpace } from "@atscript/moost-db";
import { Controller, Inherit } from "moost";
import * as sales from "../src/odata/sales.as";
import { OrderSetBase, SalesOperationsBase } from "../src/odata/sales.controllers.gen";

provideDbSpace(space, "sales");

// The operations bound to orders, as db actions of the OrderSet controller.
@TableController(sales.Order, "api/sales/OrderSet")
export class OrderSetController extends OrderSetBase {}

// The unbound operations, one POST route each.
@Inherit()
@Controller("api/sales/ops")
export class SalesOperations extends SalesOperationsBase {}

Atscript UI shows the db actions of OrderSet as buttons on its table (with a form where the operation takes parameters); POST /api/sales/ops/GetPrice calls an unbound one.

What becomes what ​

In the serviceOn the Moost serverIn the browser
An OData v4 action or function bound to an entity; an OData v2 import with sap:action-for whose parameters cover the keyA db action on rows of each set of the type: the row's key fills the call, the form holds the restThe same db action, on the set's client
An OData v4 action or function bound to the collection; a v2 sap:action-for import that does not cover the keyA db action on the table, the whole parameter list as its formThe same db action, on the set's client
An unbound function import, action import or function importA route of the service's operations base: POST, the parameters as the JSON body, no UIodata.call(ops.GetPrice, { params }), no UI
A draft lifecycle operation; one the service marks never availableNothingNothing

Each operation has a generated <Name>Params interface in the .as file, its form (see Generating Models), and a typed handle in the model module's ops.

The controllers module ​

controllers writes <name>.controllers.gen.ts beside the .as file, in the same build, and rewrites it when the metadata changes. Never edit it.

OptionMeaning
controllers: trueWrite the module at the default path
controllers: { output }Its path, relative to the plugin's root
controllers: { writable: ["OrderSet"] }The sets whose base extends ODataTableController (writes too); every other base extends ODataReadableController
operations: { exclude: [...] }Operations left out of the types, the handles and the controllers, by import, local or qualified name

It holds:

  • A base per entity set with bound operations, named <EntitySet>Base. Each method is op_<Name> at the route actions/<Name>, <Name> the operation's local name (the import name on v2).
  • The operations base of the service, <Service>OperationsBase, when it has unbound operations: each method op_<Name> at the route <Name>.

A generated method, here of an OData v2 import on rows:

ts
@Post("actions/ReleaseOrder")
@DbAction("ReleaseOrder", {
  label: "Release",
  maxIds: 50,
  queryTarget: { maxRows: 50 },
  requiredFields: ["Release_ac", "__etag"],
  disabled: (rows) => rows.map((row) => row.Release_ac === false),
  onDisabledRows: "skip",
})
@ODataOperation(ops.OrderSet.ReleaseOrder, { grouping: "isolated" })
op_ReleaseOrder(
  @DbActionRows() rows: Pick<T.Order, "OrderId" | "__etag">[],
  @InputForm(T.ReleaseOrderParams) params: T.ReleaseOrderParams,
): Promise<ODataRowsAnswer<T.Order>> {
  return this.runOperation({ rows, params });
}

Everything on it is Moost DB's own action machinery, its options written from the metadata at build:

  • label: the operation's label (sap:label, Common.Label, or the label of a UI.DataFieldForAction naming it), else its name.
  • The availability gate of an operation on rows: the service's availability path (v2 sap:applicable-path, v4 Core.OperationAvailable) as requiredFields, and disabled where it is false. A row it says no to is skipped (onDisabledRows: "skip", as Fiori Elements continues with the applicable rows); null is unknown, and the service decides.
  • __etag among requiredFields on a set with a version token, for an operation that writes (a v4 action, a v2 import that is not a GET): the row load reads it, and the call sends it as If-Match. A function sends If-Match: * instead (see below), so its row load does not read it.
  • @DbActionIDs() in place of @DbActionRows() where there is nothing to read: no availability path and no token to send (and on a set whose reads must filter outside its key). The ids are the key alone, and no row is read before the call.
  • @InputForm where the operation has parameters to fill in: the form is the live <Name>Params type. An operation without them opens no dialog.
  • queryTarget on an operation on rows: Atscript UI's "all matching rows" (see Several rows). Not on a set whose reads must filter outside its key.
  • @ODataOperation marks the method with the operation's handle, and on rows with the grouping it runs several rows by (the build's UI.DataFieldForAction grouping, else isolated; see Several rows).

generateODataModels lists every db action and route in the result's controllers, so a regeneration that adds one shows.

See it live

Retire, Stock value and Reprice all on Coffees in the Moost server app come from the generated CoffeesBase. Code: src/server/controllers.ts.

What you write ​

A leaf per base, declared, guarded and registered like any controller:

  • A set's controller extends its base, with Moost DB's @TableController or @ReadableController (they mark the class @Inherit() themselves). Bound by model token, the space registered under the service's name with provideDbSpace (see Moost Server).
  • The operations controller extends the operations base with Moost's @Controller(path) and @Inherit(); without @Inherit() its routes are not bound. It calls the space registered under the service's name (provideDbSpace(space, "sales")), which it finds by the handles' service.
  • Guards on the leaf class (@Authenticate, @ArbacResource, an interceptor) cover every inherited route. A guard refuses before anything of the operation runs.

Calling them ​

A db action is called as Moost DB's actions are: POST <controller>/actions/<Name> with { ids, input }, which client.action(name, ids, input) of @atscript/db-client and Atscript UI send.

POST /api/sales/OrderSet/actions/ReleaseOrder   { "ids": [{ "OrderId": "4500000001" }], "input": { "Note": "ok" } }
POST /api/sales/OrderSet/actions/CopyOrder      { "input": { "SourceOrder": "4500000001" } }
POST /api/sales/ops/GetPrice                     { "Material": "M-100" }
StepWhat happens
GuardsYours first: a caller they refuse gets your 401 or 403
The build's checkAn operation the live service no longer fits is refused (see below)
RowsAt most 50 ids; with a gate or a token, one read of the key, the availability path and __etag: a missing row 404, rows the path says no to skipped, none left 409
Form or bodyValidated against the live <Name>Params type: Moost DB's 400 with the field paths
The callOne call with the server's credentials and session, several rows one $batch (see Several rows); on a call that writes (a v4 action, a v2 import that is not a GET) each row's __etag the row load read as If-Match
The answerOn rows, Moost DB's action target summary with one value per row (see Several rows); on the table and on the operations base { value, message?, messages?, details? }. The service's messages as texts (message the leading one) and as sent (details)
  • A refused call's messages are reported by field, as a write's: a message whose target names a parameter of the operation is at that parameter, the field of the input form (percent), for a bound operation as for an unbound one; one that names a property of the bound entity (in/Price, Price) at that property. Both hosts map them alike.
  • The __etag is the server's own read, from the row load right before the call: a caller sends ids, which carry no token. A 412 means the row changed between that load and the call; the server answers Moost DB's 409 VERSION_MISMATCH with the entity's current token, as for a stale write (or 404 when the entity is gone), and does not retry.
  • Ids without a row load on a set with a version token (a set whose reads must filter outside its key, see below): the server reads the entity's ETag right before the call, and reads it again after a 412, three attempts, then 503 SERIALIZATION_FAILURE. A row that read does not find is Moost DB's 404 NOT_FOUND, and its call is not sent. So is a row the service answers 404 on the call.
  • A function (a v4 bound function, a v2 GET import) called on a row of a set with a version token sends If-Match: *: it writes nothing, so there is no change to lose, and * asserts only that the entity exists. SAP CAP refuses a bound call without If-Match (428); with * it answers the function, or 404 for a row that is gone. A 412 to * says the same, since * holds for any entity that exists: both hosts answer it 404 NOT_FOUND, never a version mismatch or a retry. No token is read first and the row's own __etag is not sent (Fiori Elements sends none on a function). On a set without a version token it sends none.
  • An operation on the collection (no row, an action or a function, a v2 import bound to the set without the key) of a set with a version token sends If-Match: * too: there is no row whose token it could send, and SAP CAP refuses a call bound to the collection of a set with an ETag without one (428). On a set without a version token it sends none.
  • The operations base takes the parameters as the body; a body that is not the type (a missing required parameter, a name the operation does not declare) is refused with 400 before any call. A request without a body gives no parameters.

What the service answers is mapped as for every call: see Operations in Errors.

From a Moost page ​

The db actions need nothing: Atscript UI calls them through @atscript/db-client. A page calls the operations base with operationsClient of @atscript/moost-odata/client, a browser entry that ships no OData and no server code (only fetch), typed by the handles of the model module's ops:

ts
import { operationsClient } from "@atscript/moost-odata/client";
import { ops } from "./odata/sales.model.gen";

const salesOps = operationsClient("/api/sales/ops"); // the path of your operations controller
const { value: price } = await salesOps.call(ops.GetPrice, { Material: "M-100" });

call(handle, params) posts to <path>/<operation> and answers { value, message?, messages?, details? }, typed by the handle. A failure throws @atscript/db-client's ClientError or TransportError, and a handle of a bound operation is refused: that operation is a db action of its table's controller (see operationsClient). The options take fetch and headers, as a Client's. Importing ops costs the page the handles only: the bundler drops the model next to them.

See it live

The Moost server app calls Bestsellers on its Overview, and Receive beans… on Coffees, through roasteryOps = operationsClient("/api/roastery/ops", …). Code: src/ui/api.ts and src/ui/routes.ts.

Several rows ​

A db action on rows called on several ids goes out as one OData $batch, as Fiori Elements runs an action on a table's selection: one round trip, one CSRF token. How the rows share it is the operation's grouping, the one its @ODataOperation carries:

GroupingThe $batchWhen a row fails
isolated (the default)Each row's call in a changeset of its own; on OData v4 with Prefer: odata.continue-on-errorThe other rows still run and stay applied
changeSetEvery row's call in one changesetThe service applies none

The build takes the grouping from the InvocationGrouping of the UI.DataFieldForAction naming the operation (a UI.LineItem first, the table's toolbar); without one, isolated, Fiori Elements' default. OData v2 metadata almost never states one: set it in an override (see Overriding).

See it live

On confirmed orders in the Moost server app, select several and Ship them: one $batch, and a row the service refuses fails alone. Code: roastery.controllers.gen.ts.

The answer is Moost DB's action target summary, which Atscript UI recognises, with the operation's values, one per row that ran, in request order:

json
{
  "matched": 3,
  "processed": 2,
  "skipped": [],
  "failed": [
    {
      "id": { "OrderId": "4500000002" },
      "reason": "Order 4500000002 is blocked",
      "status": 400,
      "code": "INVALID_QUERY"
    }
  ],
  "value": [
    { "OrderId": "4500000001", "Status": "R" },
    null,
    { "OrderId": "4500000003", "Status": "R" }
  ],
  "message": "Order released",
  "messages": ["Order released"],
  "details": [{ "code": "ZSD/001", "message": "Order released", "id": { "OrderId": "4500000001" } }]
}
OutcomeAnswer
Every row ran201, the summary, failed: []
isolated, some rows failed201, the summary: each failed row in failed with the service's message as reason, and the status and code a call on it alone is answered with; its value is null
isolated, every row failedThe first row's error, as a call on it alone is answered, with the entries of every row at that row ([0], [1].Note). One row: its own error, unchanged. Where the gate skipped rows, or on all matching rows: the summary, processed: 0, every row that ran in failed, as Moost DB's own targets answer
changeSet, refusedIts one error, nothing applied: a 412 to the rows' tokens is 503 SERIALIZATION_FAILURE, a 404 (or a 412 to *) 409 CONFLICT, any other status as a single call, a 412 to no If-Match included (a set without a version token: the server's 502 STORE_FAILED, PRECONDITION_REQUIRED). A message that names a row is at that row's index in the request's ids ([1]), with its key as params.id (on all matching rows, which list no ids, at "" with params.id); any other at "", the whole run
The $batch failed as a wholeAs a single call's failure: nothing is known to have run
  • A row's __etag is the row load's: a 412 on it is that row's 409 VERSION_MISMATCH (in failed, reason: "version_mismatch"), as for one row.
  • A message names a row of a refused changeset by the Content-ID of its request on OData v4, and on OData v2, which sends none, by a target that is the row's key path (/OrderSet('4500000002')). SAP CAP's v2 adapter writes no such target: there every message is the whole run's.
  • Skipped rows: the rows the availability gate says no to are listed in skipped and never sent, as Fiori Elements continues with the applicable rows; none left is Moost DB's 409.
  • One row goes out as one plain call, answered with the summary.
  • A function (a v4 bound function, a v2 GET import) goes out a part per row, whatever the grouping.
  • Ids without a row load on a set with a version token: their ETags are read first, in a $batch of their own, and each row's call goes with the ETag read (* for an entity that comes without one, and for every row of a set that cannot be read from the root). A 412 then is that row's 503 SERIALIZATION_FAILURE, not retried. A row whose read finds no entity is never sent: it is that row's 404 NOT_FOUND. Under changeSet a row whose ETag cannot be read, or that does not exist, refuses the run before its changeset goes out, nothing applied, answered as a refused changeset with that row's error at the row ([1]).
  • All matching rows: every generated action on rows takes Moost DB's queryTarget ({ maxRows: 50 }), so Atscript UI's "select all matching" runs it on the rows a filter matches (a dry run counts them first), at most 50, as one $batch.
  • Without $batch: the space's batch: false (see Moost Server) sends none. isolated rows then go one call after the other, on past a failed one, with the same answers; a changeSet run is refused before any call, 400 NOT_SUPPORTED, since calls one after the other cannot be applied all or none. So does a service whose $metadata says it has no $batch (Capabilities.BatchSupported false), and one that answered a $batch 404, 405 or 501 in the last ten minutes (then a $batch is tried again).
  • The summary is no confirmation: Atscript UI refreshes the table after it, so the rows that ran show their new state. Showing the failed rows is your @action handler's, which receives the summary.

Overriding ​

Generated decorators are the build's facts; change them the Moost way, in your subclass:

ts
@TableController(sales.Order, "api/sales/OrderSet")
export class OrderSetController extends OrderSetBase {
  // Another guard on one action, kept beside the class's: route, action and form stay.
  @Authenticate(approvers)
  override op_ReleaseOrder(...args: Parameters<OrderSetBase["op_ReleaseOrder"]>) {
    audit(args[0]);
    return super.op_ReleaseOrder(...args);
  }

  // Not served: no route, not in /meta.
  @Inherit(false)
  override op_CopyOrder(): never {
    throw new Error("not served");
  }
}

@Inherit()
@Controller("api/sales/ops")
export class SalesOperations extends SalesOperationsBase {
  // OData v2: a parameter the import does not declare, set in code.
  override op_GetPrice(params: sales.GetPriceParams) {
    return this.runOperation({ params, extra: { Context: "SD" } });
  }
}
  • An override without decorators keeps the route, the action, the form and the marker of the base.

  • Relabel with an @DbAction(name, { … }) of your own on the override, the same name and the options the base writes: your options win in /meta. The base's disabled still runs as well; to change the availability, give your own requiredFields and disabled.

  • Regroup with @ODataOperation(handle, { grouping: "changeSet" }) on the override: all rows or none. The usual case is an OData v2 service, whose metadata states no grouping:

    ts
    @ODataOperation(ops.OrderSet.ReleaseOrder, { grouping: "changeSet" })
    override op_ReleaseOrder(...args: Parameters<OrderSetBase["op_ReleaseOrder"]>) {
      return super.op_ReleaseOrder(...args);
    }
  • extra (OData v2 only) sends parameters the import does not declare, untyped. Set them in code: never pass on what a request sent.

  • Leave an operation out for good with operations.exclude, or @Inherit(false) on an override. Hide one per caller with Moost DB's allowedActions or applyMetaOverlay; icon and intent go through buildActions.

  • prepareRequest: the OData bases implement it (a set gone live, an operation the live service no longer fits). An override calls await super.prepareRequest(ctx) first. One that forgets still gets the operation refused when its method runs, but after the rows were read, so an availability path gone live fails that read first.

A button over an unbound operation ​

An unbound operation has no UI of its own. To offer one as a row or toolbar button, add a db action to your table controller that calls it, with @ODataOperation and its handle:

ts
import { DbAction, DbActionRow, InputForm, TableController } from "@atscript/moost-db";
import { ODataOperation } from "@atscript/moost-odata";
import { Post } from "@moostjs/event-http";
import { ops } from "../src/odata/sales.model.gen";

@TableController(sales.Order, "api/sales/OrderSet")
export class OrderSetController extends OrderSetBase {
  @Post("actions/recalc")
  @DbAction("recalc", { label: "Recalculate" })
  @ODataOperation(ops.RecalcOrder)
  recalc(
    @DbActionRow() row: Pick<sales.Order, "OrderId">,
    @InputForm(RecalcForm) form: RecalcForm,
  ) {
    return this.runOperation({ params: { ...form, OrderId: row.OrderId } });
  }
}

RecalcForm is an .as interface of your own: the form without the key. The row holds the key only: @DbActionRow() loads the id columns and what requiredFields names. For a toolbar button, leave out @DbActionRow() and take @InputForm(sales.RecalcOrderParams). The call is unbound, so it sends no If-Match.

When the service changes ​

A Moost server holds the live service to its build. On a slow path, every operation the build generated gets a verdict against the live $metadata:

The live serviceVerdictThe action or route
Has it as before; or changed its labels, facets, result or v2 method; added an optional parameter; changed its groupingfitsruns, on the live metadata
Removed it, or bound it to something elsegone404 NOT_FOUND, Moost DB's body
Removed, retyped or made required a parameter; added a required one; changed or dropped its availability path; overloads it alikeincompatible500, logged: "… the build no longer fits it: rebuild it"
  • Refused after your guards, before anything else: no id is read, no row loaded, no call sent. A caller your guards refuse gets their 401 or 403.
  • Hidden: a refused db action is not in /meta, $actions or GET /meta/actions/:id.
  • Reported: the drift report at start lists the operations added, removed and incompatible, with the reason (ReleaseOrder: parameter Note Edm.String → Edm.Int32).
  • An operation only the live service has is listed and not served until a rebuild.
  • The grouping is the build's, or your override's, whatever the live service says.

Rebuild against the live service to serve what it has now.

In the browser ​

The browser client is the live client: it offers and calls the operations the live service has, nothing more. Register the service as on Browser Client; nothing else is declared.

ts
import { createODataClientFactory } from "@atscript/odata-client";
import * as sales from "./odata/sales.as";
import { model, ops } from "./odata/sales.model.gen";

export const odata = createODataClientFactory({
  services: [{ baseUrl: "/sap/opu/odata/sap/ZDEMO_ORDERS_SRV", model, types: sales }],
});

// Typed by the handle: its parameters, its result.
const { value: price } = await odata.call(ops.GetPrice, { params: { Material: "M-100" } });

// On a row as read: its key, and its __etag as If-Match.
const order = await odata.client(sales.Order).one("4500000001");
await odata.call(ops.OrderSet.ReleaseOrder, { row: order!, params: { Note: "ok" } });

Actions in Atscript UI ​

Each client lists the operations bound to its set's type as db actions, the way a Moost server's generated base declares them, so an Atscript UI table shows them as it shows a Moost server's: an operation on rows on each row and on the selection, one on the table in the toolbar, a form where it takes parameters. Atscript UI calls them through the client; the app writes nothing.

Client memberODataClient
meta().actionsOne per operation of the live service bound to the set's type: its local name (the key in ops), rows or table, processor: "backend", the label, inputForm where it has parameters
getActionForm(name)Its live <Name>Params type
action(name, ids, input)Validates input against that type, reads the rows' tokens, calls the operation: several rows as one $batch by the live grouping
availableActions(id)The row actions the service offers on one row: one read of the key and the availability paths
$actions on query(), pages(), one()$actions on each row: the row actions the service offers on it
actionOnQuery(), countActionTarget()Reject: ClientError 400 NOT_SUPPORTED
  • The label is the @meta.label of the live <Name>Params type (the service's label, or yours through annotate), else the operation's name.
  • Every set lists its bound operations, with no step of yours. To keep one out of the app, name it in the plugin's operations.exclude (the live selection leaves it out too); to keep it off one screen, use Atscript UI's :row-actions policy ({ exclude: ["ReleaseOrder"] }, or include).
  • On rows, ids are the rows' keys, as Atscript UI sends them. For an operation that writes (a v4 action, a v2 import that is not a GET) on a set with a version token, one read takes the rows' tokens (the key filter, $select of the key); a row it does not find is 404 NOT_FOUND, as on a Moost server for an action without an availability gate. The call sends the token as If-Match; a 412 on it is a VersionMismatchError with the entity's current token. A function reads nothing first and sends If-Match: * on a set with a version token.
  • The answer is the Moost server's: on rows the action target summary with one value per row (see Several rows), on the table { value, message?, messages?, details? }. Atscript UI shows message and refreshes the table.
  • Several rows go out as one $batch (several past batch.maxParts), with the outcomes and errors of Several rows. The grouping is the live operation's: on OData v2, whose metadata almost never states one, isolated applies, and nothing in the browser sets another. Every given row is sent: skipped is always empty. With the registration's batch: false the rows go one call after the other, and a changeSet run is refused (ClientError 400 NOT_SUPPORTED).

See it live

On Coffees in the browser app: Retire and Stock value in a row's menu, Reprice all in the toolbar. On Orders, each order offers the actions its status allows. Code: ListScreen.vue.

Availability ​

The service's availability (v2 sap:applicable-path, v4 Core.OperationAvailable) is passed on as a hint: Atscript UI offers a row action only where the service says it applies ($actions on its reads), and availableActions(id) answers it for one row. null or a missing value is unknown, and the action is offered. Nothing is filtered or refused by it: every call goes to the service, which decides.

Calling an operation ​

odata.call(handle, input?) calls an operation of a registered service by its handle of ops, connecting the service first:

inputMeaning
paramsThe parameters, validated against the operation's live <Name>Params type: ClientValidationError before any call
rowAn operation on rows: the row as read, its key and its __etag. On a call that writes (a v4 action, a v2 import that is not a GET) the token goes as If-Match (a 412 on it is a VersionMismatchError), and a row without one has the ETag read first (last-write-wins; a row that read does not find is ClientError 404 NOT_FOUND, never called); a function sends If-Match: * on a set with a version token
extraOData v2 only: parameters the import does not declare, sent untyped. Set them in code; OData v4 refuses them (UNKNOWN_PARAMETER)

It answers { value, message?, messages?, details? }, value what the operation returned. The handle alone types the call: params is required when the operation has a required parameter, row when it is called on rows (and refused otherwise), and value is its result. A mistake is one compile error: Property 'Material' is missing in type '{}' but required in type 'GetPriceParams'. The third argument takes signal and locale: the locale goes out as Accept-Language, so the service's messages come in it, as the clients send Atscript UI's (see Locale).

An operation the build does not know (only the live service has it) is called by name, untyped, with odata.callByName(name, input?):

ts
await odata.callByName("Z_RECALC", { params: { Plant: "1000" } }); // the factory's only service
await odata.callByName("ZSALES.release", { entitySet: "Orders", row, params }); // a v4 bound one: its qualified name
await odata.callByName({ service: "sales", operation: "Z_RECALC" }, { params }); // with several services

call() takes handles only: a name passed to it (from a template or JavaScript) is refused with an error pointing to callByName(). See Type Safety for what the handles check on each host.

Unbound operations have no UI in the browser either. A page in front of a Moost server calls its operations base through operationsClient of @atscript/moost-odata/client, typed by the same handles: see From a Moost page.

See it live

Bestsellers on the Overview is an unbound function, odata.call(ops.bestsellers, …); Receive beans… in a coffee's row menu on Coffees is an unbound action, odata.call(ops.receiveBeans, …) from a dialog typed by its parameters. Both in the browser app. Code: OverviewScreen.vue and src/routes.ts.

When the service changes, in the browser ​

No verdict, no hiding, no diff: the browser runs on the live service as it is.

The live serviceIn the browser
Has an operation the build does not knowListed and callable: its action, form and availability come from the live $metadata; untyped
Changed one (parameters, label, availability)Follows the live service
Dropped oneNot listed; a typed handle of it fails when called: ClientError 400, UNKNOWN_OPERATION on the entry

What differs from the Moost server ​

CaseMoost serverBrowser
A row the availability path says no toSkipped; none left 409Called: the service decides
An id that does not exist404; on an action with an availability gate 409 (the row counts as unavailable)404 where the tokens or the ETag are read, or the service answers 404; else the service's answer
More than 50 ids400Not checked; past batch.maxParts several $batch requests
The grouping of several rowsThe build's, or the override'sThe live operation's; on OData v2 almost always isolated
All matching rows (queryTarget)On every generated action on rowsNot offered (actionOnQuery rejects)
An operation dropped or changed live404 or 500, hidden from /metaFollows the live service (table above)
An operation only the live service hasNot served until a rebuildListed and callable
The labelThe build's; relabel in the subclassThe live type's @meta.label

Everything else answers alike on both hosts: the actions and their forms, a row action, a stale token, several rows (the summary, every row failed, a refused changeset), invalid parameters, the service's failures (see Operations in Errors).

See it live

On Orders in the Moost server app, select every loaded row: the table offers all orders the filter matches. Code: ListScreen.vue.

Limitations ​

  • At most 50 rows per call. Under isolated a failed row leaves the others applied; the run answers its summary, which Atscript UI does not show yet (your @action handler does).
  • No value help on parameters, no confirmation text (Common.IsActionCritical), no draft operations. No confirmation before the skipped rows of a run, as Fiori Elements asks.
  • A set whose reads must filter on a property outside its key (sap:required-in-filter, Capabilities.FilterRestrictions.RequiredProperties) cannot have its rows read by key: its actions take the ids without a row load, get no availability gate, and read the ETag right before the call.
  • An availability path no row can be checked by (one of a v2 import on the table, one that names no Boolean) is listed in the generation result and not gated.
  • Labels are those of the saved $metadata, and few OData v2 imports carry one: the others show their name. Relabel in an override.
  • A set base extends one OData base, so the operations do not combine with an Aooth ARBAC controller class.
  • SAP Gateway on OData v2 refuses a changeset of more than one operation unless the service's DPC redefines CHANGESET_BEGIN, so a v2 changeSet grouping (an override) can be refused as a whole there: nothing is applied, and the answer is that refusal.
  • Browser: a live-only operation is untyped, and code that calls one the live service dropped fails at runtime. No query targets (actionOnQuery). Several rows go out by the live metadata's grouping, which on OData v2 almost never states one: isolated, Fiori's default, applies, and nothing in the browser sets another.

DOs and DON'Ts ​

  • Extend the generated bases — never edit *.controllers.gen.ts, and never write @DbAction for a generated operation from scratch.
  • Mark the operations controller @Inherit() beside @Controller(path) — without it no route is bound.
  • Register the space under the service's name with provideDbSpace — the operations base finds it there.
  • Guard the leaves — the inherited routes have no guard of their own.
  • Call await super.prepareRequest(ctx) first in an override of prepareRequest — the build's check runs there.
  • Set extra in an override — never from the request body.
  • Call an operation of the build by its handle (odata.call(ops.GetPrice, …), salesOps.call(ops.GetPrice, …)) — callByName is for one only the live service has.
  • Name only the sets you want written in controllers.writable — every other base is read-only.
  • Pass odata.call the row as read, with its __etag — a bare key makes the call last-write-wins.
  • Regroup an action that must be all or none (changeSet) in an override on OData v2 — its metadata states no grouping, so its rows run isolated.
  • Read failed of a run's summary — under isolated a 201 can carry failed rows.

See also ​

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.