SAP HANA Scripted Calculation View input parameters
Welcome again to our next tutorial. You’ve already learn about dynamic filtering on the output of a calculation view using variables in our previous tutorial. This tutorial deals with another type of dynamic filtering – SAP HANA Scripted Calculation view input parameters. These dynamic filters, based on user input, allow filtering to be done inside the core logic of the HANA SQL Script.
Creating an SAP HANA Scripted view input parameter
We continue with the state of code we have from our previous tutorial.
Click on your script_view node to open up the code. To create a new input parameter, right click on the “Input Parameters” folder and click “New” from the context menu.
This opens up the below pop-up window. Primarily, the data required is a name and label for this parameter and its datatype.
The name and label has been filled up as P_DOC_TYPE since we will try to use this as a filter on P_DOC_TYPE in this view. The datatype of this input parameter has been also entered as NVARCHAR string of length 10 characters.
Please note that unlike variables, Input parameters are not linked to any fields while being created. Although the variable name is P_DOC_TYPE, it could be used in any place where you require an input parameter of the same datatype. Doing that would be not recommended though, since naming the variable something and using it somewhere else could be confusing for someone else who reads the code.
Press OK after filling the information as below.
This brings us back to the code. Earlier, we had hard coded the filter for document type field AUART to the value ‘TA’ but now we remove that and instead of it, place the input parameter. Notice that the colon symbol precedes the input parameter name whenever used in an SAP HANA SQL Script code. So the input parameter P_DOC_TYPE will be written as :P_DOC_TYPE in the code as shown below.
Now what the input parameter does in the below case is that it tells the HANA system that the AUART field has a filter on it which will be provided at runtime by the user. Notice that only input parameters can provide this dynamic filtering at the code level.
Due to this, data can be filtered before the join executes and precious memory is not wasted in retrieving data which is not required.
Save and activate the view.
Once done, execute the data preview. This would again bring up the pop up asking for values of the Material Variable we created earlier and also the new P_DOC_TYPE input parameter.
Since the material variable was not mandatory, we leave it empty for now and fill in P_DOC_TYPE with the value ‘TA’.
As seen below, the distinct values tab confirms that only the value TA is present for filed DOC_TYPE.
This concludes our tutorial on SAP HANA Scripted calculation view input parameters. Thank you for reading. I hope it was easy to comprehend.
Be sure to help this website grow by using the share buttons to spread this post on social media. This will also keep me motivated to write more.