09-13-2016 10:41 AM
I'm using some tried and tested code that I've built up over the years to send an email using the CL_BCS class. In one particular program the method SET_SEND_IMMEDIATELY has been raising an exception and I don't know why. The really strange thing is that the exception is being raised depending on the logged on user and if debugging is active:
My user - the email is sent successfully
Two other users - the exception is raised
Same other users but debugging to see where the exception is raised - the email is sent successfully!
So this says to me it's some sort of timing issue. I can't see any difference between my userid and the ones that fail. I've copied one of these users and still have the same issue. All of this is occurring on my PC, so it's not a PC or SAPGUI problem.
As I can't reproduce the problem whilst debugging, all I can see is that the exception CX_OS_ERROR or CX_SYSTEM_ERROR is begin caught in method CL_SEND_REQUEST_BCS->SETU_ASYNCHRONOUS, and as it's not being caught into a reference variable I can't see any further detail. It's then propogated as CX_SEND_REQ_BCS with error type CX_BCS=>OS_EXCEPTION.
If I remove the call to method SET_SEND_IMMEDIATELY completely then the program short dumps with an uncaught exception CX_OS_OBJECT_NOT_FOUND during the SEND method - again this only happens for the two other test users and not my own.
Very strange. As I said earlier it's code that I've taken from my own library and have used it many times before with no problem.
Any suggestions on where to go from here?
Thanks
09-21-2016 2:33 PM
Problem solved - it was because there was a COMMIT WORK buried in a bespoke class that was being called after the BCS document had been created. It doesn't explain though why it consistently worked with one userid and consistently failed with another - they should have both failed.
Lots of points awarded to me.
09-13-2016 12:36 PM
09-21-2016 11:32 AM
Code is as follows - I've stripped out error handling etc. that is irrelevant to the problem.
TRY.
* Create document
lr_document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = lt_body
i_subject = 'subject' ).
* Pass the document to the send request
lr_send = cl_bcs=>create_persistent( ).
lr_send->set_document( lr_document ).
* Set Sender
lr_send->set_sender( cl_sapuser_bcs=>create( sy-uname ) ).
* Add Recipient
lr_send->add_recipient( cl_cam_address_bcs=>create_internet_address( <email> ) ).
* Send email immediately
lr_send->set_send_immediately( abap_true ).
lr_send->send( ).
COMMIT WORK.
* Email error
CATCH cx_bcs INTO lx_bcs.
ENDTRY.
09-21-2016 2:33 PM
Problem solved - it was because there was a COMMIT WORK buried in a bespoke class that was being called after the BCS document had been created. It doesn't explain though why it consistently worked with one userid and consistently failed with another - they should have both failed.
Lots of points awarded to me.