Procedures
Stored procedures in HANA (written in SQLScript) encapsulate database-side logic, calculations, complex transformations, multi-step operations, that run inside the database for speed. They are a key tool in the code-to-data toolkit.
ABAP can call HANA procedures (via AMDP, ABAP-managed database procedures) to push heavy logic down.
- A stored procedure is reusable SQLScript logic stored in HANA and callable by name.
- Prefer views (calculation/CDS) for read/query models, they are optimised and reusable.
- Input/output parameters and table parameters.
- Watch out: Row loops in SQLScript instead of set operations.
What procedures are for
A stored procedure is reusable SQLScript logic stored in HANA and callable by name. Procedures are used when logic is too complex for a single view or must run in steps, complex calculations, data transformations, or operations that update data, all executed close to the data for performance.
SQLScript features
- Input/output parameters and table parameters.
- Local variables and table variables.
- Control flow (IF, loops) alongside set-based SQL.
- Read-only vs read-write procedures.
When to use a procedure vs a view
Prefer views (calculation/CDS) for read/query models, they are optimised and reusable. Use procedures when you need procedural steps, side effects (writes), or logic that does not fit a declarative view. Favour set-based operations inside procedures over row loops for performance.
In SAP applications
ABAP can call HANA procedures (via AMDP, ABAP-managed database procedures) to push heavy logic down. AMDP lets developers write SQLScript within ABAP classes, combining ABAP lifecycle with HANA-side execution.
Common pitfalls
- Row loops in SQLScript instead of set operations.
- Procedures where a view would do (less reusable).
- Heavy logic in ABAP that should be pushed down (AMDP).