Learn how to work with enhancements of a global class — such as post-methods — and get to know how to plan, structure, and implement a project in which you make your enhancements switchable. Assign the relevant packages to a switch, assign the switch to a reversible business function, and switch the whole project on in transaction SFW5.
Using the Switch Framework, a framework in the ABAP stack of SAP NetWeaver, you can make all your enhancements switchable by encapsulating all enhancements with a business function to the switches. If your business function is reversible, you can easily switch off all enhancements of the Enhancement Framework to return an application to its original state.
Get to know a more complex example that uses different ways of enhancing a global class. In this example, you will learn how to use the advantages of the enhancement technology efficiently and thereby build different add-on functionality for the basic application. The use case is not extremely complex and is simplified so that you can focus on the enhancement technology. The basic application allows you to retrieve flight data from a database table. You will develop two enhancement projects. In the first enhancement project, you need to get additional information for every row by adding two columns and retrieve the additional data by selecting it in a post-method. Next, in a second enhancement project, you insert an additional search condition in a new input field and create an additional button. To make the new search criteria work, you need an overwrite method for the controller method and a new method in the back end.
Once you have created and wired up all the enhancements you need for this example, you are going to make the two projects switchable so that you can decide which of the two enhancements to switch on. Your enhancement projects profit from the Switch Framework in two ways:
- You can provide different add-on functionality on top of a standard application, for example, in the global IT department of your company and just switch on or off the new functionality in subsidiaries as needed.
- Encapsulating your enhancements with switches and a business function helps you to decide if errors in the SAP application that you have adapted result from a problem with the SAP code or if they were caused by your code.
Just encapsulate all your enhancements by switches, bundle the switches in a reversible business function, and there you are. If the business function is switched on, the new functionality — including the new UI elements — is available at runtime. If you switch off the new functionality, you return to the former state of the application. Elements that are switched off or deactivated are not even compiled, so they cannot slow down an application or influence its performance in any way. Just switch off your code. If the problem vanishes, the culprit is most probably in your code; if the problem persists, this indicates that the problem lies within the SAP code.