There are at least two ways to park a Logistics Invoice. One of them is by using BAPI_INCOMINGINVOICE_PARK. The other one makes use of the INVOIC IDoc and requires the OSS Note 501524 to be implemented. Unfortunately, both of those methods only allow creating a document with the document status “A” – Parked. The point is, this also causes follow-on documents (like financial posting document) being parked. Once developing one of my integration scenarios, I have met a requirement to park a Logistics Invoice in such a way that no follow-on documents were created. In particular, the financial posting document could not be created (yet) for some reason. As the solution appeared to be more complex and difficult than I initially expected, I decided to share it with you, as it might turn out useful for someone else.
Although my solution was based on the BAPI_INCOMINGINVOICE_PARK function module, both this BAPI and INVOIC IDoc use the same part of code, so you can use any of those methods. If you need further assistance in using this BAPI, please refer to its Documentation in transaction BAPI in your system. You will find an explanation of importing parameters, as well as examples of use in several scenarios there. I will not focus on the BAPI itself, because it is not the purpose of this blog.
As you might have already noticed, the BAPI I was using calls a form MRM_INVOICE_CREATE_CALL_N, passing the hardcoded C_RBSTAT_PARKED (equal ‘A’, which means Parked) as the expected status of the document to be created. It might seem that providing a new implementation to enhancement section:
ENHANCEMENT-SECTION BAPI_INCOMINGINVOICE_PARK_33 SPOTS ES_SAPLMRM_BAPI.
passing a different status could solve the problem. But in this case, some functionalities of the form form MRM_INVOICE_CREATE_CALL_N do not work correctly. Which means we need to go deeper in the code to find a workaround.
After a detailed analysis, I have found the function module MRM_INVOICE_PARK (used by both: INVOIC and BAPI…) which is the right place to put the enhancement that will change the document status. To make the case even more difficult, the parameter is passed by reference, so its value cannot be changed easily inside the FM, which makes the scenario even more complex approach.
First of all, we will need a global field symbol in function group MRMH to change the value of the I_RBSTAT_NEW (Invoice document status) importing parameter of MRM_INVOICE_PARK function module. In order to do it, go to top include LMRMHTOP of function group’s main program SAPLMRMH, find the enhancement point:
ENHANCEMENT-POINT lmrmhtop_03 SPOTS es_saplmrmh STATIC.
Create your own ehnancement implementation and declare a field symbol there:
ENHANCEMENT 43 ZGG_DECLARE_FIELD_SYMBOL.
FIELD-SYMBOLS: <tp_rbstat> TYPE rbstat.
Secondly, we need to have the previously declared field symbol assigned to the variable that contains a value for I_RBSTAT_NEW. We will use an implicit enhancement implementation at the beginning of the function module MRM_INVOICE_CREATE for this purpose. Create an implementation with the following code:
ENHANCEMENT 42 ZGG_ASSIGN_FIELD_SYMBOL.
ASSIGN i_rbstat_new TO <tp_rbstat>.
Finally, we need to put a new value to the parameter I_RBSTAT_NEW using our previously assigned field symbol. We will use an implicit enhancement implementation again, this time at the beginning of function module MRM_INVOICE_PARK. You should also perform some additional checks at the beginning, to make sure your code is only executed for your scenario.
ENHANCEMENT 60 ZGG_INVOICE_PARK_STATUS_D.
DATA: ltp_var_name TYPE char30 VALUE ‘(SAPLMRMH)<tp_rbstat>’.
FIELD-SYMBOLS: <ltp_rbstat> TYPE rbstat.
IF … “check your conditions here to make sure that it works only for your scenario
ASSIGN (ltp_var_name) TO <ltp_rbstat>.
IF sy-subrc = 0 AND <ltp_rbstat> IS ASSIGNED.
<ltp_rbstat> = c_rbstat_saved_po. “Entered and held
Finally we have made enough to have the document properly parked, or literally: “Entered and held”. Try testing your scenario again (execute BAPI_INCOMINGINVOICE_PARK or reprocess/send new INVOIC IDoc) to see the results.
The result, as you see it in the Overview of Invoice Documents in transaction MIR6, will be the following: