Application Development 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: 

Why only BADI and not normal Z-Classes?

Former Member
0 Kudos

Usually an SAP program calls a BADI using a code

similar to:

CLASS CL_EXITHANDLER DEFINITION LOAD.

DATA MYEXIT TYPE REF TO IF_EX_BADINAME.

CALL METHOD CL_EXITHANDLER=>GET_INSTANCE

CHANGING INSTANCE = MYEXIT.

“ fetching instance of the BADI class

MYEXIT->BADIMETHOD “ calling the BADI method

EXPORTING….

……

IMPORTING….

It is recommended that the BADI we create also be called

the same way.. It would work juz fine if i create a

normal interface and class and call them from my

program.. If the BADI's are implemented by use of normal

Classes and Interfaces why should we go for BADI's and

why the special name 'BADI'?

Or is there any special functioning of a BADI? Does any

one know how BADI's exactly work and how they are

different from normal interfaces and classes? If anyone

has a link to some BADI reference material pls do provide

the link..

Thank you..

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

Hi,

BADI is Business Addin , here you can add a specific logic/fucntionality to the existing SAP standard Program or Transaction. you cannot add your own code where ever you feel. SAP will not support those. and you cannot use or implement what ever you feel in BADI, there are BADI's defined for certain functionalities like adding of customer screens, doing some checks etc...

Regards

Vijay

6 REPLIES 6

former_member188685
Active Contributor
0 Kudos

Hi,

BADI is Business Addin , here you can add a specific logic/fucntionality to the existing SAP standard Program or Transaction. you cannot add your own code where ever you feel. SAP will not support those. and you cannot use or implement what ever you feel in BADI, there are BADI's defined for certain functionalities like adding of customer screens, doing some checks etc...

Regards

Vijay

former_member188685
Active Contributor

Former Member
0 Kudos

Anand,

BADI's are nothing but user exits. So, you use them only if you want to add more to the standard functionality. You usually don't create a BADI for yourself, all you do implement a BADI which SAP has provided.

Technically, BADI is implemented using classes / methods / interfaces and user exits are done using function modules.

For your custom coding, you should always go with creating CLASSES / METHODS - SE24. You don't create BADI's.

Hope things are clear now.

Regards,

Ravi

Note : Please mark the helpful answers

0 Kudos

Hi Ravi,

allow me to disagree with you on this. Creating your own BAdI can be very useful, see this link for excelent example:

<u>/people/sergey.korolev/blog/2005/03/14/the-time-for-me-to-have-a-badi-of-my-own

Here is another example.

Every year, there will be a conversion of one DB table. What is unknown is what are the rules for conversion, it will change every time.

One aproach is to create program and then change it every year.

Another one is to create BAdI, write program once and then code specific business logic separately in BAdI implementation.

Hope this helps.

DD

Hope this

0 Kudos

Dusan,

The whole idea of BADI is to add value to the standard processing. I went through the weblog you have mentioned.

What the author of the weblog is doing is to create a new BADR, no doubt about it. However, if you have observer it closely he is calling it from a user exit (Function module). That means, whether its a standard BADI or a custom BADI, we are still dependent on the standard code to provide a user exit. Now assume a case, where you don't have a user exit, what are you going to do by creating a custom BADI, you cannot call that anyways.

So, my point of view is, for this thread's question - BADI vs Z-Classes - These are two different things. You can implement a standard / custom BADI only when there a provision made by the SAP Developers. Where as Custom classes are specific to my functionality and I can use it as it is applicable.

Now, coming to weblog's point of creating a custom BADI - If I have to create a custom BADI, I can as well create a custom class and a custom interface and implement that in the user exit (Function) provided. Technically I don't have to create a BADI. And the custom class will still serve the same purpose. As I have an interface, every programmer using this interface can have their own implementation, so it doesn't mandate me to create my own BADI.

Your thought's please?

regards,

Ravi

Former Member
0 Kudos

BAdI Works under the concepts of Run time polymorphism. BADI is a User exit. Standard SAP Program call the interface method not the Z-class that u going to create. Objects cannot be handled without creating the instances .

CREATE OBJECT ref TYPE class.

CREATE OBJECT ref TYPE (class).

This are two syntax help to create object for the class with reference of interface . BADI works like this , it will contain the name of the class that u created and currently been activated(since many implementation can there for same definition,add-ins) . This help to call that class method using instance create by above syntax. This is what happen in the CL_EXITHANDLER=>GET_INSTANCE method. They help to get the activated business add-in which it as to reflect in the standard SAP program and create the instance to the method.