CAST Expression
Supported Operands: Literal, column, path expression, build-in function, arithmetic expression
- Various data types in ABAP namespace supported
- Result length determined at activation time
- No nesting of CAST expressions
- Alias names required for resulting columns
Example:
Cast foreign currency amount from sbook as reduced_amount and Savings
@AbapCatalog.sqlViewName: 'Zcds_cast_sql' |
|
define view Zcds_cast as select from sbook |
|
{ |
|
forcurkey, |
|
forcuram as Amount, |
|
cast( forcuram as abap.fltp ) + ( cast ( -forcuram as abap.fltp ) * 0.03 ) as ReducedAmount, |
|
cast( forcuram as abap.fltp )* 0.03 as Savings |
|
} |
Unit Conversion
The function UNIT_CONVERSION performs a unit conversion for the value passed to the formal parameter quantity.
@AbapCatalog.sqlViewName: 'zcds_unit_sql' |
|
define view zcds_unit as select from sbook |
|
{ |
|
bookid, |
|
unit_conversion ( |
|
quantity => luggweight, |
|
source_unit => wunit, |
|
target_unit => cast( 'G' as abap.unit ) ) as `Weight_In_Grams |
|
} |
Currency Conversion
The function CURRENCY_CONVERSION performs a currency conversion for the value passed to the formal parameter amount.
@AbapCatalog.sqlViewName: 'zcds_curr _sql' |
|
@ClientDependent: true |
|
define view zcds_curr as select from sbook |
|
{ |
|
currency_conversion( |
|
amount => loccuram, |
|
source_currency => loccurkey, |
|
target_currency => cast('EUR' as abap.cuky(5)), |
|
exchange_rate_date => order_date ) as euro_amount |
|
} |