Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

CL_BCS strange exception CX_OS_ERROR

peter_collins3
Explorer
0 Kudos

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

1 ACCEPTED SOLUTION

peter_collins3
Explorer
0 Kudos

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.

3 REPLIES 3

Chintu6august
Contributor
0 Kudos

Hi,

can you share your code for better understanding?

thank you!!

peter_collins3
Explorer
0 Kudos

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.

peter_collins3
Explorer
0 Kudos

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.