03-10-2023 11:08 AM
Hi Experts,
I'm using the CDS in hana studio, I need to have in final report a custom field ZFIELD like this:
IF budat => sy-datum AND budat =< (sy-datum + 30). ZFIELD = '+30D'
ELSEIF budat < sy-datum AND budat => (sy-datum - 30). ZFIELD = '-30D'
How can I have?
Thanks
03-11-2023 10:53 AM
Hi Francesco,
HANA CDS native ? Long time no see... In general documentation with syntax point to same behavior
I didn't tested in CDS but I guess you can figure out with SQL sample below. Ignore the dummy party to create fake data and focus on zfield:
select *,
case when budat >= current_date and budat <= (add_days(current_date,+30)) then '+30D'
when budat < current_date and budat >= (add_days(current_date,-30)) then '-30D'
else ''
end as zfield
from
(select current_date from dummy),
(select '20230305' as budat from dummy union
select '20230310' as budat from dummy union
select '20230311' as budat from dummy union
select '20230312' as budat from dummy union
select '20230315' as budat from dummy);
Result:
Regards, Fernando Da Rós
03-10-2023 12:38 PM
Hello
have an look at https://4js.com/techdocs/fjs-fgl-manual/index.html#fgl-topics/c_fgl_odiaghdb_005.html
regards
Christian Fritsch
03-11-2023 10:53 AM
Hi Francesco,
HANA CDS native ? Long time no see... In general documentation with syntax point to same behavior
I didn't tested in CDS but I guess you can figure out with SQL sample below. Ignore the dummy party to create fake data and focus on zfield:
select *,
case when budat >= current_date and budat <= (add_days(current_date,+30)) then '+30D'
when budat < current_date and budat >= (add_days(current_date,-30)) then '-30D'
else ''
end as zfield
from
(select current_date from dummy),
(select '20230305' as budat from dummy union
select '20230310' as budat from dummy union
select '20230311' as budat from dummy union
select '20230312' as budat from dummy union
select '20230315' as budat from dummy);
Result:
Regards, Fernando Da Rós