Skip to content

ABAP Keyword Documentation →  ABAP - Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Data Definitions →  ABAP CDS - DDL for Data Definitions 

ABAP CDS - typing

Other versions: 7.31 | 7.40 | 7.54

Syntax


... dtype | data_element  ...

Effect

Types elements or parameters of CDS entities in CDS DDL. The following is typed:

  • Elements of CDS entities:
  • Input parameters of CDS entities

A typing can be specified either directly with dtype (using a built-in data type in ABAP Dictionary) or using the name of a data element data_element. The table below shows the possible options for dtype and their meanings. The last two columns indicate whether the typing is possible for elements or input parameters.

dtype Built-In Data Type in ABAP Dictionary Element Parameter
abap.accp(6) ACCP (only in a table function) x -
abap.char( len ) CHAR with length len x x
abap.clnt[(3)] CLNT x x
abap.cuky[(5)] CUKY x x
abap.curr(len,dec) CURR with length len and with dec decimal places x x
abap.d16n[(16)] DECFLOAT16 x x
abap.d34n[(34)] DECFLOAT34 x x
abap.datn[(8)] DATN x x
abap.dats[(8)] DATS x x
abap.dec(len,dec) DEC with length len and with dec decimal places x x
abap.fltp[(16,16)] FLTP x x
abap.geom_ewkb GEOM_EWKB x -
abap.int1[(3)] INT1 x x
abap.int2[(5)] INT2 x x
abap.int4[(10)] INT4 x x
abap.int8[(19)] INT8 x x
abap.lang[(1)] LANG x x
abap.numc( len ) NUMC with length len x x
abap.quan(len,dec) QUAN with length len and with dec decimal places x x
abap.raw(len) RAW with length len x x
abap.rawstring RAWSTRING x -
abap.sstring(len) SSTRING with length len x x
abap.string STRING x -
abap.timn[(6)] TIMN x x
abap.tims[(6)] TIMS x x
abap.unit[(2 3)] UNIT with length 2 or 3 (standard length) x
abap.utcl[(27)] UTCLONG x x

In len and dec, specific values must be specified for the length and decimal places (with respect to the relevant generic types). The values specified here in parentheses must be within the value ranges permitted by ABAP Dictionary. The predefined values can be specified for types with fixed lengths and decimal places, but this is not mandatory (except for abap.accp). For data_element, every ABAP Dictionary data element whose built-in type is listed in the table above can be specified.


Note

Currently no structured or tabular parameters are supported, only elementary data types.


Example

The following CDS view has two input parameters. p_date is typed with data elementDEMODATE and p_num is typed with the built-in data type DEC with a specified length and number of decimal places.

@AbapCatalog.sqlViewName: 'DEMO_CDS_PTYPE'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view demo_cds_parameter_type
with parameters
p_date :demodate,
p_num :abap.dec( 10, 3 )
as select from
demo_expressions
{
key id,
:p_date as col_date,
:p_num + dec3 as col_num
};    

The program DEMO_CDS_PARAMETER_TYPE accesses the view using the following SELECT statement:

SELECT id, col_date, col_num
       FROM demo_cds_parameter_type( p_date = @sy-datlo,
                                     p_num  = '1.234' )
       INTO TABLE @DATA(result).