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

How Badi is called (when multiple implementations exist)?

Former Member
0 Likes
6,515

Hi,

When we want to implement a SAP Provided BADI for a standard t-code (say VL02),

how is our Badi implementation called when the tcode (say VL02) is executed?

There may be multiple (say 5 different) implementations of the same Badi for the same Tcode.

11 REPLIES 11
Read only

custodio_deoliveira
Active Contributor
0 Likes
3,629

Hi Monika,

SAP HELP says the BAdI will be called in a random order, which means you cannot control the execution sequence, hence you must be very careful.


Multiple use for BADI definitions  means that there can be several

active BADI implementations. When there is a call, they are all called

up - however, in an unpredictable sequence.

If you have multiple-use BADI definitions, the sequence must not play

any role therefore. A typical example is the execution of checks before

a save.

Cheers,

Custodio

Read only

0 Likes
3,629

Hi,

Thanks a lot.

That answers my question.

Appreciated your quoting the 'SAP Help' contents.

Read only

Former Member
0 Likes
3,629

Hi Monika,

Please use the below code to coll the BADI implementation-

CALL METHOD CL_EXITHANDLER=>GET_INSTANCE

EXPORTING EXIT_NAME = LV_EXITNAME

NULL_INSTANCE_ACCEPTED = SEEX_TRUE

CHANGING  INSTANCE = LV_INSTANCE.

LV_INSTANCE will point to the instance of BADI implementation.

LV_EXITNAME is the Badi implementation to be called.

LV_INSTANCE must be TYPE REF TO BADI's interface.

Thanks,

Anuj

Read only

0 Likes
3,629

Hi Anuj,

Hope this code works for CLASSIC BADI.

Thanks for your interest in this topic.

Read only

former_member182354
Contributor
0 Likes
3,629

Hi,

    There is no particular sequence which triggers the BADI implementation. They will be triggered randomly.

Raghav

Read only

0 Likes
3,629

Hi,

Thanks a lot.

That answers my question.

Read only

0 Likes
3,629

Monica..Please mark question answered if your query is answered.

Raghav

Read only

0 Likes
3,629

Pls tell the steps to mark this post as 'Answered'

Read only

0 Likes
3,629

You can't mark it correct as it is a discussion, not marked as question.

It was either not marked as question from the very beginning, or a moderator did it acting upon an alert.

Read only

0 Likes
3,629

Hi Monika,

That's how you d it:

Cheers,

Custodio

Read only

former_member184611
Active Participant
0 Likes
3,629

Hi Monika,

In case of New BADI(Kernel), the attribute 'Runtime Behavior' of the BADI implementation also plays a very important role. 


suppose a BADI has 2 implementations,  BADI_IMP1 and BADI_IMP2. And Both the BADI Implementations are active and Runtime Behavior will be 'Implementation is active'. At a later point of time BADI_IMP1 is deleted and only BADI2 exist and is active. But the BADI assigment of BADI_IMP1 to the enhancement implementation still exist. Then while execution, when the control comes to Enhancement Implementation, it'll check for the BADI implementations in that. There BADI_IMP1 and BADI_IMP2 are present. And if BADI_IMP1 (deleted BADI) runtime behaviour is active, then control will just skip the remaining BADI's, as BADI1 is not available. So BADI2 will not be executed.


Thanks and regards,

Abyson Joseph