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

Creating ST22 dump from ABAP Exception Object

Former Member
0 Likes
2,554

Hi all.

I want to create an ST22 dump from an ABAP Exception Object.

Reason behind this is that I want to display a custom simplified error message to the user, but have sufficient details for the developer to do tracing.

Implementation Details:

Since our application is a portal application, I created a subclass for CL_WDR_MAIN_TASK, and reimplemented the method IF_HTTP_EXTENSION~HANDLE_REQUEST with the following code (snippet). The problem is that after catching the error, I still want to cause a dump in ST22 with the stack in the exception object.:

  TRY.

       super->if_http_extension~handle_request(

         EXPORTING

            server = server

       ).

     CATCH cx_sy_message_in_plugin_mode INTO lr_exception.

       "Whatever application error should be caught here

       IF lr_exception->msgid = '14' AND

          lr_exception->msgno = '060'. "User session (HTTP/SMTP/..) closed after timeout

         "Populating Time Out error contents into lv_html_body

       ELSE.

         "Populating other error contents into lv_html_body

       ENDIF.

       server->response->set_header_field(

         name  = 'Content-Type'

         value = 'text/html'

       ).

       server->response->set_cdata( data = lv_html_body ).

       "me->raise_to_st22( lr_exception ).

   ENDTRY.

1 ACCEPTED SOLUTION
Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
1,725

Hi,

Did you try using message type 'X'?

Hi,

Did you try using message type 'X'?

5 REPLIES 5
Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
1,726

Hi,

Did you try using message type 'X'?

Read only

Former Member
0 Likes
1,725

Hi.

Thanks for the reply.

Yes, it will cause an ST22 log, however the stack trace in the log will point me to the source I triggered the MESSAGE statement, and not the stack information that I have within the exception object itself.

I am doing this as a workaround at the moment. Almost there

I have been looking into how SAP creates these dumps. But a where used on the tables seem to show that these tables are not updated at ABAP level.

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
1,725

Just a thought. Did you check what happens if you simply raise the exception within your CATCH block and do not catch it anywhere in the call stack. Would it not lead to a dump? If it does, you might have the call stack preserved in the exception object.

Read only

Kartik2
Contributor
0 Likes
1,725

Hi,

I did not get the reason as of why you want to raise a dump. Anywas, if you really want a dump then you can try zero divide ( 1 / 0 ).

Regards,

Kartik

Read only

jeroen_verbrugge2
Active Participant
0 Likes
1,725

Hi,

What about using assert or log-point statements?

Using transaction SAAB, you can activate on request where you can specify user and server as parameters.

For assert, you can choose to log, to break, to create a shortdump or to be inactive.

For log-point, you can choose between log and inactive.

With both statements, you can use the FIELDS addition to include variables in the log or dump.

Have a look at the documentation.

Rgds,

Jeroen