Calling a method from a function library in a UDF in message mapping.
During SAP PO development all of us at some point in time have come across an issue where we need to re-use methods/functions defined in a Function Library inside our local UDF’s. It is fairly easy to use UDF’s of a function library inside Graphical Mapping but when it comes to calling methods written in “Attributes and methods” section it becomes tricky.
Here we will have a look at a solution to the problem!
I had a requirement where I wrote a Function library(with no UDF’s) for writing Custom Audit Log Entries and I wanted to call the method defined in Attributes and method of the Function Library inside my message mapping.
The aim here is to be able to call the function “putAuditLogEntry” inside a message mappings UDF.
(why I am not writing these as a UDF in FL itself and using them in the MM…because I needed to use these methods inside my code multiple times depending on some variables….)
Step 1) Have a closer look at your Function Library!
Now if you look at the highlighted part the Class Name is “AuditLogEntry” and the package name is abc.functionlibrary
To be able to call this method first add this function library to the definition tab of message mapping.
Message Mapping(Definition Tab)
Next import the class in the import area of Functions Tab.
Then create an object of the class inside the UDF or globally!
Now the final part…..calling the method
This is just a way to access Function Library methods inside a MessageMapping’s UDF. It gives more flexibility when we are able to use global methods in local Message mapping UDF code instead of using them as UDF’s in Graphical Mapping.
Note: You can also call the UDF’s defined in the FunctionLibrary in Similar Fashion.