Application Development and Automation 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: 
Read only

Exception Handeling Error

Former Member
0 Likes
3,987

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.

5 REPLIES 5
Read only

mvoros
Active Contributor
0 Likes
1,979

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

Read only

Former Member
0 Likes
1,979

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.

Read only

Sougata
Active Contributor
0 Likes
1,979

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.

Read only

Former Member
0 Likes
1,979

This message was moderated.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,979

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