14.01.2020 Views

ABAP_to_the_Future

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Defining BAdIs 6.3

Why would you want to call more than one BAdI implementation? As an example,

say that your BAdI is to be called when you’re saving a database record.

When saving the main record, you may want to update some Z tables, send messages

to external systems, send emails, start a workflow, and have SAP recite a

poem to the user (you can actually make SAP do just that, but it’s probably best

not to describe how to do so here). Each of these tasks is unrelated to the others,

and not all are done by each country. Th e United States may send an email and

start a workflow, Germany may do only the Z table updates, Australia might do

everything, France may just recite the poem, and Poland may do nothing at all. In

this case, you define one BAdI implementa tion for each of these assorted tasks,

and then set a filter for the countries that are going to use that task.

Note

In a really complicated application you often find that several developers want to work

on the same part of the program at once for different reasons. If the assorted tasks mentioned

previously were in one big routine, then any developer changing one part of that

routine would lock the whole thing; you could end up in a crazy situation in which you

have six development requests all needin g to be solved by changing user exit

MV45AFZZ and so they have to go into a queue. Solving this problem is just another

bonus to the BAdI approach.

The next screen area in Figure 6.14 is titled Instance Creation Mode . Sometimes,

you want to buffer the data inside your BAdI so that if it gets called twenty

times in a row the program doesn’t have tokeep going to the database or recalculating

all the values. Other times, however,you do want to reread the database or

recalculate the values each time.

To make sure the data inside the BA dI is created anew each time, choose Newly

Created Instantiation. If you are happy with just reusing the same data each

time, then choose Reusing Instantiation. The latter is the singleton pattern, in

which only one instance of a class can ever exist.

The bottom of the screen shown in Figure 6.14 star ts talking about a fallback

class; Section 6.4 addresses creating and dealing with such a beast.

Defining a Filter

The next step in creating the BAdI definition is to define a filter (look at the middle

of the left-hand side of the screen shown in Figure 6.14). You’ll see an icon

239

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!