14.01.2020 Views

ABAP_to_the_Future

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6

The Enhancement Framework and New BAdIs

Another example could involve an inte rface from SAP to a monster-making

machine, of which there are 10 possible varieties. Some of them have mandatory

data fields, varying depending on the company that made the machine. These

mandatory fields would be the same in any country where you were using that

variety of machine. However, some (but not all) countries have laws governing

what mandatory information must appear on the external machine’s display;

those laws were created before any machine was even invented, and they are naturally

different between countries.

You can handle this by creating one BA dI implementation for each variety of

machine to validate that each machine-sp ecific mandatory field is filled. Then,

create BAdI implementations for each country that has special laws to validate the

relevant fields as well. When you call the BAdI, any machine-specific checks and

any country-specific checks are performed; if either se t of checks fails, then an

error is raised. There may be no country- specific checks or no machine-specific

checks, and you may need to introduce a new country-specific check if a new law

is created. None of this matters to the calling program: It only needs to handle

any error messages sent to it.

6.6 Summary

This chapter gave you a cr ash course on user exits, focusing on the two most

recent types: BAdIs and the enhancemen t framework. You should now have a

good idea of how (and why!) to use these in your own code.

In the last code sample (Listing 6.4), you will notice comments such as “Do some

error handling.” This was left deliberately vague, because it leads in to the next

chapter, which is all about error handling.

Recommended Reading

왘 How To Define a New BAdI Within the Enhancement Framework:

http://scn.sap.com/people/thomas.weiss/blog/2006/04/03/how-to-define-a-newbadi-within-the-enhancement-framework--part-3-of-the-series

(Thomas Weiss)

왘 Back to the Future: http://scn.sap.com/community/abap/blog/2012/08/31/

back-to-the-future--part-06 (Paul Hardy)

252

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

Saved successfully!

Ooh no, something went wrong!