cancel
Showing results for 
Search instead for 
Did you mean: 

Catching message errors after submit

Former Member
0 Kudos

Is there any way to catch message after submitting report?

I mean any type of message, i.e. E,S,I and so on. And if it's possible, I need to suppress them. Maybe this can work with help of the system calls?

Accepted Solutions (1)

Accepted Solutions (1)

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

If you want to see the transaction step-by-step,you can use 'A' mode.

'E' mode helps us to see the screen if the transaction encounters error.

'N' mode is for no display of screens.

Here is the sample code.

CALL TRANSACTION 'MEQ1' USING i_bdcdata MODE 'N'
                          MESSAGES INTO i_messtab.

  IF NOT i_messtab IS INITIAL.
    SORT i_messtab BY msgtyp.
* Check BDC message table for error
    READ TABLE i_messtab INTO w_messtab WITH KEY msgtyp = c_e
                                                BINARY SEARCH.
    IF sy-subrc NE 0.
....
    Endif.

Former Member
0 Kudos

Hi, Dom and Jayanthi!

Thank you, but I can't use Batch Input technology here, because I have one condition - no transaction creating at all. There may be many other reports, that I have to submit, so it's not possible too to create a transaction for each one. And guessing your farther answer - I can't use 'SE38'.

Former Member
0 Kudos

Hi,

Did u try :

EXPORTING LIST TO MEMORY

submit prog name
             exporting list to memory
             with SO_BNAME-LOW = w_upload-bname
             and return.

          if sy-subrc = 0.

Hey just check this out:

Regards,

Anjali

Message was edited by: Anjali Devi

Former Member
0 Kudos

Hi, Anjali!

That's the main problem! Submit operator doesn't return sy-subrc and sy-msgid too for message errors. This syntax restriction is making my life terrible.

Former Member
0 Kudos

HI Vitaly,

You can try the 'SUBMIT VIA JOB' option and then read the job log and/or spool for any messages. Here is a rough code.


  DATA: l_jobcount LIKE tbtcjob-jobcount.

  CALL FUNCTION 'JOB_OPEN'
       EXPORTING
            jobname          = 'MYTESTJOB'
       IMPORTING
            jobcount         = l_jobcount
       EXCEPTIONS
            cant_create_job  = 1
            invalid_job_data = 2
            jobname_missing  = 3
            OTHERS           = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
            INTO i_return_messages-message.
    i_return_messages-type = 'E'.
    APPEND i_return_messages.
    CLEAR i_return_messages.
    EXIT.
  ENDIF.
  SUBMIT zbwm_sap_to_dsc_enr_rel_notice
    WITH p_relno = release_nbr
    USER sy-uname VIA JOB 'MYTESTJOB'
  NUMBER l_jobcount AND RETURN.
  CALL FUNCTION 'JOB_CLOSE'
       EXPORTING
            jobcount             = l_jobcount
            jobname              = 'MYTESTJOB'
            strtimmed            = 'X'
       EXCEPTIONS
            cant_start_immediate = 1
            invalid_startdate    = 2
            jobname_missing      = 3
            job_close_failed     = 4
            job_nosteps          = 5
            job_notex            = 6
            lock_failed          = 7
            OTHERS               = 8.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
            INTO i_return_messages-message.
    i_return_messages-type = 'E'.
    APPEND i_return_messages.
    CLEAR i_return_messages.
  ENDIF.

After this, you will have to check if the job has completed or not(in a loop). To do that you can call the function module SHOW_JOBSTATE. This will tell the status of the job. Once the job status is 'FINISHED' or 'ABORTED', you can then call another function module BP_JOBLOG_READ to read the job log.

But again, you will have parse through the text to identify the message type, number, message text etc.

Former Member
0 Kudos

Hi, Srinivas!

Thank you for your attention, but I already checked this. When I'm using job I can't use EXPORTING LIST TO MEMORY. So I have to get list from SAP-SPOOL and this is a problem. Maybe you can tell me the easiest way to get list?

Former Member
0 Kudos

Look at function module 'BAPI_XBP_JOB_SPOOLLIST_READ'for clues.

It calls BP_JOB_READ to get the spool ID of the job step and then calls RSPO_RETURN_ABAP_SPOOLJOB to get the spool itself.

Srinivas

Message was edited by: Srinivas Adavi

Former Member
0 Kudos

Did this help? If so, please close the thread.

Former Member
0 Kudos

Thank you very much, Srinivas!

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Vitaly

I don't think so.

However, if you want the report to run entirely in the dark, assign a transaction code to it and CALL TRANSACTION...MODE 'N'...MESSAGES INTO LT_MSGTAB.

Then you won't get any messages on the screen.

Cheers

Dom

christian_wohlfahrt
Active Contributor
0 Kudos

Hi Vitaly,

there is a specific list of errors, which can be catched with 'CATCH', have a look in the help. But I doubt, that you can even catch everything inside of a submit - somehow it's not designed for this.

Anyway there are a lot of errors, which can't be catch - and you will never be able to catch a message X, unless you modify short dump creation.

If you want to have a program, which can still go on after some errors in a submitted report, place the submit in a asynchronous function call.

Regards,

Christian

Former Member
0 Kudos

Hi, Christian!

'CATCH' is need only for ABAP runtime errors, so I can't use it. If you mean to catch exception in class, then I've not yet tried it - it seems not helpfull too.

Thank you.