Sei sulla pagina 1di 3

A Tour of the New Enhancement Framework: A Guide for SAP Below is a snippet from one of hundreds of articles available

to ERPtips subscribers. If you would like a complimentary copy of the full article, please email Mark.Downs@ERPtips.com (include the title of the article in your email) To subscribe to ERPtips, go to www.ERPtips.com/Subscribe.asp. ERPtips Journal is published by Klee Associates, Inc. ERPtips University provides both public and onsite training for SAP clients. For more about ERPtips University, including the current schedule, click here: www.ERPtips.com/WorkshopSchedule.asp

A Tour of the New Enhancement Framework: A Guide for SAP

What`s new with the Enhancement Framework in NetWeaver? Rehan Zaidi provides us with a guided

Click here to read this Snippet

SAPtips4On ABAP / J2EE


August / September 2008 Volume VI Issue 4
Page 

An enhancement spot element may be linked with either one or multiple simple enhancement spots. These are then assigned to a composite enhancement spot. Composite enhancement spots are used for meaningful grouping of simple spots. A composite spot may contain one or more simple or related composite enhancement spots. Lets consider the example shown in Figure 2. In our example, the main composite enhancement spot is SAP, which contains another composite spot, SD. The spot Invoicing is contained in SD, and contains a simple spot named Pricing. Within the pricing spot are two enhancement options: one is comprised of source code enhancement and the other is a BAdI definition. Two important types of enhancement options that SAP allows within the program coding are Enhancement Points and Enhancement Sections (these will be covered in detail in the next section). The Enhancement points are used for defining additional data, or for adding an additional coding block. On the other hand, the Enhancement section concept lets you replace the already-defined data or an existing code block. There may be both Static and Dynamic types of enhancement points and sections. Static options let you make additional data declarations. The keyword STATIC is used to denote the static types. Moreover, form routines, class, and routines are specified using dynamic types. Dynamic calls do not have any additional keywords.

Figure 2: Composite and Simple Enhancement Spots

There may be two types of enhancement options in source code enhancements. They are listed here: Enhancement Points In this option, the implementer has the power of adding new lines to the program. These lines are executed when the statement ENHANCEMENT POINT is reached at runtime. After execution of the implementer code, the control flow goes to the next line after the enhancement point in question. You may have one or more (or even no) implementations assigned to an enhancement point.

Source Code Enhancements and Source Code Plug-Ins

SAPtips Journal

Enhancement Section SAP recommends using a Business Add-In to be used A major drawback of the enhancement points are that when possible since a BAdI has a proper interface and they may only be executed as additions to the existing the provider of the option has control over the implecode. They may not replace existing code or cannot mentation. In addition, the BAdI implementation can be part of an ABAP statement. For example, consider only access the data that is passed via the parameters a situation in which you cannot add a new condition of the various BAdI methods. The parameters are to a SELECT statements WHERE clause. In this case determined by the BAdI creator. However, BAdIs have enhancement points fail, and enhancement sections disadvantages also. For example, it would be difficult to survive. use a BAdI in a situation where you cannot predict the data that the implementer of your enhancement options Consider this SELECT statement (as shown in Figure will require. In other words, if you cannot determine the 3). interface requirements, you may not be able to use a BAdI. In such cases, the Source Code Enhancements must be SELECT * FROM ZTAB INTO TABLE ITAB1. used. Figure 3: Select Statement

SAPtips.com

SAPtips 2008 Klee Associates, Inc.

SAPtips4On ABAP / J2EE


August / September 2008 Volume VI Issue 4
Page 

If you like the implementer to have the option to add WHERE clause, the SELECT statement must be marked as an enhancement section as shown in Figure 4. One enhancement section may have only one active implementation. Note: The source code enhancement technology is suitable if you want to provide an enhancement option, but do not want to specify an interface.

ENHANCEMENT-SECTION FOR_SELECT SPOTS ES_MY_FIRST_SPOT. SELECT * FROM ZTAB INTO TABLE ITAB1. END-ENHANCEMENT-SECTION.
Figure 4: WHERE Clause SELECT Statement

ENHANCEMENT-POINT DECLARATION SPOTS FLIGHTS_DISPLAY_B STATIC. ENHANCEMENT 1 FLIGHTS_DISPLAY. DATA : . .. ENDENHANCEMENT.

Figure 5: Source Code Plug-In Now lets discuss Source Code Plug-ins. In a program, you may have predefined points that may be enhanced via enhancement options. You may have an enhancement point that is a type of an enhancement option. You can attach enhancements at these points, known as Source Code Plug-ins. When the program flow reaches the enhancement point, the relevant plug-in is executed. The plug-in, in other words, acts as if it is part of the report in question.

Creating Your Own Explicit Enhancement Options

In most cases, you are able to implement enhancement options provided by SAP. However, in some cases, you may be required to develop enhancement points yourself. Developers that create applications to be used and enhanced by other developers may create their own enhancement options. We will now take a look at the steps required for creating an enhancement option (in our case, we use enhancement point as an example). While defining an enhancement point, the enhancement point has to be part of an enhancement spot. If an existing enhancement spot may not be used, you need to create a new one while defining the enhancement point. Lets go through the steps required in creating an enhancement point: Open the source code of the object that you want to enhance, in Change mode. Place the cursor on the line where you want to create the enhancement point. Right-click in order to access the context menu, as shown in Figure 6. Choose the menu path Enhancements Create. A dialog box appears, as shown in Figure 7. Enter the name of the enhancement point in the field provided. Specify whether it is an enhancement point or a section. Also specify whether it is a data declaration or a code.

A source code plug-in is shown in Figure 5. In Figure 5, the enhancement point is shown in bold. The enhancement element 1 is assigned to the enhancement-point. The enhancement spot is FLIGHTS_DISPLAY_B and the enhancement is FLIGHTS_DISPLAY. The source code may not have enhancements anywhere else except the allowed enhancement options. There are enhancement options where enhancement elements may be inserted. This will be shown in detail later in the article.

SAPtips Journal

The source code may not have enhancements anywhere else except the allowed enhancement options.

SAPtips.com

SAPtips 2008 Klee Associates, Inc.

Potrebbero piacerti anche