SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Creating Table User Defined Functions

Leveraging SQLScript in Stored Procedures, User Defined Functions, and User Defined Libraries

Overview

🎓 intermediate 15 min. SAP HANAIntermediateSqlExpress Edition

You will learn

  • โœ”How to transform a procedure to a table function.
Rich Heilman R Rich Heilman November 1, 2022
Created by September 5, 2016
Contributors

Prerequisites

Prerequisites

Steps

Intro

There are application and scenarios where you need a table function instead of procedure to leverage the advantage of direct selects on the output, for example, filtering, sorting and grouping. In the following exercise, we show you how you can easily transform a procedure to a table function.


Step 1 Create New Function
โ€”

Return to the functions folder, and right click and choose New, then Function.

New Function
New Function

  1. Enter the name of the file as get_po_counts. Then click Create.

create
create

  1. The editor will be shown

SQL editor
SQL editor

Step 2 Modify Parameters
+
Step 3 Insert Code
+
Step 4 Edit WHERE Clauses
+
Step 5 Change Variable Name
+
Step 6 Remove LIMIT Clause
+
Step 7 Add a RETURN SELECT
+
Step 8 Check Complete Code
+
Step 9 Save and Build
+
Step 10 Enter Input Parameter
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 10
1. Create New Function 2. Modify Parameters 3. Insert Code 4. Edit WHERE Clauses 5. Change Variable Name 6. Remove LIMIT Clause 7. Add a RETURN SELECT 8. Check Complete Code 9. Save and Build 10. Enter Input Parameter

Learn more →