06-29-2020 8:29 AM
I am joining several tables. In the join, I am getting a range of dates - begin date and end date. I need to pass this into a CDS view with parameters. But I am unable to pass the fields from the join as parameters. Is there a way to do this?
Here is my code snippet. The problem is that I am unable to take the fields from the _pallocdates and pass them as parameters to the ZOTC_I_PRODALLOC_SUMMED which is a table that uses these dates to calculate the sum of the quantities.
define view ZOTC_I_PRODALLOC_SEARCH
with parameters p_input_date : abap.dats // Take the date as the input to add flexibility instead of just system date
as select from I_ProdAllocQuantityAssignment as paqty // Get the ProAllocAssignedOrder and Item
inner join I_ProdAllocSequenceConstraint as paconstraint
on paqty.ProdAllocSqncConstraintUUID = paconstraint.ProdAllocSqncConstraintUUID
left outer join ZOTC_I_PRODALLOC_DATES( p_input_date: :p_input_date ) as _pallocdates
on _pallocdates.ProdAllocSqncConstraintUUID = paconstraint.ProdAllocSqncConstraintUUID
and _pallocdates.ProductAllocationObjectUUID = paconstraint.ProductAllocationObjectUUID
left outer join ZOTC_I_PRODALLOC_SUMMED( p_startdate : _pallocdates.CalculatedStartingDate, p_enddate : _pallocdates.EndingStartingDate)
Here is my ZOTC_I_PRODALLOC_SUMMED:
@AbapCatalog.sqlViewName: 'ZOTC_PRODALCSUM'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Product Allocation Summed'
define view ZOTC_I_PRODALLOC_SUMMED
with parameters
p_startdate : prodallocationperiodstartdate,
p_enddate : prodallocationperiodstartdate
as select from ZOTC_I_PRODALLOC {
key ProductAllocationObjectUUID,
key CharcValueCombinationUUID,
sum(ProductAllocationQuantity) as SummedProductAllocationQty
} where ProdAllocationPeriodStartDate between :p_startdate and :p_enddate
group by ProductAllocationObjectUUID, CharcValueCombinationUUID
Do I need to change ZOTC_I_PRODALLOC_SUMMED so that this does not use parameters for the join to work?
horst.keller - I saw a post that you said that this was not possible (but that was a while back so I was wondering if that has changed. Any suggestions? Here is the link to the article you had replied to CDS View parameter within join
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_...
Thanks
Jay