‎2010 Aug 31 10:09 AM
Hi Experts,
I have program to convert Form to PDF and then send to Email. There I am using below code for attachment.
* create attachment (PDF file)
document->add_attachment(
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = descr
i_att_content_hex = pdf_content ).
But as my cursor reaches this, this code raises an exception (An exception (CX_DOCUMENT_BCS) occurred
). I already used Try Catch.
CATCH cx_bcs INTO bcs_exception.
RAISE EXCEPTION TYPE cx_send_req_bcs
EXPORTING
error_type = bcs_exception->error_type.
but this shows Run time error with below details
What happened?
*The exception 'CX_SEND_REQ_BCS' was raised, but it was not caught anywhere
along the call hierarchy.*
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SEND_REQ_BCS', was not caught in
procedure "EMAIL_SEND_WITH_PDF" "(METHOD)", nor was it propagated by a RAISING
clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
An exception occurred
Please help
Khan.
‎2010 Aug 31 10:35 AM
Hi,
in your code you are catching only exception with type cx_bcs. If you want to also catch an exception with type CX_DOCUMENT_BCS then you have to add additional CATCH statement. For more info check ABAP documentation for statement CATCH.
Cheers
‎2010 Aug 31 12:22 PM
Hi Martin,
I tried to catch an exception with type CX_DOCUMENT_BCS, But same error comes.
After that I tried like below and it worked.
RAISE EXCEPTION TYPE cx_send_req_bcs
EXPORTING
ERROR_TYPE = bcs_exception->error_type.
CATCH cx_bcs INTO bcs_exception.
I write Raise statement before Catch.
Please share you comments
Khan.
‎2010 Aug 31 12:29 PM
You could try:
DATA: lx_root TYPE REF TO cx_root.
..........
TRY.
...........
CATCH cx_root INTO lx_root.
RAISE EXCEPTION ......
CLEANUP.
...............
ENDTRY.
See how you go.
Cheers,
Sougata.
‎2010 Sep 01 6:25 AM
‎2010 Sep 01 10:28 AM
Hello Khan,
CATCH cx_bcs INTO bcs_exception.
RAISE EXCEPTION TYPE cx_send_req_bcs
EXPORTING
error_type = bcs_exception->error_type.Why have you raised the exception CX_DOCUMENT_BCS ?
This exception is already propagated inside the ADD_ATTACHMENT method. (check the implementation of ADD_ATTACHMENT you'll find the RAISE exception type cx_document_bcs statement)
You just need to handle the exception using TRY-CATCH block. No need to raise the exception !!
When you write this code:
RAISE EXCEPTION TYPE cx_send_req_bcs
EXPORTING
ERROR_TYPE = bcs_exception->error_type.
CATCH cx_bcs INTO bcs_exception.You are handling the exception CX_DOCUMENT_BCS with the CATCH statement. Hence you don't get a dump.
Hope i am clear.
BR,
Suhas