Skip to content

Language

GallusHuber edited this page Aug 4, 2024 · 5 revisions

📖 Table of Contents

  1. ER2CDS Model
  2. Entity
  3. Attributes
  4. Relationship

ER2CDS Model

ER2CDS models are specified in .er2cds files with the er2cds keyword and a model name. After the header follows the specification of the model elements (i.e. entities and relationships).

Entity

An entity includes a name and an optional alias, as well as attributes within curly braces.

// Entity with Alias
entity withAlias {
   alias Alias
}

// Entity with Attributes
entity withAttributes {
   key attr1 : CHAR
   attr2 : CHAR
}

Attributes

// Classifiers
attr
key attr
no-out attr

// Datatype
attr : CHAR

// Alias
attr : CHAR as Attribute

Classifiers

Classifier Description
none Simple
key Key attributes
no-out Used for modeling; not part of CDS output

Datatypes

Datatype Description
DEC Calculation/amount field
INT1 Single-byte integer
INT2 Two-byte integer
INT4 Four-byte integer
CURR Currency field
CUKY Currency key
QUAN Quantity
UNIT Unit
FLTP Floating point number
NUMC Numeric text
CHAR Character
LCHR Long Character
STRG String of variable length
RSTR Byte string of variable length
DATS Date
ACCP Accounting period YYYYMM
TIMS Time HHMMSS
RAW Byte string
LRAW Long byte string
CLNT Client
LANG Language
D16D Decimal Floating Point Stored as Binary Number
D16R Decimal Floating Point Stored as Binary Number
D34D Decimal Floating Point Stored in BCD Format
D34R Decimal Floating Point Stored as Binary Number
INT8 8-Byte Integer
PREC Two-byte integer
SSTR Character String

Relationship

Degree

We require all relationships to be binary.

relationship Binary {
    E1 -> E2
}

Type

ER2CDS supports all types of CDS relationships. For explanation please refer to the official documentation.

// Join relationship
relationship Join {
}

// Association relationship
association relationship Association {
}

// Association-to-Parent relationship
association-to-parent relationship Association-to-Parent {
}

// Composition relationship
composition relationship Composition {
}

Cardinality

Cardinality corresponds to the maximum constraint in the number of allowed entity instances. The value for cardinality can be either 1 (one) or 0..N (many).

// 1-1 (One-To-One)
relationship Rel1 {
    E1[1] -> E2[1]
}

// 1-N (One-To-Many)
relationship Rel2 {
    E1[1] -> E2[0..N]
}

// N-N (Many-To-Many)
relationship Rel3 {
    E1[0..N] -> E2[0..N]
}

Join Order

The join order determines the order of joins in the resulting CDS view entity.

// Join gets executed first
relationship Rel1 {
    E1[1] -> E2[1]
    join order 1
}

// Join gets executed second
relationship Rel2 {
    E1[1] -> E2[0..N]
    join order 2
}

Join Clauses

The join clauses are interpreted as the ON clause within a join.

// Join with defined on-clause
relationship Rel1 {
    E1[1] -> E2[1]
    join order 1
    attr11 = attr21
    attr12 = attr22
}
Clone this wiki locally