cancel
Showing results for 
Search instead for 
Did you mean: 

How to continue executing batch job even after error

RaviSee
Explorer
0 Kudos
724

Hello,

I have a requirement where i have to continue batch job even after error and the job should not cancel and the message should appear as error not like information or warning in the job log.

Sandra_Rossi
Active Contributor
0 Kudos
See explanation and solution in the official ABAP documentation of MESSAGE (behavior in a background job): https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_message_batc...
RaviSee
Explorer
0 Kudos
It seems there is no other way to handle error msg without stopping the job?
Sandra_Rossi
Active Contributor

Please read again the documentation. Isn't it clear how to solve?

Messages of type E and A are written to the log. A check is then performed to see whether the message is handled using error_message. If this is not the case, the message is also written to the log with message number 564 of the message class 00 and current background processing is terminated, whereby a message of type A executes a database rollback and a message of type E does not. Background processing is resumed when the message is handled.

It means that the "current background processing is terminated" only if you don't handle using error_message, which means "it is not terminated" if you handle using error_message. "error_message" is a hyperlink to another document.

RaviSee
Explorer
0 Kudos
Hello @Sandra_Rossi, Sorry for the late answers, i am new to this topic. Yes i have seen errors in V_SA (Collective log) but it is creating deliveries.

Accepted Solutions (1)

Accepted Solutions (1)

RaviSee
Explorer
0 Kudos

Hello,

I have resolved the issue by writing the below logic.

if delivery contains an errors and sy-batch = 'X'. "ct_finchdel (IF_EX_LE_SHP_DELIVERY_PROC~DELIVERY_FINAL_CHECK)

Note: Ct_finchdel contains custom errors which is populated at (IF_EX_LE_SHP_DELIVERY_PROC~DELIVERY_FINAL_CHECK)

            DELETE ct_vbuk WHERE vbeln <lfs_likp>-vbeln.  "$       1 entry
            DELETE ct_vbup WHERE vbeln <lfs_likp>-vbeln. "$       1 entry
*           clearing Update indicator so that delivery cannot be created and deleting the temp delivery no. so that delivery no. should not be assigned
            CLEAR<lfs_likp>-updkz<lfs_likp>-vbeln.
*           Deleting the entries from VBPA
            CLEARct_vbpact_vbuv.

* Set the UPDKZ as D for the entries with VBELN as "$    1" in the ct_lips and ct_vbfa

endif.

Answers (3)

Answers (3)

raymond_giuseppi
Active Contributor

In the BAdI implementation did you

  • (wrong) use a MESSAGE statement to raise an error
  • (good) fill the CT_FINCHDEL with document number and message variable
RaviSee
Explorer
0 Kudos
Thanks.. will check
RaviSee
Explorer
0 Kudos

I have executed the program RVV50R10C in foreground and it is populating the error in ct_finchdel but still it is creating delivery and in background it is not creating any delivery and not throwing any error

raymond_giuseppi
Active Contributor
0 Kudos
  • Is an application log available in SLG1 or in transaction V_SA?
  • Are pop-up windows displayed during interactive execution?
  • Did you already look for OSS notes?
  • Are other Customer Exit/BAdI/User Exit active that would check sy-batch or require a GUI connexion?
RaviSee
Explorer
0 Kudos
Hi @raymond_giuseppi, I am checking your mentioned points and get back with the answers.
RaviSee
Explorer
0 Kudos
Hello @raymond_giuseppi, I have created a job via sm36 for the error scenario at delivery but still it is creating deliveries even though i populated errors at CT_FINCHDEL and it is showing in V_SA. Is there any way not to create deliveries when error occured without terminating the job.
Sandra_Rossi
Active Contributor
0 Kudos
It will be difficult to help you if you do not answer the questions...
Sandra_Rossi
Active Contributor
0 Kudos

I mean, you don't help us a lot if you don't answer ALL the questions asked by Raymond:


@raymond_giuseppi wrote:

Is an application log available in SLG1 or in transaction V_SA?
Are pop-up windows displayed during interactive execution?
Did you already look for OSS notes?
Are other Customer Exit/BAdI/User Exit active that would check sy-batch or require a GUI connexion?


 

RaviSee
Explorer

Hello, thanks everyone for guiding me.. I have found the solution by using a below code at USEREXIT_SAVE_DOCUMENT_PREPARE to skip the error deliveries without stopping the background job.

if delivery contains an errors and sy-batch = 'X'.  "ct_finchdel (IF_EX_LE_SHP_DELIVERY_PROC~DELIVERY_FINAL_CHECK)

            DELETE ct_vbuk WHERE vbeln <lfs_likp>-vbeln.  "$       1 entry
            DELETE ct_vbup WHERE vbeln <lfs_likp>-vbeln. "$       1 entry
*           clearing Update indicator so that delivery cannot be created and deleting the temp delivery no. so that delivery no. should not be assigned
            CLEAR<lfs_likp>-updkz<lfs_likp>-vbeln.
*           Deleting the entries from VBPA
            CLEARct_vbpact_vbuv.

* Set the UPDKZ as D for the entries with VBELN as "$    1" in the ct_lips and ct_vbfa

endif.

 

Sandra_Rossi
Active Contributor
0 Kudos

@RaviSeeThanks for the feedback. You'd better post a separate answer, it will be difficult to find it at the end of this unrelated answer. NB: what is this comment in your code: "ct_finchdel (IF_EX_LE_SHP_DELIVERY_PROC~DELIVERY_FINAL_CHECK)"?

RaviSee
Explorer
0 Kudos

Hello Sandra,

Thanks for the response, I am creating a delivery using batch job for program RVV50R10C and inside this we have implemented some validation at IF_EX_LE_SHP_DELIVERY_PROC~DELIVERY_FINAL_CHECK and raising an error using message statement (TYPE E) for manual process (VL01N, VL02N) and we need to implement the same error for the batch job (RVV50R10C) without terminating the job.

As per your suggestion i am going to create a new custom function module with exception error_message to handle validation inside IF_EX_LE_SHP_DELIVERY_PROC~DELIVERY_FINAL_CHECK using message statement.

Am i following the correct procedure, please guide me.

 

 

Sandra_Rossi
Active Contributor
0 Kudos
I don't know RVV50R10C, so I don't know if it can run in background. I guess that it can send standard error messages and that will stop the background job. If you don't want to stop the job for your message, you should send it as type 'S' instead of 'E'. I guess that the user exit is called in other contexts, so you should add a condition.
RaviSee
Explorer
0 Kudos

Hello Sandra_Rossi,

RVV50R10C running through background job only but i can't make message as success because it will create the delivery for the current record, want to stop the execution for the current record when the validation is success and store the message in the job log and go for the next record to process. 

Will it work like this, if i write like below?

Inside the Implicit enhancement if i create a custom function module like below
call zfunc

exporting v1

exceptions

error_message = n_error

zfunc (implementation)

if xyz = '1'.

message ' Throw error' type 'E'.

endif.

 

 

 

Sandra_Rossi
Active Contributor
0 Kudos
It should take two minutes for you to verify.
turkaj
Active Participant
0 Kudos

Hello,

There are various ways to implement the requirement.

Here are some questions regarding this:

  • Are these messages generated by you, i.e., is it Z-Coding?
  • A standard report is being executed:
    • Here, it depends on which report is being executed and to what extent you can intervene.

One possibility is to develop a process around the job:

  • You can run your own tracking job that tracks your job in the background and, for example, continues from where the other job left off. For instance, by restarting the job and continuing the processing from that point.
  • Another possibility is to copy the standard report and adjust it in the Z namespace according to your requirements.

It is crucial to know which job and which report are being executed in the background. Depending on this information, you can implement your solution.

RaviSee
Explorer
0 Kudos

Hello Turkaj,

It is a custom error message handled at IF_EX_LE_SHP_DELIVERY_PROC~DELIVERY_FINAL_CHECK, but the execution program is RVV50R10C. Please help me how to raise error_message for my issue.

Creating a custom function module with exception error_message and write error message statement inside that function module at IF_EX_LE_SHP_DELIVERY_PROC~DELIVERY_FINAL_CHECK will handle the issue?