Ansicht
Dokumentation

ABENCDS_CONV_FUNC_TYPES_V2 - CDS CONV FUNC TYPES V2

ABENCDS_CONV_FUNC_TYPES_V2 - CDS CONV FUNC TYPES V2

CL_GUI_FRONTEND_SERVICES - Frontend Services   CPI1466 during Backup  
This documentation is copyright by SAP AG.
SAP E-Book

- CDS View Entity, Type Conversion Functions

... 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 entity.

Notes

  • These functions execute special conversions that cannot be handled in a general CAST expression.
  • If an argument has the null value, the result of the conversion function is also the null value.



Variant 1

... FLTP_TO_DEC( arg AS dtype )


Effect

Conversion of an argument arg of type FLTP to a packed number. Literals, fields of a data source data_source, and path expressions 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 \lbr The only valid value for decimals is 2.
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

  • If arg is assigned a currency key using the annotation Semantics.amount.currencyCode, then the result field must also be assigned a currency key using the same annotation.
  • If arg is assigned a unit of measurement key using the annotation Semantics.quantity.unitofMeasure, then the result field must also be assigned a unit of measurement key using the same annotation.
  • The conversion of type FLTP to a packed number using the function FLTP_TO_DEC is platform dependent and does not have to be reversible using a CAST.
  • The general CAST is designed to be platform-independent, which means it does not allow conversions of type FLTP to other numeric data types.
  • Since a literal with a prefixed sign is interpreted as an arithmetic expression, the argument arg of the function FLTP_TO_DEC cannot be a negative literal. Instead, the sign can usually be specified before the function.
  • The built-in conversion function FLTP_TO_DEC is especially useful for converting literals with a decimal point to a packed number.

Example

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



Variant 2a

... BINTOHEX( arg )


Variant 2b

... HEXTOBIN( arg )


Effect

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

  • BINTOHEX takes a byte string and converts it to a character string containing the half bytes of arg, converted to the hexadecimal characters "0" to "9" and "A" to "F" (left-aligned). The valid argument type is RAW with a maximum length of 255. The result has the type CHAR with twice the length of arg. Only fields of data sources can be specified as arguments.
  • HEXTOBIN converts a character string to a byte string whose half bytes are determined from the hexadecimal characters of arg. Any leading blanks are removed before the conversion from arg and all trailing blanks are then replaced by "0". The valid argument types are is CHAR or NUMC with a maximum length of 510. The result has the type RAW with half the length of arg. Fields of data sources, path expressions, and literals can be specified as arguments. The total of all characters must be even and it can contain only the hexadecimal characters "0" to "9" and "A" to "F" (uppercase or lowercase) and leading and trailing blanks. Literals cannot contain any leading blanks.

Example

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






General Data in Customer Master   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 11211 Date: 20240427 Time: 013147     sap01-206 ( 125 ms )