Using SRM Standard FM in BAdI coding is necessary as not all relevant information for documents is available in the BAdI methods input parameters. However, developers should be aware of a few key points before coding calls to these functions to avoid unexpected side effects.
It seems basic stuff, but from the volume of problems I saw in my years as Support Engineer at SAP, more people should be aware of these topics.
1)SRM Function Modules are in ‘Not Released’ status
As written in note 109533, only notes that are in status ‘Released for Customer’ will be supported by SAP. Which means that if the function does not behave as expected or the behavior changes after a SP upgrade or note implementation, this will not be supported by SAP AG.
But if the errors you find also affects the standard SAP programs, you can open a message for SAP Support.
2)Avoid using these functions when possible
Make sure that the information you requested is not already available in the method parameters. I saw many times BAdI coding using FM BBP_PD_PO_GETDETAIL to find information already available in method parameters.
The reason for this is that most of these functions are intended to work with SRM program only. For example, FM BBP_PROCDOC_GETDETAIL retrieves document information but also updates internal buffers used by the standard program. Sometimes, this can cause an abort error due to different versions of the document stored in these buffers. KBA Note 1697675 contains relevant information about this topic.
- SAP Note 1697675 Use of SRM Function Modules in BAdI implementation causes “Buffer Table not up to date” error
So, if you are using one of these functions in your code, test it thoroughly. If finding any unexpected issues, deactivate the BAdI and retest to make sure there is no influence from your custom program.
3)Think about performance
While one could think that FM BBP_PD_PO_GETDETAIL is the best choice to get PO information, you have to consider it runs other tasks beyond bringing document data. Considering that BAdIs may be called several times while editing a document, this is not an optimal choice.
FM BBP_PD_PO_GETDETAIL actually gets data from PD Layer, so it is a better choice to call PD Layer functions directly. FM BBP_PROCDOC_GETDETAIL brings complete document information. If only item info is necessary, consider FM BBP_PROCDOC_GETITEMLIST and FM BBP_PROCDOC_ITEM_GETDETAIL.
4)Before coding it, debug the function in the standard program
Maybe the function does have the results you expect, or it is causing errors in your code. To make sure you are invoking the FM correctly, put a breakpoint on it and use the application. Check how the program calls it, the values in the variables, and the results. Compare to your code. With this simple action, I have helped several of our customers to fix their BAdIs.