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

Need help on displaying exception message

amol_samte
Contributor
0 Likes
5,029

Hi All,

I was trying to display SQL_MESSAGE but not successful. Can anybody help me out?  We are on 7.4 SP09.

CATCH cx_amdp_error INTO DATA(lt_amdp_error).

      DATA(lw_text) = lt_amdp_error->get_text( ).

      MESSAGE lw_text TYPE 'I' DISPLAY LIKE 'E'.

-Amol S

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,040

Hi,

Your attribut SQL_MESSAGE seems to be public and defined in the CX_AMDP_DBPROC... Have you got something like that in your completion:



CX_AMDP_ERROR->CX_AMDP_DBPROC->SQL_MESSAGE ?


or,


CX_AMDP_ERROR->CX_AMDP_DBPROC->GET_TEXT( ) ?


Otherwise, try to:

1) copy the Class Exception: "CX_AMDP_ERROR" as "ZCX_AMDP_ERROR" from SE24.

2)  Create a Getter method GET_SQL_MESSAGE that return your attribut SQL_MESSAGE.

And try this code. You have to type strongly your Exception instance to get the right cast on the good type.


TRY .

data lo_exception TYPE REF TO zcx_amdp_error.

  

    

   CATCH cx_amdp_error INTO lo_exception.

     DATA(lv_text) = lo_exception->get_message_sql( ).

     MESSAGE lv_text TYPE 'I' DISPLAY LIKE 'E'.

ENDTRY.

Rachid.

Hi All,

I was trying to display SQL_MESSAGE but not successful. Can anybody help me out?  We are on 7.4 SP09.

CATCH cx_amdp_error INTO DATA(lt_amdp_error).

      DATA(lw_text) = lt_amdp_error->get_text( ).

      MESSAGE lw_text TYPE 'I' DISPLAY LIKE 'E'.

-Amol S

2 REPLIES 2
Read only

Former Member
0 Likes
3,041

Hi,

Your attribut SQL_MESSAGE seems to be public and defined in the CX_AMDP_DBPROC... Have you got something like that in your completion:



CX_AMDP_ERROR->CX_AMDP_DBPROC->SQL_MESSAGE ?


or,


CX_AMDP_ERROR->CX_AMDP_DBPROC->GET_TEXT( ) ?


Otherwise, try to:

1) copy the Class Exception: "CX_AMDP_ERROR" as "ZCX_AMDP_ERROR" from SE24.

2)  Create a Getter method GET_SQL_MESSAGE that return your attribut SQL_MESSAGE.

And try this code. You have to type strongly your Exception instance to get the right cast on the good type.


TRY .

data lo_exception TYPE REF TO zcx_amdp_error.

  

    

   CATCH cx_amdp_error INTO lo_exception.

     DATA(lv_text) = lo_exception->get_message_sql( ).

     MESSAGE lv_text TYPE 'I' DISPLAY LIKE 'E'.

ENDTRY.

Rachid.

Read only

0 Likes
3,040

Hi Rachid,

Thanks for your reply.

I have archived like below.

CATCH cx_amdp_dbproc_create_failed INTO DATA(lt_amdp_error).

      lw_text = lt_amdp_error->sql_message.

-Amol S