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 - sql_functions → 

ABAP CDS - Byte String Functions

The following table shows the possible SQL functions for byte strings in a CDS view, plus the requirements made on the arguments. The meaning of the functions can be found under SQL Functions for Byte Strings.

Function Valid Argument Types Result Type
BINTOHEX(arg) RAW in a maximum length of 255 CHAR with twice the length of arg
HEXTOBIN(arg) CHAR or NUMC in a maximum length of 510 CHAR with half the length of arg

The following can be specified as the arguments arg:

Example

The following CDS view applies predefined SQL 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
    }