Skip to Content

Call a CDS view from another CDS View with parameters

Hello experts,

I have CDs view1 with two-parameter I am calling in CDs view2 the view2 has one parameter from that I need to get data and that data need to pass to view1 parameters.

define view ZPS_QTY_SUM //view1

with parameters P_MATNR : matnr, P_WERKS:werks_d

as select from nsdm_e_mard { sum(labst) as Total } where matnr = $parameters.P_MATNR and werks = $parameters.P_WERKS and lgort <> '1900' group by matnr,werks

define view ZPS_COLOR //view2

with parameters P_PLNUM:plnum

as select from resb as a {

a.matnr ,

a.werks

// //////////////////////////////select * from ZPS_QTY_SUM(p_matnr:a.matnr,p_werks:a.werks )

} where plnum = $parameters.P_PLNUM

Please help me to achieve this requirement. thanks in advance.

Thanks

Srinivas

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Apr 08 at 08:25 AM

    It is not possible to pass column values as parameter values. Please check the documentation here.

    The question is why you need that construct with parameters at all. Looking at your example it seems everything can be done with a standard join or association.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 08 at 09:27 AM

    Hello Alluri Srinivas,

    Basically the thing is, any query fetches the data at once based on the condition(joins/where).

    Here what you are trying to achieve is for every record fetched from view 2 u are applying that as condition to get the data from view 1. Which I don't think is a feasible solution and that's why its not possible with what you are trying to do and that's why its not supported by CDS views As well at the moment.

    For this you can simply create another view for view1 if you still want to use the parametered cds view view1 and write a join/association to view2.

    See the below code.

    define view ZPS_QTY_SUM //view1 with out parameter
               as select from nsdm_e_mard 
    { sum(labst) as Total } 
     where lgort <> '1900' group by matnr, werks.
    
    
    define view ZPS_COLOR //view2
          with parameters P_PLNUM:plnum
    as select from resb as a 
     association [0..1] to ZPS_QTY_SUM as b on
        b.matnr = a.matnr and
        b.matnr = a.matnr
    {
    a.matnr ,
    a.werks
    } where plnum = $parameters.P_PLNUM
    
    

    this will work out for you hopefully.

    Regards,

    Rahul.

    Add a comment
    10|10000 characters needed characters exceeded

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.