Skip to Content
author's profile photo Former Member
Former Member

Any way to catch exceptions from asynchronous call that short dumps?

Hi,

We have a requirement for a program that we know will occasionally short dump under normal conditions. We want to use an asynchronous call to let it plow ahead. To that end I've created a test program that calls a divide by zero func that short dumps. It tests fine because it proceeds afterward. Better yet would be a way to capture some information from the function where the dump happens and raise it to the calling program. Any ideas?

Thanks,

Doug

Example:

REPORT ZJUNK2

data: junkdone TYPE c VALUE space,

write: / 'before'.

CALL FUNCTION 'ZJUNK2'

STARTING NEW TASK 'z_junktask'

PERFORMING junk ON END OF TASK

EXCEPTIONS

communication_failure = 1

system_failure = 2

other_exception = 3.

  • Receive remaining asynchronous replies

wait until junkdone = 'X'.

write: / 'after'.

FORM junk USING taskname.

RECEIVE RESULTS FROM FUNCTION 'ZJUNK2'

EXCEPTIONS

communication_failure = 1

system_failure = 2

other_exception = 3.

junkdone = 'X'.

ENDFORM.

FUNCTION ZJUNK2.

*"----


""Local Interface:

*"----


data: i type i.

i = 1 / 0.

ENDFUNCTION.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jan 22, 2010 at 03:49 PM

    Hey Doug. You need to catch the class exception cx_root in your function, then pass back the message. This will catch a lot of system exceptions, but probably not all.

    DATA: junkdone TYPE c VALUE space.
    DATA: lv_message TYPE char255.
    
    WRITE: / 'before'.
    
    CALL FUNCTION 'ZJUNK2'
      STARTING NEW TASK 'z_junktask'
      PERFORMING junk ON END OF TASK
      EXCEPTIONS
        communication_failure = 1
        system_failure        = 2
        other_exception       = 3.
    
    * Receive remaining asynchronous replies
    WAIT UNTIL junkdone = 'X'.
    
    WRITE: / 'after'.
    
    IF lv_message IS NOT INITIAL.    "<-- Check for error and write message
      WRITE:/ lv_message.
    ENDIF.
    
    *&---------------------------------------------------------------------*
    *&      Form  junk
    *&---------------------------------------------------------------------*
    FORM junk USING taskname.
    
    
      RECEIVE RESULTS FROM FUNCTION 'ZJUNK2'
           IMPORTING
                e_message = lv_message   "<-- Import the message
           EXCEPTIONS
                communication_failure = 1
                system_failure = 2
                other_exception = 3.
    
      junkdone = 'X'.
    
    ENDFORM.                    "junk
    
    
    
    FUNCTION zjunk2.
    *"----------------------------------------------------------------------
    *"*"Local Interface:
    *"  EXPORTING
    *"     VALUE(E_MESSAGE) TYPE  CHAR255
    *"----------------------------------------------------------------------
    
      DATA: lo_exception TYPE REF TO cx_root.
      DATA: i TYPE i.
    
      TRY.
          i = 1 / 0.
        CATCH cx_root INTO lo_exception.
          e_message = lo_exception->get_text( ).
      ENDTRY.
    
    ENDFUNCTION.

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 22, 2010 at 09:04 PM

    As Rich says, you definitely can't catch ALL exceptions.

    Moreover, when the call is using SUBMIT, asynchronous RFC, CALL TRANSACTION and a few others (when a internal session is started, in fact), you can't catch exceptions from the calling program. You always have to catch exceptions in the internal session where they occur (as Rich did).

    These are known behaviors (and already discussed in the forum if you want more information).

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.