Skip to content
✦ Made with Docsie · generated from video

How to Create a Function Module in SAP

This guide covers the basics you need before you create a function module in SAP ABAP: what function modules are, what they contain, and how to open the Function Builder. You then build a complete report that prompts for a number and calls the predefined SPELLAMOUNT function module to convert it into words. The example shows how to set up the function call, handle the return code, and run the finished report.

SAP 13 steps 9 screenshots 1128 words Source video 10:14 Generated cost $3.85

Video: SAP ABAP - Function Module by TutorialsPoint (2018). All credit for the demonstration goes to the creator; watch the original on YouTube. The written guide below was generated from this video by Docsie. Creator? Request a change or removal.

This guide covers the basics you need before you create a function module in SAP ABAP: what function modules are, what they contain, and how to open the Function Builder. You then build a complete report that prompts for a number and calls the predefined SPELL_AMOUNT function module to convert it into words. The example shows how to set up the function call, handle the return code, and run the finished report.

Prerequisites

  • Access to the SAP Easy Access screen.
  • The ability to open transactions SE37 (Function Builder) and SE38 (ABAP Editor).
1

Understand what function modules are

Before you create a function module in SAP ABAP, it helps to know how function modules work:

  • Function modules are sub-programs that contain a set of reusable statements with importing and exporting parameters.
  • Unlike include programs, function modules can be executed independently.
  • SAP provides several predefined function modules that you can use in different programs.
  • You can also create custom function modules.
  • Function modules are grouped into function groups, which act as containers for logically related modules.
2

Learn the components of a function module

Every function module is built from the following components:

  • IMPORT: Input to the function module.
  • EXPORT: Output from the function module.
  • EXCEPTIONS: Handle specific types of errors in the function module.
  • TABLES: Internal tables (ITABs) that act as importing and exporting parameters.
  • CHANGING: A variable or work area (WA) that acts as both an importing and an exporting parameter.
Slide titled "Function Module" listing the characteristics of function modules and a numbered list of their components
Slide titled "Function Module" listing the characteristics of function modules and a numbered list of their components
3

Open the Function Builder to start working with function modules

The Function Builder is where you view and create function modules in SAP.

  1. Go to the SAP Easy Access screen.
  2. Enter SE37 in the command field to open the Function Builder.
SAP Easy Access screen with se37 entered in the command field to open the Function Builder
SAP Easy Access screen with se37 entered in the command field to open the Function Builder
4

Create the program for the function module example

In this example, the report prompts the user for a numeric amount. When the user runs the report, the SPELL_AMOUNT function module converts the entered number into words.

  1. Go to transaction SE38 to open the ABAP Editor.
  2. Create a new program named Z_SPELLAMOUNT.

The "Example on Function Modules" slide summarizes the overall approach:

  • Create the program in SE38.
  • Enter code that sets up a parameter, so a value can be entered and passed to the function module. The text element text-001 reads "Enter a Value".
  • To write the function call, use CTRL+F6. In the window that appears, CALL FUNCTION is the first option in the list. Enter spell_amount in the text box and click the continue button.
Slide titled "Example on Function Modules" with the steps for creating and coding the Z_SPELLAMOUNT program in SE38
Slide titled "Example on Function Modules" with the steps for creating and coding the Z_SPELLAMOUNT program in SE38
5

Switch to change mode

If the report opens in display mode, switch to change mode so you can edit it. Confirm that the title bar reads ABAP Editor: Change Report ZSPELLAMOUNT.

6

Define a result structure for the output

Declare a variable above the function call to hold the output of the function module.

  1. Enter the following line at the top of your report:

DATA result LIKE spell.

  1. Note that this creates a variable result based on the predefined structure spell, which the output requires.

For reference, SPELL is a predefined SAP structure that stores the output of SPELL_AMOUNT. It contains fields such as NUMBER, DECIMAL, CURRDEC, and WORD, which represent the amount in words and related details. You can view its definition in the Data Dictionary.

ABAP Editor with the line "Data result like spell." added above the function call
ABAP Editor with the line "Data result like spell." added above the function call
7

Add a parameter for user input

Define a parameter so the user can enter the amount to convert.

  1. Add the following line near the top of your report:

PARAMETERS: num_1 TYPE I.

  1. Note that this creates an input field where the user enters an integer value.
ABAP Editor with the line "parameter num_1 TYPE I." added to provide a user input field
ABAP Editor with the line "parameter num_1 TYPE I." added to provide a user input field
8

Insert the function module call

