SAP CDS UNTYPED LITERAL V2



Get Example source ABAP code based on a different SAP table
  


• literals ABAP_CDS_SELECT

ABAP_CDS_DDL - CDS View Entity, Untyped Literal

ABAP_SYNTAX
... 'character_literal'$|numeric_literal ...

What does it do?
Untyped literal in a SELECT statement of a CDS view entity. It is either a character literal or a numeric literal:
Untyped character literal A character literal 'character_literal' is a character string enclosed in quotation marks. If the character string consists exclusively of digits, it is handled as a numeric text literal and the data type of the literal is NUMC . If this is not the case, the data type is CHAR. When activated, the length of the corresponding field in the database system is set to a size at least as large as the actual length of the literal. A character literal can have a maximum of 1333 characters.
Untyped numeric literal A numeric literal numeric_literal is a series of digits between 0 and 9. It can be directly prefixed by a + or - sign and can contain a decimal point (.) after the first digit. A numeric literal without a decimal point is handled as an integer literal of the type INT1, INT2, INT4, or INT8, depending on the value. A numeric literal with a decimal point is a binary floating point literal of the type FLTP . The value of a numeric literal must be within the value range of the valid types.
Literals can be used at all operand positions where this is documented.



Latest notes:

0.5 is a valid numeric literal, but .5 is not.
A literal prefixed with a sign is interpreted as an arithmetic expression and can be specified in all operand positions where arithmetic expressions are allowed.
The built-in conversion function FLTP_TO_DEC can be used to convert literals with a decimal point to a packed number.
Literals can be of data type CHAR, NUMC, INT1, INT2, INT4, INT8, or FLTP. If an operand expects input of any other data type, then a literal is not possible in this operand position. There are a few exceptions to this rule, for example, some date and time conversion functions accept literal input which is then interpreted as date or time data type. These exceptions are mentioned in the documentation of the respective functions.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The CDS view entity demonstrates various literals at operand positions while making use of the database table SPFLI. The class CL_DEMO_CDS_LITERALS_VE uses SELECT to access the view entity.
DDLS DEMO_CDS_LITERALS_VE
ABAP_EXAMPLE_END