Restricted column in SAP HANA
Welcome to the next tutorial in this series where we learn how to work with the concept of Restricted columns in SAP HANA. Just as the name suggests, a restricted column is a user created column that is restricted in it’s output by a condition that we specify.
For example, if we do not want everyone to see all the data in a field but based on a condition we decide whether this data should be displayed or not. This will become much more clear from our use cases below.
Restricted Column – An illustrated Example
Let’s say we want to create a new restricted column called RESTRICTED_NETWR which should show values only when the corresponding value in field AUART is ‘SO’. To achieve this, first right click on the “Restricted Columns” field on the right and select “New” from the context menu as shown below.
The below screen pops up demanding technical name and description as always in the “Name” and “Label” column respectively. The column drop down is used to select the numerical field on which this restriction needs to be applied- which in this case is NETWR. In the restrictions section, you can choose to apply a simple restriction using an existing field or if it is a complicated condition, use the Expression editor via the radio button.
In our current scenario, the restriction is simple – AUART = ‘SO’ so we do not need the expression editor.
Fill in these values as shown below. And press Ok.
Save and Activate your view. Now do a data preview to check if this works.
As seen below, the RESTRICTED_NETWR field displays values only where AUART = SO as specified by our restriction.
Conditions for restrictions are not always static. This means that there are requirements where conditions are provided to be provided by the user on run-time. Let’s take an example where there would be an input parameter that specifies the value of AUART for which the values of RESTRICTED_NETWR must be displayed.
To achieve this, first let’s create a new Input parameter to capture the AUART value. Right click on “Input Parameters” and click on “New”.
Provide the values as shown below.
Now we have a new input parameter P_AUART ready for capturing values on run-time.
Double click on the RESTRICTED_NETWR field to edit it.
This time, we need to take value of AUART from an input parameter and hence this requires the use of the expression editor.
It asks for your confirmation to move even the existing condition into the expression editor. Press Ok.
We see that the old condition we had is also now converted into an expression code. All we now have to do is to replace ‘SO’ by the input parameter. Delete SO and double click on our P_AUART to add it in.
The expression editor should look like the image below.
Press Ok. Then, save and activate the view. Run the data preview and you would get the below value entry screen. Here I fill out the old input parameters with some values as well as the new P_AUART with value of ‘SO’.
As seen from the output below, our dynamic restriction worked perfectly and RESTRICTED_NETWR only shows values now for the ‘SO’ AUART.
Let’s try again for a different AUART field value. This time we fill the value with ‘TA’ whilst keeping the other values constant.
As seen below, only ‘TA” values now display the restricted column. Hence, our condition was successful.
I hope a restricted column is something easy to create from now on for everyone who read this tutorial.Comment below with your thoughts.
Please show your support for this website by sharing these tutorials on social media by using the share buttons below. Stay tuned for the next ones.