Skip to Content
-1

get current year in ABAP CDS view

Feb 08 at 10:37 PM

384

avatar image

Hello,

I need to get the revenue of the current year in my ABAP CDS view. I tried using the environment variables which provides me the entire date. Is there any feature in ABAP CDS where I can I simply get the year like I get lv_date+0(4) in ABAP ?

Thanks,

Kabir

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Horst Keller
Feb 09 at 07:48 AM
0
Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hello Horst,

Many thanks for the response. Here is my futile attempt:

define view zabc_myview with parameters
@Environment.systemField: #SYSTEM_DATE
p_date:substring(syst_datum,1,4)
as select from but050 as rel
inner join but000 as bp on bp.partner = rel.partner2
inner join but000 as cust on cust.partner = rel.partner1
inner join zrevenue as revenue on revenue.bp_number = rel.partner1 and  
				  revenue.calyear = :p_date

There is an error at syst_datum. Tried using substring after revenue.calyear found a syntax error again. My construct is terribly wrong.

Thank You,
Kabir

0

"My construct is terribly wrong."

Indeed.

p_date:substring(syst_datum,1,4)

What should that be?

A function call in a parameter declaration?

0

The idea is to get the year from system date. for e.g. (20170101). The idea was I'll get 2017 as result. I plead guilty to my stupidity in calling function in parameter declarations. An act of desparation.

0
Kabir Siddarth Mar 23 at 10:02 PM
0

I used AMDP and Table Functions to overcome this.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Apr 30 at 10:21 AM
0

use Parameter Annotation to pass ABAP system field value to Input Parameter

define view ZSAM2 
with parameters 
    @Environment.systemField : #SYSTEM_DATE
    p_cdate : abap.dats 
as select from scarr {
    carrid,
    carrname,
    :p_cdate as today
}
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Nagababu.

The above problem is to fetch the year value from the date field and moreover above issue is closed also. Please don't reopen the closed one.

0