Professional Documents
Culture Documents
Creating A New Program: Step 1 Step 2
Creating A New Program: Step 1 Step 2
modularized code using function modules, allowing for code reuse, by themselves, their
developers and also by their customers.
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 system contains several predefined function modules that
can be called from any ABAP program. The function group acts as a kind of container for
a number of function modules that would logically belong together. For instance, the
function modules for an HR payroll system would be put together into a function group.
To look at how to create function modules, the function builder must be explored. You can
find the function builder with transaction code SE37. Just type a part of a function module
name with a wild card character to demonstrate the way function modules can be
searched for. Type *amount* and then press the F4 key.
The results of the search will be displayed in a new window. The function modules are
displayed in the lines with blue background and their function groups in pink lines. You
may look further at the function group ISOC by using the Object Navigator screen
(Transaction SE80). You can see a list of function modules and also other objects held in
the function group. Let's consider the function module SPELL_AMOUNT. This function
module converts numeric figures into words.
IF SY-SUBRC <> 0.
Write: 'Value returned is:', SY-SUBRC.
else.
Write: 'Amount in words is:', result-word.
ENDIF.
Step 5 − The variable which the function module returns is called IN_WORDS. Set up the
corresponding variable in the program called ‘result’. Define IN_WORDS by using the
LIKE statement to refer to a structure called SPELL.
Step 6 − Save, activate and execute the program. Enter a value as shown in the following
screenshot and press F8.
The above code produces the following output −