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

COMMIT WORK in BADI

Former Member
0 Likes
3,056

Hi there,

I have been working on one issues, which is - In the BADI, we have one check, if that check fails then create a log in the table and raise an error message to stop the transaction.

IF Variable NE <Value>.

     CALL FM <fm1> which have UPDATES statements and FMs. ( And require COMMIT statement.)

     MESSAGE <> RAISE error_occurred.

ENDIF.

1. If i keep COMMIT statement after FM, there could be chance of unnecessary updates to DB.

2.There would be no use of 'IN UPDATE TASK' to the FM as this will not go to the update task since we are raising error message. Still i tried but no use.

Is there a way to handle this issue? Appreciate if someone could give me a way to handle this issue.

-Thanks

5 REPLIES 5
Read only

Former Member
0 Likes
1,735

Hi Srikanth,

Almost every BADi has a parameter and a method where in we can pass our messages. Do a scan of your BADi (methods) to check if we have any such parameters.

For a COMMIT WORK to trigger for your database the design should be like check everything is okay or not only then fire your update FM's.

Cheers,

Varun

Read only

Former Member
0 Likes
1,735

I hope we can add ROLLBACK WORK statement before calling the FM, can we?

IF Variable NE <Value>.

     ROLLBACK WORK.

     CALL FM <fm1> which have UPDATES statements and FMs. ( And require COMMIT statement.)

     MESSAGE <> RAISE error_occurred.

ENDIF.

Read only

0 Likes
1,735

Hey Srikanth,

You can definitely make use of the statement ROLLBACK WORK but with this you ignoring all the changes?

No logical point in writing ROLLBACK when you are not committing any changes to DB! Were you not able to find any parameters for capturing messages or is it not available?

Cheers,

Varun

Read only

kirankerudi
Active Participant
0 Likes
1,735

Srikanth, Did you try CALL FUNCTION IN BACKGROUND TASK ? This creates a separate LUW.

But, AFAIK, there might be some other methods within BADI implementation that can be used which is called during update. Do check documentation if available for the BADI.

Regards,

Kiran

Read only

karthikeyan_p3
Contributor
0 Likes
1,735

Hi Srikanth,

I am not sure why you would require to update the custom table while throwing the error message.

You could write the logic to update the ztable in a custom function module and create it as RFC enabled.

Before throwing the error message in your badi, you could call like this

CALL FUNCTION 'ZTEST' STARTING NEW TASK 'T1'

  DESTINATION 'NONE'.

The function module ZTEST will be executed in a separate task and do not influence the standard program flow.

Thanks,

Karthikeyan