Ansicht
Dokumentation

ABENCDS_TYPED_LITERAL_V2 - CDS TYPED LITERAL V2

ABENCDS_TYPED_LITERAL_V2 - CDS TYPED LITERAL V2

BAL_S_LOG - Application Log: Log header data   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.
SAP E-Book

- CDS View Entity, Typed Literals

... dtype'...'

Effect

Typed literal in a SELECT statement of a CDS view entity. Typed literals can be created for all built-in ABAP Dictionary types with the exception of LCHR, LRAW, GEOM_EWKB, PREC, ACCP, DF16_SCL, DF34_SCL, and VARC. A typed literal can be used in all operand positions where this is documented.

dtype is the name of a built-in dictionary type with the type namespace abap. and it is followed by the character-like representation of the value in single quotes ('). Only those values can be specified that are accepted by the data type of the literal. Length and decimal places are derived from the literal value, they must not be explicitly specified.

Notes

  • Typed literals should be used instead of untyped literals. They offer many advantages, such as more flexibility with regard to the data type they can have, explicit type declaration, and checking type compatibility of the value specified.
  • Currently, typed literals are available in CDS view entities and in CDS hierarchies in all operand positions where untyped literals are possible with one exception: typed literals are not supported in the ON condition of a CDS association.

Typed literals can be divided into the following categories:

Typed Numeric Literals

The following table describes the typed numeric literals:

Syntax Name Possible Characters
abap.int1'...'\lbr abap.int2'...'\lbr abap.int4'...'\lbr abap.int8'...' Integer literal Uninterrupted string of digits, with an optional sign + or - as a prefix. At least one digit must be specified. The value of the number must be in the value range of the respective dictionary type. An empty literal `` is not allowed.
abap.dec'...' Packed number literal String of digits with a maximum of one decimal point (.). This point can be located in front of, between, or after the digits. The string can be prefixed with an optional sign + or -. At least one and no more than 31 digits can be specified. The maximum number of decimal places is 14. The length used in the memory and the number of decimal places are determined by the number of digits specified. An empty literal `` is not allowed.
abap.decfloat16'...'\lbr $| abap.d16n'...' \lbr abap.decfloat34'...'\lbr $| abap.d34n'...'\lbr Decimal floating point literal Mantissa followed by an optional exponent. The mantissa is a string of digits with a maximum of one decimal point (.). This point can be located in front of, between, or after the digits. The string can be prefixed with an optional sign + or -. Length restrictions, typing conventions, and scaling rules of the respective dictionary type apply. An empty literal '' is not allowed.
abap.fltp'...' Binary floating point literal Mantissa followed by an optional exponent. The mantissa is a string of digits with a maximum of one decimal point (.). This point can be located in front of, between, or after the digits. The string can be prefixed with an optional sign + or -. The maximum number of valid places is 16. An empty literal '' is not allowed.

Notes

  • A zero with a sign + is not allowed for integer literals and packed number literals. For example, abap.int4'+0' is not allowed. This rule is verified by the syntax check. A zero with a sign - is allowed though.

Example

Use of a typed numeric literal in different operand positions in a CDS view entity.

Typed Character Literals

The following table describes the typed character literals:

Syntax Name Possible Characters
abap.char'...' Text field literal String of any alphanumeric characters. The length of a text field literal must lie between 1 and 255 characters. An empty text field literal abap.char'' is allowed and denotes the initial value of one blank. Trailing blanks are removed but the type length includes the trimmed trailing blanks.
abap.string'...'\lbrabap.sstring'...' Text string literal String of any alphanumeric characters. A typed text string literal can have a maximum of 255 characters. A typed text string literal can be empty and the typed text string literal abap.string'' represents an empty string with length 0. \lbr For data type abap.sstring, trailing blanks are removed but the type length includes the trimmed trailing blanks. \lbr For data type abap.string, trailing blanks are not removed.

Example

Use of typed character literals in a CDS view entity.

The program DEMO_CDS_CHAR_TYPED_LIT accesses the view and demonstrates the following:

  • Trailing blanks are included in the type length of text field and text string literals.
  • Trailing blanks are removed from typed literals of type CHAR and SSTRING, but not from typed literals of type STRING.

Typed Byte Literals

The following table describes the typed byte literals:

Syntax Name Possible Characters
abap.raw'...' Byte field literal String including the characters 0-9 and A-F. No other characters are allowed. The number of characters must be even. At least two characters must be specified. An empty literal abap.raw'...' is not allowed.
abap.rawstring'...'\lbr $| abap.rstr'...' Byte string literal String including the characters 0-9 and A-F. No other characters are allowed. The number of characters must be even. The empty byte string literal abap.rawstring'' represents an empty byte string.

Notes

  • The specified characters are used to represent byte values in a hexadecimal format.
  • The letters A-F must be in uppercase.

Example

Use of a typed byte field literal in a CDS view entity.



Typed Literals for Character-Like Types with Special Semantics

The following table describes the typed literals for character-like types with special semantics:

Syntax Name Possible Characters
abap.numc'...' Numeric text literal Character string consisting of the digits 0 to 9. The length of a numeric text literal must lie between 1 and 255 characters. Empty numeric text literals abap.numc'' or blanks within numeric text literals are not allowed. Negative values are not allowed.
abap.clnt'...' Client literal String of any alphanumeric characters with a length of exactly 3 characters. Blanks are not allowed. An empty literal abap.clnt'' is not allowed.
abap.lang'...' Language key literal A language key literal can contain any alphanumeric character and it consists of exactly one character. An empty literal abap.lang'' is not allowed. A blank space is allowed.

Example

Use of a typed numeric text literal in a WHERE condition.

Typed Date and Time Literals

The following table describes the typed date and time literals:

Syntax Name Possible Characters
abap.dats'..'\lbrabap.datn'...' Date literal Character string that represents a date in the format YYYYMMDD. Must contain a valid date according to the rules for valid dates described for time stamp literals below. An empty string '' is not allowed.
abap.tims'...'\lbrabap.timn'...' Time literal Character string that represents a time in the format HHMMSS. Must contain a valid time according to the rules for valid times described for time stamp literals below. An empty literal '' is not allowed.
abap.utclong'...'\lbr $| abap.utcl'...' Time stamp literal Character string that represents a time stamp in the format YYYY-MM-DD HH:MM:SS,SSSSSSS, precise to 100 nanoseconds. YYYY-MM-DD consists of eight digits separated by hyphens. They must represent dates that are valid in accordance with the calendar rules: YYYY (year): 0001 to 9999, mm (month): 01 to 12, DD (day): 01 to 31. "1582-10-05" to "1582-10-14" are skipped due to the conversion from the Julian to the Gregorian calendar. HH:MM:SS,SSSSSSS consists of digits separated by colons and a full stop. They must represent a time in a 24-hour range in the format HHMMSS: 00 to 23 for HH (hours) and 00 to 59 for MM (minutes) and 00 to 59 for SS.SSSSSSS (seconds with exactly seven decimal places). No other characters are allowed. An empty literal abap.utcl'' is not allowed.

Note

60 cannot be specified in a time, either as minutes or as seconds. In particular, this means that leap seconds cannot be specified.

Example

Use of typed literals as operands in a CDS view entity.

Typed Currency and Quantity Literals

The following table describes the typed currency and quantity literals:

Syntax Name Possible Characters
abap.curr'...' Currency field literal Uninterrupted string of digits with an optional sign + or - as a prefix. Cannot contain more than one decimal point (.). At least one and no more than 31 digits can be specified. Exactly two decimal places must be specified.
abap.cuky'...' Currency key literal String of any alphanumeric characters with a maximum of 5 characters. An empty literal abap.cuky'' is allowed and denotes five blanks.
abap.quan'...' Quantity field literal Uninterrupted string of digits with an optional sign + or - as a prefix. Cannot contain more than one decimal point (.). At least one and no more than 31 digits can be specified. The maximum number of decimal places is 14.
abap.unit'...' Unit key literal String of any alphanumeric characters with a maximum of 3 characters. An empty literal UNIT`` is allowed and denotes two blanks.

If a currency or quantity field is specified in the SELECT list using a CDS typed literal, a reference to a currency key or unit of reference key is mandatory. This is specified with the following annotations:

  • Currency key: Semantics.amount.currencyCode
  • Unit key: Semantics.quantity.unitOfMeasure

Example

CDS view entity with currency and quantity literals.






SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 22341 Date: 20240511 Time: 082636     sap01-206 ( 233 ms )