Filters:Type 3- SAP HANA Input Parameters

Input parameters are the magical underappreciated providers of flexibility in SAP HANA. They are somewhat similar to variables but are available at every node in the view. Input parameters are of great importance and have multiple applications but here we learn how to use it as a dynamic filter at the lowest node.

Input Parameters explained with an example

Let’s say we need to add a filter on field GRUPP from VBAK table. When the user selects a value during data preview, this filter should be applied to Projection_1 and thus only the reduced data set should undergo further calculations. This is the requirement. In this case variable can’t be used as we need to apply this dynamic filter at a lower node level and not at the top level.

First things first- Let’s add one more field GRUPP to the view by propagating it to semantics and then activating the view again.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS

Now, single click on the VBAK node if you already haven’t and then on the right side, you would see a folder for Input Parameters as shown below. Right click on it and select “New” to create a new one.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS



1

1

The below window appears which is similar to our variable creation screen. Give it a name and a description.

Notice that there is no attribute to bind this value to here. Input parameters can be created independent of fields unlike variables. Picture them as a value that can be used anywhere and this value being dynamic, can be entered at run-time by the user. Provide a datatype and length of this input parameter. Press OK.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS

Notice that an input parameter has been created and appears in the folder as shown below. Now, double click on the “Expression” under filters.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS
This opens up the expression editor. You can see here that the static filter that we applied earlier also appears here. We created it by simply right clicking the VBTYP field and assigning a filter value = ‘C’ there but due to that the system auto-creates the corresponding filter expression code in here. Notice that it is greyed out because there was no manual coding of filters yet. But with curious developers like us, we have to explore the options that lie ahead! Press the Edit button marked below.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS



1

HANA throws us a warning that from now on, filters for this projection can only be maintained as an expression code. This means that no more rights click + apply filter functionalities will work in this node. Every time you need a filter (even a static one) you would have to add a small bit of code here. We do this because Input Parameters can only be added as filter via the expression editor. Press OK to move ahead.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS

This opens up the expression editor for editing. Place an AND operator after the existing filter to tell HANA that you are adding a second condition here.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS

After the AND, add an opening brace of a bracket and double click on the GRUPP field as shown below.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS

This adds the GRUPP field into the expression editor. Now, we need to tell HANA that the filter is GRUPP = The input parameter. Place an equal sign and double click on the parameter name as shown below.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS

Close the bracket after the expression has been written as shown. Notice that the input parameter is always represented as covered by single quotes and double dollar signs on either side whenever used in a code.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS

Press OK, save and activate the view. Click on data preview to bring up the selection screen where along with the V_VKORG variable, you now have the P_GRUPP input parameter. In this case, I provide it the value 1200.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS

The data preview opens up and it looks like GRUPP has only the 1200 values.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS

Just to be sure, let’s check the “Distinct Values” tab. Dragging and dropping GRUPP here confirms that the only values it has are all ‘1200’.

SAP HANA INPUT PARAMETERS IN GRAPHICAL VIEWS CALCULATION VIEWS

Thus, we successfully used input parameters as filters.

There are also further usages of Input parameters which we would learn as we progress. One step at a time.

Major differences between Input parameters and variables in SAP HANA

The differences are:

  1. Variables apply filter after execution of all nodes till the semantics (at the top level) whereas Input parameters can apply filters at any projection level.
  2. Variables are bound to attributes/specific fields whereas an input parameter is independent of any field in the view.
  3. Variables have a sole purpose of filtering data whereas filtering is only one of the reasons to use an input parameter.

Thank you for reading this tutorial. Please help this website grow by sharing the document on social media using the share buttons below and subscribe to our newsletter for the latest updates.

<<Previous Tutorial                                                                                           Next Tutorial>>

Tagged , , , , , , , , , .

94 Comments

  1. Hi,
    We see that there are 4 types of input parameters. And in the filter option (in data foundation of analytic view) we have option of ‘list of values’. I was trying to have input parameters as ‘list of values’ and the value help comping from a ‘column’ of a table (COLUMN i/p parameter type) or (DERIVED from table). But as the value help i am not able to select a list of values. Can you help please

  2. Hi shyam,
    i did not understood this point.
    Variables have a sole purpose of filtering data whereas filtering is only one of the reasons to use an input parameter.
    what are the other usages of ip parameter ?

    • Input parameters can be used in dynamic calculations to make any statement dynamic. Simple example would be to have an input parameter called bonus_factor. Let’s say there’s a new calculated field BONUS which should be equal to SALARY* bonus_factor . so bonus_factor comes in as part of user input and helps derive a calculated field. Variables can’t do this.

  3. Hi Shyam,

    Thanks for the great post. Trust me, I have been following you from the days of my core BW understanding. Your posts are simply unique.
    I have a question – You said that Variables apply filter right at the end when all the nodes have been processed. However, according to SAP Best practise, We should restrict the data at the initial stage as much as possible which improves the overall performance.
    Please tell me, why is variable used in HANA then? I believe Input parameters as filters should be used so that we can apply anywhere as filter in initial nodes in place of variables everywhere.

    Thanks,
    Gaurav

    • Variables are a bit tricky.. they may or may not push down the filter based on how that field gets propagated from the source to target… there are many factors.. types of joins, whether any calculations were performed on it.. and so on. Variables are propagated to SAP reporting tools like WebI but don’t work with 3rd party tools like Cognos. I use input parameters extensively and don’t really use variables ..but as I said, in SAP Business Objects based reporting scenarios, it may work out.

  4. Hi Shyam, very good posting. I have one question regarding input parameter and a variable. How does the input parameter behaves and shows the results when we won’t provide any input to the non-mandatory input parameter?

    • This bug exists in some of the HANA versions. If you are applying only simple filters that can be done from the GUI, you should not edit and write these filters. If you need to write advanced filters, remove all existing filters and then it will allow you to write custom filters.

Leave a Reply

Your email address will not be published. Required fields are marked *