ABAP CDS on HANA-9

cds

Conversion Functions for Currencies and Units in CDS view

 

 

Function CURRENCY_CONVERSION performs a currency conversion for the value passed to formal parameter amount.The currency conversion is performed on the basis of the rules stored in the database tables TCURR.

 Function UNIT_CONVERSION performs a unit conversion for the value passed to formal parameter quantity.The unit conversion is performed on the basis of the rules stored in transaction CUNI and in the database tables T006.

Function DECIMAL_SHIFT sets the decimal separator of the value that is passed to formal parameter amount according to a currency.

Below post shows to perform a currency conversion. We have SFLIGHT entries with respect to carrid ‘AA’ where price is available in USD but our CDS view should show a price in a different currency.

1

The CDS view with currency_conversion function, pass the amount to be converted, source currency, target currency and the exchange rate date.

2


@AbapCatalog.sqlViewName: ‘ZFLIGHT_VW’
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: ‘Flight View with Aggregation Operation’
define view Zflight_View
with parameters p_curr: abap.cuky(5),
p_dat:abap.dats
as select from sflight as s
{
key s.carrid,
key s.connid,
key s.fldate,
currency_conversion( amount => s.price,
source_currency => s.currency,
target_currency => :p_curr,
exchange_rate_date => :p_dat ) as local_amount,

:p_curr as local_currency

} where carrid = ‘AA’


Data Preview: provide the target currency and the date.

3

Here is the amount in the target currency.

4


Syntax for Unit_Conversion Function.

unit_conversion( quantity =>  ”,
                                  source_unit => ”,
                                  target_unit => ” ,
                                  error_handling => ” )


Syntax for Decimal Shift Function.

decimal_shift( amount => ”,
                              currency => ”,
                              error_handling => ‘ ‘ ) 


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s