S/4 HANA ABAP CDS  Functions
Check of NULL value
COALESCE( arg1, arg2 )
Numeric Functions
{
abs(       num1          ) as r_abs,
ceil(      fltp1         ) as r_ceil,
floor(     dec1          ) as r_floor,
div(       num1, num2    ) as r_div,
mod(       num1, num2    ) as r_mod,
division(  dec2, dec3, 3 ) as r_division,
round(     dec3, 2       ) as r_round
}

String Functions
{
length(            char1               ) as r_length,
instr(             char1, ‘CD’         ) as r_instr,
concat(            char1, char2        ) as r_concat,
concat_with_space( char1, char2, 10    ) as r_concat_with_space,
left(              char1, 3            ) as r_left,
lower(             char1               ) as r_lower,
right(             char2, 3            ) as r_right,
lpad(              char1, 10, ‘x’      ) as r_lpad,
rpad(              char2, 10, ‘y’      ) as r_rpad,
ltrim(             char1, ‘A’          ) as r_ltrim,
rtrim(             char1, ‘E’          ) as r_rtrim,
replace(           char2, ‘GHI’, ‘XXX’ ) as r_replace,
substring(         char2, 2, 3         ) as r_substring,
upper(             char2               ) as r_upper
}
Type Conversion Functions
{
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
}
UNIT_CONVERSION
{
id,
dec3                              as original_value,
cast( ‘MI’ as abap.unit(3) )      as original_unit,
unit_conversion( quantity => dec3,
source_unit => cast( ‘MI’ as abap.unit(3) ),
target_unit => :to_unit,
error_handling => ‘SET_TO_NULL’ ) as converted_value,
:to_unit                          as converted_unit
}
CURRENCY_CONVERSION
{
id,
currency_conversion( amount => amount,
source_currency => currency,
round => ‘X’,
target_currency => :to_currency,
exchange_rate_date => :exc_date,
error_handling => ‘SET_TO_NULL’ ) as amount,
:to_currency                      as currency
}
DECIMAL_SHIFT
{
id,
@Semantics.amount.currencyCode:’currency’
amount                            as original,
@Semantics.currencyCode
currency,
decimal_shift( amount => amount,
currency => cast( ‘0 ‘ as abap.cuky(5) ),
error_handling => ‘SET_TO_NULL’ ) as shift_0,
decimal_shift( amount => amount,
currency => cast( ‘1 ‘ as abap.cuky(5) ),
error_handling => ‘SET_TO_NULL’ ) as shift_1,
decimal_shift( amount => amount,
currency => cast( ‘2 ‘ as abap.cuky(5) ),
error_handling => ‘SET_TO_NULL’ ) as shift_2,
decimal_shift( amount => amount,
currency => cast( ‘3 ‘ as abap.cuky(5) ),
error_handling => ‘SET_TO_NULL’ ) as shift_3,
decimal_shift( amount => amount,
currency => cast( ‘4 ‘ as abap.cuky(5) ),
error_handling => ‘SET_TO_NULL’ ) as shift_4,
decimal_shift( amount => amount,
currency => cast( ‘5 ‘ as abap.cuky(5) ),
error_handling => ‘SET_TO_NULL’ ) as shift_5
}
Date Function 
{
id,
dats1                                   as date1,
dats_is_valid(dats1)                    as valid1,
dats2                                   as date2,
dats_is_valid(dats2)                    as valid2,
dats_days_between(dats1,dats2)          as difference,
dats_add_days(dats1,:p_days,’INITIAL’)  as day1,
dats_add_months(dats2,:p_months,’FAIL’) as day2
}



Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Team Lead
Contact : serkurumsal@yandex.com