SAP CDS LITERAL V1
Get Example source ABAP code based on a different SAP table
• ' ABAP_CDS_SELECT_V1
• #domain ABAP_CDS_SELECT_V1
• :domain ABAP_CDS_SELECT_V1
ABAP_CDS_DDL - DDIC-Based View, literal> ABAP_SYNTAX ... $[#$|:domain.$]'character_literal'$|numeric_literal ...>
ABAP Addition
... #$|:domain.>
What does it do?
Literal in a SELECT> statement> of a ABAP_CDS_V1_VIEW >. It is either a character literal or a numeric literal:
A character literal 'character_literal'> is a character string enclosed in quotation marks. If the character string consists exclusively of digits, 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.
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 a field of the type INT1>>, INT2>>, INT4>>, or INT8>>, depending on the value. A numeric literal with a decimal point is floating point number of type FLTP>>. The value of a numeric literal cannot be greater than the value range of the valid types.
Literals can be used at all operand positions where this is documented.
Escape characters:
A single quote (') must be used to escape a single quote ('...''...' >) in a character literal.
Latest notes:
0.5> is a valid numeric literal, but .5> is not.
Byte-like literals are currently not supported.
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.
It is not> possible to specify a literal in an operand position that expects a type-compliant operand in a data type that is not numeric or character-like, such as UTCLONG>. In the following example, the operand after when> cannot be specified as literal and therefore, the syntax is invalid: case utcl_current( )
when '2020020720162345' then 'ok'
else 'no'
end as demo>
NON_V5_HINTS
ABAP_HINT_END
ABAP_EXAMPLE_VX5
The CDS view demonstrates various literals at operand positions.
DDLS DEMO_CORP_SALES_ORDER
ABAP_EXAMPLE_END
ABAP Addition
What does it do?
In certain operand positions, a literal can be prefixed with a name of a DDIC domain> domain> introduced using the character #> or :> and separated by a period (.>). In this case, a check is made to verify whether the value of the literal is defined as a fixed value> in the value range> of the domain. If this is not the case or if the domain does not exist as an active domain, a syntax check warning occurs. Apart from this, the literal is handled like a regular literal.
A domain can be specified in front of a literal in the following operand positions:
Element of the SELECT> list>
Right side of a comparison condition>
Parameters passed to built-in functions>
Latest notes:
In the case of character literals consisting only of letters, numbers, underscores (_>), and slashes (/>) and that start with a letter, underscore, or slash, the quotation marks can be omitted after the domain.
#domain.xXx> has the same semantics as
#domain.'xXx'>.
Numeric literals can only be checked using fixed values of numeric domains.
Currently, not all potential literal values can be represented as fixed values of domains. For example, a numeric domain can only have positive integers as fixed values and there are no fixed values for domains of type FLTP>.
NON_V5_HINTS
ABAP_HINT_END
ABAP_EXAMPLE_VX5
Fixed value EXA> of the domain ABDOCTYPE>> as the operand of the WHERE> condition of a view.
DDLS DEMO_ABAPDOC_TREE
ABAP_EXAMPLE_END