The function modules are very common used artefact in SAP. Despite the fact that most of the new development in classic ABAP is carried out with the object-oriented approach, there are still areas that cannot be implemented without the use of a functional module for example RFC and some types of extensions.
PREREQUISITES:
- Access to any SAP system based on either SAP Netweaver or ABAP Platform
- SAPGUI installed on your local PC
- Authorization to access SE37
- Developer key for system based on Netweaver
- ABAP Function Group (How to create ABAP Function Group)
Step 1. Go to transaction SE37 (ABAP Function Modules). Put “SE37” in the command field and hit Enter:
Step 2. In Function Module field put name of function module for example “Z_FB_ADD“. Keep in mind that most of SAP ABAP artefacts need to starts with “Z” or “Y” letter:
Step 3. Click on Create button:
Step 4. In Create Function Module popup fill Function Group for example “Z_FG_ARITHMETIC“. You also need to fill Short Text which is just simple description of your function module:
Step 5. Click on Save button:
Step 6. Our function will multiply two integer. We need to create two Import parameters X and Y. Fill everything like this:
Step 7. Go to Export tab and fill export parameters like following:
Step 8. Now go to Source Code tab and put following code:
z = x * y.
In the end it should look like this:
Step 9. Click on Save button and then on Activate button:
Step 10. Out function is ready and active. Now we can test it. Click on Test button:
Step 11. Fill both import parameters:
Step 12. Click on Execute button and check value given in result parameter:
The result should be as follow: