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

Display error message in batch job log

Karan_Chopra_
Active Participant
0 Likes
19,034

Hello

I have a batch job running and I have an error coming during some validation logic.

The problem is I need to continue the batch job when this error message comes and it should not cancel the batch job as it is doing currently but display that error message in batch job log, there are more similar error messages coming in job log and job gets finished, but when my error message comes job gets cancelled.


I cannot give it as info message as it will give wrong idea about message type.


Is there any FM by which we can add message in job log?

1 ACCEPTED SOLUTION
Read only

Karan_Chopra_
Active Participant
10,666

Hi All

Issue is resolved

I had to create a new FM with exception specifically as 'ERROR_MESSAGE'.

Thanks everyone for helping !

Hello

I have a batch job running and I have an error coming during some validation logic.

The problem is I need to continue the batch job when this error message comes and it should not cancel the batch job as it is doing currently but display that error message in batch job log, there are more similar error messages coming in job log and job gets finished, but when my error message comes job gets cancelled.


I cannot give it as info message as it will give wrong idea about message type.


Is there any FM by which we can add message in job log?

21 REPLIES 21
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
10,666

Hi Karan

When a program is run in batch job this is how we do. We add information message. Seconldy if you are not happy with this way you can create a  log samea s visible in SLG1

Nabheet

Read only

0 Likes
10,666

Already there are error messages which are getting displayed in Job log and they are returned as hard error messages only in the program, but in my case job gets cancelled but not in there case.

And i see error messages are displayed as Error messages only in job log with processing continued till end and not cancelled.

Please see screenshot

Read only

0 Likes
10,666

Hi Karan -

Is the message with message class 'ZVSC' is the message that you are showing as type 'E' ?

If that is the case then you can put a condition

IF sy-batch is initial.

MESSAGE E<messageno>(ZVSC).

ELSE.

MESSAGE I<messageno>(ZVSC).

endif.

The above code is just an example. You can do your coding as for your requirement.

Read only

0 Likes
10,666

message with class 'ZVSC' is not shown by me.

I have only shown info message(third one in message log) which I want to display as 'E' and not 'I'

Read only

0 Likes
10,666

If you will throw an error mesasge the processing will stop. One of the option you can use is

message e001 into lv_message.

write /message

Nabheet

Read only

former_member187748
Active Contributor
0 Likes
10,666

Hi Karan,

if it is your custom program through you are creating job, then you can change your message

like shown below

if sy-batch = 'X'.

Message 'Error in updating data ' type 'I'.

endif.

Read only

0 Likes
10,666

Sanjeev I have done that but problem is I do not want to give that as Information message but Error message only and continue processing.

If you see in screenshot 3rd message is given by me as information and you can see error messages also 6th and 7th and job continued till it is finished

Basically I want that 'I' to be displayed as 'E'.

Read only

0 Likes
10,666

Hi Change the code as shown below

if sy-batch = 'X'.

Message 'Error in updating data ' type 'I' DISPLAY LIKE 'E'.

endif.

Read only

0 Likes
10,666

this will not display message as 'E' in log, but as 'I' only.

already tried that

Read only

0 Likes
10,666

Hi karan,

i am sorry, i just misses that you are showing it as a log.

Let me see your issue more specifically.

Read only

Former Member
0 Likes
10,666

Hi Karan,

Instead of raising error message why you cant try with ALV for all the messages ?

Thanks & Regards,

Arun

Read only

0 Likes
10,666

Hi Aruna

Job is run thru standard SAP transaction for Shipment document create and we have some enhancements from where messages are coming, cannot display them in ALV

Read only

Karan_Chopra_
Active Participant
0 Likes
10,666

Experts

Any suggestion on this?

Read only

ThangaPrakash
Active Contributor
0 Likes
10,666

Hello KC,

Have you tried ROLLBACK WORK after the error message.

Regards,

Thanga

Read only

0 Likes
10,666

Thanga Prakash error message will stop the processing no rollback work will work

Read only

0 Likes
10,666

Yes you are right, I checked in my program and it is not working.

Read only

0 Likes
10,666

Nabheet

As I showed in screenshot it is possible to show error message in Job log and continue but I am not able to find a solution how ?

Read only

RaymondGiuseppi
Active Contributor
0 Likes
10,666

Only available solution with job log seems to be the sending of an error message and then its handling it  with an error_message exception option. (*)

So you may be required to develop

  • a FM that executes the standard report
  • a wrapper progam that call this FM and monitor exception error_message.

But if the main report is a standard you should not be allowed to do that, changing the type of message without any other change would then allows execution of the "transactions".

In which customer-exit/BAdI is this message raised ?

Regards,

Raymond

(*) Read MESSAGE documentation : Messages in background processing

Read only

0 Likes
10,666

I am using a user exit so anyhow I can use FM in that.

Can you tell me how to handle with FM

Read only

Karan_Chopra_
Active Participant
10,667

Hi All

Issue is resolved

I had to create a new FM with exception specifically as 'ERROR_MESSAGE'.

Thanks everyone for helping !

Read only

0 Likes
10,666

Hi,

I am also having similar requirement, can you please share code of your new FM ?