Professional Documents
Culture Documents
1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1 About this Document. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Target Audience. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Before an end user can track and trace with the global track and trace option for SAP Logistics Business
Network, a GTT metadata model must be created to define the metadata of tracked processes or objects. This
can be done in the Metadata Modeling app (MM app), a plugin of SAP Web IDE, also known as the Global Track
and Trace plugin for SAP Web IDE.
You can use the MM app to create GTT metadata models and save them either in the temporary workspace or
in a GIT repository they define. After finishing the metadata definition, you deploy and activate the model in the
runtime repository. This is a microservice on the target runtime environment and provides data access APIs to
other components or microservices.
Each GTT metadata model is in a specific GTT project associated with a specific namespace. One namespace
belongs to one specific user and may have multiple versions. GTT models are defined in the format of CDS
Definition Language.
Recommendation
Before you start working through this document, ensure that you have the most recent version of this
document that is available from the SAP Help Portal at:
help.sap.com/gtt
This document guides you through creating and deploying user-defined GTT metadata models. It also details
the structure of GTT metadata and includes a CDS modeling language guide for your reference. The upgrade
guide at the end provides instructions and tips for upgrading existing GTT models to a new version.
Role Activity
Modeling Expert or Solution Administrator Create, maintain, deploy, and activate GTT metadata mod
els.
The MM app provides you with an easy-to-use development interface to model tracked processes or objects.
The tasks are as follows:
2.1 Prerequisites
Ensure that you have selected the Global Track and Trace plugin on the Features page. This is a one-time
activity.
Note
If you cannot log on to SAP Web IDE for Full-Stack Development application, ask your onboarding assistant
or system administrator for help. For details, see Troubleshooting [page 16].
You must create a GTT model in either simple mode or standard mode, the default.
Recommendation
Simple mode is useful for getting started and for initial testing.
The major differences between the two modes are explained in the following table:
Simplifies modeling by defining your metadata model with Defines your metadata model in detail with full model and UI
model information and basic UI layout information layout information
Does not support some functionality, for example it only Supports full functionality and is always where new function
supports showing a map view on a process’ details page ality is introduced
Note
You can convert a model from simple to standard mode, but it is complicated and must be done manually.
● application model and the differences between simple and standard modes, see: Overall Structure [page
42]
● model files and the differences between simple and standard modes, see: Application Model Details [page
112]
Context
Procedure
1. Choose File New Project from Template . The Template Selection page appears.
2. In the Category list, choose Global Track and Trace and then choose Next.
3. Type a Project Name for your GTT project.
4. Choose Next. The Project Customization page appears.
5. Choose Standard or Simple mode.
6. Type Namespace and Version. You can add .<your_input> after the default namespace to make it
unique.
Note
Here a template means a sample implementation pre-defined in a group of sample files. You can also
choose None if you want to model a tracked process or object without using a template. In that case,
you can also specify a dependency metadata model in the Dependency box. Then your new metadata
model can use the entities and attributes defined in the dependency metadata model.
The EPCIS Model option is automatically disabled if you choose a template that uses a non-EPCIS
model. The option is automatically enabled if you choose the EPCIS template for object tracking. It is
only selectable when you choose None for Template.
Results
A GTT project is created. Below shows an example of a standard mode project with a delivery template.
Context
GTT project settings are the information gathered from the project customization step when the project was
created. These settings can be changed.
1. Choose Development ( ) in the left-hand pane and navigate to the Workspace folder.
2. Select the folder for your GTT project.
3. In the context menu of the folder, choose Project Project Settings . The project settings pane
appears.
4. In the project settings pane, choose Global Track and Trace.
5. Modify your GTT project settings information on the right-hand pane.
6. Choose Save .
GTT metadata models include tracked processes or objects. You can define models using the CDS Definition
Language.
Working in a GTT project of simple or standard mode, you can model a tracked process or object in CDS
format.
Note
For information on the structure of GTT metadata and the CDS modeling language, see the "Structure of
Track and Trace Metadata" and "Modeling Language Guide" sections in this document.
Procedure
1. Choose Development ( ) in the left pane and navigate to the Workspace folder.
2. Under Workspace your project model , do one of the following:
○ If your GTT project is created with the Delivery, Shipment, Purchase Order or EPCIS template, open the
DeliveryModel.cds, ShipmentModel.cds, PurchaseOrderModel.cds or EPCISModel.cds file and modify
the template.
○ If your GTT project is created without a template, open the <project_name>Model.cds file and model
the tracked process or object in the editor in CDS format.
It is recommended that you do not change the file name of <project_name>Model.cds. If you do want
to change the file name, you can only change the <project_name> part, not the Model.cds part,
otherwise the deployment of the model fails.
Related Information
Working in a standard-mode GTT project, you can set up services and UI annotations for tracking processes or
objects.
Note
For details on how to define services or UI annotations in CDS Definition Language, see the "Modeling
Language Guide" section in this document.
Procedure
1. Choose Development ( ) in the left pane and navigate to the Workspace folder.
2. To set up services, for example, configure the fields to be exposed for display in the GTT app, do the
following:
1. Under Workspace your project service , open the <project_name>Service.cds file.
2. Modify the file in the editor in CDS format.
Note
It is recommended that you do not change the file name of <project_name>Service.cds. If you do
want to change the file name, you can only change the <project_name> part, not the Service.cds
part, otherwise the deployment of the model fails.
Note
It is recommended that you do not change the file name of <project_name>UI.cds. If you do want
to change the file name, you can only change the <project_name> part, not the UI.cds part,
otherwise the deployment of the model fails.
Related Information
The global track and trace option for SAP Logistics Business Network has a user interface that supports 7
languages: English (default), German, Simplified Chinese, Spanish, Brazilian Portuguese, French and Russian,
according to the language setting in the user's web browser.
Some UI text displayed in the GTT and GMM apps comes from related items defined in a GTT metadata model.
For example, process name and description displayed in these apps are read from the corresponding settings
in the GTT Model. Field names and table column headings are copied from related UI annotations. If you want
such texts to display in a language other than English in the apps, you need to modify your GTT model at design
time to support that language.
Note
You cannot support a language other than the languages mentioned above.
The MM app uses internationalization files (i18n files) to realize multi-language support for GTT models.
i18n_de.properties German
i18n_es.properties Spanish
i18n_fr.properties French
i18n_ru.properties Russian
Note
The global track and trace option for SAP Logistics Business Network only supports the above languages. If
you add an i18n file for another language, it won't be supported.
All the i18n files contain key/value sets. As explained in the following, the default values are already translated
in the i18n files of the supported languages. If you wish to provide your own UI text for any of the supported
languages, you may overwrite the values for that language in the specific i18n file for that language.
Note
You must never change the keys. They must remain in English.
● Process name. The value is read from your setting in the project-creation wizard. For example:
com.sap.gtt.core.Process_Name=Outbound Delivery
If you use the default process name suggested by the project-creation wizard, the value is in English in the
default i18n file, and already translated into the appropriate languages in the other i18n files.
If you have changed the default process name during project creation, the value is in English in all language
versions of the i18 files. You need to manually translate the value in the non-English i18n files. For example,
in i18n_de.properties, change the value to German.
● Process description. The value is read from your setting in the project-creation wizard. For example:
If you use the default process description suggested by the project-creation wizard, the value is in English
in the default i18n file, and already translated into specific languages in the other i18n files.
If you have changed the default process description during project creation, the value is in English in all
language versions of the i18 files. You need to manually translate the value in the non-English i18n files. For
example, in i18n_de.properties, change the value to German.
● All the UI annotations are predefined in the template model that your GTT project uses.
To support multiple languages, a template model includes UI annotations as i18n keys instead of exact
values. The exact values are maintained in i18n files. In each i18n file, the values are already in the specific
language that the i18n file supports. You do not need to manually maintain them.
entity ShippingStatus {
key Code: String(10) @title:'{@i18n>Status_Code}' @Common:{ Text:Text,
TextArrangement:#TextOnly };
Text : String(50) @title:'{@i18n>Status_Name}';
};
Then the default i18n file includes the following key/value sets.
Status_Code=Status Code
Status_Name=Status Name
In a non-English i18n file, the values are in the specific language that the file supports.
Thus, when these 2 UI annotations are displayed as field labels in the GTT app, the values are displayed in a
supported language if the browser language is set to that language.
Sometimes you want to add UI annotations to your GTT model apart from the predefined ones in the
template model. In that case, you need to add the annotations as i18n keys and then add the key/value sets
to the i18n files.
If you didn't choose any template when creating your GTT project, the i18n files do not contain any UI
annotation key/value sets. To support multiple languages, you need to define UI annotations using i18n
keys in your GTT model, and then add related key/value sets to the i18n files.
Context
Some items defined in a GTT metadata model, such as process name, description, and UI annotations, are
displayed as user interface text in apps like GTT and GMM.
If you want such text to display in a language other than English in the apps, you need to modify your model in
the MM app.
Procedure
1. Choose Development ( ) in the left pane and navigate to the Workspace folder.
In your workspace, your GTT project folder includes a model folder that contains one or more model files
and an i18n folder that contains five i18n files.
2. Modify your model as follows:
○ If you have set a process name or description other than the default during project creation, translate
the value for com.sap.gtt.core.Process_Name or com.sap.gtt.core.Process_Description,
respectively, in the non-English i18n files for the languages that you want to support. You don't need to
update the default i18n.properties file.
Then add the key and its value to both the default English-version i18n file and the non-English i18n
files for the languages that you want to support. The following is the example in the English-version
i18n file:
Plant_Num=Plant Number
○ If you didn't use any template model for your GTT project, add your UI annotations as i18n keys in the
format of {@i18n><key_name>, where <key_name> must start with a letter and only contains letters,
digits, and underscores. Then add these keys and their values to both the default English-version i18n
file and the non-English i18n files for the languages that you want to support.
○ If you used the default process name and description during project creation, and don't want to add
any UI annotations to your GTT model, do nothing.
Results
When you track and trace processes or objects based on the deployed GTT model, the process name, process
description, and related UI labels are displayed in a supported language according to the language setting of
your web browser.
Context
Some items defined in a GTT metadata model, such as process name, description, and UI annotations, are
displayed as user interface text in apps like GTT and GMM.
If you want such text to display in a language other than English in the apps, but your GTT project was created
prior to the 2018.09a delivery, you need to modify and redeploy your model in the MM app.
Procedure
1. Choose Development ( ) in the left pane and navigate to the Workspace folder.
2. Select the folder for your GTT project.
After the enablement, the UI annotations in your model file were changed from using exact values to using
i18n keys in the format of {@i18n><key_name>.
Meanwhile, a new folder, i18n, appears in your project folder with a default English-version
i18n.properties file in it. The file contains the key/value sets for the process name and description you
have set, and the i18n key names for all the UI annotations included in your GTT model.
5. In the context menu of the i18n folder, choose New File to create non-English i18n files for the
languages that you want to support.
i18n_de.properties German
i18n_es.properties Spanish
i18n_fr.properties French
i18n_ru.properties Russian
Note
The global track and trace option for SAP Logistics Business Network only supports English and the
above languages. If you add an i18n file for another language, it won't be supported.
6. In each non-English i18n file, copy and paste all the key/value sets from the default i18n.properties file,
translate the values to the specific language that the file supports, and then save the file.
7. Re-deploy the GTT project.
Results
The modified model now supports multiple languages. When you track and trace processes or objects based
on the model, the process name, process description, and related UI labels are displayed in a supported
language according to the language setting of your web browser.
Context
After the modeling, you can deploy your GTT model to the runtime repository.
Procedure
1. Choose Development ( ) in the left pane and navigate to the Workspace folder.
2. Select the folder for your GTT project.
3. In the context menu of the folder, choose Deploy Activate GTT Model .
This starts the model deployment process. Messages pop up in the upper-right corner of the window,
showing the step-by-step deployment progress. You can also choose (Console) on the right edge of the
window to open the Console to view the messages. When the deployment completes, the status of the
deployed model becomes Active.
Note
If you only want to compile your metadata model and may deploy it at a later time, choose Deploy
Compile GTT Model .
You can also preview a compiled or deployed metadata model by choosing Deploy Preview GTT
Model . The preview shows mock data only, not the real data.
Note
If you cannot compile or deploy your GTT model, refer to Troubleshooting [page 16].
After a GTT metadata model is deployed to the runtime repository, you can make limited changes to the model
and deploy it again.
The following lists the changes that are allowed and forbidden for a deployed metadata model.
The following changes are allowed for a deployed metadata model. Making these changes does not require the
creation of a new version of the namespace. Allowed changes do not lead to any data conversion.
● Adding fields
Adding fields to an entity is allowed if there is a canonic default value for all instances not being created
with this field. For integer such a value would be 0, for associations NULL, and for strings the empty string.
● Increasing length and precision
Increasing the length of a string and the precision of a decimal are allowed because the original type is not
changed.
● Changing UI annotations
UI changes are allowed because UI is rendered during the runtime following the Fiori Elements approach.
● Changing enum values
Similar to UI annotations, enum defines a set of possible values with symbolic names. Changing enum
values does not lead to any data conversion.
Forbidden Changes
All changes that are not included in the Allowed Changes list above are forbidden for a deployed metadata
model. Such changes may lead to data loss or inconsistencies.
2.9 Troubleshooting
● Issue: I tried to log on to SAP Web IDE Full-Stack Development, but got an error message "You are not
authorized to access SAP Web IDE from this account."
Workaround: Ask your onboarding administrator or system administrator to grant you the required
authorization. To use the Global Track and Trace plugin for SAP Web IDE, you need either the Solution
Administrator or the Modeling Expert role in GTT solution.
● Issue: When compiling a GTT model in SAP Web IDE Full-Stack Development, I got an error message
"Insufficient scope for this resource."
The global track and trace option for SAP Logistics Business Network tracks processes or objects that are
influenced by business events. All tracked processes, objects, and business events have a common core
behavior and share a common set of basic attributes.
Therefore, the overall GTT solution consists of a generic track and trace core engine and applications
leveraging the core engine, as follows:
● The core engine provides generic functionality to track processes or objects, to handle business events and
provides the modeling environment described in this document.
● GTT applications enrich the generic functionality by adding domain specific semantics in terms of data,
behavior, and user experience using SAP Web IDE.
Both the core engine’s data model and the application’s data model are described by metadata as a classical
entity relationship model with various enhancements like annotations and extension concepts.
Track and trace applications deal with the following central objects and terms:
● Tracked Process
A tracked process comprises the following:
○ Involved parties acting in or being affected by the process;
○ Multiple tracked objects;
○ A set of planned events that are expected to happen within the tracked process. The planned events
are also named as milestones.
Note
“Milestones” is the term used in SAP ERP applications like SAP Event Management.
○ A set of events that actually happened against the process. This could be a realization of a planned
event or also an unplanned event
● Events
Events can be planned events or unplanned events that might occur against a process. When an event
happens, an actual event needs to be matched against a planned event of that process or get an unplanned
event in case no suitable planned event can be identified. Otherwise if no suitable planned event can be
identified it becomes an unplanned event.
○ Planned Event
○ Has a fixed semantic.
○ Has a planned date and time (with time zone) + tolerance window, planned location, and other
planned data.
3.2 Example
To illustrate the structure of metadata and modeling language, an outbound delivery process is provided as an
example.
An outbound delivery process within a business network comprises at least three involved parties: A supplier
as sender, a carrier and a customer as receivers of the delivery. The customer orders goods from the supplier.
The supplier starts a delivery process and hands over the goods to the carrier. The carrier delivers the goods to
the customer and the customer confirms the completed delivery.
The example includes one process and at least the following three events:
● Picking completed
● Goods issued
● Proof of delivery
These events describe the planned process flow and therefore are called planned events, but there might be
unplanned events that we may foresee in the delivery process tracking. For example, the truck of the carrier
has an accident which leads to loss of goods. The supplier has to react to that and send the goods again as the
customer requires it. Financial compensation for damaged goods and the delay is another process.
The core engine knows these central terms and objects from a generic perspective. In terms of an entity
relationship model the core engine provides entities for generic abstract tracked processes and generic events.
These generic entities contain data that is common to all applications and used within the core engine. The
core engine does not provide any definition of event messages, as the message is only the carrier for the event
itself, hence the message content is derived from the event that is reported.
Generic Event
The core engine offers generic functionality, such as overdue event monitoring and unplanned events alerting,
by leveraging these generic set of attributes.
Application Enhancements
Track and trace applications enhance the generic parts with their domain specifics. This could be any simple
attributes, structures or even additional entities in the sense of ERM (Entity-Relationship Modeling). This
enhancement can be considered as an “is a” relationship between the application specific process/event and
the generic process/event.
In our outbound delivery example, a delivery process is a tracked process, whereas the tracked process can be
a delivery.
Customer Enhancements
Sometimes pre-configured applications delivered by SAP do not cover all requirements from customers. Hence
customers need possibility to enhance the delivered applications. The entity relationship model allows multiple
levels of extension to fulfill customer requirement.
The following figure shows the structure of the entity relationship model in UML notification.
As described in previous topics, tracked processes and events are entities in terms of ERM (Entity-Relationship
Modeling). Entities are described by annotations and properties: Properties model the content of events and
tracked processes, whereas annotations describe use case specific static behavior like UI texts. Both are either
scalar values, complex structures or (deep) table types. The latter would be a separate weak entity in classical
ERM. A GTT metadata model describes how tracked processes and events are being modeled so that the core
engine and applications can leverage the definitions.
The following figure shows the GTT metadata model and its relation to the ERM model.
The language used for GTT metadata modeling is the CDS Definition Language (CDL). It is based on the Core
Data Services (CDS) concept and format. CDS follows the principles of entity relationship models with
annotations and can easily be interpreted by compilers and thus transferred in other formats following ERM
principles, such as the metadata document describing OData services.
Before describing the usage of CDS for the global track and trace option for SAP Logistics Business Network,
we briefly give a general overview of CDS and describe those portions of CDS that are currently used for the
track and trace solutions.
Data models represented in CDS Definition Language (CDL) are written in a more or less human readable
language, compiled and transferred into other machine readable formats like JSON or XML. This makes CDS
an optimal format to share and interpret models with minimal footprint and dependencies, independent of
source or target environments.
This section outlines the key building blocks of a conceptual reference architecture for CDS implementations
as well as the key design principles of CDS.
The following figure shows the key building blocks for CDS implementations.
The compiler accepts metadata model definitions in source format (i.e. CDL) and processes them in these
(logical) steps:
Compile The compiler frontend compiles sour persist them, share/import them to
ces into an internal format. This internal other systems, or process them in 'diy'
format can be represented in CDM mode.
(Common Data Model).
Import The definitions from compiled models browse and introspect definitions, re
are written to the catalog, containing solve annotations, add extensions, etc.
annotations to the annotation service.
Activate The compiler backend generates run run queries to read/write data using the
time artifacts for the given definitions, usual CRUD operations.
i.e. SQL tables and views.
Implementations are not required to offer these steps individually. If they do, this allows you to deal with
models transiently, for example, to dynamically create local temporary models at runtime.
Catalog
The catalog stores compiled models, i.e. the defined types and entities as well as extensions thereof. Note that
extensions are not applied by the catalog. They are just stored as is.
Introspection APIs – Each CDS implementation is expected to provide a REST-based introspection API that
allows you to browse models, filtered by certain metadata, and return complete model excerpts in CDM
(Common Data Model) format. In addition, implementations may offer other forms to introspect models, for
example, through the like of SQL catalog views.
Model Import APIs – CDS implementations should provide a REST-based API to import models in CDM
format. This allows you to easily share models between CDS implementations in different stacks within
heterogeneous landscapes. As opposed to the source/compiler-based way to add models, only essential
checks are required.
Runtime
The runtime executes queries based on activated models, i.e. generated runtime artifacts. In case of the
standard implementations, these are SQL tables and views. Upon generation, potential extensions are applied
to the base definitions' runtime artifacts.
Given the standard SQL persistence, CDS needs only a minimal runtime on top of SQL, if any at all. For
example, queries can be pre-compiled and no additional runtime is required.
Annotations are not a core feature of CDS and should be managed separately from the types and entities in the
catalog. On one hand, this is because activation through the catalog/SQL is likely an expensive operation as
compared with adding annotations which are not evaluated at all. On the other hand, annotations are
independent from the actual data models (and vice versa). A separate annotation service can allow you to
annotate anything which can be identified by unique names.
CDS does not abstract from the underlying database features or “shield” developers from SQL, which is in
contrast to most persistence frameworks, especially object-relational mappers. We do want developers to use
SQL and hence leverage its strengths instead of seeking refuge in abstractions. This applies to models as well
as runtime.
The canonic mapping to SQL is part of the specification and applies common practices: Generated tables/
views are as close as possible to how one would have done it manually.
Everything being defined through CDS can always be consumed through native SQL! (i.e. including any vendor-
specific extensions)
CDS does not introduce a data access layer, neither with respect to how queries are expressed, nor to how
results are represented. Queries are expressed in SQL, to which CDS adds only careful extensions, which can
be unfolded to plain SQL in pre-compilers and/or implemented natively in SQL engines.
3. Zero Lock-in
CDS does not assume a certain environment or depend on any platform technology or programming language.
You can use it with the technology stacks you choose. We thereby want to promote interoperability and reduce
fragmentation in landscapes with increasingly heterogeneous technology stacks.
CDS does not impose a programming model or force you into an all-or-nothing game. Its features are largely
independent from each other and can be used individually and easily be combined with other technologies. For
example, you can import CDS data models into a JPA-based application, while not using CDS QL/SQL,
annotations or the other features at all.
CDS does not invent anything new or enforce new paradigms. It is primarily based on and borrows from proven
standards and methods like SQL and entity-relationship modeling. The interesting thing is that this even more
allows CDS to be combined with technologies that do invent new paradigms, definitely more than if CDS came
with its own.
The CDS Definition Language allows you to define conceptual data models in the form of Entity-Relationship
Models.
entity Orders {
key ID : Integer;
product : Association to Products;
price : Amount;
tax : Decimal(2,2);
total = price.value * (1+tax);
}
type Amount {
value : Decimal(10,3);
currency : Currency;
}
entity Currencies {
key code : String(3);
name : String(44);
}
type Currency : Association to Currencies;
entity Products as SELECT from Material mixin {
campaign : Association to Campaigns on category = campaign.pcat
} into {
*, unitPrice * (1 - campaign.discount) as price
}
Overview
We use a derivate of Extended Backus–Naur form (EBNF) for syntax definitions (see Syntax Notation for more
information).
Entities are structured types with named and typed elements. The type of elements can in turn be the
following:
In total, these concepts constitute the CDS Type System as depicted below:
Each top-level definition is globally identified by a unique absolute name. To avoid always typing fully-qualified
names, the following can be used:
For example:
context foo.bar; //> like context foo.bar {...} for all below
using some.other.context as soc;
using some.other.Entity as soe;
entity Foo { ... } //> foo.bar.Foo { ... }
type Zoo : soc.Zoe; //> foo.bar.Zoo : some.other.context.Zoe
context sue {
entity Car as //> foo.bar.sue.Car as
SELECT from soe; //> SELECT from some.other.Entity
}
Name Resolution
(Relative) names are always looked up in the inner-most lexical {...} scope first and then up to the file scope,
but not beyond. This combined with the restriction, that using does not support a using x.y.* mode,
guarantees, that bindings are not accidentally impacted through 'remote' changes/additions in other modules.
Some examples:
context foo;
type Foo : String;
type Boo : Integer;
context bar {
type X : Foo; //> resolves to foo.bar.Foo (below)
type Y : :Foo; //> resolves to foo.Foo (above)
type Z : Boo; //> resolves to foo.Boo (above)
entity Foo { ... }
}
The colon-prefix in :Foo is an operator that forces name resolution to start in the next outer scope.
Definitions
Definitions are expressed through statements like define entity Foo <details>, in which the leading keyword
define is the default and can be omitted.
The specified name is relative in the current context and can itself be qualified, for example:
context foo.bar;
context boo {
entity full.Moon {...} //> foo.bar.boo.full.Moon
}
Expressions
In general, CDL inherits expressions from SQL of underlying databases. That is, depending on the occurrence,
you can use all functions and operators your database supports.
In addition, all implementations of CDS are expected to support the following operators (in order from highest
to lowest precedence):
NOT
||
* /
+ -
< <= > >=
= == != <> IS IS NOT IN LIKE
AND
OR
Lexical Conventions
CDS is case-insensitive re keywords and (unquoted) identifiers, i.e. FOO, Foo and foo would all refer to the same
thing.
Literals
Punctuation
The following elementary symbols in CDL are used as in, for example, JavaScript:
● Curly braces { ... } enclose record-like structures, for example, an entity’s elements.
● Round parenthesis ( ... ) enclose lists of parameters/arguments.
● Square brackets [ ... ] are used for array literals.
● Colons : precede type specifications, such as in element definitions.
● Semicolons ; delimit definitions.
Colons before and semicolons after {...} blocks are optional. Moreover, colons directly before the = in
calculated fields are optional.
Syntax Notation
● The native SQL types of your underlying database (for example, varchar, ...)
● The CDS built-in types listed below
Constructor Description
Date Local date with values ranging from Jan 1, 0001 through Dec
31, 9999
Time Time values with second precision and values ranging from
00:00 to 23:59:59
DateTime UTC date and time with seconds precision and values rang
ing from Jan 1, 0001 00:00:01 through Dec 31, 9999
23:59:59
Timestamp UTC date and time with micro seconds precision and values
ranging from January 1, 0001 00:00:00 through December
31, 9999 23:59:59.9999999
Entities are the primary subjects of your metadata model, representing queryable sets of data.
Examples:
context cds.xmples;
type Currency : Association to Currencies;
entity Payslip {
key ID : Integer;
employee : Association to Employees;
netAmount : {
The following is the relevant excerpt from the Definition Language syntax:
All entities have a signature of a structured type with named and typed elements. They can be defined as
follows:
One or more elements can be qualified with key to specify an entity's primary key.
Entities—and structured types in general—contain zero or more element definitions enclosed in {...}. Each of
which can start with the prepended keyword element, but that is optional.
Type Declarations
Most frequently an element’s type is derived from one of the built-in types or from a custom-defined one.
Some of the built-in types accept parameters. Examples are:
entity Foo {
name : String(44);
netAmount : Amount; //> referring to custom-defined type Amount (a struct)
taxrate : Decimal(3,2);
}
entity Foo {
netAmount { value: Decimal; currency: Association to Currencies; }
}
Finally you can use the type of operator to infer the type from another element’s type:
entity Foo {
grossAmount : type of netAmount;
}
Note
The type names after type of are resolved from the inner most {...} scope. Use a : prefix, in case a
name in that scope shadows the definition in an outer scope you want to refer to. For more information, see
Name Resolution in the CDS Definition Language (CDL) topic.
Virtual/Calculated Elements
Virtual elements have no data stored in the database but are always calculated at runtime, that is query
execution time. They are read-only in a sense that no other values can be written to them.
entity Foo {
virtual pure : Integer; // to be filled by application logic on top
virtual calc : Date = now(); // filled by SQL queries (not persisted)
}
Pure virtual elements are marked with the virtual modifier but do not have a calculation expression specified.
They are used to declare elements that have values to be calculated by application logic on top of SQL/CDS. On
database level, they do not exist at all and are never returned in result sets of queries. The reason to still declare
them in models is to provide hooks for annotations, for example, for use in generic clients.
Calculated elements have a calculation expression specified through = expr, which is evaluated by the query
runtime in SQL/CDS. They may optionally be marked with the virtual modifier, which does not have any
additional effect, though. The calculation expressions can be applied to scalar elements as well as to structs as
shown in this example:
Type Inference – Explicit type declarations may be omitted for calculated fields, if, and only if, a type –
including relevant details, e.g. dimension of a string, precision/scale of a decimal – can unambiguously be
inferred from a given expression. Note that this is not possible for string types used in entity definitions as the
maximum length parameter for the string would not be possible to infer through expressions.
Constants
Constants are similar to calculated elements but with a guaranteed constant value. They can be defined using
the same syntax as for calculated fields prepended with the modifier const. For example:
Constants are essentially just named symbols for literals, which can be used by name wherever a literal value
can show up in CDL. They do not show up in persistence or in runtime structures. They are merely symbols
used by the compiler; no value can be assigned at runtime. The expressions must be resolvable to a literal value
at compile time.
Enumerated Values
Enumerated values are defined using key word enum followed by a list of values. For example:
Default Values
The default expr clause is a 1:1 pass-through of the same clause in standard SQL.
Corresponding default values are inserted if no other value is specified upon inserting a new row. Most often
single literals are specified, but the expression can also contain function calls and/or references to other
elements within the same entity.
Views = Projections
Views are entities defined as projections on other entities – basically the equivalent of SQL views, and as those
using SQL SELECT statements, including CDS QL enhancements. From a consumer’s perspective a view’s
signature is indistinguishable from an entity’s signature.
Example:
As in to SQL you can use view instead of entity – both are equivalent.
Inferred Signatures – Views are entities, with their signature usually inferred from the given projection. The
inferred signature of the example above would resolve to that equivalent:
entity EmployeesView {
id: Integer; name: String; salary: Amount;
manager : Association to Employees; //> from orgunit.manager
orgunit : String; //> from orgunit.name as orgunit
}
Explicit Signatures – If required, you can explicitly specify the (expected) signature. In that case, the inferred
signature is checked against the expected one, and an activation error is thrown if they would not match. For
example:
entity EmployeesView {
id: Integer; name: String; salary: Amount; //> expected signature
} as SELECT from Employees {
id, name, salary //> inferred signature
}
Key Elements, etc. – Within the projection clause of view definitions you can prepend element clauses with the
element modifiers key, virtual and/or masked. For example:
In contrast to entities, keys in views do not imply any uniqueness constraint. When defining a view,
potentially required key elements must always be marked explicitly in the view; they are never implicitly
derived from the underlying entities.
Primary Keys
In general, each entity must specify a primary key, that is, an attribute combination that uniquely identifies
instances. The order of appearance of key elements within an entity definition determines the order of the
primary key attributes.
entity Address {
key streetAddress : String(77);
key zipCode : String(11);
city : String(44);
}
If a struct-typed element is denoted as key, all database columns representing the nested fields of this
structure are part of the primary key.
Reuse Types
You can define global, named types for reuse as in this example:
context cds.xmples;
type Currency : Association to Currencies;
type Amount : {
value : Decimal;
currency : Currency;
}
entity Payslip {
...
netAmount : Amount;
}
The same options are available as described above for element types, except for the element modifiers.
In CDS-based models, we add associations by adding an element to a source entity with an Association type
that points to a target entity. The most basic form expects a fully specified join condition. We call this form
unmanaged associations.
Examples:
Syntax:
Association =
| Association to [one|many] target [joinspec]
| Association [cardinality] to target [joinspec]
cardinality = [ [ maxs, ][ min .. ][ max ] ]
joinspec = on <expr>
target = QualifiedName -- expected to resolve to an entity
Analysis:
As explained above, associations are elements with an Association type. Hence, Association is not a
keyword but the name of a built-in type, similar to String or Decimal. And as with those, it accepts the
following parameters in SQL-like parameter clauses style:
4.1.3.4 Compositions
entity SalesOrders {
description: varchar(111);
Items : Composition of many {
product : Association to Products;
quantity : Integer;
}
}
Syntax:
Association +=
| Composition [ cardinality ] of (target)
| Composition of [ one|many ] (target)
Analysis:
The Composition of syntax is a convenient shortcut for defining individual entities with involved
associations. The example above would be expanded to:
entity SalesOrders {
description: varchar(111);
Items : Composition of many SalesOrders.Items on Items.parent=$self;
}
entity SalesOrders.Items {
parent : Association to SalesOrders;
product : Association to Products;
quantity : Integer;
}
The anonymous type in the nested definition is expanded to a type with the qualified name <name of
parent entity>.<name of composition element>. Alternatively, the non nested option can be used as
in the expanded version above. In that case, the alternative keywords merely result in the association being
flagged as a composition association in the model’s metadata.
Associations to self
The pseudo variable $self refers to the current entity and can be used wherever an association to the own
entity (current instance) is required. For example, $self is frequently used to define one-to-many
associations:
Think of $self as an implicitly defined self-join association for each entity as follows:
Redirecteds define the association or composition in the service the same way as they are defined in the
models.
4.1.3.6 Annotations
Annotations allow you to augment data models with additional metadata, which can be introspected at
runtime. They are triples of the following:
In the context of CDS, targets are entities or views and elements thereof. For example:
@Some.header.property: ‘SomeValue’
entity SomeTarget {
element someElementInTarget @<Some.element.property: 4711;
}
Annotation vocabularies declare typed schemas for annotations which allow you to check annotations and
provide tool support such as hints and code completion in editors. Whether to use or mandate vocabularies
can be decided on project level. The core annotation service also allows annotations without vocabularies in
place.
Assigning Annotations
Within CDS metadata model definitions, types, entities and views as well as individual elements thereof
can be annotated as shown in the following examples.
@UI.label: ‘Customer’
entity Customer {
name : String(44) @<UI: { label: ‘Customer Name’, localized: [
{ lang: ‘de’, label: ‘Kundenname’ }
]};
...
}
@UI.label: ‘Customers’
view SalesView as SELECT from SalesOrders {
buyer.name as customer @<UI.label: ‘Customer’, ...
}
// or in a separate metadata extension:
@UI.label: ‘Customers’
Syntax:
Annotations syntax
Analysis:
Annotations can be applied to definitions within SDL documents. Possible targets are the signature of all kind
of definitions, such as types, entities and views on header level, as well as individual elements and parameters
in structured types, entity and view definitions. Two syntax options are supported: either before a target
definition each prefixed with a “@”, or in case of elements after the definition, immediately before the delimiter
– i.e. “;” in case of type and entity definitions and “,” in case of query elements in view definitions (except the
last one). Suffixed annotations start with a “@”, followed by a “<” (no space in between). For example:
@Some.annotation: 4711
entity Foo {
@Field.annotation: 'bar'
foo : String(44);
}
is equivalent to:
@Some.annotation: 4711
entity Foo {
foo : String(44) @<Field.annotation:'bar';
}
● Literals, i.e. strings, numbers, true, false, enum symbols, records and arrays
● The atoms null
● Expressions
Most frequently literal values or null are assigned statically. Assigning expressions are used to express
conditions which lead to dynamically resolved values. If no value is specified at all, true is implicitly assigned.
This is a shorthand to allow for intuitive annotations such as:
entity Foo {
foo : String(44) @<mandatory;
}
The annotation service ultimately stores only scalar values. Yet, we can assign records, which is a syntactical
shortcut for annotations with common prefixes. For example, the following three annotations are equivalent,
with the former two simply being shortcut notations for the third one:
Among others this is important to keep in mind when overriding annotations in derived types, views or
extensions. For example, the following annotation on a derived type would override the width while the label
would still remain 'Customer':
@UI.field: { width: 33 }
That is, this annotation does not override the complete record for @UI.field, as it is just a shortcut notation
for @UI.field.width: 33.
Assigning Arrays
The annotation service ultimately stores only scalar values. The assignment of record and array literals are
syntactical shortcuts for annotations with common prefixes. For example, the following three annotations are
equivalent, with the former two simply being shortcut notations for the third one:
is equivalent to:
See Introspecting Annotations for further information on obtaining annotation records and arrays at runtime.
Track and Trace leverages CDS to provide the generic tracked process or object metadata model and to allow
applications to model their own, domain specific processes, objects, and events. To do so, CDS is used in a
specific way which is described in this chapter.
The generic tracked processes and events are provided as entities with a set of common fields which are ready
to be included via extension in application specific models.
The generic metadata is provided in a set of separated CDS files that have content to be referenced within
application specific metadata definitions. In addition, some reusable data types from SAP IoT Application
Enablement are being reused and provided within the generic metadata part.
● A model definition that defines the metadata model of tracked processes and events for a particular
application
● A service definition that exposes the metadata model to be consumed by OData services
● A UI annotation file that allows usage of SAP Fiori Elements as generic UI for applications. The advantage is
that applications do not need to write their own user interfaces but can leverage proven SAP technology.
To distinguish entities and types we have to have namespaces. For the core model, the namespace is fixed and
set to com.sap.gtt.core. SAP applications use application specific namespaces below structuring
namespace com.sap.gtt.app, for example, com.sap.gtt.app.deliverysample. Custom specific
applications have to use a custom owned namespace, for example, com.<customer name>.gtt.app.
Core Model
The entity event is a generic entity without specific business semantic beside the event itself with actual data
when the event happened.
The link between tracked processes and events is the process event directory, which actually serves two
purposes. First, to store a map of planned events and second, to store actual events that either match a
planned event or become an unplanned event.
The core service exposes the necessary core entities to consumers like OData. The Core UI provides UI
annotations usable for SAP Fiori Elements to ensure consistent user experience across all applications within
the global track and trace option for SAP Logistics Business Network.
Based on the core model, an application can define its own model that consists of the following parts (a simple
mode application model only consists of the first part):
1. The metadata model itself that extends tracked processes and events with additional business domain
specific data
2. The application service that exposes the metadata model to OData consumers like UI
3. The UI annotations for SAP Fiori Elements
4. The write service that's exposed for processes and events ingestion.
Continuing the example of the delivery application, this results in the following structure:
The delivery process extends the abstract core tracked process by adding new fields for business related data.
The delivery service extends the core service and exposes the newly defined entities as required to the UI. The
UI annotation file may include the core UI definition file to re-use certain default configurations for entities from
the core model to ensure proper and common user experience across applications.
CoreModel.cds
namespace com.sap.gtt.core;
// Reuse IoT AS data types
using sap.appcore.cs.i.CoreTypes;
using sap.appcore.bp.p.BusinessPartner;
using sap.appcore.loc.p.Location;
using sap.appcore.prod.p.Product;
context CoreModel {
// Remarks for naming:
// According to API rules names have to follow field names from Global Field
Catalog
// This has to be done for all fields once a common naming is agreed on
/////////
// Annotations
// ----------------------------------------------------------------------
annotation ObjectIdentifierType : String(255) enum { // object identifier
type code as given in key mapping
// ObjectIdentifierType for Business Partner
customer = 'customer';
vendor = 'vendor';
businessPartner = 'businessPartner';
others = 'others';
// ObjectIdentifierType for Location
CoreServices.cds
namespace com.sap.gtt.core;
using com.sap.gtt.core.CoreModel;
using sap.appcore.cs.i.CoreTypes;
using sap.appcore.bp.p.BusinessPartner as bp;
using sap.appcore.loc.p.Location as loc;
using sap.appcore.prod.p.Product as prod;
context CoreServices {
@abstract context TrackedProcessService {
extend entity CoreModel.Event with {
@TimeZoneInfo.toLocalString: {
UTCTimestamp: actualBusinessTimestampUTC,
TimeZone: actualBusinessTimeZone
}
actualBusinessTimestampUTC_text : String(255)
@Common.FieldControl: #Hidden;
};
entity Event as projection on CoreModel.Event excluding {
tenant
};
entity GTTOverdueEvent as projection on CoreModel.GTTOverdueEvent
excluding {
tenant,
plannedEvent
};
entity GTTResetPlannedEventStatusEvent as projection on
CoreModel.GTTResetPlannedEventStatusEvent excluding {
tenant
};
entity HierarchyNode as projection on CoreModel.HierarchyNode;
entity ObjectReference as projection on CoreModel.ObjectReference {
*,
event : redirected to Event
};
entity GTTPersonalDataBlockingEvent as projection on
CoreModel.GTTPersonalDataBlockingEvent excluding {
tenant
};
CoreTypes.cds
namespace sap.appcore.cs.i;
context CoreTypes {
type Uuid : String(50);
type Name : String(255);
type Description : String(255); //Description, usually in
language depenant "text" tables
// business partner and location types
/*--type Geolocation : hana.ST_GEOMETRY(4326); **/
type LocationID : Uuid;
type BusinessPartnerID : Uuid;
type Boolean : Integer; // 0 = false, 1 = true
// Tenant field to be used in all transaction and master data tables
// Check table: sap.appcore.cs.p::Tenant
type Tenant : String(36);
type TenantStatus : String(1);
// ISO-2 language code to be used in all language dependent tables
// Check table: sap.appcore.cs.p::Language
type Language : String(2);
CoreAnnotations.cds
CoreWriteServices.cds
namespace com.sap.gtt.core;
using com.sap.gtt.core.CoreModel;
using sap.appcore.cs.i.CoreTypes;
using sap.appcore.bp.p.BusinessPartner as bp;
using sap.appcore.loc.p.Location as loc;
context CoreServices {
context TrackedProcessWriteService {
entity QualifiedTrackingId as projection on
CoreModel.QualifiedTrackingId {
altKey,
validFromUTC,
validToUTC
};
entity ProcessEventDirectory as projection on
CoreModel.ProcessEventDirectory {
eventType,
location,
plannedTechnicalTimestampUTC as plannedTechnicalTimestamp,
plannedBusinessTimestampUTC as plannedBusinessTimestamp
};
entity ObjectReference as projection on CoreModel.ObjectReference {
obsType,
objKey
};
entity ObserverAddDeleteByBusSysKey as projection on
CoreModel.ObserverAddDeleteByBusSysKey {
altKey,
validFromUTC,
validToUTC,
action
};
entity GTTResetPlannedEventStatusEvent as projection on
CoreModel.GTTResetPlannedEventStatusEventForWrite
actions {
@Swagger.POST
action GTTResetPlannedEventStatusEvent(@Swagger.parameter:
'requestBody' GTTResetPlannedEventStatusEvent: GTTResetPlannedEventStatusEvent)
returns String;
};
};
};
This chapter describes the scalar and complex data types and entities the core model provides.
Tracked Process
Tracked process is the heart of the global track and trace option for SAP Logistics Business Network. The
abstract TrackedProcess entity as defined in the core model provides all attributes and associations that are
necessary to track a process.
Event
Note
There are two “sender” fields: The sender of the event message and the sender in sense of an owner of the
tracking ID. For example: A carrier sends an event for a delivery of a supplier. The sender of the event is the
carrier, the sender of the ID is the supplier.
The process event directory is the link between tracked processes and events and serves two purposes:
1. List the planned events of the tracked process with plan data. Link to an actual event once the event has
happened.
From a business perspective, planned and unplanned events should be covered together in one common list.
Master data entities are those entities that are used to describe master data including business partners,
locations, and products.
Business Partner
The BusinessPartner entity describes the business partner master data with the following attributes:
The Location entity describes the location master data with the following attributes:
Product
The Product entity describes the product master data with the following attributes:
Helper entities are those entities that are not tracked processes or events, but required to be modeled as an
entity in an ERM.
Time Zone
The main use case of a TimeZone entity is a value help on the UI. This entity can be defined with the following
attributes:
Qualified Tracking ID
The tracking ID is not a simple value but consists of a quadruple of sender, logical system, ID type and the ID
itself. The QualifiedTrackingId entity is used to assign this quadruple together with a validity period to a
tracked process. The tracking ID that uniquely identifies the tracked process is the primary ID.
Often we do not distinguish between the qualified tracking ID (quadruple) and the tracking ID (scalar
value), but in most cases we mean by “tracking ID” actually the “qualified tracking ID”.
Event Status
The EventStatus entity is a helper entity to allow value help in user interfaces and assign properties to an
event status that can be used in reporting. This entity can be defined with the following attributes:
4.2.2.5 Annotations
Annotations are a powerful concept within CDS to extend a metadata model definition with additional
metadata to control behavior of consumers of the metadata model. The core model defines the following
annotations that are used by the core engine.
In principle, each CDS element can be annotated. However annotations fulfill a certain purpose and hence can
only be used for certain elements defined by annotations scope.
● customer
● vendor
● businessPartner
● others
● customerLocation
● vendorLocation
● businessPartner
● shippingPoint
● plant
location
@CoreModel.ObjectId
entifierType:
#customerLocation;
};
● inboundMessage
● userInterface
● search
● searchResult
● TrackedProcess
● BusinessPartner
● Location
Notes:
Notes:
● @DPP.DataSubjectID
can only be used on an
attribute that is an email
address.
● An attribute annotated
with
@DPP.DataSubjectID
must also be annotated
with @DPP.PII.
● If @DPP.PII@DPP.SPI
is used in a model, the
model must have one
and only one or
@DPP.DataSubjectID.
The core model service exposes the following entities and can be extended by applications. For all entities any
kind of tenant information is being excluded.
● Event
● ProcessEventDirectory
The location ID of planned location is included.
With additional action EditEvent
● QualifiedTrackingId
● BusinessPartner
● Location
● TimeZone
● EventStatus
● TrackedProcess
With additional action ReportUnplannedEvent
4.2.3 UI Annotations
To be able to use SAP Fiori Elements as generic UI to display tracked processes and events, a special set of
annotations is required to control the UI layout.
In the following we provide the subset of SAP Fiori Elements annotations that are currently supported by the
global track and trace option for SAP Logistics Business Network.
As shown in the Overall Structure section, we have annotations for the core engine and for applications
leveraging the core engine. Both are mixed together during runtime.
Related Information
4.2.3.1 UI Structure
For each tracked process type defined in applications we use overview pages and object pages of SAP Fiori
Elements. The overview page shows a list of all tracked processes with filter capabilities, and the object page
shows the details of one tracked process instance with a list of events.
To get the overview page rendered we have to use the following annotations for the tracked process type. As we
annotate in a separate file than the service definition, we use the following CDS syntax to define the UI layout.
Common
The common block defines overall behavior for the overview page and contains the following attributes:
● Common.Label
Defines the label for the overview page, for example, a natural language term for the tracked processes like
“Delivery”.
CDS Annotation Definition:
Common: {
Label: 'Delivery'
}
● Common.SemanticKey
An array of field names as defined in the annotated service that describe the semantic key of the tracked
process (for example: ‘deliveryId’).
CDS Annotation Definition:
Common: {
SemanticKey: [
deliveryId,
]
}
These fields are rendered as bold style in the list report table.
● Common. FilterExpressionRestrictions
An array of tuples has the following two fields:
○ Property
○ AllowedExpressions
Where Property denotes a field name as defined in the annotated service and AllowedExpressions defines
how a filter can be entered. The global track and trace option for SAP Logistics Business Network currently
allows only the value #SingleInterval for date type fields.
CDS Annotation Definition:
Common: {
FilterExpressionRestrictions: [
UI
The UI block defines how the overview page looks like. The following attributes are allowed:
● UI.Identification
List of field names as defined in the annotated service that uniquely identify the tracked object. Usually this
is the same list as specified for Common.SemanticKey.
CDS Annotation Definition:
UI: {
Identification: [
{Value: deliveryId}
]
}
● UI.HeaderInfo
Defines how the header of the overview page looks like. The following attributes are possible.
CDS Annotation Definition:
UI: {
HeaderInfo: {
TypeName: 'Delivery',
TypeNamePlural: 'Deliveries',
Title: {
Label: 'Outbound Delivery',
Value: deliveryId
},
Description: {
Label: 'Track Outbound Delivery',
Value: description
}
}
}
● UI.HeaderInfo.TypeName
The name of the tracked process type in singular form (for example: “Delivery””)
● UI.HeaderInfo.TypeNamePlural
The name of the tracked process type in plural form (for example: “Deliveries”)
● UI.HeaderInfo.Description
A tuple of Label and Value that defines the description of the object page for one particular tracked process
instance. The description is rendered beside the title.
● UI.SelectionFields
A list of field names as defined in the annotated service that are initially visible in the filters bar.
CDS Annotation Definition:
UI {
SelectionFields: [
deliveryId,
sender,
salesOrganization,
deliveryDate,
deliveryStatus,
shippingStatus
]
}
● UI.PresentationVariant
Defines how the result is displayed in the table. Currently the global track and trace option for SAP
Logistics Business Network only allows SortOrder, which is a list of sort criteria for the default sorting.
UI {
PresentationVariant: {
SortOrder: [
{Property: deliveryId, Descending: true},
{Property: deliveryDate, Descending: true},
]
}
}
The above example defines the initial sorting by 'deliveryId' and 'deliveryDate` properties in descending
order.
Capabilities
The capabilities section defines overall behavior of the application. It may contain the following attributes:
● Capablities.Insertable
Capablities.Updateable
Capablities.Deleteable
These properties define whether an instance can be inserted, updated or deleted from the UI. For the
global track and trace option for SAP Logistics Business Network these values must be false.
CDS Annotation Definition:
Capabilities: {
Insertable: false,
Updatable: false,
Deletable: false,
}
● Capabilities.FilterRestrictions
Defines restrictions on the filter capabilities of the overview list. Currently the global track and trace option
for SAP Logistics Business Network only allows NonFilterableProperties, which is a list of field
names as defined in the annotated service that cannot be used as filter criteria.
CDS Annotation Definition:
Capabilities: {
FilterRestrictions: {
NonFilterableProperties: [
description,
sender,
shipToParty,
soldToParty,
shippingPoint,
to_shippingType,
to_deliveryStatus,
to_shippingStatus,
deliveryWeightUnit,
deliveryVolumeUnit,
]
}
}
Capabilities: {
SortRestrictions: {
NonSortableProperties: [
senderbusinessPartnerID,
shipToPartybusinessPartnerID,
soldToPartybusinessPartnerID,
shippingPointlocationId,
]
}
}
● Capabilities.SearchRestrcitions
Defines the search restrictions. Currently the global track and trace option for SAP Logistics Business
Network does not allow any search capabilities beside filtering, hence the only admissible property
Searchable must be set to false.
CDS Annotation Definition:
Capabilities: {
SearchRestrictions: {
Searchable: false
}
}
Annotations on Fields
Some fields shall be rendered in the UI in a different way that is defined by annotations. As we annotate in a
separate file than the service definition, we use the following CDS syntax to define the UI layout.
● title
Defines the label for a certain field.
CDS Annotation Definition:
● Common.FieldControl
Defines the appearance of the field on the UI. Currently the only supported value is #Hidden.
CDS Annotation Definition:
The overview page contains a list of all tracked processes that match the given filter criteria. The appearance of
the list needs to be defined with annotations as well.
For that, we annotate the tracked process type with a set of fields to appear in the list. We use the following
CDS syntax for this kind of annotation.
● Value
Is the field name as defined in the annotated service that shall appear in the list. This property is
mandatory.
The object page is defined via facets. A facet contains a set of fields or a list of referenced entities to be
displayed. A facet is either described by a field group or by line item annotations of an associated entity.
We use the following CDS syntax to define the faces and field groups.
The object page is structured in facets, whether for header or for the object details. Each facet hereby is a
single data point, a field group, or a set of other facets.
UI.HeaderFacets
This contains all field groups or data points to be displayed in the header of the object page. The annotation is a
list of tuples with $Type and Target.$Type is always UI.ReferenceFacet, whereas Target is a reference to the
field group in format @UI.FieldGroup#<ID> or data point that defines the data to be show in format
@UI.DataPoint#<ID>.
UI.Facets are an array of structure with the following fields and can be nested.
● $Type
The type of the facet. If this facet contains sub facets, the type should be UI.CollectionFacet,
otherwise it is UI.ReferenceFacet. This value is mandatory.
● ID
The unique ID of the facet. This value is mandatory.
● Label
A label for the facet. This value is optional.
● Target
● UI.FieldGroup
An ordered collection of data fields with a label for the group. It is used to represent parts of a single data
instance in a form.
CDS Annotation Definition:
The annotations for line items on the object page are the same as line items on the overview page.
You need to reference this UI.LineItem annotation associated another entity in UI.Facets in form of
<association>/@UI.LineItem.
In the GTT app, you can track an object which includes a hierarchy table to show packaging hierarchy of the
target object. To enable this hierarchy table, you must add relevant scripts to your metadata model. The
example below shows how to modify a model to enable an object's packaging hierarchy.
Standard Mode
First, you must display a section to show a table for holding the hierarchy property as follows.
{
$Type: 'UI.ReferenceFacet',
ID: 'Hierarchy',
Label: 'Hierarchy',
Target: 'hierarchy/@UI.LineItem',
}
In the EPCISUI.cds, annotate the hierarchy property of EPCTrackedObject to enable the hierarchy
function as shown below:
You must define the columns in the hierarchy table. In the EPCISUI.cds, add the below scripts:
You can define metadata models in the MM app to track and trace business processes and physical objects.
When creating an application model, you can choose either of the following modes:
● Simple Mode
A simple-mode application model contains only one CDS file, which defines the tracked processes and
events for the application, as well as some basic service and UI annotations. You do not need to configure
complex UI annotations and services. These configurations are predefined and automatically applied to
your model when the model is deployed.
● Standard Mode
A standard-mode application model consists of more CDS files. This mode allows you to customize the UI
display, services, and API references for your application in separate CDS files.
The delivery application comes with additional metadata model definition that extends the generic tracked
process definition with delivery specific fields.
Standard Mode
A standard-mode delivery application consists of four files. The details are described in the subsequent topics
in this section.
Simple Mode
A simple-mode delivery application only consists of the DeliveryModel.cds file. The model details are
similar to those for the standard mode. However, a simple-mode delivery model does not have separate service
and UI annotation files. The DeliveryModel.cds file for simple-mode delivery application also includes some
basic service and UI annotations.
● notStarted = '01'
● pickingCompleted = '02'
● goodsIssued = '03'
● proofOfDelivery = '04'
● onTime = '01'
● delayed = '02'
● truck = '01'
● mail = '02'
● train = '03'
● ship = '04'
● airplane = '05'
● driverUnload = 'DU'
● liftgate = 'LG'
● ltl = 'LT'
● multimodal = 'MM'
● nextDayAir = 'P1'
● secondDayAir = 'P2'
● ground = 'P3'
● truckVSWM = 'WM'
Helper entities within the delivery application serve mainly for value lists.
Shipping Status
Delivery Status
Shipping Type
Delivery Items
The delivery process is the major entity of the delivery application. It extends the abstract tracked process as
defined in the core engine.
General Data
Namespace: com.sap.gtt.app.delivery.sample
Context: Delivery
Attributes
@CoreModel.PlannedEvents
List of planned events for the delivery process that consists of the following:
● PickingCompletedEvent (match location, technical tolerance window 2 hours, business tolerance value 1
hour)
● GoodsIssuedEvent (does not match location, technical tolerance window 1 day, business tolerance value 1
hour)
● ProofOfDeliveryEvent (does not match location, technical tolerance window 1 minute, business tolerance
value 1 hour)
@CoreModel. AdmissibleUnplannedEvents
● DelayedEvent
@CoreModel.StatusProperties
List of the following status attributes that must not be passed via any message:
● shippingStatus
● deliveryStatus
4.2.4.1.5 Events
The following events are defined for the delivery application as extension to the generic event as defined in the
core model. None of the events have event specific attributes, only annotations.
Similar with the delivery process, a base version for each event is firstly defined and both the core event and
base version event are inherited by each event.
PickingCompletedEvent
@SAP_EM.eventCode
Code: PICK_COMPL
Type: PLANNED
@CoreModel.UpdateStatus
Field: DeliveryProcess.shippingStatus
New value: 02
@SAP_EM.eventCode
Code: GI
Type: PLANNED
@CoreModel.UpdateStatus
Field: DeliveryProcess.shippingStatus
New value: 03
ProofOfDeliveryEvent
@SAP_EM.eventCode
Code: POD
Type: PLANNED
@CoreModel.UpdateStatus
Field: DeliveryProcess.shippingStatus
New value: 04
DelayedEvent
@SAP_EM.eventCode
Code: DELAY
Type: UPLANNED
@CoreModel.UpdateStatus
Field: DeliveryProcess.deliveryStatus
New value: 02
Within the delivery metadata model we have defined entities for inbound processing.
Namespace: com.sap.gtt.app.deliverysample
Context: Delivery
Description: The entity is used for data mapping during processing of generic messages sent by SAP Event
Management
Annotations
Attributes
deliveryId DEL_NO
salesOrderId SO_NO
salesOrganization SALES_ORGANIZATION
deliveryDate DELIVERY_DATE
loadingDate LOADING_DATE
transPlanDate TRANS_PLAN_DATE
shippingPoint SHIPPING_POINT
deliveryNetWeight DELIVERY_NET_WEIGHT
deliveryWeightUnit DELIVERY_WEIGHT_UNIT
deliveryVolume DELIVERY_VOLUME
deliveryVolumeUnit DELIVERY_VOLUME_UNIT
shippingType SHIPPING_TYPE
numberOfPackages NO_OF_PACKAGES
purchaseOrderId PO_NO
deliveryWeight DELIVERY_WEIGHT
Namespace: com.sap.gtt.app.deliverysample
Context: Delivery
Description: The entity is used for data mapping during processing of generic messages sent by SAP Event
Management
Annotations
Attributes
deliveryItem DELIVERY_ITEM
plant PLANT
storageLocation STORAGE_LOC
material MATERIAL
deliveryQty DELIVERY_QTY
qtyUnit QUANTITY_UNIT
pickingQty PICKING_QTY
distributionChannel DISTRIBUTION_CHANNEL
The delivery application service extends the core service and exposes in addition the following entities:
Entity Description
ShippingType
EventDescription Newly defined entity to provide value help for events with
code and description
The application service is extended from the core service. For example, DeliveryService.cds is defined as
follows:
namespace com.sap.gtt.app.deliverysample;
using com.sap.gtt.app.deliverysample.DeliveryModel from "DeliveryModel";
using com.sap.gtt.core.CoreServices.TrackedProcessService from "CoreServices";
using com.sap.gtt.core.CoreModel from "CoreModel";
service DeliveryService @extends: TrackedProcessService {
@CoreModel.UsageType: #userInterface
@CoreModel.MainEntity: true
entity DeliveryProcess as projection on DeliveryModel.DeliveryProcess {
*,
shippingPoint.locationId as shippingPoint @title:'Shipping Point',
items : redirected to DeliveryItem,
trackingIds : redirected to TrackedProcessService.QualifiedTrackingId,
sender : redirected to TrackedProcessService.BusinessPartner,
processEvents : redirected to TrackedProcessService.ProcessEventDirectory,
shipToParty : redirected to TrackedProcessService.BusinessPartner,
soldToParty : redirected to TrackedProcessService.BusinessPartner
} excluding {
tenant, name, trackedProcessType, trackingIds,
lastProcessedEvent,
CreatedByUser, CreationDateTime,
LastChangedByUser, LastChangeDateTime
};
}
The following are some important restrictions to be considered when you want to extend your application
service from the core service.
● The "using ... from ..." statements must be written in the order from top to bottom of the models.
You must import high level models before low level models. The models ordered from top down are:
1. DeliveryUI
2. DeliveryService
3. DeliveryModel
4. CoreServices
5. CoreModel
6. CoreType
● You must use the syntax "@extends:" to extend your application service from the core service. This is a
special syntax sugar feature which is only supported for application service models in the global track and
trace option for SAP Logistics Business Network.
● You must use the annotation "@CoreModel.MainEntity: true" on the entity which needs to be
displayed in the application UI. For example, "DeliveryProcess" entity in the Delivery Application
Service.
The UI annotation file contains the layout definition for delivery processes within SAP Fiori Elements.
The following shows a full example CDS code for Delivery UI annotations. For annotation definition details, see
the previous "UI Annotations" section.
Related Information
Write service is used to expose APIs from your GTT models. You can view these APIs are shown in the Model
Management App. The delivery application write service extends core write service. The following examples
show you how to define write service for simple-mode and standard-mode delivery models.
In the DeliveryModel.cds file, define a write version of process and event for each tracked process and
event. For example:
BaseDeliveryProcess and BasePickingCompletedEvent include the process specific fields and event
specific fields respectively. You may check the Outbound Delivery template model in the MM app for details.
Standard Mode
● In DeliveryModel.cds, define a write version of process and event for each tracked process and event.
For example:
You may check the Outbound Delivery template model in the MM app for details.
The shipment application comes with additional metadata model definition that extends the generic tracked
process definition with shipment specific fields. The definitions are similar with those in the delivery
application, which are described in the previous section.
Simple Mode
A simple-mode shipment application only consists of the ShipmentModel.cds file. The model details are
similar to those for the standard mode. However, a simple-mode shipment model does not have separate
service and UI annotation files.
In the GTT app, you can track one or more shipment processes on a map view on the processes list page
and/or a process' details page. The examples below show how to modify shipment template models to enable
map-related functions.
Standard Mode
Prerequisites
{
$Type: 'UI.ReferenceFacet',
ID: 'ProcessGeoMap',
Label: '{@i18n>Map}',
}
@UIExt.GeoMap.DisplayOnObjectPage.FacetID: 'ProcessGeoMap'
processRoute;
@UIExt.GeoMap.Route.Status.Text.PropertyPath: to_deliveryStatus.Text
@UIExt.GeoMap.Route.Status.Value.PropertyPath: deliveryStatus
@UIExt.GeoMap.Route.Status.ValueList.Entity: DeliveryStatus
processRoute;
@Common.FieldControl: #Hidden
processRoute;
@Common.FieldControl: #Hidden
currentProcessLocation;
@UIExt.GeoMap.DisplayOnListReportPage.Enabled: true
processRoute;
@UIExt.GeoMap.Route.Status.Text.PropertyPath: to_deliveryStatus.Text
@UIExt.GeoMap.Route.Status.Value.PropertyPath: deliveryStatus
@UIExt.GeoMap.Route.Status.ValueList.Entity: DeliveryStatus
processRoute;
@CoreModel.Map.CurrentProcessLocation.Longitude: true
longitude: Decimal(9,6) @title:'{@i18n>Longitude}';
@CoreModel.Map.CurrentProcessLocation.Latitude: true
latitude : Decimal(8,6) @title:'{@i18n>Latitude}';
1. To display a map popover on the processes list page, in the ShipmentUI.cds file, add the below scripts:
@UIExt.GeoMap.DisplayOnListReportPage.PopupPresentationVariantID: 'GeoMap'
processRoute;
@Common.FieldControl: #Hidden
processRoute;
@Common.FieldControl: #Hidden
currentProcessLocation;
Simple Mode
Note
The simple-mode shipment model only supports showing a map view on a process' details page. To show
the map view on the processes list page, you need to use the standard mode, as described above.
@CoreModel.MapEnabled: true
You can define EPCIS model or non-EPCIS model in the MM app for tracking physical objects and related
events.
Note
One tenant can only contain at most one active EPCIS model.
An EPCIS object tracking model contains one EPCIS tracked object entity and at most three EPCIS event
entities: object event, aggregation event, and transaction event. The EPCIS tracked object and events must be
inherited exactly once.
In a non-EPCIS object tracking model, the EPCIS event entities must not be inherited.
You can include object tracking packaging hierarchy in an object tracking model. For details, see Object
Tracking Hierarchy in Object Page.
A simple-mode EPCIS model only consists of the EPCISModel.cds file with model information and basic UI
layout information.
You can add fields to ILMD in an EPCIS model. These fields may come from the EPCIS standard vocabulary for
ILMD, or may be constructed based on the customer’s industry requirements. For example:
@CoreModel.EPCIS.URI: 'urn:epcglobal:cbv:mda:countryOfOrigin'
countryOfOrigin : String(2) @title:'Country/Region
Of Origin';
// GTT specific ILMD fields
@CoreModel.EPCIS.URI: 'http://gtt.sap.com/epcis/ilmd:gtin'
gtin : String(255) @title:'GTIN';
extend CoreModel.BusinessStepID {
name = 'uri';
};
To support showing information from different process types in one hierarchy table. A virtual entity like
AllTrackedProcess should be defined in model layer and exposed in service layer. For example:
entity AllTrackedProcessForEPCTrackedObject :
CoreModel.GTTAllTrackedProcessForEPCTrackedObject, BaseEPCTrackedObject{};
GTT core model has been upgraded from version 10.0.0 to 11.0.0 in the 2018.12a delivery. To ensure that your
existing GTT models work properly in the new delivery, proceed as follows:
● If you have an existing simple-mode model that defines the tracking of packing hierarchy but cannot see
the Hierarchy section in the GTT app, redeploy your model.
● If you have an existing model that includes map-related functions, revise your model as described below
and redeploy it.
To revise your standard-mode or simple-mode model that includes map-related functions, make the following
changes where applicable:
entity BaseShipmentProcess {
processRoute : Association to one CoreModel.ProcessRoute {id};
}
○ To display current process location on the map, add the following "one-to-one" association to the
entity BaseShipmentProcess section.
Since 2018.12a, one process can only have one current process location. To avoid compilation errors, if
your existing model includes a "one-to-many" association, do not delete it. Just add this "one-to-one"
association.
entity BaseShipmentProcess {
currentProcessLocation : Association to one
CoreModel.CurrentProcessLocation {id};
}
@Common.FieldControl: #Hidden
processRoute;
@Common.FieldControl: #Hidden
UI: {
Capabilities: {
FilterRestrictions: {
NonFilterableProperties: [
processRoute,
currentProcessLocation,
]
},
}
}
@UIExt.GeoMap.DisplayOnObjectPage.FacetID: 'ProcessGeoMap'
processRoute;
○ Add the following to set color, text, value and value list for the process route status shown on the map:
@UIExt.GeoMap.Route.Status.Color.PropertyPath:
to_deliveryStatus.Criticality
@UIExt.GeoMap.Route.Status.Text.PropertyPath: to_deliveryStatus.Text
@UIExt.GeoMap.Route.Status.Value.PropertyPath: deliveryStatus
@UIExt.GeoMap.Route.Status.ValueList.Entity: DeliveryStatus
processRoute;
Showing a map view on the processes list page is a new feature introduced to 2018.12a. It is only supported by
standard mode models. To enable this for your existing model, revise the <project_name>Model.cds file as
follows:
1. Add the following to enable a map view on the processes list page:
@UIExt.GeoMap.DisplayOnListReportPage.Enabled: true
processRoute;
2. Add the following to set color, text, value and values list for the process route status shown on the map:
@UIExt.GeoMap.Route.Status.Color.PropertyPath: to_deliveryStatus.Criticality
@UIExt.GeoMap.Route.Status.Text.PropertyPath: to_deliveryStatus.Text
@UIExt.GeoMap.Route.Status.Value.PropertyPath: deliveryStatus
@UIExt.GeoMap.Route.Status.ValueList.Entity: DeliveryStatus
processRoute;
3. Add the following to show a pop-up information box when a process is selected on the map:
@UIExt.GeoMap.DisplayOnListReportPage.PopupPresentationVariantID: 'GeoMap'
processRoute
1. To enable the map view on the process' details page, add @CoreModel.MapEnabled:true as highlighted
below:
@CoreModel.MapEnabled: true
entity ShipmentProcess : CoreModel.TrackedProcess, BaseShipmentProcess{};
2. To display shipping route on the map, add the following "one-to-one" association to the entity
BaseShipmentProcess section.
Since 2018.12a, one process can only have one shipping route. To avoid compilation errors, if your existing
model includes a "one-to-many" association, do not delete it. Just add this "one-to-one" association.
entity BaseShipmentProcess {
processRoute : Association to one CoreModel.ProcessRoute {id};
}
3. To display current process location on the map, add the following "one-to-one" association to the entity
BaseShipmentProcess section.
Since 2018.12a, one process can only have one current process location. To avoid compilation errors, if
your existing model includes a "one-to-many" association, do not delete it. Just add this "one-to-one"
association.
entity BaseShipmentProcess {
currentProcessLocation : Association to one
CoreModel.CurrentProcessLocation {id};
}
For more information on modeling map-related functions, see Map-related Functions in a Shipment Process
[page 133].
GTT core model has been upgraded from version 9.0.0 to 10.0.0 in the 2018.08a delivery.
If you have an existing model that includes a hierarchy table in the object page, you need to revise your model
to define the columns for the hierarchy table, as shown below:
Old:
New:
Hyperlinks
Some links are classified by an icon and/or a mouseover text. These links provide additional information.
About the icons:
● Links with the icon : You are entering a Web site that is not hosted by SAP. By using such links, you agree (unless expressly stated otherwise in your
agreements with SAP) to this:
● The content of the linked-to site is not SAP documentation. You may not infer any product claims against SAP based on this information.
● SAP does not agree or disagree with the content on the linked-to site, nor does SAP warrant the availability and correctness. SAP shall not be liable for any
damages caused by the use of such content unless damages have been caused by SAP's gross negligence or willful misconduct.
● Links with the icon : You are leaving the documentation for that particular SAP product or service and are entering a SAP-hosted Web site. By using such
links, you agree that (unless expressly stated otherwise in your agreements with SAP) you may not infer any product claims against SAP based on this
information.
Example Code
Any software coding and/or code snippets are examples. They are not for productive use. The example code is only intended to better explain and visualize the syntax
and phrasing rules. SAP does not warrant the correctness and completeness of the example code. SAP shall not be liable for errors or damages caused by the use of
example code unless damages have been caused by SAP's gross negligence or willful misconduct.
Gender-Related Language
We try not to use gender-specific word forms and formulations. As appropriate for context and readability, SAP may use masculine word forms to refer to all genders.
SAP 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. All
other product and service names mentioned are the trademarks of their
respective companies.