Skip to content

ABAP Keyword Documentation →  ABAP Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Views →  ABAP CDS - DDL Statements →  ABAP CDS - DEFINE VIEW →  ABAP CDS - SELECT →  ABAP CDS - SELECT, Operands and Expressions 

ABAP CDS - literal

Other versions: 7.31 | 7.40 | 7.54

Syntax


... 'character_literal'|numeric_literal|#domain.value ...

Effect

Literal in a SELECT statement of a CDS view in ABAP CDS. It can be either a character literal, a numeric literal, or a fixed value of a domain:

  • A character literal 'character_literal' is a character string enclosed in inverted commas. If the character string consists exclusively of numbers, 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 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, or INT4, depending on the value. A numeric literal with a decimal point is floating point number of type FLTP.
  • A fixed value value of a domain domain. The value specified in value is handled like a normal literal at runtime. During the syntax check, the system checks whether the value is defined as a fixed value of the domain value range. If this is not the case or if the domain has not been activated, a warning is raised. The name of the domain domain must be introduced with the character # and must be separated from value value with a period ..
  • Fixed values value, which comply with the naming rules for names, must be specified directly.
  • Fixed values value, which represent a numeric literal, must be specified as such.
  • All other fixed values must be specified in inverted commas. The fixed value of the domain must be enclosed in quotation marks to avoid a warning. They are not, however, part of the literal value in the CDS view.

Literals can be used at all operand positions where this is documented.


Notes

  • 0.5 is a valid numeric literal, but .5 is not.

  • No byte-like literals are currently supported.

  • The following:

Example

The CDS view demonstrates various literals at operand positions.

@AbapCatalog.sqlViewName: 'CORP_SO_VW'
define view corp_sales_order as
  select from snwd_so
         association [1..1] to snwd_bpa as partner
           on snwd_so.buyer_guid = partner.node_key
         { key snwd_so.so_id as sales_order_id,
               snwd_so.buyer_guid,
               partner.bp_id as corporation_id,
               partner.company_name as corporation_name,
              'corporation' as legal_form,
             @Semantics.currencyCode
              'EUR' as currency_code,
             @Semantics.amount.currencyCode: 'currency_code'
               snwd_so.gross_amount as sales_order_gross_amount }
         where partner.legal_form = 'Inc.' //Corporations only
           and snwd_so.currency_code = 'EUR'
           and snwd_so.gross_amount > 100000


Example

Fixed value EXA of the domain ABDOCTYPE as the operand of the WHERE condition of a view.

AbapCatalog.sqlViewName: 'ABAPDOCTREE'
  define view abapdoc_tree as
  select from abapdocu_tree
         { * }
         where node_type = #ABDOCTYPE.EXA;