2015 Dec 11 11:19 AM
Hi,
we got the problem, that we have to implement a BADI that is not is multiple use.
With oder words:
We can either implement Badi (A) oder Badi (B).
So we decedied to implement Badi (A)
As a result the statement:
GET BADI lr_data_provision.
returns Badi (A).
We got now the requirement that - in special cases - not Badi (A) should be called. Instead Badi (B) should be called.
Is there a special ABAP statement where I can overwrite the implementing class in lr_data_provision?
Thanks
Regards
Mario
2015 Dec 11 11:24 AM
Hi Mario,
I would suggest the following approach to implement this requirement using the strategy pattern.
1.) Implement one BAdI S. This is the BAdI that is active in the BAdI customizing.
2.) Inside S check for you special case. If the special case is present call implementation class B, otherwise call implementation class A.
This way you don't need any modifications or something like this.
Christian
Hi,
we got the problem, that we have to implement a BADI that is not is multiple use.
With oder words:
We can either implement Badi (A) oder Badi (B).
So we decedied to implement Badi (A)
As a result the statement:
GET BADI lr_data_provision.
returns Badi (A).
We got now the requirement that - in special cases - not Badi (A) should be called. Instead Badi (B) should be called.
Is there a special ABAP statement where I can overwrite the implementing class in lr_data_provision?
Thanks
Regards
Mario
2015 Dec 11 11:24 AM
Hi Mario,
I would suggest the following approach to implement this requirement using the strategy pattern.
1.) Implement one BAdI S. This is the BAdI that is active in the BAdI customizing.
2.) Inside S check for you special case. If the special case is present call implementation class B, otherwise call implementation class A.
This way you don't need any modifications or something like this.
Christian
2015 Dec 11 11:35 AM
Hi Christian,
nice approach!!
Would you tell me how to/which ABAP statement to use to call e.g. the implementation of BADI (B)
Unfortunatelly the BADI has no constuctor; I guess that is the SAP intention.
A BADI is compareable to a factory; That is, why you habe to use the GET BADI statement.
Regards
Mario
2015 Dec 11 12:10 PM
Hi Mario,
the BAdI is implemented using a class that implements a certain interface. Simply instantiate the BAdI implementation class in your custom code. So instead of GET BADI simply use data badi_ref = new <badi implementation class>.
The only drawback I see for this approach is that you code against a specific class implementation not against a specific BAdI implementation. That means if e.G. SAP changes teh implementation class used to implement BAdI Implementation X from Class cl_badi_impl_1 to cl_badi_impl_2 your code would still invoke cl_badi_impl_1. However, I see this a merely a theoretical issue.
Christian
2015 Dec 11 12:13 PM
Thanks
I already coded a variant of your suggestion!
Works fine!
10 Points!
2015 Dec 11 11:25 AM
Can you not place the code in one BADI with a conditional expression:
if condition badi a
code which is in badi a
elseif condition badi b
code which is in badi b.
endif.
2015 Dec 11 11:37 AM
Hi Peter,
you missunderstoud my question.
Instead of calling BADI (A) (wich is customized as implementation) I want to call BADI (B).
Regards Mario
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |