A Tour of the New Enhancement Framework

download A Tour of the New Enhancement Framework

of 3

Transcript of A Tour of the New Enhancement Framework

  • 7/31/2019 A Tour of the New Enhancement Framework

    1/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

    [email protected](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

    Click here to read this Snippet

    http://www.erptips.com/Snippets/hopndcakjb.pdf#page=2http://www.erptips.com/Snippets/hopndcakjb.pdf#page=2
  • 7/31/2019 A Tour of the New Enhancement Framework

    2/3

    SAPtips

    SAPtipsJournal

    August/Sep

    tember2008VolumeVIIssue4

    SAPtips.com SAPtips 2008 Klee Associate

    4On ABAP / J2EE

    An enhancement spot element may be linked witheither one or multiple simple enhancement spots. Theseare then assigned to a composite enhancement spot.

    Composite enhancement spots are used or meaningulgrouping o simple spots. A composite spot may containone or more simple or related composite enhancementspots.

    Lets consider the example shown in Figure 2.

    In our example, the main composite enhancement spotis SAP, which contains another composite spot, SD. Thespot Invoicing is contained in SD, and contains a simplespot named Pricing. Within the pricing spot are twoenhancement options: one is comprised o source codeenhancement and the other is a BAdI denition.

    Two important types o enhancement options that SAPallows within the program coding are EnhancementPoints and Enhancement Sections (these will be cov-ered in detail in the next section). The Enhancementpoints are used or dening additional data, or oradding an additional coding block. On the other hand,the Enhancement section concept lets you replace thealready-dened data or an existing code block.

    There may be both Static and Dynamic types oenhancement points and sections. Static options let

    you make additional data declarations. The keywordSTATIC is used to denote the static types. Moreover,orm routines, class, and routines are specied usingdynamic types. Dynamic calls do not have any addi-tional keywords.

    Source Code Enhancements and SourceCode Plug-InsSAP recommends using a Business Add-In to be usedwhen possible since a BAdI has a proper interace andthe provider o the option has control over the imple-mentation. In addition, the BAdI implementation canonly access the data that is passed via the parameters

    o the various BAdI methods. The parameters aredetermined by the BAdI creator. However, BAdIs havedisadvantages also. For example, it would be dicult touse a BAdI in a situation where you cannot predict thedata that the implementer o your enhancement optionswill require. In other words, i you cannot determine theinterace requirements, you may not be able to use aBAdI. In such cases, the SourceCode Enhancements must beused.

    There may be two types o enhancement options insource code enhancements. They are listed here:

    Enhancement Points

    In this option, the implementer has the power o ading new lines to the program. These lines are execut

    when the statement ENHANCEMENT POINT isreached at runtime. Ater execution o the implemener code, the control fow goes to the next line ater thenhancement point in question. You may have oneor more (or even no) implementations assigned to aenhancement point.

    Enhancement Section

    A major drawback o the enhancement points are ththey may only be executed as additions to the existincode. They may not replace existing code or cannotbe part o an ABAP statement. For example, consida situation in which you cannot add a new condition

    to a SELECT statements WHERE clause. In this caenhancement points ail, and enhancement sectionssurvive.

    Consider this SELECT statement (as shown in Figu3).

    Figure 2: Composite and Simple Enhancement Spots

    Figure 3: Select Statement

    SELECT * FROM ZTAB INTO TABLE ITAB1.

  • 7/31/2019 A Tour of the New Enhancement Framework

    3/3

    SAPtips

    SAPtipsJournal

    August/Sep

    tember2008VolumeVIIssue4

    SAPtips.com SAPtips 2008 Klee Associate

    4On ABAP / J2EE

    I you like the implementerto have the option to addWHERE clause, the SELECT

    statement must be markedas an enhancement section asshown in Figure 4.

    One enhancement section mayhave only one active imple-mentation.

    Note: The source code enhance-ment technology is suitablei you want to provide anenhancement option, but do notwant to speciy an interace.

    Now lets discuss Source CodePlug-ins. In a program, youmay have predened points that may be enhanced viaenhancement options. You may have an enhancementpoint that is a type o an enhancement option. You canattach enhancements at these points, known as SourceCode Plug-ins. When the program fow reaches theenhancement point, the relevant plug-in is executed.The plug-in, in other words, acts as i it is part o thereport in question.

    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 enhance-ment-point. The enhancement spot is FLIGHTS_DISPLAY_B and the enhancement is FLIGHTS_DISPLAY.

    The source code may not have enhancements anywhereelse except the allowed enhancement options. Thereare enhancement options where enhancement elementsmay be inserted. This will be shown in detail later in thearticle.

    Creating Your Own Explicit EnhancementOptionsIn most cases, you are able to implement enhance-ment options provided by SAP. However, in some caseyou may be required to develop enhancement pointsyoursel. Developers that create applications to be useand enhanced by other developers may create their owenhancement options.

    We will now take a look at the steps required orcreating an enhancement option (in our case, we useenhancement point as an example).

    While dening an enhancement point, the enhance-ment point has to be part o an enhancement spot. I aexisting enhancement spot may not be used, you needcreate a new one while dening the enhancement poinLets go through the steps required in creating anenhancement point:

    Open the source code o the object that you want toenhance, in Change mode.

    Place the cursor on the line where you want to creatthe enhancement point. Right-click in order to accesthe 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 o the enhancement point in the eldprovided. Speciy whether it is an enhancement point a section. Also speciy whether it is a data declarationa code.

    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

    The source code may not have

    enhancements anywhere

    else except the allowed

    enhancement options.