SAP HANA HDB Procedure – Part 3
So you made it to Part 3? Great.. I knew you were a serious SAP HANA student. In this tutorial we go back to the SAP HANA HDB Procedure and slightly increase the complexity.If you landed directly on this page without completing the Part 1 and Part 2, I highly recommend doing so before this Part 3 tutorial.
By this point in the tutorial, I hope you are quite comfortable with SQL joins in SQL join tutorial and Not the Join types tutorial.
SAP HANA HDB Procedure with Input Parameters
A simple join picking up some fields from VBAK joining with VBAP is applied below. The output fields have also been given aliases for better understanding.
1
In addition to this, we also add an input parameter p_material which should accept the input as a material number. This input parameter is then used as a where condition to our existing JOIN condition.
Thus now, the logic of this code essentially states that tables VBAK and VBAP join to provide a certain set of fields for only the material number which comes in as an input parameter to this stored procedure.
Now, switch to the SQL editor and use the CALL statement again. This time, we also need to provide the input parameter. In this example, we now run this procedure for the input parameter p_material = ‘PROD319’ which is the material number provided between the brackets shown below.
This provides us the below output which , as seen is just for the material number we called it for.
This concludes scenario-1 which showed you how to use a stored procedure to read tables and return output based on a logic. The technique was very similar to table functions and you would have realized it by now if you read the previous tutorials. As I wrote earlier, in such scenarios, table functions are the preferred approach and only they should be used whenever the only operation we need the logic to do is “Read” tables. This is one of those crossroads in SAP development when knowing what you “Should do” separates a skilled developer from a “Could do” fresher.
Thank you for reading the Part 3 of this tutorial on SAP HANA HDB Procedure. Please read on to Part 4 for the conclusion of this scenario.