IT CanvassTalk to an advisor
SAP HANA · LessonBy , SAP Trainer, 10 yrs · Published · SAP S/4HANA 2023 · all levels

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.

Quick answer

ABAP can call HANA procedures (via AMDP, ABAP-managed database procedures) to push heavy logic down.

Key takeaways
  • 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).

Practice challenge

+0 XPStreak ×0
Question 1 of 3
Which statement is true of Procedures?

Frequently asked questions

What does the term Procedures refer to in SAP?
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.
What is another point to note about Procedures?
ABAP can call HANA procedures (via AMDP, ABAP-managed database procedures) to push heavy logic down.
What else is worth knowing about Procedures?
A stored procedure is reusable SQLScript logic stored in HANA and callable by name.
What tends to go wrong with Procedures?
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).
Already working on SAP and stuck on a live ticket?Get an expert SAP developer on screen-share to finish your daily tasks with you. Deliver on time, protect your reputation and your job. Monthly support only, no task-wise plans.Task assigned · no idea where to startStill stuck · your job on the lineExpert joins your screenDelivered on timeExplore On Job Support