Passing Input Parameter(s) from One Calculation View to Another
In HANA it is common to consume one view in another view while creating data models and most often to provide flexibility and restrict data we use input parameters in underlying view. In such cases, we need to pass these input parameters from wrapper view to inner views. We can split this requirement into two scenarios:
Scenario 1:
You have one graphical calculation view (GC_View_1) which has a mandatory input parameter (IP_1) and you are consuming this view in another graphical calculation view (GC_View_2). In this case, you need to pass IP_1 from this GC_View_2 because it is a mandatory input parameter of GC_View_1. In such scenario, you need to create an input parameter(IP_2) in your GC_View_2 and need to map IP_1 with IP_2.
A solution for this scenario is very well covered under below link:
Scenario 2:
You have one graphical calculation view (GC_View_1) which has a mandatory input parameter (IP_1), now you are consuming this view in a script calculation view (SC_View_2). In this case, you need to map input parameter of SC_View_2 to GC_View_1.
Although as per latest guidelines from SAP we should avoid using Script Calculation view however if you still have a use case where you need to use a script view then here is the solution for such use cases.
Just for the sake of simplicity and ease of understanding, I am covering this scenario with a very simple example.
I have created a graphical calculation view GC_View_Sal in which IP_Country is the mandatory input parameter:
Output:
Now I have created a wrapper view which is a script calculation view and in this view, I will call my graphical view:
Initially, I copied the select query from Job Log of my graphical calculation view and paste it into my script view:
As you can see in above screenshot $$IP_COUNTRY$$ has hard coded value US because this is what I passed while previewing data of my graphical view. In the real use case, this selection has to be dynamic and to make this selection dynamic I have created an input parameter IP_COUNTRY_SC in my script view.
And finally, now we need to map this IP_COUNTRY_SC with IP_COUNTRY of our graphical calculation view. So here is the mapping syntax:
Note: If you make any changes in above syntax like put PLACEHOLDER under quotes or used single quotes for $$IP_COUNTRY$$ instead of double quotes then you will receive syntax error.
Pasting syntax below so that you can copy and use it in your view:
One input parameter:
(PLACEHOLDER.”$$IP_COUNTRY$$” => :IP_COUNTRY_SC)
Multiple input parameters:
(PLACEHOLDER.”$$IP_1″ => :IP_1_SC,
PLACEHOLDER.”$$IP_2$$” => :IP_2_SC)
View Output:
This helps a lot!! Thank you.
We have a question , while passing multiple parameter can following be achieved ,
(PLACEHOLDER.”$$IP_1$$″ => :IP_1_SC,
'PLACEHOLDER' = ('$$IP_2$$', '2')) ---- "lets assume, that for second parameter we need to pass constant value, hence number 2.
while trying this, it's giving syntax error. tried placing additional '(' but didn't work out.
Appreciate your inputs!!.
Thanks.
Hi Amit,
Thanks for appreciating the efforts.
As far as I know Script View still does not support passing of multiple values. I tried passing multiple values for one of my scenario as well and it did not work.
Regards,
Abhishek
Good day Abhishek,
I was exactly looking for something you described in scenario 1 but you link seems to be dead.
Can you help me with the correct one?
Thanks in advance,
Djim
Hi Djim,
You are right that link is broken now, but don't worry I found out the new link, hopefully this will help:
https://help.sap.com/viewer/52715f71adba4aaeb480d946c742d1f6/2.0.02/en-US/d7155860bb571014bb2dbe4e75bab58a.html
Cheers,
Abhishek
Thanks Abhishek!
Thank you Abhishek!
Very useful!
I made a small mistake while adapting the second scenario.
So I'd like to share it here so other users don't make the same mistake I did...
I gave my source an alias in the FROM clause.
But when doing that you have to use your code snippet before the alias definition, otherwise you'll encounter an error!
So looking at your example, the correct code with an alias would be;
FROM "_SYS_BIC"."abhisheagraw/GC_VIEW_EMP_SAL" (PLACEHOLDER.”$$IP_COUNTRY$$” => :IP_COUNTRY_SC) as EMP_SAL
Hope it helps!
Cheers,
Mattia