Need to send an email with a PDF attachment during Production order saving processing, I'm using CL_BCS for email and cl_document_bcs for attachment preparation. Because the email processing involves standard DB update processing, I didn't use commit work after the call method send_request->send.
I thought the email processing would be committed automatically when DB commits its work. But actually, it'll not happen. Instead, I get the email status with SO672 (Still no entry in the queue). It has been discussed many times like this one, hope this article will not hurt anyone facing the same issue. Some useful notes:
717265 - Sending in PERFORM-ON-COMMIT as of Release 6.10
We recommend that you do not call the send interface at the time of the PERFORM-ON-COMMIT but during the update.
If this is not possible, enclose the call of the send interface in a function module that is called with RFC. The 'NONE' destination is sufficient. A COMMIT WORK must be executed in the function module after the send interface was called.
Instead of calling its own function module with RFC, the application can also call the SO_DOCUMENT_SEND_API1 function module which is part of the send interface. In this case, you must set the COMMIT_WORK import parameter to 'X'.
1895298 - SO672 - Still no entry in queue
It's mandatory to each application explicitly call COMMIT WORK, after the sending application has been called.
Do not execute COMMIT WORK command during an update process. Additional instructions will be found under SAP Note 717265:
"If this is not possible, enclose the call of the send interface in a function module that is called with RFC. The 'NONE' destination is sufficient"
Also, there are some circumstances when a COMMIT WORK is suppressed in the coding.
Perform On Commit
End Transaction event
Check if "sy-oncom" is on one of the above states when it reaches COMMIT WORK. If yes, then include a new COMMIT WORK outside of the process. For example, if code is within a 'Call Dialog', initiate a new COMMIT WORK when it leaves the "Call Dialog".
In my case which sends an email during update processing, the key is:
Enclose the call of the send interface in a function module that is called with RFC. The 'NONE' destination is sufficient".
Put BCS email logic inside one FM with RFC suppported.
Tick the checkbox of pass value for input parameters cause RFC doesn't support reference ones.