ABAP - Keyword Documentation →  ABAP - Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Data Definitions →  ABAP CDS - DDL for Data Definitions →  ABAP CDS - DEFINE VIEW →  ABAP CDS - SELECT →  ABAP CDS - SELECT, Built-In Functions →  ABAP CDS - Special Functions →  ABAP CDS - Conversion Functions → 

ABAP CDS - Type Conversion Functions

Syntax

... FLTP_TO_DEC( arg AS dtype ) ...
... BINTOHEX( arg ) ...
... HEXTOBIN( arg ) ...

Variants:

1. ... FLTP_TO_DEC( arg AS dtype )

2a. ... BINTOHEX( arg )

2b. ... HEXTOBIN( arg )

Effect

Functions for conversions between data types in a CDS view.

Notes

Variant 1

... FLTP_TO_DEC( arg AS dtype )


Effect

Conversion of an argument arg of type FLTP to a packed number. Literals and fields of a data source data_source of the current CDS view can be specified for arg. arg must have the type FLTP.

A target data type DEC, CURR, or QUAN must be specified with dtype for a packed number, as follows:

The following table shows the syntax for specifying built-in data types:

dtype Dictionary Type
abap.dec(len,decimals) DEC with length len and decimals decimal places
abap.curr(len,decimals) CURR with length len and decimals decimal places
abap.quan(len,decimals) QUAN with length len with decimals decimal places

The value range of the data type dtype must cover the value range of the operand type. An exception occurs if the value range of the target data type is not sufficient. Any surplus decimal places are cut off without rounding.

Notes

Example

The following CDS view applies the function FLTP_TO_DEC in the SELECT list to columns of the database table DEMO_EXPRESSIONS. The program DEMO_CDS_FLTP_TO_DEC uses SELECT to access the view. Note that there is no rounding.

@AbapCatalog.sqlViewName: 'DEMO_CDS_FLTPDEC'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view demo_cds_fltp_to_dec
  as select from
    demo_expressions
    {
      fltp_to_dec( fltp1 as abap.dec(10,0) ) as dec1_10_0,
      fltp_to_dec( fltp1 as abap.dec(10,3) ) as dec1_10_3,
      fltp_to_dec( fltp2 as abap.dec(10,0) ) as dec2_10_0,
      fltp_to_dec( fltp2 as abap.dec(10,3) ) as dec2_10_3
    }  


Variant 2a

... BINTOHEX( arg )

Variant 2b

... HEXTOBIN( arg )



Effect

The functions BINTOHEX and HEXTOBIN convert byte strings to character strings and back:

Example

The following CDS view applies the conversion functions for byte strings in the SELECT list to columns of the database table DEMO_EXPRESSIONS. The program DEMO_CDS_SQL_FUNCTIONS_BYTE uses SELECT to access the view.

@AbapCatalog.sqlViewName: 'DEMO_CDS_BINFUNC'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view demo_cds_sql_functions_byte
as select from
demo_expressions
{
bintohex( raw1 ) as r_bintohex,
hextobin( char1 ) as r_hextobin
}