I have a requirement to run DATS_DAYS_BETWEEN function only if right parameter date is non blank. However CASE statement doesn't allow me to use function in WHEN statement. We want to keep such records so filtering them beforehand may not help.
WHEN AR.bldat ='00000000'
ELSE cast(dats_days_between(cast(today_date as abap.dats), AR.bldat) as abap.dec(5,0))
END as days