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

Re: BADI EXECUTION

Former Member
0 Likes
1,529

Hi All.

I have developed a custom badi in Se18 & implemented in se19. I want to use custom badi in SE38. Can anyone explain how to call custom badi in se38 . urgent usefull will be Rewarded.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
958

Hi

For example The Badi def is: MB_MIGO_BADI. For this

U create the implementation and activate the implemenation using se19 transaction.

Actually SAP not interact the implemenation classes directly . Sap interact with the implementation classes using the Business add-in class(For ex in this cas:CL_EX_MB_MIGO_BADI).

The sample code is as follows:

data: l_badi_inst type ref to IF_EX_MB_MIGO_BADI

CALL METHOD CL_EXITHANDLER=>GET_INSTANCE

EXPORTING

EXIT_NAME = 'MB_MIGO_BADI'

CHANGING

INSTANCE = l_badi_inst

EXCEPTIONS

NO_REFERENCE = 1

NO_INTERFACE_REFERENCE = 2

NO_EXIT_INTERFACE = 3

CLASS_NOT_IMPLEMENT_INTERFACE = 4

SINGLE_EXIT_MULTIPLY_ACTIVE = 5

CAST_ERROR = 6

EXIT_NOT_EXISTING = 7

DATA_INCONS_IN_EXIT_MANAGEM = 8

others = 9.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

If sy-subrc = 0. The cl_exithandler take the input as interface reference variable and return back to the object of business add-in class.

To use this object and interact with the implemenation classes.

else.

call method l_badi_inst->(u r reuired method in implemenattion class).

If it is helpful rewards points.

Regards

Pratap.M

3 REPLIES 3
Read only

uwe_schieferstein
Active Contributor
0 Likes
958

Hello Rajesh

Depending on which SAP release you are working alread you either can use

- class CL_EXITHANDLER (static method GET_INSTANCE) or

- statement GET BADI

to retrieve an instance of your custom BAdI. Whereas the first way should always work I am not sure about the second way with custom BAdIs.

Regards

Uwe

Read only

chaithanya_mk
Participant
0 Likes
958

Hi Rajesh,

Uwe's reply is the standard method to call BADI from SE38.

Other than that, there is another workaround as follows.

1. When you create a BADI in SE18 it actually creates a class and it's method.

2. When you implement it in SE19 a interface is created. You can access the methods using this interface.

3. Hence, create a object of the class and then you can call the methods using this object.

Rewards if useful.

Thanks,

Chaith.

Read only

Former Member
0 Likes
959

Hi

For example The Badi def is: MB_MIGO_BADI. For this

U create the implementation and activate the implemenation using se19 transaction.

Actually SAP not interact the implemenation classes directly . Sap interact with the implementation classes using the Business add-in class(For ex in this cas:CL_EX_MB_MIGO_BADI).

The sample code is as follows:

data: l_badi_inst type ref to IF_EX_MB_MIGO_BADI

CALL METHOD CL_EXITHANDLER=>GET_INSTANCE

EXPORTING

EXIT_NAME = 'MB_MIGO_BADI'

CHANGING

INSTANCE = l_badi_inst

EXCEPTIONS

NO_REFERENCE = 1

NO_INTERFACE_REFERENCE = 2

NO_EXIT_INTERFACE = 3

CLASS_NOT_IMPLEMENT_INTERFACE = 4

SINGLE_EXIT_MULTIPLY_ACTIVE = 5

CAST_ERROR = 6

EXIT_NOT_EXISTING = 7

DATA_INCONS_IN_EXIT_MANAGEM = 8

others = 9.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

If sy-subrc = 0. The cl_exithandler take the input as interface reference variable and return back to the object of business add-in class.

To use this object and interact with the implemenation classes.

else.

call method l_badi_inst->(u r reuired method in implemenattion class).

If it is helpful rewards points.

Regards

Pratap.M