SAP CDS TYPED LITERAL V2 Get Example source ABAP code based on a different SAP table
SAP Help
• ABAP.INT1 ABAP_CDS_LITERAL
• ABAP.INT2 ABAP_CDS_LITERAL
• ABAP.INT4 ABAP_CDS_LITERAL
• ABAP.INT8 ABAP_CDS_LITERAL
• ABAP.DEC ABAP_CDS_LITERAL
• ABAP.DECFLOAT16 ABAP_CDS_LITERAL
• ABAP.DECFLOAT34 ABAP_CDS_LITERAL
• ABAP.D16N ABAP_CDS_LITERAL
• ABAP.D34N ABAP_CDS_LITERAL
• ABAP.FLTP ABAP_CDS_LITERAL
• ABAP.CHAR ABAP_CDS_LITERAL
• ABAP.STRING ABAP_CDS_LITERAL
• ABAP.SSTRING ABAP_CDS_LITERAL
• ABAP.RAW ABAP_CDS_LITERAL
• ABAP.RAWSTRING ABAP_CDS_LITERAL
• ABAP.RSTR ABAP_CDS_LITERAL
• ABAP.NUMC ABAP_CDS_LITERAL
• ABAP.CLNT ABAP_CDS_LITERAL
• ABAP.LANG ABAP_CDS_LITERAL
• ABAP.DATS ABAP_CDS_LITERAL
• ABAP.DATN ABAP_CDS_LITERAL
• ABAP.TIMS ABAP_CDS_LITERAL
• ABAP.TIMN ABAP_CDS_LITERAL
• ABAP.UTCLONG ABAP_CDS_LITERAL
• ABAP.UTCL ABAP_CDS_LITERAL
ABAP_CDS_DDL - CDS View Entity, Typed Literals ABAP_SYNTAX ... dtype>'...'> What does it do? 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. Latest 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>. NON_V5_HINTS ABAP_HINT_END Typed literals can be divided into the following categories: ITOC Typed Numeric Literals The following table describes the typed numeric literals: Syntax>Name>Possible Characters> abap.int1'...'> lbrabap.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. Latest 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. For all decimal floating point literals >, there are alternative notations for the data type. This is indicated in the table above by the $| sign. A literal prefixed with a sign is never> interpreted as an arithmetic expression>. NON_V5_HINTS ABAP_HINT_END ABAP_EXAMPLE_VX5 Use of a typed numeric literal in different operand positions in a CDS view entity. DDLS DEMO_CDS_NUMERIC_TYPED_LIT ABAP_EXAMPLE_END Typed Character Literals The following table describes the typed character literals: Syntax>Name>Possible Characters> abap.char'...'> Text field literal > String of any 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 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. ABAP_EXAMPLE_VX5 Use of typed character literals in a CDS view entity. DDLS DEMO_CDS_CHAR_TYPED_LIT The class CL_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>. ABAP_EXAMPLE_END 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. Latest notes: The specified characters are used to represent byte values in a hexadecimal format. The letters A-F must be in uppercase. NON_V5_HINTS ABAP_HINT_END ABAP_EXAMPLE_VX5 Use of a typed byte field literal in a CDS view entity. DDLS DEMO_CDS_TYPED_BYTE_LIT ABAP_EXAMPLE_END 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 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 character and it consists of exactly one character. An empty literal abap.lang'' > is not allowed. A blank space is allowed. ABAP_EXAMPLE_VX5 Use of a typed numeric text literal in a WHERE> condition. DDLS DEMO_CDS_NUMERIC_TEXT_TYP_LIT ABAP_EXAMPLE_END 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. Latest notes: 60 cannot be specified in a time, either as minutes or as seconds. In particular, this means that leap seconds> cannot be specified. NON_V5_HINTS ABAP_HINT_END ABAP_EXAMPLE_VX5 Use of typed literals as operands in a CDS view entity. DDLS DEMO_CDS_DATE_AND_TIME_TYP_LIT ABAP_EXAMPLE_END 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 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 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> ABAP_EXAMPLE_VX5 CDS view entity with currency and quantity literals. DDLS DEMO_CDS_CURR_AND_QUAN_TYP_LIT ABAP_EXAMPLE_END