Skip to Content

All error message in the job log from the report executed in background

Hi All,

I execute the report in background with following code:

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = l_jobname

IMPORTING

jobcount = l_jobcount.

SUBMIT z_my_report

AND RETURN

VIA JOB l_jobname NUMBER l_jobcount.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = l_jobcount

jobname = l_jobname

strtimmed = abap_true.

The report of course issues a messages which appears in the job log. This is done with following code:

LOOP AT lt_message INTO ls_message.

MESSAGE ID ls_message-msgty TYPE ls_message-msgty NUMBER ls_message-msgno

WITH ls_message-msgv1 ls_message-msgv2 ls_message-msgv3 ls_message-msgv4.

ENDLOOP.

Once there is an error message, the report is finished with the status Canceled, which is expected.

The issues is that only the first error message appears in the job log (as the report is canceled). I would like to get all of the error message from the report in the job log. I can of course change the message type of the messages to 'I', but then the job will have status Finished, which is not intended.

Kind regards,

Radim

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Nov 16, 2015 at 01:57 PM

    try to first create a log to be displayed thru SLG1 (some FM to use)

    • BAL_LOG_CREATE
    • APPL_LOG_WRITE_MESSAGES or BAL_LOG_MSG_ADD
    • BAL_DB_SAVE

    Reference: Read Application Log – Guidelines for Developers (BC-SRV-BAL) and demo report SBAL_DEMO_01 or SBAL_DEMO_05.

    Only then raise an error to abort background job execution.

    Else, just add every message in log as an Information "I" message, then raise again first message as an error "E".

    Regards,

    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Raymond,

      Else, just add every message in log as an Information "I" message, then raise again first message as an error "E".

      This I'm already doing, but it is not nice. Because all the error messages appear as info message despite they are errors.

      It seems that there is no other solution, so I let it like this.

      Kind regards,

      Radim

  • Posted on Nov 16, 2015 at 01:36 PM

    Hi Radim,

    First check whether there are any 'E' messages... If yes set a Flag to 'X'.

    Then, Try to Loop at messages and capture all the messages in the LOG (Log_handles) ..

    Then, If the Flag is 'X' have one more 'Exception' and have the job 'Cancelled' at that point!!

    Hope this helps.

    Cheers,

    Kripa Rangachari.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 18, 2015 at 09:17 AM

    Hi Radim,

    Another option what you can try is using WRITE command and FORMAT options with color. Since you are already looping into your message table, instead of using MESSAGE command, we can use WRITE command to show a simple tabular output.

    Using the FORMAT COLOR option will highlight the error messages in red with all the messages still being displayed. This way, in a background job spool output, it would be easy to spot the error message among a list of messages.

    I believe the code would be something like:

    LOOP AT lt_message INTO ls_message.

    MESSAGE ID ls_message-msgty TYPE ls_message-msgty NUMBERls_message-msgno

    WITH ls_message-msgv1 ls_message-msgv2 ls_message-msgv3 ls_message-msgv4

    INTO lv_line.

    IF ls_message-msgty EQ 'E'.

    FORMAT COLOR 6 ON.

    WRITE:/1 lv_line.

    FORMAT COLOR 6 OFF.

    ELSE.

    WRITE:/1 lv_line.

    ENDIF.

    ENDLOOP.

    Kind Regards,

    Arnab

    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.