Quantcast
Viewing all articles
Browse latest Browse all 333

Sending Monitor Log Messages with a Custom Formula

In the context of Transformations you can choose for rule type Formula. SAP delivered a Formula Builder with many ready-to-use Formulas. It is even possible to extend the Formula Builder with your own custom Formulas by implementing Business Add-in (BAdI) RSAR_CONNECTOR.

My requirement was not only to deliver such a custom Formula. I also had to add a message to the Monitor Log in case a certain condition was met. In this blog I would like to share with you how to handle such a requirement and to discuss some implementation aspects.

BAdI Implementation

Custom Formulas can be made available by implementing classic BAdI RSAR_CONNECTOR. Next to the on-line BAdI documentation you can refer to the following documents for detailed implementation instructions:

 

 

Result of my implementation is a new custom group with custom Formulas.

 

Image may be NSFW.
Clik here to view.
Figure_1_Example_Custom_Group.jpg

Figure 1: Example custom group with custom Formulas

 

The last custom Formula is used in the example Transformation rule.

 

Image may be NSFW.
Clik here to view.
Figure_2_Example_Transformation_Rule.jpg

Figure 2: Example Transformation rule with a custom Formula

Monitor Log Messages

Implementing the BAdI was actually the easy part. It was not so easy to implement Monitor Log messages in the custom Formula.

For reference purposes I used standard Formula LOG_MESSAGE. I copied the relevant source code from the standard Formula and appended it to my own implementation. Please refer to line 12 to 17 in the next screenshot.

 

Image may be NSFW.
Clik here to view.
Figure_3_Source_Code_BAdI_Implementation.jpg

Figure 3: Source code in BAdI implementation

 

Unfortunately, my custom Formula did not send any messages to the Monitor Log. After some investigation I found that also standard Formula LOG_MESSAGE did not send the messages to the Monitor Log.

I raised an SAP Support ticket and it turned out to be a program error. After implementing SAP Note 2285154 - 730SP15:Standard formula function LOG_MESSAGE doesn't send the issue was solved for the standard Formula. However, the custom Formula still did not send any messages.

 

Diving a bit deeper I found an interesting explanation. The generated Transformation program is based on template programs such as RSTRAN_RULE_TMPL_ROUTINE.  In the source code you can see how the Formula routine is composed. Pay attention to line 173 in the next screenshot.

 

Image may be NSFW.
Clik here to view.
Figure_4_Template_Program_Transformation_Rule.jpg

Figure 4: Template program for Transformation rule

 

The source code of line 174 to 180 is only applied if the Formula contains string LOG_MESSAGE.

 

So the “hidden feature” is that you have to include string LOG_MESSAGE in the technical name of the custom Formula. Only then the crucial source code is appended to the Transformation rule routine in the generated program.

 

Image may be NSFW.
Clik here to view.
Figure_5_Generated_Transformation_Program.jpg

Figure 5: Generated Transformation program

Conclusion

In this blog I demonstrated how to send a message to the Monitor Log in the context of a custom Formula. You have to append similar source code to the BAdI implementation as found in standard Formula LOG_MESSAGE. A small “hidden feature” is that you also have to include string LOG_MESSAGE in the technical name of the custom Formula. Only then crucial source code is appended to the Transformation rule routine in the generated program. Now the messages are correctly sent to the Monitor log.


Viewing all articles
Browse latest Browse all 333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>