Ansicht
Dokumentation

ABENCDS_LITERAL_V1 - CDS LITERAL V1

ABENCDS_LITERAL_V1 - CDS LITERAL V1

Addresses (Business Address Services)   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

- DDIC-Based View, literal

... $[#$|:domain.$]'character_literal'$|numeric_literal ...

Addition:

... #$|:domain.

Effect

Literal in a SELECT statement of a . 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.

Notes

  • 0.5 is a valid numeric literal, but .5 is not.
  • Byte-like literals are currently not supported.
  • 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

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


Addition

... #$|:domain.

Effect

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:

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.

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';






rdisp/max_wprun_time - Maximum work process run time   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 9840 Date: 20240425 Time: 112344     sap01-206 ( 94 ms )