Use the pattern tool to add the function module call to your function module example.

  1. Place the cursor where you want the function call.
  2. Click the Pattern button in the ABAP Editor toolbar.
  3. In the Ins. statement dialog, select CALL FUNCTION.
  4. Begin typing spell_amount in the function name field and select it from the dropdown.

Click the green checkmark (Continue/Enter) to insert the template. The editor adds a code block for CALL FUNCTION 'SPELL_AMOUNT' with exporting, importing, and exception parameters, mostly commented out.

ABAP Editor with the Ins. statement dialog open, CALL FUNCTION selected, and spell_amount being entered
ABAP Editor with the Ins. statement dialog open, CALL FUNCTION selected, and spell_amount being entered
9

Configure the function module call

Edit the inserted template so it passes your input and captures the result.

  1. Uncomment the EXPORTING and IMPORTING parameter sections.
  2. Remove the EXCEPTIONS section if your program doesn't need it.
  3. Set the parameters as follows:
    • AMOUNT = num_1
    • CURRENCY = '' (leave blank if not required)
    • FILLER = '' (leave blank if not required)
    • LANGUAGE = SY-LANGU
    • IN_WORDS = result

The code should look like this:

CALL FUNCTION 'SPELL_AMOUNT'
  EXPORTING
    AMOUNT   = num_1
    CURRENCY = ''
    FILLER   = ''
    LANGUAGE = SY-LANGU
  IMPORTING
    IN_WORDS = result.
10

Add error handling and output logic

After the function call, check the return code sy-subrc to see whether the function module ran successfully.

  • If sy-subrc is not equal to 0, the program outputs the returned value.
  • If sy-subrc is 0, the program outputs the converted amount using the result-word field.

Enter the following code after the function call:

IF sy-subrc <> 0.
  WRITE: 'Value returned is:', SY-SUBRC.
ELSE.
  WRITE: 'Amount in words is:', result-word.
ENDIF.
ABAP Editor showing the completed IF/ELSE logic with the WRITE statements for the amount in words and the returned value
ABAP Editor showing the completed IF/ELSE logic with the WRITE statements for the amount in words and the returned value
11

Save the report

Click the save icon (floppy disk) in the ABAP Editor toolbar, or press Ctrl+S. Make sure there are no syntax errors before you continue.

ABAP Editor with the save icon highlighted and the completed code visible
ABAP Editor with the save icon highlighted and the completed code visible
12

Activate the report

If prompted, activate the report so you can run it. In the Inactive Objects dialog, select your report (ZSPELLAMOUNT) and confirm the activation.

Inactive Objects dialog with ZSPELLAMOUNT selected for activation
Inactive Objects dialog with ZSPELLAMOUNT selected for activation
13

Execute the report and verify the output

  1. Run the report.
  2. Enter a numeric value when prompted, for example 2314.
  3. Check the output screen. It should display the amount in words:

Amount in words is: TWO THOUSAND THREE HUNDRED FOURTEEN

Summary

By following these steps, you have:

  • Reviewed what function modules are and how their components work.
  • Opened the Function Builder with SE37.
  • Built a report that calls the SPELL_AMOUNT function module with a user-entered value.
  • Implemented error handling for the function module call.
  • Displayed the result in words when the function executes successfully.
  • Saved, activated, and executed the report to verify it works.

Your ABAP report now lets users enter a number and receive its value in words. The example shows how parameters enable user input, how SPELL_AMOUNT does the conversion, and how modularization lets a function module run independently of the report that calls it.

Generation details: cost, quality tiers

Docsie billed 5,500 credits ($3.85) to analyze this 11-minute video at standard quality. The rewrite, template fill and Word/PDF exports were included. The same video at each quality tier:

QualityFrames sampledCreditsApprox. cost
Draftevery 16-30 s2,750$1.92
Standard (this guide)every 8-15 s5,500$3.85
Detailedevery 4-7 s11,000$7.70
Ultraevery 1-3 s22,000$15.40

Credits priced at $0.70 per 1,000; plans include a monthly allowance. Enterprise customers on on-premise or bring-your-own-model deployments run this on their own inference and pay no per-video credits.

Generated by Docsie Video-to-Docs on 2026-11-15 from a 10-minute video. Screenshots are frames from the source video and belong to their creator, TutorialsPoint, whose original is embedded above. If you own this video and want the guide removed or credited differently, contact us and we will act within one business day.

Turn your own training videos into guidesJoin teams that save hours, reduce documentation work and scale training with Docsie.
See Docsie in action. No commitment.

Ready to Transform Your Documentation?

Start creating professional documentation that your users will love