Skip to Content
author's profile photo Former Member
Former Member

COMMIT WORK in BADI

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Dec 16, 2015 at 06:56 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 16, 2015 at 07:00 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • Posted on Dec 17, 2015 at 02:11 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 17, 2015 at 02:18 PM

    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

    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.