How to catch and store function module input parameters using FBGENDAT and FBGENMAC?

This tutorial will save you some headaches in the future. This technique is very useful when you need to debug a function module call. In our example we will use custom function module to present this functionality but FBGENMAC include is part of most BAPIs. If you want to save data for standard BAPIs you can jump to steps 5 straight away.

PREREQUISITES:

  • Access to SAP System base on Netweaver or ABAP Platform
  • Authorization to SE37, SU01 and SA38
  • SAPGUI installed
  • Developer key (only for Netweaver based systems)
  • Function module (How to create ABAP function module)

Step 1. First we need to extend some function module. First go to transaction SE37 – ABAP Function Modules. Put SE37” in the command field and hit Enter:

Step 2. Click on Change button:

Step 3. At the beginning of the function module, add the following ABAP code:

INCLUDE FBGENMAC.
fbgenmac ‘Z_FB_EXAMPLE’.

It should look like this:

Step 4. Activate your change – click on Activate button:

Step 5. Now we need to add user parameters to user for which we want log function module calls. In real life it would be probably RFC user or end user that is having some problems with our function module. For tutorial purpose you can use your own user. Go to transaction SU01 – User Maintenance. Put /N SU01” in the command field and hit Enter :

Step 6. In User field put username, in my case it’s “PGRZESKO“:

Step 7. Click on Change button:

Step 8. Go to Parameters tab:

Step 9. Add FBGENDAT parameter with value “X“:

Step 10. Save changes by clicking on Save button:

Step 11. The last thing we have to do is activate logging using the FBGENDAT program. Go to SA38 – ABAP Reporting. Put /N SA38” in the command field and hit Enter:

Step 12. In Program field put “FBGENDAT“:

Step 13. Click on Execute button:

Step 14. In Function Module field put function module name for which you want to active logging. In this tutorial we will use earlier created function “Z_FB_EXAMPLE“. You can also choose from one of the available logging modese:

Now every time you will call Z_FB_EXAMPLE function module all parameters will be stored in Data Variant Dictionary:

Written by 

Leave a Reply

Your email address will not be published. Required fields are marked *