Hi Experts,
I've question about user defined functions UDF - scalar type.
In my CDS view I tried to use currency_conversion function - with success.
@AbapCatalog.sqlViewName: 'Z079MM_CV_CDS_07'
@EndUserText.label: 'MBEW'
define view Z079mm_Cv_Mebew_Z_Ext
with parameters p_to_currency:abap.cuky(5), p_exc_date:abap.dats,
as
select from mbew join t001k on mbew.bwkey = t001k.bwkey join t001 on t001k.bukrs = t001.bukrs
{ key mbew.bwkey, key mbew.matnr, key mbew.bwtar, lbkum, salk3, :p_to_currency as currency,
/////----------->here
currency_conversion( amount => salk3, source_currency => waers, round => 'X', target_currency => :p_to_currency, exchange_rate_date => :p_exc_date ) as salk3_cur
}
This function is defined by SAP in schema SAPABAP1:
![c.jpg]()
Later I wanted to use my function DIV_CURR defined in schema EXRMATUSZEWSKI:
@AbapCatalog.sqlViewName: 'Z079MM_CV_CDS_09'
@EndUserText.label: 'MBEW'
define view Z079mm_Cv_Mebew_Z_Ext2
with parameters p_to_currency:abap.cuky(5), p_exc_date:abap.dats
as
select from mbew join t001k on mbew.bwkey = t001k.bwkey join t001 on t001k.bukrs = t001.bukrs
{ key mbew.bwkey, key mbew.matnr, key mbew.bwtar, lbkum, salk3, :p_to_currency as currency,
currency_conversion( amount => salk3, source_currency => waers, round => 'X', target_currency => :p_to_currency, exchange_rate_date => :p_exc_date ) as salk3_cur,
/////----------->here div_curr(salk3,2) as result2 //"EXRMATUSZEWSKI"."DIV_CURR"(salk3,2) as result3
}
}fffd
but compilator says "Function div_curr is unknown". I tried to add schema name but it not worked.
Both functions are scalar functions and are defined in similar way:
![d.jpg]()
What is wrong with my code in CDS view? Is my own function really unreachable from CDS view?
In contrast in SQL console:
this works:
select div_curr(10,2) as result
from dummy
this is not working:
select currency_conversion( amount => '1000', source_currency => 'PLN', rounding => 'X', target_currency => 'EUR', exchange_rate_date => '20151211' ) as salk3_cur from dummy
select "SAPABAP1"."CURRENCY_CONVERSION"( amount => '1000', source_currency => 'PLN', rounding => 'X', target_currency => 'EUR', exchange_rate_date => '20151211' ) as salk3_cur from dummy
Again why? what's the difference between those functions?
Best regards
Rafal