Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

CDS View parameter within join

philipp_steidl
Explorer
0 Kudos
12,046

Hi,

whats the correct syntax to user column values as parameter values on table joins at cds views?

i want the value lfgja from table prev to be used as parameter input at the join.

define view zbc_wcr_invent_6_months
as select from zbc_wcr_invent as prev
inner join zbc_wcr_invent_plus_month( p_yearIn:  :prev.lfgja , p_monIn: :prev.lfmon)  as future1  on future1.werks = prev.werks 
{ 
key prev.mandt,
key prev.vkorg,
key prev.spart,
prev.lfgja as prevlfgja,
prev.lfmon as prevlfmon,
prev.stockvalue as prevValue,
prev.stockvalue0815 as prevvalue0815,
future1.stockvalue as ValueFuture,
future1.stockvalue0815 as value0815Future
}

the joined view:

define view zbc_wcr_invent_plus_month
with parameters p_yearIn : abap.char(4),
               p_monIn: abap.char(2)
as select from zbc_wcr_invent_prev_mon_p_func ( p_yearIn: :p_yearIn, p_monIn: :p_monIn ) {//
    key werks,
mandt,
vkorg,
spart,
lfgja,
lfmon,
sum (stockvalue) as stockvalue,
sum (stockvalue0815) as stockvalue0815
}  group by mandt,vkorg, werks, spart,lfgja,lfmon

thanks

Philipp

1 ACCEPTED SOLUTION

horst_keller
Product and Topic Expert
Product and Topic Expert
2,685

Check the documentation to see that you cannot pass columns to parameters.

https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abencds_f1_select_...

3 REPLIES 3

horst_keller
Product and Topic Expert
Product and Topic Expert
2,686

Check the documentation to see that you cannot pass columns to parameters.

https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abencds_f1_select_...

0 Kudos
2,685

Hi Horst,

If you have a view with a parameter, then if we are not able to join with other views and use those fields as input to the parameters, the only way is to wrap the view with a parameter with another view. Is that the only way?

I have a scenario, where the date is an input parameter. I need to get this input date from a join from other tables. So the only way it appears is to wrap the view with a parameter with another view without this parameter but just a field instead.

Your feedback would be appreciated. I did post another question and tagged you but I did not hear back from you.

Thanks,

Jay

0 Kudos
2,685

Why do you need the parameter? Is one more join not possible?
A date parameter requires a single date value. A literal, a parameter (with a default system field value or without), a session-variable. Even in AMDP you need something like a scalar variable. A field of a view is not scalar at all.