Skip to Content

SAP CDS how to perform a join with a view that needs parameters as inputs from another join

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_parameters.htm

Thanks

Jay

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.