2023 Aug 26 11:12 AM
Hi Guys,
I'm trying to create some custom BADI for our custom reports. Therefor I created BADI definition and interface with three methods in it. Now when I do an implementation of BADI and do NOT implement all interface methods, SE19 throws error that I have to implement all methods. How can I change this? Not every customer has to implement all methods of the BADI.
I saw this flag default IGNORE or default FAIL, but it looks like that it has no impact on the error if I set it to FAIL. Only setting it to IGNORE lets the message disappear. My problem is in the custom report I have some coding where the BADI is implemented. Now if I do an empty method in the BADI implementation it looks like that method is implemented an customer wants to use this BADI method, so I need a criteria to find out if a BADI method is used or not. How can I do that? Of course I could give a EXPORTING parameter lets say ED_IMPLEMENTED which I set to true or false, but does not sound that smart.
Regards
Michael
2023 Aug 26 12:26 PM
That's weird, I don't remember to do anything about BAdI methods I don't use, I just implement the one method I need, activate the class, the other methods are just created empty and there's no error...
I just checked by creating an enhancement spot, BAdI definition, implementation, no problem.
I guess the second part of your question is a workaround for the main issue, so I think that you don't need an answer to it, you just need to understand what's the issue with the first part.
2023 Aug 26 12:34 PM
Actually it is not a syntax error in the class, but when activate the implementation, it always requires adjustment and afaik it also get problems when trying to transport some unadjusted badi.
2023 Aug 26 1:26 PM
I see this in CALL BADI documentation: ABAP Keyword Documentation (sap.com)
If a method is added to a BAdI afterwards, it may be missing in a BAdI implementation. In this case the call is executed as if the method existed with an empty implementation. Actual parameters that are bound to EXPORTING or RETURNING parameters passed by value are initialized. All other actual parameters remain unchanged.
2023 Aug 27 9:27 AM
Yes, i know that. Let my explain my intention more detailly.
I defined a custom BADI interface which has three methods in it. In my custom report there are lets say three coding places where the three methods are called individually. Every method stands for a time for example at init, at save, after save. Now if it gets enrolled to a customer, not every customer uses all three methods, so if he just uses one of them I normally would create a BADI implementation where i only implement the desired method and not the other two. When I do that, when activating the badi i get the attached screen in my previous post. I can activate the badi but whenever i get into it i come to this screen. And i did not test it but in my mind if i want to transport the badi implementation it gets error when releasing the transport request because system says please to adjustment at first.
So to get rid of the problem i can just say i would implement all the three methods, two of them empty. But when doing that i now get some problems with my coding implementation. I need - if doing like that - a criteria which gives me difference if method is implemented empty or method is implemented with code because in my main program where the badi is called it should stop if method is implemented empty. So i thought best way is to not implement the method and then catch not implemented exception but when doing that i get the above named problem when activating the badi implementation.
2023 Aug 27 10:08 AM
It's what I said in my answer, I don't reproduce on my system, if I implement only one method, the other method is created empty implicitly. We should investigate about how you "implement only one method", about your system version, etc.
I don't get what is the issue (apart the issue about the dump which requires some investigation).
It's difficult to me to discuss without example, here is my proposal below.
CALL BADI custom_badi->action_1 EXPORTING ... RECEIVING result = DATA(result_of_action_1).
IF result_of_action_1-verb_to_describe_action_1 = abap_false.
" STOP
ENDIF.
If empty or not implemented, it will stop.
If there is an implementation, it must always contain:
result-verb_to_describe_action_1 = abap_true.
2023 Aug 27 10:12 AM
But this means that I have to create a parameter lets name it rd_method_in_use in every method just to check if method is "really" implemented with code or just "fake" implemented without any code?
2023 Aug 27 1:22 PM
There are two kinds of BAdI methods concerning your topic.
There's no problem to use the second kind of methods.
I think you are confusing "really implemented" with a BAdI method returning a boolean (or multiple choices) to select the logic to apply.
2023 Aug 27 2:51 PM
Hm the problem is the considered BADI is a mix of both. In my example I have a button which is above an alv tree. The button visibility is dependent on badi implementation. So no badi implementation, no button. But when badi is implemented button click reaction is that some tree entries get filtered and tree gets updated.
So first call would be true or false return to control button visibility, second call would be importing a tree entry and returning flag for each tree entry which will be looped after pushing the button. But with these two different calls I have to set some parameter optional because first call of course canot import tree entry. Of course I could differ in two different interface methods but creating one method just to proove button active or not sounds a bit overdesigned for me.
2023 Aug 27 6:00 PM
I think you're wrong, you should create 2 methods, it's better design. Simple as that.
3 weeks ago
Hello,
as I had this problem as well, through its been a few years since this was asked, and the answer from Sandra Rossi was rather useless for the actual solution, here is the solution I found:
In the Interface Methode you can either add "DEFAULT IGNORE" after the method name in eclipse or do the same by going to the method properties and selecting "Define runtime behavior when method is not implemented" -> "Emulate empty method implementation".
After doing this, the BAdI Implementation does not need all the method implemented anymore.