SAP HANA Table Function linking with Calculation view Input Parameters
This tutorial is a continuation of the SAP HANA Table Function Part-1 tutorial and Part-2 tutorial. Please read them first if you have directly landed on this page.
SAP HANA Table function (Contd..)
To understand how input parameters work with an SAP HANA table function, we continue with the same example we used earlier. Go to the repositories tab again and double click on our table function to edit it.
Let’s say the new requirement is to have an input parameter take the value of a sales document from the user and this sales document number should be used as a filter in our select statement.
To start off, as explained earlier, in Line 1 of the code, the round brackets should enclose the input parameter(s) we require in the code. In this case, we create one called p_sales_doc of datatype NVARCHAR and length 10 as shown below.
Also, modify the SELECT statement to include the WHERE condition as shown below. Here we tell HANA that we need only values where the value of sales document (VBELN field of table VBAK) matches the value specified by the input parameter p_sales_doc.
Note: As explained earlier in the scripted calculation view tutorial, input parameters are used in SQL codes with a colon (:) suffix.
Activate the table function again using the Activate button marked below.
Once this is done, switch back to the Systems tab and open the Calculation view we created for this table function in the previous tutorial.
Click on the projection tab to open the fields and other properties.
The calculation view cannot automatically detect an input parameter coming in from the table function. Therefore, we need to create an input parameter for this calculation view with the same data type and map the input parameter from the table function to the one of this calculation view.
To start off, right click on the input parameters folder and select “New”.
In the window that opens up, then we provide the same name and data type as the table function parameter.
Note: It is not mandatory to have the same name. It was just kept the same here for consistency. Data types and lengths should ideally be compatible and preferably same.
Press OK when done.
We now see that the input parameter has been successfully created.
The next step is to establish a connection between the table function’s input parameter and the calculation view’s input parameter.
To do this, right click on Input parameters and click on “Manage Mappings”.
On the left side, you would see the input parameter from the table function and on the right hand side the calculation view input parameter would be present as shown below.
Drag the one on the left and drop it on the right one to create a mapping.
Once you drag and drop it, the mapping would get established as illustrated below.
Press Ok to confirm the mapping.
Even after the mapping, you would see no difference in the view properties though.
Activate this view now.
Execute a data preview. This would bring up the pop-up asking for a value for the sales document number.
A sales document number that exists in this table is entered as an example. Press Ok.
As seen below, the filter was passed on to the logic of table function and it got applied successfully. Only the row with the selected sales document was sent to the output.
This confirms that our table function and the input parameter mapping was a success.
Help this website grow by sharing this document on social media by using the icons below. Be sure to subscribe to our newsletter when the message pops up for latest alerts on new tutorials.