Skip to Content
Technical Articles

abap-fm-logger: A tool to trace the Function Module (RFC) parameters

Many SAP systems provide some Remote-Enabled Function Modules (RFC) as interfaces to external systems. To trace the issues of system integration. We often need log tables to store the exporting/importing parameters’ values..

It is a dull work to create lots of log tables for FM. And given the complex and interdependent nature of an SAP system, it may be imperative to carefully manage the log code and tables, in order to avoid duplication. And there may be several background jobs to make sure that the outdated logs be archived/cleaned.

To simplify the log work of FM, I created a tool: abap fm logger.

With abap fm logger, we can save logs of different FM in just ONE table. Search logs in a general report program, like this,

https://raw.githubusercontent.com/hhelibeb/helloworld/master/log%20report.png

The importing/exporting values are not store in separate table fields, but in 4 special fields with JSON format.

We can also reprocess records by log id (like WE19 for IDoc).

 

And it is very easy to use. Benefit from a unified JSON field format, we don’t need to write special code for the different interface definition. Here is an example,

FUNCTION z_fm.
  
**initialize logger. It should be always on the top of the FUNCTION.
  /afl/log_init.

**optional, you can specify at most 3 fields for search.
  /afl/set_custom_fields 'cust field1' 'cust field2' 'cust field3'. 

**optional, you can save a status code and message text for search.
  /afl/set_status 'S' 'message'.

**save logs. It should be always on the bottom of the FUNCTION.
  /afl/save.

ENDFUNCTION.

 

In the most cases, we may just need two macros /afl/log_init and /afl/save. It is enough.

You can access https://github.com/hhelibeb/abap-fm-logger for more details of abap fm logger and install it by abapGit.

Feel free to comment the tool.

Thanks

/
https://raw.githubusercontent.com/hhelibeb/helloworld/master/log%20report.png
8 Comments
You must be Logged on to comment or reply to a post.
    • Thanks for your continuous support. In fact I’m using it in some new projects and not go-live yet. So if you find any issue or requirement, please tell me :)

  • UPDATE: I just got a response which indicates that the macros is not necessary. I think it is right. So later I will provide the OO-based interface, and keep the macro interface remaining.

    And I also think it is an advantage of the open source: when we do something wrong/right, we can get comments from others to help us understand what we really did.

  • Initially, I didn’t read your blog post because of the title “abap-fm-logger: A general log tool for Function Modules (RFC)“, I thought it was yet another general message logger, like https://github.com/epeterson320/ABAP-Logger.

    Maybe a title like “rfc-call-logger to trace the RFC parameters” could be more attractive or at least right at the point.

    Nice job, thanks !

  • An interesting utility.

    Thanks for sharing.

     

    Please review also FBGENDAT, a tool developed by SAP sales development team, which allows to generate automatically function test data.

    • I just review the code in fbgenmac, it is very helpful to develop an oo-based api for abap-fm-logger. Thanks for your help.

       

  • By the way, people may wonder whether there is a standard mechanism to trace the values of parameters. There is one, far from being as good as yours: the RFC trace. It can be activated at RFC destination level (SM59), but not at level of RFC function module. In the RFC developer trace, you’ll then see the detailed contents of bytes passed in the raw format of the RFC protocol, which can be more or less be interpreted by human. Example after calling RFC_READ_TABLE with parameter QUERY_TABLE=’T000′:

    | 000330 | 0102001C 52004600 43005F00 52004500 |....R.F.C._.R.E.|
    | 000340 | 41004400 5F005400 41004200 4C004500 |A.D._.T.A.B.L.E.|
    | 000350 | 01020503 00000503 013100E6 2A54482A |.........1.æ*TH*|
    | 000360 | 0300E600 00533447 2F636C64 7334686C |..æ..S4G/clds4hl|
    | 000370 | 696E7831 5F533447 5F323220 20202020 |inx1_S4G_22     |
    | 000380 | 20202020 20000152 4F535349 53202020 |     ..ROSSIS   |
    | 000390 | 20202020 20202020 20202020 20202020 |                |
    | 0003a0 | 20202020 20202053 45333720 20202020 |       SE37     |
    | 0003b0 | 20202020 20202020 20202020 20202020 |                |
    | 0003c0 | 20202020 20202020 20202020 20202000 |               .|
    | 0003d0 | 01533447 2F636C64 7334686C 696E7831 |.S4G/clds4hlinx1|
    | 0003e0 | 5F533447 5F323220 20202020 20202020 |_S4G_22         |
    | 0003f0 | 20414433 44444339 39314137 33303038 | AD3DDC991A73008|
    | 000400 | 30453030 35463436 37384630 34353033 |0E005F4678F04503|
    | 000410 | 39313030 0001000D 3AAA88F2 1EDB8685 |9100....:ª.ò.Û..|
    | 000420 | 4ADFFF5D 3DBF5F86 A0EC2700 93A7E100 |Jßÿ]=¿_. ì'..§á.|
    | 000430 | 0000C0A8 01060000 00000000 00E22A54 |..À¨.........â*T|
    | 000440 | 482A0131 05140010 ECA0865F 0027A793 |H*.1....ì ._.'§.|
    | 000450 | E1000000 C0A80106 05140420 00040000 |á...À¨..... ....|
    | 000460 | 00000420 05120000 05120201 00124400 |... ..........D.|
    | 000470 | 45004C00 49004D00 49005400 45005200 |E.L.I.M.I.T.E.R.|
    | 000480 | 02010203 00022000 02030201 000E4E00 |...... .......N.|
    | 000490 | 4F005F00 44004100 54004100 02010203 |O._.D.A.T.A.....|
    | 0004a0 | 00022000 02030201 00165100 55004500 |.. .......Q.U.E.|
    | 0004b0 | 52005900 5F005400 41004200 4C004500 |R.Y._.T.A.B.L.E.|
    | 0004c0 | 02010203 003C5400 30003000 30002000 |.....<T.0.0.0. .|
    | 0004d0 | 20002000 20002000 20002000 20002000 | . . . . . . . .|