BC425 Enhancements and Modifications
.
INSTRUCTOR HANDBOOK INSTRUCTOR-LED TRAINING . Course Version: 10 Course Duration: 3 Day(s) Material Number: 50110543
SAP Copyrights and Trademarks
© 2012 SAP AG. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. ●
Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
●
IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.
●
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
●
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries.
●
Oracle is a registered trademark of Oracle Corporation
●
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
●
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.
●
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.
●
●
Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.
●
SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjects Explorer, StreamWork, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.
●
Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects Software Ltd. Business Objects is an SAP company.
●
Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere, and other Sybase products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Sybase, Inc. Sybase is an SAP company.
All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.
© Copyright . All rights reserved.
iii
iv
© Copyright . All rights reserved.
About This Handbook This handbook is intended to complement the instructor-led presentation of this course, and serve as a source of reference. It is not suitable for self-study. Typographic Conventions American English is the standard used in this handbook. The following typographic conventions are also used.
This information is displayed in the instructor’s presentation
Demonstration
Procedure
Warning or Caution
Hint
Related or Additional Information
Facilitated Discussion
User interface control
Example text
Window title
Example text
© Copyright . All rights reserved.
v
vi
© Copyright . All rights reserved.
Contents ix
Course Overview
1
Unit 1:
2 8 17
Lesson: Explaining Terms for Adjusting SAP Standard Software Lesson: Describing Classic Enhancement Types Unit 2:
18 29 37
Unit 3:
Unit 4:
56 65 75 79 83 87 95 103 104 117 118 121 127 133 137 143 149 159 165
20 Minutes 25 Minutes
30 Minutes 70 Minutes 30 Minutes 40 Minutes 25 Minutes 70 Minutes 30 Minutes
Business Transaction Events Lesson: Implementing Business Transaction Events (BTEs)
Unit 6:
50 Minutes
Customer Exits Lesson: Handling Enhancement Projects Lesson: Enhancing Programs Using Program Exits Exercise 3: Implement a Customer Exit – Program Exit Lesson: Enhancing Menus Using Menu Exits Exercise 4: Implement a Customer Exit – Menu Exit Lesson: Enhancing Screens Using Screen Exits Exercise 5: Implement a Customer Exit – Screen Exit
Unit 5:
90 Minutes 20 Minutes
Enhancement of Dictionary Elements Lesson: Enhancing Tables Using Append Structures and Customizing Includes Exercise 2: Enhance a Table Lesson: Enhancing Texts of Data Elements
43 47
15 Minutes 30 Minutes
Personalization Lesson: Implementing Transaction Variants Exercise 1: Create a Transaction Variant
38
55
Adjustment of SAP Standard Software
30 Minutes
Classic Business Add-Ins Lesson: Describing an ABAP Objects Interface Lesson: Describing Classic Business Add-Ins (BAdIs) Lesson: Enhancing Programs Using Classic BAdIs Exercise 6: Implement a BAdI Program Exit Lesson: Implementing Classic BAdI Program Exits Exercise 7: Create a BAdI Definition for a Program Exit Lesson: Implementing Classic BAdI Screen Exits Exercise 8: Implement a BAdI Screen Exit Lesson: Explaining Advanced Details of BAdIs
© Copyright . All rights reserved.
20 Minutes 40 Minutes 60 Minutes 45 Minutes 90 Minutes 45 Minutes 90 Minutes 45 Minutes 20 Minutes
vii
173
Unit 7:
174 183 191
Lesson: Modifiying the SAP Standard Software Lesson: Modifying with the Modification Assistant Exercise 9: Implement Modifications
30 Minutes 30 Minutes 15 Minutes
196 200
Lesson: Implementing User Exits Lesson: Adjusting Modifications
15 Minutes 30 Minutes
211
Unit 8:
212 221 233 234
viii
Modifications of the SAP Standard
Classic Enhancements and New Enhancement Framework Lesson: Identifying Classic Enhancements Lesson: Identifying the New Enhancement Framework
Unit 9:
15 Minutes 30 Minutes
Outdated Enhancement Techniques Lesson: Identifying Outdated Enhancement Techniques
30 Minutes
© Copyright . All rights reserved.
Course Overview TARGET AUDIENCE This course is intended for the following audiences: ●
Project Manager
© Copyright . All rights reserved.
ix
x
© Copyright . All rights reserved.
UNIT 1
Adjustment of SAP Standard Software
Lesson 1 Explaining Terms for Adjusting SAP Standard Software
2
Lesson 2 Describing Classic Enhancement Types
8
UNIT OBJECTIVES ●
Describe options for adjusting SAP standard software
●
Describe classic enhancement types
© Copyright . All rights reserved.
1
Unit 1 Lesson 1 2
Explaining Terms for Adjusting SAP Standard Software
LESSON OVERVIEW This lesson provides an overview of the options available for modifying your SAP system and outlines guidelines that help you decide which option to use. Business Example You would like to learn about the options available for modifying and enhancing your SAP system. For this reason, you require the following knowledge: ●
Different levels at which you can make changes to the standard delivered by SAP
●
The most suitable method for changing the standard
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Describe options for adjusting SAP standard software
Overview of Change Levels
Figure 1: Overview Diagram – Changing the SAP Standard
You can change SAP standard software using any one of the following ways: ● Personalization
2
© Copyright . All rights reserved.
Lesson: Explaining Terms for Adjusting SAP Standard Software
●
Modification
●
Enhancement
Change Levels
Figure 2: Change Levels
The table explains how you can adjust the ERP system to meet your needs: Level
Description
Customizing
You can set up specific business processes and functions for your system according to an Implementation Guide. Therefore, possible changes have been thought through and organized.
Personalization
You can make changes to the global display attributes of certain fields, such as setting default values, hiding fields, and creating user-specific menu sequences.
Modification
You can change SAP repository objects at the customer site. If SAP delivers a changed version of the object, you must adjust the customer’s system to reflect these changes. Prior to Release 4.0B, these adjustments had to be made manually using upgrade utilities. As of Release 4.5A, the Modification Assistant has automated this procedure.
Enhancement
© Copyright . All rights reserved.
You can create repository objects for individual customers that refer to objects that already exist in the SAP repository.
3
Unit 1: Adjustment of SAP Standard Software
Level
Description
Customer Enhancement
You can create repository objects unique to individual customers in the customer namespaces.
You can do Customizing and most personalization using the tools found in SAP Business Engineer. You can make customer developments, enhancements, and modifications using the tools available in the ABAP Workbench. Procedure for Changing Functionality
Figure 3: Procedure for Changing the Functionality
If Customizing or personalization cannot fulfill your requirements, you can either start a development project or use a Complementary Software Product (CSP) solution, if available. A list of SAP-certified CSP solutions is available in the SAP Service Marketplace under an alias or software partner. A development project falls into the customer development category if the SAP standard does not already contain functions similar to the one you are trying to develop. However, if a similar SAP function exists, try to include it in your development project by either enhancing or modifying it, by using a user exit, or simply by copying the appropriate SAP program. Sometimes, modifications can cause problems. After an upgrade, you must compare new versions of SAP objects to modified versions of SAP objects that you have created and adjusted, if necessary. Prior to Release 4.0B, you had to make these adjustments manually using upgrade utilities. As of Release 4.5A, the Modification Assistant has automated this procedure. You should only make modifications in the following situations: ● Customizing or personalizing cannot satisfy your requirements.
4
●
SAP developers did not plan similar enhancements or user exits.
●
Copying the SAP object to the customer namespace does not make sense.
© Copyright . All rights reserved.
Lesson: Explaining Terms for Adjusting SAP Standard Software
Customizing
Figure 4: Customizing
The Business Engineer consists of all the SAP implementation tools. These SAP implementation tools are as follows: ● The R/3 Reference Model Contains all of the models used to describe R/3 (the process model, the data model, and the organization model) ●
The Implementation Guide (IMG)
●
A complete list of all customizing activities Demonstration: How to Access the SAP Reference IMG Explain what kinds of adjustments can be made to the SAP system during Customizing. The steps to access the SAP Reference IMG are as follows: 1. Show the participants the SAP Reference Implementation Guide. On the SAP Easy Access screen, choose Tools → Customizing → IMG → Execute Project ( SPRO).Next, choose Goto → SAP Reference IMG. 2. Perform a simple Customizing transaction. In Customizing, choose Enterprise Structure → Definition → Logistics – General → Define, copy, delete, check division. Next, enter PB to create a new division for plastic bags. Use the Customizing Organizer to show them the table and view currently being edited.
© Copyright . All rights reserved.
5
Unit 1: Adjustment of SAP Standard Software
Personalization The following ways can help achieve personalization: ● Global display attributes of fields
●
-
Variant transactions
-
SET/GET parameter
-
User-dependent or client-dependent table control settings
Personalized menus -
Role-based menu
-
Favorites
-
Shortcuts on your desktop
Personalization accelerates and simplifies the ERP system’s processing of business cases. During personalization, you can adjust individual application transactions to meet the business needs of your company as a whole or even the needs of specific user groups within your company. All unnecessary information and functions found in the transaction are switched off. Using personalization, you can simplify an application without having to use the ABAP Workbench. The personalization techniques can be as follows: ● Global display attributes These allow you to define default values for specific screen fields. You can also suppress individual fields or table control columns in a particular transaction or even a whole screen. ●
Personalized menus Role-based menus, favorites, and shortcuts on the desktop allow you to adjust menu sequences to reflect the needs of different user groups within your company. Demonstration: How to Make Global Field Settings The steps to make global field settings are as follows: 1. Start transaction SHDG (menu path Tools → Accelerated SAP → Personalization → Global Field Values). Here, choose Application Components → Financial Accounting.Choose Change Global Fields for Financial Accounting. Set company code 1000. Mark the subtree and activate it. However, in most of the training systems your settings won't take effect because the profile parameter "dynpro/global_fields" is not set to "Yes" but has its default value "No". 2. Show how the administrator can make client-wide ("global") table control settings. Starting your demo with transaction VA01, you can also show the SET/GET parameter. 3. Choose the following data and confirm your entries:
6
Field Name or Data Type
Value
Order Type
CD ( for Delivery free of charge)
© Copyright . All rights reserved.
Lesson: Explaining Terms for Adjusting SAP Standard Software
Field Name or Data Type
Value
Sales Organization
1000
Distribution Channel
10
Division
00
The sold-to-party and ship-to-party should be 1000. In the sales items, you can enter material M-05, a quantity and a price. 4. Save your work. You can change the table control now. 5. Move some columns. Now, choose the Settings pushbutton. Next, choose the administrator function and set the column Customer material no. to invisible. Activate your settings. 6. Leave transaction VA01 and start TA VA21 (Create Quotation) or VA03 (Display Sales Order). Explain why the order number is already in the field. Show the table control "All items" where you changed the settings. 7. Create personalized menus. To do so, integrate TA SE80 to the favorites in the SAP Easy Access session manager by right-clicking on favorites. 8. Create shortcuts on the desktop (only in the Citrix Client) using the Generates a shortcut icon. One time with TA SE80 for your training system, the second time with the /H command (type /H in the transaction field when creating a shortcut). This will start the debugger. To start the ABAP debugger session, call TA FD03. Next, drag the shortcut icon from your desktop to the window in TA FD03. This initiates the debugger.
LESSON SUMMARY You should now be able to: ●
Describe options for adjusting SAP standard software
© Copyright . All rights reserved.
7
Unit 1 Lesson 2 7
Describing Classic Enhancement Types
LESSON OVERVIEW This lesson describes the change levels of SAP software using the ABAP Workbench. It also lists and explains the available enhancements types and their uses. Business Example To work in the SAP system, you will need to learn several enhancement techniques. For this reason, you require the following knowledge: ●
The available enhancement types and their uses
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Describe classic enhancement types
Change Levels Using the ABAP Workbench
Figure 5: Change Levels Using the ABAP Workbench
The following are the levels of changing SAP Business applications using the ABAP Workbench: ● Modification
8
© Copyright . All rights reserved.
Lesson: Describing Classic Enhancement Types
Modifications are changes to SAP objects in customer systems. The characteristics of modifications are as follows: -
-
●
Executed with the help of user exits (these are subroutines reserved for customers within objects in the SAP namespace) Hard-coded at various points within SAP repository objects
Customer developments Customers develop programs that can call SAP repository objects, such as SAP function modules.
●
Enhancement The role distribution is inverted in the enhancement concepts. SAP programs call repository objects that you, as a customer, have created or changed. For example, you use a function module exit that an SAP program calls. You can enhance your system at the following levels: -
In ABAP programs, using function module exits
-
On graphical user interfaces (GUI), using menu exits
-
On screens, by inserting a subscreen in an area that SAP specifies, using screen exits
-
-
On screens, by processing customer code that refers to a specific field on the screen, using field exits In ABAP Dictionary tables or structures, using table enhancements
Table Enhancements
Figure 6: Table Enhancements
SAP provides the following ways to enhance tables and structures with fields: ● Append structures ●
Customizing Includes (“CI Includes”)
© Copyright . All rights reserved.
9
Unit 1: Adjustment of SAP Standard Software
Both techniques allow you to attach fields to a table without actually modifying the table itself. An append structure is a structure you assign to exactly one table. There can be several append structures for a table. During activation, the system searches for all active append structures for that table and attaches them to the table. Append structures differ from include structures in how they refer to their tables. To include fields from an include structure in a table, you must add a “.INCLUDE...” line in the table. In this case, the table refers to the substructure. Append structures refer to their tables. In this case, the reference does not alter the tables in any way. Table Enhancements – SAP and the Customer
Figure 7: Table Enhancements – SAP and the Customer
Append structures allow you to attach fields to a table without actually modifying the table itself. Therefore, SAP developers do not have to plan table enhancements using append structures. An append structure can only belong to one table. In contrast, CI_Includes allow you to use the same structure in multiple tables. The include statement must already exist in the SAP table or structure. However, SAP developers have to plan table enhancements using CI_Includes.
Program Enhancements
Figure 8: Program Enhancements – How They Work
10
© Copyright . All rights reserved.
Lesson: Describing Classic Enhancement Types
The purpose of a program enhancement is always to call an object in the customer namespace. You can use the following techniques in program enhancements: Techniques
Description
User exit
This is a subroutine.
Customer exit
This is a special exit function module that the SAP application program calls. The function module is part of a function group that the system handles in a special manner.
Business transaction event
This is a function module that the SAP application program calls dynamically in the customer namespace.
Business Add-Ins
This is a method of a class or instance of a class that the application program calls. This class lies in the customer namespace.
Program Enhancements – SAP and Customer
Figure 9: Program Enhancements – SAP and Customer
With program enhancements, you can execute additional program logic for the SAP application program. SAP currently provides the same techniques used in the table enhancements. Later units will discuss the advantages and restrictions of the particular enhancement techniques in detail.
© Copyright . All rights reserved.
11
Unit 1: Adjustment of SAP Standard Software
Menu enhancements
Figure 10: Menu Enhancements – SAP and Customer
Menu enhancements permit you to add additional menu options to an SAP standard menu. The system currently provides the following options: ● Customer exits ●
Business Add-Ins
The additional menu options are merged into the GUI. When the system implements the function code, you can change the text of the menu option and change the icons, but this is possible only if the SAP developer provided the option for the same.
12
© Copyright . All rights reserved.
Lesson: Describing Classic Enhancement Types
Screen Enhancements
Figure 11: Screen Enhancements
Screen exits are a type of customer exit. They allow you to display additional objects on the SAP application program screen. To implement screen exits, the SAP developer must do the following: ● Define the subscreen areas. ●
Specify the corresponding calls in the flow logic.
●
Provide the framework for the data transport.
●
Include the screen exit in an enhancement.
●
Maintain the documentation.
As of SAP Web Application Server 6.20, Business Add-Ins can also contain screen exits.
© Copyright . All rights reserved.
13
Unit 1: Adjustment of SAP Standard Software
Modifications
Figure 12: Modifications
Any change that you make to an object that SAP has already delivered is known as a modification. Modifications can lead to complications at upgrade. When SAP delivers a new version of the object, you must decide whether you should use the new object or whether you want to continue using your old object. Prior to Release 4.0B, the system records user modifications at the repository object level (for example, an include program). Since Release 4.5A, the granularity for recording modifications has been finer. The Modification Assistant has made this possible. SAP has overhauled the modification adjustment process. LESSON SUMMARY You should now be able to: ●
14
Describe classic enhancement types
© Copyright . All rights reserved.
Unit 1
15
Learning Assessment
1. Which of the following include the options for adjusting SAP standard software? Choose the correct answers. X
A Personalization
X
B Enhancement
X
C Customer development
X
D Modification
2. Which of the following include classic enhancement types? Choose the correct answers. X
A Modification
X
B Customer development
X
C Enhancements
X
D Personalization
© Copyright . All rights reserved.
15
Unit 1
16
Learning Assessment- Answers
1. Which of the following include the options for adjusting SAP standard software? Choose the correct answers. X
A Personalization
X
B Enhancement
X
C Customer development
X
D Modification
2. Which of the following include classic enhancement types? Choose the correct answers.
16
X
A Modification
X
B Customer development
X
C Enhancements
X
D Personalization
© Copyright . All rights reserved.
UNIT 2
Personalization
Lesson 1 Implementing Transaction Variants Exercise 1: Create a Transaction Variant
18 29
UNIT OBJECTIVES ●
Personalize transactions
●
Enhance transactions using variants
●
Enhance transactions using GuiXT
© Copyright . All rights reserved.
17
Unit 2 Lesson 1 18
Implementing Transaction Variants
LESSON OVERVIEW This lesson explains how you can adapt SAP standard functions using transaction variants and GuiXT. Business Example Your end users use only a small part of the functions provided by the SAP system. To simplify their daily work, you should set up their workplace to correspond to their needs. Your colleagues should be able to execute simplified transactions using transaction variants. For this reason, you require the following knowledge: ●
Personalize transactions using transaction variants and GuiXT
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Personalize transactions
●
Enhance transactions using variants
●
Enhance transactions using GuiXT
Personalization Levels
Figure 13: Overview Diagram – Personalization
18
© Copyright . All rights reserved.
Lesson: Implementing Transaction Variants
The figure shows an overview of personalization of SAP programs. Personalization Levels
Figure 14: Personalization Levels
The SAP system adjusts itself to the user's working style and offers only those functions that you use in everyday work. You do not need to navigate through functions unnecessarily. In the past, you could call menus in the Session Manager or in the dynamic menu in the SAP system. As of Release 4.6A, role-based menus appear in the form of a tree at logon. A selected function starts in the same session. The executed function replaces the role-based menu. The menu appears again automatically when you leave a transaction or start a new session. On the role maintenance screen (transaction PFCG), the administrator can combine the menu structure for a role consisting of transactions, reports, and Internet or intranet links with a user menu. You can choose any structure and description for the functions combined by the administrator. Note: The enterprise menu is no longer available as of Release 4.6A.
Demonstration: How to Personalize a User Menu You can personalize a user menu using the following steps: 1. Create an area menu. Start transaction SE43. Create a new area menu ZAREA_MENU. Give a description to this area menu. This will be the topmost node in your area menu. Place the cursor on this node and choose Edit → Insert as Subnode. A window appears. Maintain the transaction column with several transactions, for example, SPRO, SE80, FD03, and menu S001 (in ABAP Workbench, the Reference to a menu flag should be set). In the text column, insert the text application. Choose Continue.
© Copyright . All rights reserved.
19
Unit 2: Personalization
2. Reassign transaction FD03 to the application folder. Place the cursor on FD03 and choose Select/Deselect. The node will be colored yellow. Then, place the cursor on the folder and choose Reassign (as subnode). Save and exit the transaction. Insert the area menu as the start menu to your user profile data, which is in the System menu. Choose User menu to see the result in the session manager. 3. Create role-based menus. Start transaction PFCG. Create a new single role ZMY_ROLE. Point out that in contrast to area menus, a role and its menu have designated authorizations to the given transactions. You have to demonstrate this here. 4. Maintain a menu. The functions are the same as in transaction SE43. You can also use the defined area menu that you created before. 5. Maintain the authorization. Choose the Authorization tab and then choose the Change authorization data pushbutton. To create the correct authorizations takes a lot of time, so for demonstration purposes, it is enough to set all authorizations to all system authorization. To do this, click the traffic light to set the status to green. You can also insert an authorization object, for example, S_CARRID, manually. Create the authorization for the object. Generate the profile. A profile name is proposed. Accept it and leave authorization maintenance. Choose the Users tab and insert a user name, for example, training or your user name. Choose User Comparison to compare the authorizations with the user master. Save and exit the transaction. See the result in the session manager by choosing the SAP Easy Access menu. In the session manager, insert a URL, for example www.google.com. Right-click Favorites and choose Add other objects. Insert the Web folder for Google.
Transaction Variants The objectives of a transaction variant are as follows: ● Simplifying transactions, which can be carried out in the following ways: -
Predefine screen fields.
-
Revoke the ready for input status.
-
Suppress screen elements that are not needed (fields, subscreens, and screens).
-
Suppress entire screens.
●
Maintaining WYSIWYG with a special recording function
●
Creating individual variants and/or standard variants
You can reduce the complexity of the system by suppressing functions that are not required. Transaction variants allow you to reduce the complexity of complete transactions for users.
20
© Copyright . All rights reserved.
Lesson: Implementing Transaction Variants
Individual Variants and Standard Variants
Figure 15: Individual Variants and Standard Variants
You can use a variant defined for a SAP transaction in either of the following ways: ● Create a variant transaction consisting of the SAP transaction and the variant. To access the variant, the user must call the variant transaction specifically. ●
Declare the variant as a standard variant of the SAP transaction. The variant is “attached” to the SAP transaction so that when the transaction is called, the system automatically uses the variant. You can define exactly one standard variant for any given SAP transaction.
Screen Variants
Figure 16: Screen Variants
A transaction variant is a reference to a set of screen variants. You can create any number of screen variants for a screen. The transaction variant consists of these screen variants.
© Copyright . All rights reserved.
21
Unit 2: Personalization
Transaction Variants
Figure 17: Transaction Variants – Example
The figure shows two screens of an SAP transaction that you want to redesign using a transaction variant. Screen 100 shows the following changes: Fields are hidden.
●
●
Field attributes are changed.
●
Buttons are suppressed or hidden.
Screen 200 shows the following changes: ● Buttons are moved. ●
Screen is inserted with GuiXT.
Creating Transaction Variants
Figure 18: Creating Transaction Variants
The figure shows the creation screen for a transaction variant.
22
© Copyright . All rights reserved.
Lesson: Implementing Transaction Variants
Filling Screen Fields
Figure 19: Filling Screen Fields
Pressing screen entries starts the transaction in the CALL mode. Triggering a dialog also triggers Process After Input (PAI) of the current screen. The system sends another screen in which you can evaluate the fields that are on the screen.
Note: You will find more about transaction variants in the online documentation. The system stores the screen you have evaluated as a screen variant, when you choose Continue.
© Copyright . All rights reserved.
23
Unit 2: Personalization
Attributes of a Screen Variant
Figure 20: Attributes of a Screen Variant
A screen variant is an independent repository object. The object has a unique name in the system, which is constructed as follows: Variant name
●
●
Client (only for client-specific transaction variants)
●
Screen number
In the screen variant, you define whether the system should copy field contents to the screen variant. You can set various attributes for the individual fields and remove the ready for input status of a field, or make it invisible.
Note: You can find a detailed list of the possibilities in the online documentation about transaction variants. Transaction Variants –Testing and Use The steps to test a variant are as follows: 1. Enter the SAP transaction code and variant name as SHD0. 2. Press F8. The steps to use a variant are as follows: 1. Create the variant transaction using the transaction code SHD0. (or, choose Goto → Create Variant Transaction). 2. Call the variant transaction. You have the following options to start a transaction variant:
24
© Copyright . All rights reserved.
Lesson: Implementing Transaction Variants
●
Test environment
●
Transaction code of the type Variant Transaction
●
User menu
You can test the process flow of the transaction in the test environment of transaction variant maintenance. This is specifically for developers creating transaction variants. Creating Variant Transactions
Figure 21: Creating Variant Transactions
To start a transaction variant from a menu, you must create a transaction code of the type Variant Transaction. You can find a link there directly on the maintenance screen for the transaction variants, under the Goto menu. Alternatively, you can create a transaction code from ABAP Workbench. If you adopt this approach, remember to choose the correct initial object, Variant Transaction.
To Create Transaction Variants You can create a transaction variant using the following steps: 1. Create the transaction variant. 2. Fill out the corresponding screen variant. 3. Define the attributes of the screen element.
To Test and Use Transaction Variants You can test and use transaction variants using the following steps:
© Copyright . All rights reserved.
25
Unit 2: Personalization
1. Enter the test environment. 2. Create a variant transaction. 3. Call the variant transaction. You can also transaction variant from a menu.
Script Language GuiXT
Figure 22: GuiXT
The supplementary tool GuiXT permits you to design the individual screens in a more flexible manner. GuiXT uses a script language to do the following: ● Position objects on the screen. ●
Set attributes.
●
Include new objects.
When you press GuiXT, an editor window appears for you to enter the script. You can also choose graphic files stored on your local machine to import scripts created on the local machine and export them to the GuiXT editor.
26
© Copyright . All rights reserved.
Lesson: Implementing Transaction Variants
GuiXT and Scripting Language
Figure 23: GuiXT, Scripting Language
You can use the GuiXT scripting language to change the layout of a screen. You can perform the following actions: ● Move objects. ●
Insert pictures.
●
Insert pushbuttons.
●
Insert value helps.
●
Change the input attributes of fields.
●
Delete screen elements.
Note: You are provided with a complete documentation of GuiXT with the installation. You can find more information on the homepage of the GuiXT vendor ( http:// www.synactive.com).
Demonstration: How to Create a Transaction Variant Create a transaction variant. Take transaction BC425_TAVAR to demonstrate it. Do it in parallel to presenting the slides.
© Copyright . All rights reserved.
27
Unit 2: Personalization
28
© Copyright . All rights reserved.
Unit 2 Exercise 1 27
Create a Transaction Variant
Business Example You need a package for this exercise. Your users complain that transaction BC425_TAVAR is much too difficult to use. All they need to do is fill in a few of the many fields. You now want to simplify the use of the transaction, by hiding the fields that are not used. Create a package and then use screen variants and transaction variants to simplify the use of a transaction. Task 1 Create a package and then assign it to a change request. 1. Name the package "ZBC425_##" (where ## is your group number) and then assign to a change request. Task 2 Create a transaction variant for transaction BC425_TAVAR. 1. How do you get to the maintenance screen for transaction variants? Include the corresponding transaction in your list of favorites. 2. Name the variant "ZBC425##" (where ## is your group number). Task 3 Go through the transaction screen by screen and create a screen variant for each of the screens. You should make the following changes: ●
●
●
Initial screen: Initialize the first two fields with DE and FRANKFURT. Next, set them to “Output only”. Second screen: Set column "Air" of the table control to invisible. Deactivate menu function “BACK”. Third screen: Deactivate menu function “BACK”. 1. Make changes to the initial screen.
2. Make changes to the second screen. 3. Make changes to the third screen. Task 4 Create a transaction code for the variant and test your results. 1. Call your transaction ZBC425##.
© Copyright . All rights reserved.
29
Unit 2 Solution 1 28
Create a Transaction Variant
Business Example You need a package for this exercise. Your users complain that transaction BC425_TAVAR is much too difficult to use. All they need to do is fill in a few of the many fields. You now want to simplify the use of the transaction, by hiding the fields that are not used. Create a package and then use screen variants and transaction variants to simplify the use of a transaction. Task 1 Create a package and then assign it to a change request. 1. Name the package "ZBC425_##" (where ## is your group number) and then assign to a change request. a) Call transaction SE80. b) Choose Workbench → Edit Object. c) On the Development Coordination tab page, choose Package and enter the name of the package you want to create in the appropriate field. d) Choose Create. e) On the next screen, enter a meaningful short description for your package. f) Assign the package to the software component Home and confirm your entries. g) On the next screen, assign a change request and confirm it. h) Assign all your subsequent development objects to the package that you have just created. Task 2 Create a transaction variant for transaction BC425_TAVAR. 1. How do you get to the maintenance screen for transaction variants? Include the corresponding transaction in your list of favorites. a) In transaction SHD0, choose System → User profile → Expand favorites to include the transaction in your list of favorites. Alternatively, you can add SHD0 to your favorites using the context menu of the favorites folder on the initial screen. 2. Name the variant "ZBC425##" (where ## is your group number).
30
© Copyright . All rights reserved.
Lesson: Implementing Transaction Variants
a) Enter the name of the transaction from which you want to create a variant in the Transaction field. b) Enter ZBC425## as the name of the variant in the Variant field (where ## is your group number). Task 3 Go through the transaction screen by screen and create a screen variant for each of the screens. You should make the following changes: ●
●
●
Initial screen: Initialize the first two fields with DE and FRANKFURT. Next, set them to “Output only”. Second screen: Set column "Air" of the table control to invisible. Deactivate menu function “BACK”. Third screen: Deactivate menu function “BACK”. 1. Make changes to the initial screen. a) On the initial screen, assign the first two fields with DE and FRANKFURT. b) Leave the screen by choosing the appropriate pushbutton. c) In the next popup window, select the With content checkbox and Output only in the corresponding checkboxes for the screen objects. d) Give the screen variant a short description. e) Save the screen variant.
2. Make changes to the second screen. a) Leave the screen by choosing the appropriate pushbutton. b) Choose With content again in the next dialog box. c) Select Output only for the column Airport of the table control. d) Choose the pushbutton for menu functions and deselect function code BACK . e) Save the screen variant. 3. Make changes to the third screen. a) Leave the third screen using the Save function. b) Deactivate menu function BACK . c) Save the screen variant. A list with a summary of all the screen variants that were created appears. d) Check your entries again and then save them to finally create the transaction variant. Task 4 Create a transaction code for the variant and test your results. 1. Call your transaction ZBC425##. a) Call transaction SHD0. b) Choose Goto → Create transaction.
© Copyright . All rights reserved.
31
Unit 2: Personalization
c) Test your results.
32
© Copyright . All rights reserved.
Lesson: Implementing Transaction Variants
LESSON SUMMARY You should now be able to: ●
Personalize transactions
●
Enhance transactions using variants
●
Enhance transactions using GuiXT
© Copyright . All rights reserved.
33
Unit 2: Personalization
34
© Copyright . All rights reserved.
Unit 2
33
Learning Assessment
1. Which of the following include levels of personalization? Choose the correct answers. X
A Enterprise structure
X
B User administration
X
C Personal configuration
X
D Customer development
2. Which of the following characteristics of a transaction variant enhance the transaction? Choose the correct answers. X
A Maintaining the authorization
X
B Simplifying transactions
X
C Maintaining WYSIWYG with a special recording function
X
D Creating individual and/or standard variant
3. Which of the following characteristics of GuiXT enhances the transaction? Choose the correct answers. X
A The GuiXT Script editor is available.
X
B Script is saved in the SAP system.
X
C You can test the process flow of the transaction.
X
D Scripts can be imported from external storage.
© Copyright . All rights reserved.
35
Unit 2
34
Learning Assessment- Answers
1. Which of the following include levels of personalization? Choose the correct answers. X
A Enterprise structure
X
B User administration
X
C Personal configuration
X
D Customer development
2. Which of the following characteristics of a transaction variant enhance the transaction? Choose the correct answers. X
A Maintaining the authorization
X
B Simplifying transactions
X
C Maintaining WYSIWYG with a special recording function
X
D Creating individual and/or standard variant
3. Which of the following characteristics of GuiXT enhances the transaction? Choose the correct answers.
36
X
A The GuiXT Script editor is available.
X
B Script is saved in the SAP system.
X
C You can test the process flow of the transaction.
X
D Scripts can be imported from external storage.
© Copyright . All rights reserved.
UNIT 3
Enhancement of Dictionary Elements
Lesson 1 Enhancing Tables Using Append Structures and Customizing Includes Exercise 2: Enhance a Table
38 43
Lesson 2 Enhancing Texts of Data Elements
47
UNIT OBJECTIVES ●
Enhance tables using append structures
●
Enhance tables using Customizing Includes
●
Enhance texts of data elements
© Copyright . All rights reserved.
37
Unit 3 Lesson 1 36
Enhancing Tables Using Append Structures and Customizing Includes
LESSON OVERVIEW This lesson explains the two ways that enable you to add extra fields to an SAP table, append structures and Customizing Includes, without actually modifying the table. Business Example You would like to add fields to SAP tables without implementing modifications. For this reason, you require the following knowledge: ●
How to enhance tables using append structures
●
How to enhance tables using Customizing Includes
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Enhance tables using append structures
●
Enhance tables using Customizing Includes
Table Enhancements
Figure 24: Enhancements to the ABAP Dictionary – Overview Diagram
38
© Copyright . All rights reserved.
Lesson: Enhancing Tables Using Append Structures and Customizing Includes
The figure shows the enhancements to the repository objects defined in the ABAP Dictionary in the SAP standard software. Table Enhancements – Overview Characteristics of the append structures are as follows: ●
Customers can create an append structure for an SAP table, without SAP preparation.
●
You can use multiple append structures with a single SAP table.
●
You can use them as normal structures in programs.
Characteristics of the Customizing Includes are as follows : ●
SAP has already integrated them into SAP tables.
●
The customer fills them with the desired additional fields.
●
They may contain source code or screen exits provided by SAP for processing or displaying these fields.
You can add extra fields to an SAP table, without modifying the table, using an append structure and Customizing Include. You can expand tables and structures in one of following ways: Using append structures
●
Append structures allow you to attach fields to a table without actually having to modify the table itself. They allow you to add customer-specific fields to any table or structure you want. Append structures are created for use with a specific table. ●
Using Customizing Include If the SAP application developer knows in advance that one of the tables or structures delivered by SAP needs to have customer-specific fields added to it, the developer includes these fields in the table using a Customizing Include statement. Unlike append structures, you can use the same Customizing Include in multiple tables or structures. This ensures consistency throughout the tables and structures affected, whenever the include is altered.
© Copyright . All rights reserved.
39
Unit 3: Enhancement of Dictionary Elements
Append Structures
Figure 25: Append Structures
The characteristics of append structures are as follows: ● Whenever you activate a table, the system searches for all active append structures for the table and attaches them to the table. ●
●
●
If you activate an append structure after creating or changing it, the table it is assigned to is also activated, and all changes made to the append structure take effect in the table as well. The usage of the fields in append structures in ABAP programs is similar to that of any other field in the table. If you copy a table that has an append structure attached to it, the fields in the append structure become normal fields in the target table.
Append Structures at Upgrade
Figure 26: Append Structures at Upgrade
You create append structures in the customer namespace. This protects them from being overwritten at upgrade or during release upgrade. New versions of standard tables will be
40
© Copyright . All rights reserved.
Lesson: Enhancing Tables Using Append Structures and Customizing Includes
loaded during upgrades. When these new standard tables are activated for the first time, the system appends fields contained in the active append structures to the new standard tables. From Release 3.0, the field sequence in ABAP Dictionary can differ from the one in the database. Therefore, no conversion of the database table is necessary when adding an append structure or inserting fields into an existing one. Adjusting the database catalog, ALTER TABLE, takes care of all necessary structure adjustments automatically. When the table is activated in ABAP Dictionary, the system changes the table’s definition and appends the new field to the database table. Pay attention to the following points when using append structures: ● You cannot create append structures for pool and cluster tables. ●
●
If a table contains a long field (either of the LCHR or LRAW data type), you cannot expand the table using an append structure. This is because long fields of this kind must always be the last field in their respective tables. You may not add any fields from an append structure after the long field. If you use an append structure to expand an SAP table, the field names in your append structure must be in the customer namespace, that is, they must begin with either YY or ZZ. This prevents naming conflicts with any new fields that SAP may insert in the future. Demonstration: How to Enhance a Table Using Append Structures The steps to enhance a table using an append structure are as follows: 1. Create an append structure named “ZASFLIGHT00” for table SFLIGHT00. The data will be entered later. 2. Create a field named “ZZMEAL”, referencing data element s_meal. 3. Activate your append structure. 4. Create another field with a name not starting with ZZ or YY. 5. Make a syntax check. Emphasize that the database table does not recognize the append structure. For the database, it is only one table. 6. Start the SAPBC_TOOLS_TABLE_COPY program with the Fill Append fields only option selected, to fill the participants’ and your append fields. You will need this data for the screen exit.
© Copyright . All rights reserved.
41
Unit 3: Enhancement of Dictionary Elements
Customizing Includes
Figure 27: Customizing Includes
Customizing Includes are part of the customer namespace. All of their names begin with “ CI_”. With this naming convention, the nonexistent Customizing Includes do not lead to errors. The SAP standard software does not deliver any code for Customizing Includes. You create Customizing Includes using special Customizing transactions. Some are already part of SAP enhancements and you can create them by using Project Management. The Customizing Include field names must lie in the customer namespace, just like field names in append structures. These names must all begin with either YY or ZZ. The rules of adding the fields of Customizing Include to your database are the same as those for append structures. Demonstration: How to Enhance a Table Using Customizing Includes The steps to enhance a table using Customizing Include are as follows: 1. Show the aufk table to the participants. 2. Scroll down and show them Customizing Include ci_aufk. 3. Double-click ci_aufk. You see that the include structure does not exist yet. 4. Create it and activate it. 5. Show the where-used list for ci_aufk to the participants.
42
© Copyright . All rights reserved.
Unit 3 Exercise 2 41
Enhance a Table
Business Example You work as a computer specialist for a large travel agency. Your fellow employees use transaction BC425_## to display flight information when helping customers. They would like more information about a flight, for example, the pilot’s name or the main meal. Your flight data is stored in the SFLIGHT## table. You need to add two columns to this table without actually modifying it. Enhance tables using append structures. Task 1 How can you add the two fields to the SFLIGHT## table without modifying it? 1. How do you go about enhancing the SFLIGHT## table? You can work with append structures just like with normal structure definitions. The append structures are created from a table or structure. Task 2 Create an append structure named “ZASFLIGHT##” for the SFLIGHT## table. 1. Create your append structure ZASFLIGHT## (## means your group number). 2. Give the details for the append structure. 3. Choose a category of enhancement for the append structure.
© Copyright . All rights reserved.
43
Unit 3 Solution 2 42
Enhance a Table
Business Example You work as a computer specialist for a large travel agency. Your fellow employees use transaction BC425_## to display flight information when helping customers. They would like more information about a flight, for example, the pilot’s name or the main meal. Your flight data is stored in the SFLIGHT## table. You need to add two columns to this table without actually modifying it. Enhance tables using append structures. Task 1 How can you add the two fields to the SFLIGHT## table without modifying it? 1. How do you go about enhancing the SFLIGHT## table? You can work with append structures just like with normal structure definitions. The append structures are created from a table or structure. a) Call the ABAP Dictionary using transaction SE11. Alternatively, in the Object Navigator, choose Edit object → Edit Dictionary objects. b) Enter SFLIGHT## as the table name and choose Display. Task 2 Create an append structure named “ZASFLIGHT##” for the SFLIGHT## table. 1. Create your append structure ZASFLIGHT## (## means your group number). a) Choose Goto → Append structure or its corresponding pushbutton. b) Enter ZASFLIGHT## as the name for it. c) Give the append structure a short description. d) Save it under the package you created. 2. Give the details for the append structure. a) Include the following fields in the structure: Field
Value
Data Element
Pilot name
YYPILOT
S_PILNAME
Meal
YYMEAL
S_MEAL
3. Choose a category of enhancement for the append structure. a) Choose Extra → Enhancement category. b) Choose Cannot Be Enhanced.
44
© Copyright . All rights reserved.
Lesson: Enhancing Tables Using Append Structures and Customizing Includes
c) Activate your append structure. If an error occurs, you can find details in the activation log.
© Copyright . All rights reserved.
45
Unit 3: Enhancement of Dictionary Elements
LESSON SUMMARY You should now be able to:
46
●
Enhance tables using append structures
●
Enhance tables using Customizing Includes
© Copyright . All rights reserved.
Unit 3 Lesson 2 45
Enhancing Texts of Data Elements
LESSON OVERVIEW This lesson shows you how to overwrite texts delivered with SAP data elements with customer-specific texts. These customer-specific texts, instead of the text delivered by SAP, are then displayed on screens and selection screens. Business Example You would like to adapt field labels and documentation for SAP data elements with customerspecific texts. For this reason, you require the following knowledge: ●
How to change field labels and documentation for SAP data elements without carrying out a modification
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Enhance texts of data elements
Text Enhancements
Figure 28: Text Enhancements – Overview
Text enhancements comprise the following: Customer-specific field labels
●
●
Documentation for SAP data elements
© Copyright . All rights reserved.
47
Unit 3: Enhancement of Dictionary Elements
Text enhancements function in all SAP applications that use the affected data element. They are the global enhancements.
SAP Field Labels Overwrite
Figure 29: Overwriting SAP Field Labels
SAP application programmers define field labels in different lengths and a short description for each data element. Customers can overwrite these field label texts with customer-specific texts. You can provide new field labels for all screen fields in the same way. Prerequisites for Overwriting an SAP Field Label
Figure 30: Prerequisites for Overwriting an SAP Field Label
48
© Copyright . All rights reserved.
Lesson: Enhancing Texts of Data Elements
You can overwrite field labels for only those screen fields for which the screen’s developer has not assigned a description text. In such cases, the Dict. Modified attribute of the screen field has the value F. The following table shows the values that the Dict. Modified attribute can have: Value
Function
SPACE
Field label that best fits the field length
1
Short field label
2
Medium field label
3
Long field label
4
Field label for header
V
Variable text transfer from the dictionary (as SPACE)
F
Fixed (no text transfer from the dictionary)
Overwriting SAP Field Labels
Figure 31: Overwriting SAP Field Labels
The figure shows the procedure to overwrite SAP field labels. To Overwrite SAP Field Labels You need to perform the following tasks to overwrite SAP field labels: 1. Edit text enhancements. a) Choose ABAP Workbench → Utilities → Enhancements → Project Management. Alternatively, use the transaction CMOD.
© Copyright . All rights reserved.
49
Unit 3: Enhancement of Dictionary Elements
2. Open the field label and documentation enhancement (overwriting) for SAP data elements. a) Choose Goto → Global Enhancements.
Restore Customer Field Labels
Figure 32: Overwritten Texts in Upgrades
If SAP has redelivered existing field labels as part of a release upgrade or you import new corrections, you need to restore your customer field labels. If you want to retain your own field labels from the previous release, choose the menu option that restores customer field labels. SAP recommends that you always restore your field labels after a release upgrade. Restoring SAP Field Labels
Figure 33: Restoring SAP Field Labels
50
© Copyright . All rights reserved.
Lesson: Enhancing Texts of Data Elements
To undo field label changes, choose the menu option Restore SAP. You can restore field labels using a program that runs in the background. This program checks all data elements that you have edited and restores their field labels, if necessary. For central field labels such as data elements BUKRS, MANDT, and so on, start the restoration when the contents of the tables that use BUKRS and MANDT are not being changed. Demonstration: How to Change Field Values of a Data Element The steps to change the field values of a data element are as follows: 1. Change the field labels (keywords) for one data element (for example, VKORG) that is used in transaction VA01. Show the participants the results in transaction VA01. 2. Change the field label of a text with attribute F (that is, no changes will be accepted). An example of this is the data element program that is used in transaction SE38 and SA38.
Enhanced Documentation for Data Elements
Figure 34: Enhanced Documentation for Data Elements
When you enhance the data element documentation, you can copy the SAP documentation as well as your own. In this case, when you press F1 in the corresponding screen field, the system displays the SAP documentation as well as the customer-specific documentation. You can generate a list of data elements that have been changed and edit the customer documentation by selecting the elements’ corresponding lines in the list. If you want to display the original SAP documentation, delete your own documentation.
© Copyright . All rights reserved.
51
Unit 3: Enhancement of Dictionary Elements
Creating Customer Documentation
Figure 35: Creating Customer Documentation
By choosing the menu path in the figure, a dialog box opens in which you must choose between the options Original text and Template. To add the SAP documentation, select the Original text option. To create customer-specific documentation without including the text of SAP documentation, select the Template option. LESSON SUMMARY You should now be able to: ●
52
Enhance texts of data elements
© Copyright . All rights reserved.
Unit 3
51
Learning Assessment
1. Which of the following characteristics of append structures enable you to enhance tables? Choose the correct answers. X
A You can use multiple append structures with a single SAP table.
X
B You can use them as normal structures in programs.
X
C You can use them in multiple tables.
X
D Customers can create an append structure for an SAP table, without SAP preparation.
2. Which of the following characteristics of Customizing Includes enable you to enhance tables? Choose the correct answers. X
A Some Customizing Includes are already integrated into SAP tables by SAP.
X
B They may contain source code or screen exits provided by SAP for processing or displaying the fields of the table.
X
C They can be used to create pool and cluster tables.
X
D They ensure consistency throughout the tables and structures affected.
3. Which of the following should be changed to enhance texts of data elements? Choose the correct answers. X
A Append structures
X
B Data elements
X
C Field labels
X
D Documentation
© Copyright . All rights reserved.
53
Unit 3
52
Learning Assessment- Answers
1. Which of the following characteristics of append structures enable you to enhance tables? Choose the correct answers. X
A You can use multiple append structures with a single SAP table.
X
B You can use them as normal structures in programs.
X
C You can use them in multiple tables.
X
D Customers can create an append structure for an SAP table, without SAP preparation.
2. Which of the following characteristics of Customizing Includes enable you to enhance tables? Choose the correct answers. X
A Some Customizing Includes are already integrated into SAP tables by SAP.
X
B They may contain source code or screen exits provided by SAP for processing or displaying the fields of the table.
X
C They can be used to create pool and cluster tables.
X
D They ensure consistency throughout the tables and structures affected.
3. Which of the following should be changed to enhance texts of data elements? Choose the correct answers.
54
X
A Append structures
X
B Data elements
X
C Field labels
X
D Documentation
© Copyright . All rights reserved.
UNIT 4
Customer Exits
Lesson 1 Handling Enhancement Projects
56
Lesson 2 Enhancing Programs Using Program Exits Exercise 3: Implement a Customer Exit – Program Exit
65 75
Lesson 3 Enhancing Menus Using Menu Exits Exercise 4: Implement a Customer Exit – Menu Exit
79 83
Lesson 4 Enhancing Screens Using Screen Exits Exercise 5: Implement a Customer Exit – Screen Exit
87 95
UNIT OBJECTIVES ●
Handle enhancement projects
●
Create enhancement projects
●
Handle program exits
●
Implement exit function groups
●
Enhance menus using menu exits
●
Enhance screens using screen exits
© Copyright . All rights reserved.
55
Unit 4 Lesson 1 54
Handling Enhancement Projects
LESSON OVERVIEW This lesson explains the fundamental aspects of an enhancement project, which you must use to implement existing customer exits. Business Example You would like to learn about the principle of an enhancement project in the customer exit environment. For this reason, you require the following knowledge: ●
An understanding of how to create, activate, and deactivate an enhancement project
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Handle enhancement projects
●
Create enhancement projects
Enhancement Management
Figure 36: SAP Application Enhancements
Application enhancements allow customers to enhance their application functions. SAP preplans customer exits, which generally consist of several components. Application enhancements are inactive when delivered, and the customer completes and activates them, when needed. The characteristics of application enhancement are as follows:
56
© Copyright . All rights reserved.
Lesson: Handling Enhancement Projects
●
Each enhancement provides you with a set of preplanned, precisely defined functions.
●
The interface between SAP and customer functions is clearly defined.
●
Customer does not need the in-depth knowledge of how to implement SAP applications.
●
Customer need not adjust enhancements at upgrade because of new functions that SAP has developed.
Customer Enhancement Projects
Figure 37: Customer Enhancement Projects
SAP application programmers create SAP enhancements from program exits, menu exits, and screen exits. For this purpose, the system provides a management function (transaction code SMOD). A catalog containing an overview of existing SAP enhancements is given to customers. They can then combine the SAP enhancements they want into an enhancement project using transaction CMOD. Enhancements and Enhancement Projects
Figure 38: Enhancements and Enhancement Projects
© Copyright . All rights reserved.
57
Unit 4: Customer Exits
SAP enhancements consist of component parts. These components include program exits, menu exits, and screen exits. You can use a specific component only once in a single SAP enhancement. This guarantees the uniqueness of SAP enhancements. SAP combines all enhancement components, which together belong to one enhancement. Customer enhancement projects consist of SAP enhancements. You can use each individual SAP enhancement only once in a single customer enhancement project. This guarantees the uniqueness of a customer project. The customer has to edit all enhancements that are to be activated together within one enhancement project. Customer Exits – Enhancement Management
Figure 39: The SAP Enhancement Creation Procedure
The following steps list the procedure to create the SAP enhancement: 1. The SAP application programmer plans possible enhancements in an application and defines the necessary components. 2. The system combines these components in SAP enhancements. 3. The programmers document their enhancements as best as they can, so that customers can implement the enhancements without having to analyze program source code or screen source code.
58
© Copyright . All rights reserved.
Lesson: Handling Enhancement Projects
Procedure at the Customer’s Premises
Figure 40: Procedure at the Customer’s Premises
The following steps show the procedure for enhancements at the customer’s premises: 1. Create an enhancement project. 2. Choose the SAP enhancements that you want to use. 3. Edit your individual components using the Project Management function. 4. Document the entire enhancement project. 5. Activate the enhancement project. This activates all of the project’s component parts. Demonstration: How to Search for SAP Enhancements Show the participants different global search scenarios for SAP enhancements. You can show the search related to a certain program later. Scenario 1 – List all or special enhancements The steps to list all or special enhancements are as follows: 1. Start transaction CMOD. 2. Choose Utilities → SAP Enhancements. 3. Enter *logon* (in small letters) in the short text field. 4. Execute. You can see two SAP enhancements. 5. Select SUSR0001, and choose Display.
© Copyright . All rights reserved.
59
Unit 4: Customer Exits
You can see that there is one component in the enhancement. 6. Place the cursor on this function module exit and then choose Documentation. Scenario 2a – Application-specific search with the application hierarchy (transaction SE81) The steps to perform an application-specific search with the application hierarchy are as follows: 1. Start transaction SE81. 2. Choose FI → General ledger Accounting → Basic functions. 3. Select this subtree, and choose Information System. 4. Choose Enhancements → Customer Exits → Enhancements. You can see the packages of the marked subtree on the right screen. 5. Execute and see the result. Scenario 2b – Application-specific search with SAP Reference IMG (transaction SPRO) The steps to perform an application-specific search with SAP Reference IMG are as follows: 1. Start transaction SPRO and choose SAP Reference IMG. 2. In Customizing, choose Financial Accounting → Financial Accounting Global Settings → Document → Document Parking → Develop Enhancements for Parking Documents. 3. Show Documentation in the Customizing screen. 4. Optional, execute this tree. You will step to transaction CMOD. 5. Create an enhancement project, and maintain the attributes. 6. Save it without activating.
60
© Copyright . All rights reserved.
Lesson: Handling Enhancement Projects
Customer Enhancement Projects
Figure 41: Creating a Customer Enhancement Project
To create a customer enhancement project, you need to follow the given steps: 1. Start the Project Management function using transaction CMOD. 2. Name your enhancement project. SAP recommends that you think up a naming convention for all of your projects. You can, for example, include the project’s transaction or module pool in its name. The project name uniquely identifies the enhancement in the system. 3. Go to the project’s attributes, and enter a short text describing the enhancement project. The system enters the remaining attributes (name stamp and time stamp for creating and changing, and status).
© Copyright . All rights reserved.
61
Unit 4: Customer Exits
Assigning SAP Enhancements to Customer Projects
Figure 42: Assigning SAP Enhancements to Customer Projects
To assign SAP enhancements to customer enhancement projects, use the Project Management function. Enter the names of the SAP enhancements you want to use on the appropriate screen. The search function gives you a catalog-like overview of existing SAP enhancements. From there, you can select your desired enhancements. Editing Components
Figure 43: Editing Components
To edit the components of your enhancement project, use the Project Management function. Depending on whether the component you are editing is a function module, a menu option, or a subscreen, you branch either to the Function Builder, a dialog box for entering menu options, or to the Screen Painter, respectively.
62
© Copyright . All rights reserved.
Lesson: Handling Enhancement Projects
Activating Enhancement Projects
Figure 44: Activating Enhancement Projects
Activation of an enhancement project affects all of its components. After successful activation, the project has the status active. During activation, the system regenerates all programs, screens, and menus containing components that belong to the project. Note that the system will regenerate programs at the time of execution. After activation, you can see the effect of the enhancements in your application functions. The Deactivate function allows you to reset an active enhancement project’s status to inactive. Transporting Projects
Figure 45: Transporting Projects
While creating the enhancement project, you should have assigned it to a change request. Each of the component pieces, which include programs, subscreens, menu exits, and so on, should be assigned to the same change request. Using the same change request allows you to transport the entire enhancement at the same time.
© Copyright . All rights reserved.
63
Unit 4: Customer Exits
LESSON SUMMARY You should now be able to:
64
●
Handle enhancement projects
●
Create enhancement projects
© Copyright . All rights reserved.
Unit 4 Lesson 2 62
Enhancing Programs Using Program Exits
LESSON OVERVIEW This lesson shows you how a program exit, implemented using a customer exit, works. It also outlines the possible uses of a program exit. Business Example You have to find program exits that are implemented using customer exits and use them to enhance functions. For this reason, you require the following knowledge: ●
How to find program exits
●
How to use them to enhance functions
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Handle program exits
●
Implement exit function groups
Program Exits
Figure 46: Program Exit Overview
Program exits allow customers to implement additional logic in application functions. SAP application programmers define where program module exits are inserted and what kind of data the module exits can transfer. SAP programmers also create an exit’s corresponding function modules that are complete with short text, interface, and documentation. The modules also describe each program exit’s intended purpose in the SAP documentation.
© Copyright . All rights reserved.
65
Unit 4: Customer Exits
You write the source code for the function modules. If needed, you must also create your screens, text elements, and includes for the function group. The system processes your ABAP code for the first time whenever the enhancement project, of which your function module is a component, is activated as a whole. Program exits have no effect prior to enhancement project activation. Program Exits – Architecture
Figure 47: Program Exits – Architecture
The figure shows the flow of a program providing an enhancement in the form of a program exit. You can call the exit function module at a point in the source text. The SAP application developer defines this point. Within the function module, users can add a function to the customer namespace using an include program. Program Exits – Syntax
Figure 48: Program Exits – Syntax
66
© Copyright . All rights reserved.
Lesson: Enhancing Programs Using Program Exits
SAP application programmers define the function module call using the ABAP statement CALL CUSTOMER-FUNCTION ‘NNN’, where ‘NNN’ is a three-digit number. SAP application programmers also create the corresponding function module and function group. These function modules always belong to function groups whose names begin with X (that is, the X function group). The following table lists the naming convention that applies to function modules: Prefix
Infix
EXIT
This is the name of the program that calls the function module.
Three-digit number
The three parts of the name are separated by an underscore.
The CALL CUSTOMER-FUNCTION statement is executed only when the enhancement project is activated. If the same function module is called several times, the activation is valid for all calls.
Find Program Exits
Figure 49: Finding Program Exits
The most frequently asked question concerning enhancements is “How can you determine whether an application program offers a program exit?”. This is a central question for every kind of enhancement. There are a number of ways to find the answer to this question. You can determine whether an application program offers a program exit in either of the following ways: ● Search by Program Follow the menu path (shown to the left of the graphic) System → Status. This displays a dialog box. It always gives you the name of the application program. In the example, a
© Copyright . All rights reserved.
67
Unit 4: Customer Exits
suitable character string would be “CALL CUSTOMER”. Use the Find icon and search globally in the program. If your search is unsuccessful, you can extend the search domain. To do so, run an environment analysis for the corresponding program and search for the specific character string in the program environment. ●
Using Search Tools The right of the graphic shows how to find the name of the required enhancement using search tools. You can restrict the search in Repository Information System using different criteria, such as: -
Package (also try generic entries)
-
Technical name of the enhancement
Editing Program Exits
Figure 50: Editing Program Exits
The figure shows how to edit function modules for program exits. To Edit Program Exits The steps to edit program exits are as follows: 1. Use the Project Management function by calling transaction CMOD. 2. Choose the pushbutton for editing components to go directly to the function module editor. The editor should be in the display mode. Note: Do not change the function module, particularly the interface. The function module contains an INCLUDE statement for an include program that you have to create in the customer namespace.
68
© Copyright . All rights reserved.
Lesson: Enhancing Programs Using Program Exits
3. Double-click the object (include program). This opens the editor of the include program, where you can enter the source code.
Structure of an Exit Function Group
Figure 51: Structure of a Function Group
To understand how an X function group works, you need to understand how a normal function group works. The following points explain how a normal function group works: ● A function group consists of includes. The system assigns unique names to the includes for different objects. Some of the include names are simply proposals and some cannot be changed. ●
●
●
The TOP include stores global data. This include is generated automatically when a function group is created. Function modules are stored in includes with sequential numbering. The includes, in turn, are all stored in an include ending with UXX. Although you are free to choose the names of the includes for all other objects (subroutines, modules, events, and so on), it is advised to accept the proposed names.
© Copyright . All rights reserved.
69
Unit 4: Customer Exits
Structure of an Exit Function Group
Figure 52: Structure of an Exit Function Group
SAP application programmers created exit function groups for enhancement exits. These exit function groups contain programs that begin with either LX or ZX. You can edit only includes beginning with a Z because they are stored in the customer namespace. You cannot add further function modules to a function group. The include program ZXAAAUNN contains the source code for the function modules of a function module exit. Global Data of an Exit Function Group
Figure 53: Global Data of an Exit Function Group
SAP application programmers can declare global data in the include program LXAAATAP. You can declare your global data in the include program ZXAAATOP.
70
© Copyright . All rights reserved.
Lesson: Enhancing Programs Using Program Exits
Include program LXAAATOP also contains the FUNCTION-POOL statement, which may not be changed. Therefore, you must always include the message class in parentheses while outputting messages, for example, MESSAGE E500 (EU). Customer-Specific Processing Blocks
Figure 54: Activating Enhancement Projects
The INCLUDE statement for program ZXAAAUNN is in a FUNCTION–ENDFUNCTION block. Due to this, events, subroutines (FORM), or modules (MODULE) are not permitted here. You need to create them in separate includes. Data declarations made here with DATA are valid locally in this function module. The SAP application programmer can also make a proposal for the source text. In this case, the system creates INCLUDE LXAAFNN, where NN is the internal number for the function module in the LXAAAUXX include. The system provides documentation within the SAP enhancement. You can copy the source code from this include to your customer include program ZXAAAUNN, using the transaction for Project Management. You can create your text elements for the function group. Other SAP Objects in an Exit Function Group
Figure 55: Other SAP Objects in an Exit Function Group
© Copyright . All rights reserved.
71
Unit 4: Customer Exits
SAP application programmers can provide you with default subroutines in include LXAAAF01. The table lists the further includes containing specific subobjects: Includes
Specific subobjects
LX...F01
Subroutines delivered by SAP
LX...E01
The events belonging to the X function group
LX...O01
Process Before Output (PBO) modules for the screens to be delivered
LX...I01
The corresponding Process After Input (PAI) modules
Customer Objects in an Exit Function Group
Figure 56: Customer Objects in an Exit Function Group
The system creates subroutines, modules, and interactive events as own include programs and includes them in the function group using include program ZXAAAZZZ. Additional includes must adhere to the following naming convention:
72
Includes
Specific subobjects
ZXAAAFNN
Subroutines
ZXAAAONN
PBO modules
ZXAAAINN
PAI modules
ZXAAAENN
Events
© Copyright . All rights reserved.
Lesson: Enhancing Programs Using Program Exits
Customer Screens
Figure 57: Customer Screens
You can use CALL SCREEN to call your screens. Create the related include programs for the PBO and PAI modules in include program ZXAAAZZZ. Use forward navigation (double-click an object) to create your screens and modules. The system gives the name of the function module’s main program SAPLXAAA automatically to the screens created in this manner. For these screens, you can find the PBO modules in include ZXAAAO01 and the PAI modules in include ZXAAAI01.
Program Exit and Exit Function Group
Figure 58: Summary – Program Exits
You can enhance SAP applications by adding your processing logic at predefined points.
© Copyright . All rights reserved.
73
Unit 4: Customer Exits
Such enhancements can include the following elements: ● Your screens with their corresponding processing logic ●
Graphical user interface
●
Text elements created by customers Demonstration: How to Implement a Customer Exit Scenario 1 – Go back to the enhancement project that you created in the first part of this unit. Explain in detail the concept of the function module exit. Again, emphasize that the SAP developer defines the interface of the function module and you cannot change it. Scenario 2 – Show the participants a simple transaction, for example, BC425_00. Identify the need for a customer enhancement. Now, you want to output an information message, when the first screen is left. Scenario 3 – Program search related to a specific program The steps to carry out a program search related to a specific function are as follows: 1. Start transaction BC425_00. 2. Choose System → Status. 3. Double-click the program name. 4. Search for the string CALL CUSTOMER-FUNCTION. It is specific for customer exits. You now know that this program consists of a customer exit. Search for the related SAP enhancement because your customer project needs it. You have to know the rule for naming function module exits. It is always EXIT_
_... 5. Go to transaction CMOD. Choose Utilities → SAP Enhancements . 6. Choose All Selections and mark only Function Module Exits. 7. Enter EXIT__* in the Component Name field. This means that you want to search for all SAP enhancements that use function module exits with the name EXIT__*. 8. Execute. The result shows three enhancements. Take the first one SBC00E01 and assign it to your customer exit project. Next, place the cursor on the enhancement name and display the documentation. Edit the component. You will reach the function module coding with an include statement. Double-click the include to create it. Confirm the message that appears. Give reasons for your demonstration. You want to check whether the user has chosen AA and 0017. If so, you want to send an information message. Enter the code for that and activate the include. Step back to component editing in CMOD and activate your project. Then, start transaction BC425_00 again to see the result.
74
© Copyright . All rights reserved.
Unit 4 Exercise 3 73
Implement a Customer Exit – Program Exit
Business Example Your coworkers have asked you to alter transaction BC425_## so that every time they try to display the details of a flight in the past, a warning message appears. Adjust the program so that there is a warning when you select a flight in the past. Do not modify the SAP program while doing so. Implement an enhancement using a program exit. Task 1 Check whether it is possible to enhance the transaction. 1. Did the SAP developer implement a customer exit for the given transaction that you can use to add the required functionality? 2. What is the name of its corresponding enhancement? Choose the enhancement with which you can implement a supplementary check when you leave the first screen of the transaction. Task 2 Implement the enhancement and check your results. 1. Name the enhancement project as TG##CUS1. 2. Program the following check: Determine whether the date that you enter is before today’s date (that is, it lies in the past). If this is the case, issue an appropriate warning. To do this, use message 011 from message class BC425. 3. Check your results.
© Copyright . All rights reserved.
75
Unit 4 Solution 3 74
Implement a Customer Exit – Program Exit
Business Example Your coworkers have asked you to alter transaction BC425_## so that every time they try to display the details of a flight in the past, a warning message appears. Adjust the program so that there is a warning when you select a flight in the past. Do not modify the SAP program while doing so. Implement an enhancement using a program exit. Task 1 Check whether it is possible to enhance the transaction. 1. Did the SAP developer implement a customer exit for the given transaction that you can use to add the required functionality? a) Choose System → Status. It gives you the name of the corresponding program SAPBC425_FLIGHT##. 2. What is the name of its corresponding enhancement? Choose the enhancement with which you can implement a supplementary check when you leave the first screen of the transaction. a) Find a customer exit. You can either search for the character string CALL CUSTOMER–FUNCTION globally in the main program or use Repository Information System to search for enhancements containing the program name in the technical name of the component (restrict the search using EXIT_SAPBC425_FLIGHT##_* in the component name). The enhancement you are looking for has the name SBC##E01. The documentation for the enhancement shows that it is intended for supplementary checks of the first screen of the transaction. Task 2 Implement the enhancement and check your results. 1. Name the enhancement project as TG##CUS1. a) Call transaction CMOD. b) Choose Tools → ABAP Workbench → Utilities → Enhancements → Project management. c) Create a project named TG##CUS1 and save it. 2. Program the following check: Determine whether the date that you enter is before today’s date (that is, it lies in the past). If this is the case, issue an appropriate warning. To do this, use message 011 from message class BC425. a) Include enhancement SBC##E01 that you found in your project.
76
© Copyright . All rights reserved.
Lesson: Enhancing Programs Using Program Exits
3. Check your results. a) Edit the components. Open the exit function module’s source code and double-click to create the include. The source code you created might be similar to : IF flight–fldate < sy–datum. MESSAGE w011(bc425) WITH sy–datum. ENDIF. b) Activate your include. c) Go back to Project management and activate your enhancement project.
© Copyright . All rights reserved.
77
Unit 4: Customer Exits
LESSON SUMMARY You should now be able to:
78
●
Handle program exits
●
Implement exit function groups
© Copyright . All rights reserved.
Unit 4 Lesson 3 77
Enhancing Menus Using Menu Exits
LESSON OVERVIEW This lesson demonstrates how menu exits are implemented. You also learn how to find and use them. Business Example You have to find and use menu exits that are implemented using customer exits. For this reason, you require the following knowledge: ●
How menu exits that are implemented using customer exits work
●
How to find and use these menu exits
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Enhance menus using menu exits
Menu Exits
Figure 59: Menu Exits Overview
Menu exits allow you to attach your functions to menu options in SAP menus. For this purpose, SAP application programmers reserve certain menu options in your graphical user interface (GUI). You can specify the entry text for your functions.
© Copyright . All rights reserved.
79
Unit 4: Customer Exits
They become visible in the SAP menu only after you activate menu exits. When you choose the corresponding menu option, the system acts like a program exit that contains your customer-specific functions. Menu Exit Requirements
Figure 60: Menu Exit Requirements
To implement menu exits, SAP application programmers must equip the GUI with function codes that begin with a plus (+) sign. Menu Exits and Program Exits
Figure 61: Menu Exits and Program Exits
SAP application programmers determine where a program reads additional function codes and how it reacts with either a program exit or a predefined function.
80
© Copyright . All rights reserved.
Lesson: Enhancing Menus Using Menu Exits
Naming and Editing Menu Exits
Figure 62: Naming and Editing Menu Exits
You can edit menu exits with the transaction for Project Management, CMOD. Choosing the pushbutton (represented by a pencil icon) for editing components, calls a dialog box, where you can enter language-dependent short descriptions for each additional menu option. You may not make any changes to the GUI.
Demonstration: How to Edit Menu Exits The steps to edit menu exits are as follows: 1. Show the participants a menu in transaction BC425_00. Go to the function key overview where you can find all the function keys belonging to that program. Look for a function code that starts with a +. Now, you know that a menu exit is given in this program. Now, search for the related SAP enhancement. 2. Start transaction CMOD again and choose Utilities → SAP Enhancement → All Selections. 3. Mark only menu entries. You have to know the naming convention for menu exits. It is always < +function code>. 4. Enter #+* as component name and execute. That means you want to search for all SAP enhancements that use menu exits with the name +... Remember ‘#+’ means the character +. The result will be SBC00E02. 5. Assign it to your project and read the documentation.
© Copyright . All rights reserved.
81
Unit 4: Customer Exits
6. Edit the components starting with the menu exit component. 7. Enter a menu text, for example, related bookings. Similarly, enter the function module exit. 8. Enter the program SAPBC425_BOOKING_00 in the include you created and activate the include. Step back and activate the project. 9. Start transaction BC425_00 again and from the menu on the second screen, choose the added function (the new menu that is created). The example demonstrates the high degree to which these two kinds of enhancements are interconnected. Course participants should now understand why an additional hierarchy level for enhancements must exist above the hierarchy level for components.
82
© Copyright . All rights reserved.
Unit 4 Exercise 4 81
Implement a Customer Exit – Menu Exit
Business Example Your colleagues are pleased. The new warning messages in transaction BC425_## help them to avoid selecting flights from the past. However, they want more. They want you to create a link in the transaction, which they use for viewing flights. The link will allow them to display a list of bookings for their current flight from within the flight display transaction. You have always used a suitable list-generating program. However, the user must call it separately and enter the current data into the program selection screen. It has the name SAPBC425_BOOKING_##. Implement an enhancement with a menu exit in combination with a program exit. Task 1 Examine transaction BC425_##. Is it possible to call the program using a menu entry in the transaction? 1. Did the SAP developer implement a customer exit that you can use to add the required functionality for the given transaction? 2. What is the name of the corresponding enhancement? Choose the enhancement with which you can implement a menu enhancement. Task 2 Implement the enhancement and check your results. 1. Name the enhancement project as TG##CUS2. 2. Edit the components of the enhancement you found. Use the supplementary menu entry to call program SAP425_BOOKING_##. Make sure the user can return to the list of flights. 3. Transfer the current transaction data to the selection screen of the program that you want to call. To do this, use the data that is available to you in the program exit.
© Copyright . All rights reserved.
83
Unit 4 Solution 4 82
Implement a Customer Exit – Menu Exit
Business Example Your colleagues are pleased. The new warning messages in transaction BC425_## help them to avoid selecting flights from the past. However, they want more. They want you to create a link in the transaction, which they use for viewing flights. The link will allow them to display a list of bookings for their current flight from within the flight display transaction. You have always used a suitable list-generating program. However, the user must call it separately and enter the current data into the program selection screen. It has the name SAPBC425_BOOKING_##. Implement an enhancement with a menu exit in combination with a program exit. Task 1 Examine transaction BC425_##. Is it possible to call the program using a menu entry in the transaction? 1. Did the SAP developer implement a customer exit that you can use to add the required functionality for the given transaction? a) Search for an enhancement that has a component name that contains the program name (restrict your search using the component name SAPBC425_FLIGHT##*). 2. What is the name of the corresponding enhancement? Choose the enhancement with which you can implement a menu enhancement. a) The name of the enhancement you were looking for is SBC##E02. Task 2 Implement the enhancement and check your results. 1. Name the enhancement project as TG##CUS2. a) Call transaction CMOD. b) Choose Tools → ABAP Workbench → Utilities → Enhancements → Project management. c) Enter TG##CUS2 as the name of the project and save it. 2. Edit the components of the enhancement you found. Use the supplementary menu entry to call program SAP425_BOOKING_##. Make sure the user can return to the list of flights. a) Include enhancement SBC##E02 that you found in your project. b) Edit the enhancement’s components. c) Assign a menu text. d) Double-click on the program exit to edit it.
84
© Copyright . All rights reserved.
Lesson: Enhancing Menus Using Menu Exits
e) Create the customer include using forward navigation. 3. Transfer the current transaction data to the selection screen of the program that you want to call. To do this, use the data that is available to you in the program exit. a) The source text of the include for group ## should be as follows: SUBMIT sapbc425_booking_## WITH so_car = flight–carrid WITH so_con = flight–connid WITH so_fld = flight–fldate AND RETURN. b) Activate the include program. c) Activate the enhancement project. d) Check your results.
© Copyright . All rights reserved.
85
Unit 4: Customer Exits
LESSON SUMMARY You should now be able to: ●
86
Enhance menus using menu exits
© Copyright . All rights reserved.
Unit 4 Lesson 4 85
Enhancing Screens Using Screen Exits
LESSON OVERVIEW This lesson explains how to find a screen exit that is implemented using a customer exit. In addition, it outlines possible uses. Business Example You have to find and use screen exits that are available in the SAP standard system. For this reason, you require the following knowledge: ●
How to find and use screen exits that are implemented using customer exits
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Enhance screens using screen exits
Screen Exits
Figure 63: Screen Exits Overview
Screen exits allow you to make use of reserved sections of a main screen. These reserved sections are the subscreen areas. You can either display additional information in these areas or input data. You can define the necessary input and output fields on a customer screen using subscreen.
© Copyright . All rights reserved.
87
Unit 4: Customer Exits
Subscreens in General
Figure 64: Subscreens in General
Subscreens are rectangular areas on your screen, which the system reserves for displaying additional screens at runtime. Another screen of the subscreen type can be displayed in each subscreen area at runtime. Calling a Normal Subscreen
Figure 65: Calling a Normal Subscreen
Your system determines which screen you need to display in a subscreen area at the Process Before Output (PBO) event. The general syntax is: CALL SUBSCREEN INCLUDING For each subscreen, Process After Input (PAI) and PBO events are processed, just as if the subscreen were a normal screen.
88
© Copyright . All rights reserved.
Lesson: Enhancing Screens Using Screen Exits
The sequence of “CALL SUBSCREEN” calls in the flow logic of the main screen determines the sequence in which the system processes the flow logic of individual subscreens. Important points to remember while calling a normal subscreen are as follows: ● You can process the function code only via the main screen. ●
You cannot enter a name for a subscreen’s command field.
●
You cannot define graphical user interface (GUI) statuses for subscreens.
●
You may not enter any value for the next screen in a subscreen’s flow control.
Defining Screen Exits
Figure 66: Defining Screen Exits
The SAP application programmer can reserve multiple subscreen areas for a screen. While defining screen exits, consider the following points: Call the subscreen during the flow control of the main screen with the CALL CUSTOMERSUBSCREEN statement.
●
●
●
Define the name of the subscreen area without apostrophes. Define the function group to which the subscreen belongs, statically in apostrophes. However, you can keep the screen number variable by using fields. It must always have four places.
Screen exit calls are inactive at first and when the screen is processed, the system skips the screen exits. The system will process the screen exit, only after you create a corresponding subscreen in an enhancement project and activate this project. You create subscreens for screen exits in X function groups. Normally, these function groups also contain program exits.
© Copyright . All rights reserved.
89
Unit 4: Customer Exits
Calling Customer Subscreens
Figure 67: Calling Customer Subscreens
Whenever the statement CALL CUSTOMER-SUBSCREEN INCLUDING occurs at PBO in the flow control of a screen, the system includes a subscreen in the subscreen area that the SAP application programmer defined. At this point, the system processes all modules called during the PBO event of the subscreen. The system processes the PAI event of a subscreen when the calling screen calls the subscreen during its PAI event. For this, the system uses the statement CALL CUSTOMERSUBSCREEN .
90
© Copyright . All rights reserved.
Lesson: Enhancing Screens Using Screen Exits
Transporting Data to Subscreens
Figure 68: Transporting Data to Subscreens
The X function group that contains your subscreen does not know the global data of the calling program. Therefore, SAP application programmers use program exits to provide this data to subscreens, explicitly. To facilitate data transport, the system calls modules in the flow control of the calling program that contain program exits for transferring data via interface parameters. The corresponding exit function modules are in the same X function group in which you must create the customer subscreen. Transporting Data from Subscreens
Figure 69: Transporting Data from Subscreens
© Copyright . All rights reserved.
91
Unit 4: Customer Exits
The calling program does not know the global data from the X function group that contains the user entries on your subscreen. As a result, you must transport data in the other direction as well. For this reason, SAP application programmers use program exits to return any data that you changed in the subscreen, to the calling program. To do this, the system calls a module at the PAI event of the main screen. This main screen contains a program exit that can receive the relevant global data for the X function group. Naming and Editing Screen Exits
Figure 70: Naming and Editing Screen Exits
The system uses the Project Management transaction CMOD for editing the screen exits. The technical names of screen exits consist of the following: Name of the calling program
●
●
●
92
Four-digit screen number for the main screen Name of the subscreen area, followed by the name of the X function group’s program and the number of the subscreen.
© Copyright . All rights reserved.
Lesson: Enhancing Screens Using Screen Exits
Editing Subscreens
Figure 71: Editing Subscreens
The SAP development environment supports the creation of customer subscreens and the respective PBO and PAI modules as a part of forward navigation. When creating the subscreen, ensure that it has the Subscreen screen type. You can neither change any of the interfaces in the X function group that the subscreen and the program exits belong to nor add any of your function modules.
Demonstration: How to Edit Screen Exits Show your students screen 200 of transaction BC425_00. Navigate to the screen painter to show the flow logic and the subscreen area. The steps to edit screen exits are as follows: 1. Search for the corresponding SAP enhancement SBC00E03. Go to CMOD and choose Utilities → SAP Enhancements → All Selections. Mark only Screen Exits. You have to know the naming convention for screen exits. It is always … Next, enter in component name 0200* and execute. That means you want to search for all SAP enhancements that use screen exits named *. The result will be SBC00E03. 2. Create a new project or assign the SAP enhancement to the given project of menu and program exit. 3. Edit the components.
© Copyright . All rights reserved.
93
Unit 4: Customer Exits
First, create the subscreen by double-clicking on it. Next, place the fields from the table sflight00 into the subscreen. 4. Go back and activate your project. 5. Show the result. It does not display any data in the new fields.
94
© Copyright . All rights reserved.
Unit 4 Exercise 5 93
Implement a Customer Exit – Screen Exit
Business Example “It would be really great if the details list of transaction BC425_## for displaying flights also displayed more data.” You accept this new challenge from your coworkers and try to solve the problem without having to modify the transaction. Specifically, you start looking for a way to add a couple of new fields to the second screen of this transaction (screen number 200). Display further fields in the screen of an SAP transaction and fill them. Task 1 What kind of possibilities are there to place additional fields on a screen? Take a closer look at screen 200 in transaction BC425_## and see if this is possible. 1. Is there a screen exit for enhancing the screen? 2. If this is the case, what is the name of the corresponding enhancement? Task 2 Implement the enhancement to add three fields to the screen (project name: TG##CUS3): 1. Add three fields to the screen. The following should appear: ●
Pilot’s name
●
Meal
●
The number of free places on the current flight
Task 3 Execute transaction BC425_## and check your results. 1. Execute transaction BC425_## and check your results.
© Copyright . All rights reserved.
95
Unit 4 Solution 5 94
Implement a Customer Exit – Screen Exit
Business Example “It would be really great if the details list of transaction BC425_## for displaying flights also displayed more data.” You accept this new challenge from your coworkers and try to solve the problem without having to modify the transaction. Specifically, you start looking for a way to add a couple of new fields to the second screen of this transaction (screen number 200). Display further fields in the screen of an SAP transaction and fill them. Task 1 What kind of possibilities are there to place additional fields on a screen? Take a closer look at screen 200 in transaction BC425_## and see if this is possible. 1. Is there a screen exit for enhancing the screen? a) Examine the flow logic of the screens for character string CALL CUSTOMER– SUBSCREEN. You will see that screen 200 of transaction BC425_## offers a screen exit. 2. If this is the case, what is the name of the corresponding enhancement? a) Get the name of the enhancement, for example, by searching in the Repository Information System. The name of the enhancement is SBC##E03. Task 2 Implement the enhancement to add three fields to the screen (project name: TG##CUS3): 1. Add three fields to the screen. The following should appear: ●
Pilot’s name
●
Meal
●
The number of free places on the current flight
a) Double-click the screen number, which is given in the component view of the enhancement project to create the subscreen. b) In the screen painter area, use layout to place the fields on the screen. Pilot and Meal is given from the structure sflight##. freeseats is a free defined field, which at first has to be defined in the TOP include.
96
© Copyright . All rights reserved.
Lesson: Enhancing Screens Using Screen Exits
c) Use the enhancement’s program exit. Create the customer include and enter the following source code: MOVE-CORRESPONDING flight TO sflight## seatsfree = flightseatsmax – flight-seatsocc. TOP include: TABLES: sflight##. DATA: seatsfree type s_seatsocc. d) Activate the program and then your enhancement project. Task 3 Execute transaction BC425_## and check your results. 1. Execute transaction BC425_## and check your results.
© Copyright . All rights reserved.
97
Unit 4: Customer Exits
LESSON SUMMARY You should now be able to: ●
98
Enhance screens using screen exits
© Copyright . All rights reserved.
Unit 4
97
Learning Assessment
1. Which of the following steps are required in the procedure to create an SAP enhancement? Choose the correct answers. X
A Define necessary components.
X
B Assign components to SAP enhancements.
X
C Document the enhancement project.
X
D Activate the enhancement project.
2. Which of the following steps are required in the procedure to create a customer enhancement project? Choose the correct answers. X
A Start the project management.
X
B Name your enhancement project.
X
C Transport the project.
X
D Enter a short text description in the project's attributes.
3. Which of the following determine whether an application program offers a program exit? Choose the correct answers. X
A Search by program.
X
B Search using search tools.
X
C Search by documents.
X
D Search for a specific character string.
© Copyright . All rights reserved.
99
Unit 4: Learning Assessment
4. Which of the following includes contains the events belonging to the X function group? Choose the correct answer. X
A LX...F01
X
B LX...E01
X
C LX...O01
X
D LX...I01
5. Which of the following characteristics of menu exits enable you to enhance menus? Choose the correct answers. X
A They allow you to attach your own functions to menu options in SAP menus.
X
B You can specify the entry text for the menu functions created.
X
C Function codes appear on the screen before activation.
X
D ABAP programmers determine where a program reads additional function codes.
6. Screen exits allow you to make use of reserved sections of a main screen. These reserved sections are called ____________. Choose the correct answer.
100
X
A normal screen
X
B subscreens
X
C program screen
X
D classical screen
© Copyright . All rights reserved.
Unit 4
99
Learning Assessment- Answers
1. Which of the following steps are required in the procedure to create an SAP enhancement? Choose the correct answers. X
A Define necessary components.
X
B Assign components to SAP enhancements.
X
C Document the enhancement project.
X
D Activate the enhancement project.
2. Which of the following steps are required in the procedure to create a customer enhancement project? Choose the correct answers. X
A Start the project management.
X
B Name your enhancement project.
X
C Transport the project.
X
D Enter a short text description in the project's attributes.
3. Which of the following determine whether an application program offers a program exit? Choose the correct answers. X
A Search by program.
X
B Search using search tools.
X
C Search by documents.
X
D Search for a specific character string.
© Copyright . All rights reserved.
101
Unit 4: Learning Assessment- Answers
4. Which of the following includes contains the events belonging to the X function group? Choose the correct answer. X
A LX...F01
X
B LX...E01
X
C LX...O01
X
D LX...I01
5. Which of the following characteristics of menu exits enable you to enhance menus? Choose the correct answers. X
A They allow you to attach your own functions to menu options in SAP menus.
X
B You can specify the entry text for the menu functions created.
X
C Function codes appear on the screen before activation.
X
D ABAP programmers determine where a program reads additional function codes.
6. Screen exits allow you to make use of reserved sections of a main screen. These reserved sections are called ____________. Choose the correct answer.
102
X
A normal screen
X
B subscreens
X
C program screen
X
D classical screen
© Copyright . All rights reserved.
UNIT 5
Business Transaction Events
Lesson 1 Implementing Business Transaction Events (BTEs)
104
UNIT OBJECTIVES ●
Explain Business Transaction Events
●
Implement Business Transaction Events
© Copyright . All rights reserved.
103
Unit 5 Lesson 1 102
Implementing Business Transaction Events (BTEs)
LESSON OVERVIEW This lesson explains what Business Transaction Events (BTEs) are and their different types. This lesson also discusses finding and using BTEs and shows a comparison between customer exits and BTEs. Business Example You have to enhance a program using BTEs. For this reason, you require the following knowledge: ●
What BTEs are
●
Find a suitable Business Transaction Event (BTE)
●
Use BTEs to enhance SAP software
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Explain Business Transaction Events
●
Implement Business Transaction Events
Properties of Business Transaction Events
Figure 72: Business Transaction Events – Overview Diagram
104
© Copyright . All rights reserved.
Lesson: Implementing Business Transaction Events (BTEs)
This figure shows an overview of SAP enhancement using BTEs. Software Delivery Process
Figure 73: Software Delivery Process
Software delivery has changed considerably. Previously, only two participants were involved – SAP (the producer) delivered the software directly to the end user. Customers could enhance this standard using customer exits. At present, more participants are involved in the software delivery process due to the strong component orientation. SAP delivers the SAP standard as base software to an Industrial Business Unit (IBU). IBU develops and offers encapsulated functions. The next link in the chain is a partner firm, which builds its own Complementary Software Program (CSP) solution based on a SAP system. The last link in the chain is the customer. All the parties involved in this process are potential users and providers of enhancements. Customer exits do not satisfy this requirement as you can use it only once. Consequently, SAP developed a new enhancement technique in Release 4.0, which allows you to reuse enhancements. Business Transaction Events (Attributes) The properties of BTEs are as follows: ● Technique for implementing program exits (developed from SAP financial accounting) ●
Have predefined interfaces allowing customer access
●
Have one of the following types of interfaces, publish and subscribe, and process interface
BTEs allow you to attach additional components, in the form of a function module, for example, to the SAP system. Following are the types of interfaces available for this purpose: ● Publish and subscribe interfaces These interfaces inform external software that certain events have taken place in an SAP standard application and provide them with the data produced. The external software returns no data to the SAP Standard System.
© Copyright . All rights reserved.
105
Unit 5: Business Transaction Events
●
Process interfaces You can use these interfaces to control a business process differently as compared to which the standard SAP system handles it. They intervene in the standard process and return data to the SAP application. You can attach various external developments to the SAP System. In addition, you can create additional developments using the ABAP Workbench.
Flow Diagram of How BTE Functions Work
Figure 74: Flow Diagram of How BTE Functions Work
The figure shows the process flow of an SAP program. The program contains an enhancement in the form of a BTE. The following describes the functioning of the BTEs: You can call a function module in the SAP program, which determines and processes the active implementations.
●
●
●
●
The names of the event function modules begin with OPEN_FI_PERFORM_ or OUTBOUND_CALL_. The event function module OPEN_FI_PERFORM_<> or OUTBOUND_CALL_<> determines the active implementations for each enhancement and stores them in an internal table. The system implements the function modules in the sequence that the internal table defines.
At this point, the system also considers the conditions under which it processes the function module in the customer namespace. For example, you can enter a country or an application as a condition. You can refer these conditions as filter values.
106
© Copyright . All rights reserved.
Lesson: Implementing Business Transaction Events (BTEs)
BTE – Call Syntax in the SAP Program
Figure 75: BTE – Call Syntax in the SAP Program
This figure shows the syntax used to call a program enhancement using a BTE. The SAP application program calls the function module “OPEN_FI_PERFORM_<...>” or “OUTBOUND_CALL_<...>”. The application transfers the interface data to this service function module. The SAP developer predefines the interface. The service function module also searches for active implementations and enters these in an internal table. The system then processes implementations found in a loop.
Scenarios of Business Transaction Events
Figure 76: BTE – Possible Scenarios (1)
The example relates to the publish and subscribe interfaces. In this case, data flows only in one direction, which is from the SAP application to the additional component. SAP application developers make interfaces available to you at certain call up points in a transaction. You can define additional logic at these points. In a very basic scenario, SAP partners and customers can use the interfaces themselves. In this case, BTEs function in the same manner as customer exits.
© Copyright . All rights reserved.
107
Unit 5: Business Transaction Events
BTE – Possible Scenarios (2)
Figure 77: BTE – Possible Scenarios (2)
This scenario also pertains solely to publish and subscribe interfaces. In contrast to customer exits, BTEs allow you to use an interface for multiple types of additional logic. If this is the case, you can decide to execute all enhancements or only specific enhancements for a given BTE. Therefore, the two enhancements coexist, without impeding each other. Publish and Subscribe Interfaces; Process Interfaces
Figure 78: Publish and Subscribe Interfaces; Process Interfaces
Characteristics of the publish and subscribe interfaces are as follows:
108
© Copyright . All rights reserved.
Lesson: Implementing Business Transaction Events (BTEs)
●
These interfaces allow you to start one or more (multiple) additional operations when a particular event is triggered. They do not influence the standard SAP program in any way.
●
Multiple operations do not interfere with each other.
●
Add-on components can only import data.
●
Additional checks such as authorizations and existing duplicates.
Characteristics of the process interfaces are as follows: ● In contrast to publish and subscribe interfaces, data exchange takes place in both directions with process interfaces. This influences the number of additions that can be attached to the interface. ●
●
When an event is triggered, a process in the standard program can be replaced only by one external process using the process interface. If you are using an add-on from an SAP partner that uses a process interface, this enhancement is processed at runtime. If you choose to use this same process interface for one of your own developments, the partner enhancement is discarded and your own enhancement is processed at runtime instead.
BTE – SAP and the Customer
Figure 79: BTE – SAP and the Customer
BTEs allow you to implement additional logic in a task function, similar to program exits. SAP application programmers determine where to place BTEs in a task function and what data should the system transfer at each point. They also create sample function modules complete with short texts, an interface, and documentation, and describe the functions possible with the enhancement in the accompanying SAP documentation. First, SAP application programmers assign a BTE an 8-digit number by which the system can identify it. These numbers should observe a particular convention. For example, the system integrates the names of events into the same SAP application program and they should be identical at the fifth and sixth characters.
© Copyright . All rights reserved.
109
Unit 5: Business Transaction Events
The SAP developer registers the event and creates a template function module, SAMPLE_INTERFACE_, which establishes the interface for the user.
Business Transaction Events
Figure 80: BTE – Search
To find out directly whether an application transaction offers BTEs, you can use the procedure described on the left of the figure. Search the source code of the application program for the character string “ OPEN_FI_PERFORM”. The number that completes the name of the function module is also the name of the event. You find the option Use business transaction events in Customizing for Financial Accounting under Financial Accounting Global Settings. Choosing this option calls transaction FIBF, where you can execute all actions necessary for using BTEs. Under Environment, you find search functions that you can use to identify appropriate BTEs. You can view the documentation for the event from the list.
110
© Copyright . All rights reserved.
Lesson: Implementing Business Transaction Events (BTEs)
BTE – Documentation
Figure 81: BTE – Documentation
The Environment menu of the service transaction FIBF contains two programs that you can use to search for BTEs. You can restrict the search by using various parameters. The BTEs that the system finds are displayed in a list. You can then perform the following actions: Display the model function module (start the Function Builder and copy it, for example)
●
●
Display the interface
●
Display the documentation
The documentation provides a clear explanation of how to use the enhancement and any restrictions that apply to it.
Implement a Business Transaction Event
Figure 82: BTE – Product
© Copyright . All rights reserved.
111
Unit 5: Business Transaction Events
Use service transaction FIBF to create a product. A product groups together a collection of enhancements. You can create products for various layers in the delivery chain. They define a sequence for processing the implementations of a BTE. You can only switch each product on or off as a whole entity. This allows the user to control the enhancements that the system should process and should not process. It also ensures the integrity of the whole enhancement. Implementing a BTE
Figure 83: Implementing a BTE
You can use transaction FIBF (called when you selected Use business transaction events from the financial accounting hierarchy) to carry out all necessary activities prior to using a BTE. First, choose an interface to which you would like to attach your function module. The Interface button displays the parameter structure for the interface you have selected. You can also use the documentation to determine what functions each interface allows you to perform. Use the ABAP Workbench to copy the sample function module SAMPLE_INTERFACE_ to the customer namespace ( Z_*) of a customer function group. You must not change the interface. You can fill the module with any source text except COMMIT WORK. Activate the function module. Create a product on the administration screen. Assign a number to your function module and product. To Implement a Business Transaction Event The steps to implement a BTE are as follows: 1. Copying template function modules as Customer FMs (Z_*). a) Maintain source code
112
© Copyright . All rights reserved.
Lesson: Implementing Business Transaction Events (BTEs)
b) Activate 2. Create product. 3. Assign customer function module to BTE using product. 4. Activate product.
Demonstration: How to Use a Business Transaction Event First, show transaction FD01 to create customers. Explain why you need enhancements to this transaction. Customers will need many more checks than are provided in these transactions. The transaction provides several BTEs; one of them is used to perform additional checks, for example, on duplicate telephone numbers. The corresponding event number is 00001350. A program-related search should be a search for string OPEN_FI_PERFORM in the main program of FD01. You will see several BTEs in the result. Go to TA FIBF and search for all publish and subscribe interfaces that use event number 000013* (menu Environment → Info System (P/S)). Find event number 00001350 and display its function module and the corresponding documentation. Create a customer product. Next, explain how these products differ from partner products. Assign your function module to the product and the event. Run transaction FD01 again to show the effects. ( Remark : You can use event 00001350 for additional checks. Using interface parameter i_dynnr, you can specify the screen on which the enhancement is working, for instance screen # 7111, which is the screen containing the address data.)
Comparison of Customer Exits and BTEs
Figure 84: Comparison – Customer Exits and BTEs
© Copyright . All rights reserved.
113
Unit 5: Business Transaction Events
In contrast to customer exits, BTEs are client specific. This means that different clients can use the same event for different purposes. Also, you can use BTEs more than once. LESSON SUMMARY You should now be able to:
114
●
Explain Business Transaction Events
●
Implement Business Transaction Events
© Copyright . All rights reserved.
Unit 5
113
Learning Assessment
1. Which of the following characteristics explain Business Transaction Events? Choose the correct answers. X
A They allow you to attach additional components to the SAP system.
X
B They have predefined interfaces allowing customer access.
X
C They do not allow you to define additional logics.
X
D Two enhancements coexist, without impeding each other.
2. Which of the following include the steps of implementing a Business Transaction Event? Choose the correct answers. X
A Choose an interface to attach you FM.
X
B Use COMMIT WORK.
X
C Activate the function module.
X
D Activate the product.
© Copyright . All rights reserved.
115
Unit 5
114
Learning Assessment- Answers
1. Which of the following characteristics explain Business Transaction Events? Choose the correct answers. X
A They allow you to attach additional components to the SAP system.
X
B They have predefined interfaces allowing customer access.
X
C They do not allow you to define additional logics.
X
D Two enhancements coexist, without impeding each other.
2. Which of the following include the steps of implementing a Business Transaction Event? Choose the correct answers.
116
X
A Choose an interface to attach you FM.
X
B Use COMMIT WORK.
X
C Activate the function module.
X
D Activate the product.
© Copyright . All rights reserved.
UNIT 6
Classic Business Add-Ins
Lesson 1 Describing an ABAP Objects Interface
118
Lesson 2 Describing Classic Business Add-Ins (BAdIs)
121
Lesson 3 Enhancing Programs Using Classic BAdIs Exercise 6: Implement a BAdI Program Exit
127 133
Lesson 4 Implementing Classic BAdI Program Exits Exercise 7: Create a BAdI Definition for a Program Exit
137 143
Lesson 5 Implementing Classic BAdI Screen Exits Exercise 8: Implement a BAdI Screen Exit
149 159
Lesson 6 Explaining Advanced Details of BAdIs
165
UNIT OBJECTIVES ●
Describe an ABAP Objects interface
●
Describe classic Business Add-Ins (BAdIs)
●
Enhance programs using classic BAdIs
●
Implement classic BAdI program exits
●
Define classic BAdI screen exits
●
Implement classic BAdI screen exits
●
Explain advanced details of BAdIs
© Copyright . All rights reserved.
117
Unit 6 Lesson 1 116
Describing an ABAP Objects Interface
LESSON OVERVIEW This lesson summarizes the basics of object-oriented programming. Business Example You want to add new functions to a flight maintenance transaction. To minimize the adjustment effort during the next upgrade, you want the implementation to contain as few modifications as possible. In particular, you want to use BAdIs made available by SAP. For this reason, you require the following knowledge: ●
An ABAP Objects interface
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Describe an ABAP Objects interface
ABAP Objects – Interfaces
Figure 85: Classes and Objects
The basic approach of object-oriented programming is to think in objects, for example, a special booking with all the attributes and their special functionality working only on the objects. The technical description of an object is given by its class and the object is an instance of a class. Each object exists only while the program is running. A class consists not only of object-dependant descriptions, but also components, which are valid in general and have no special dependence to a concrete object. They are called static components.
118
© Copyright . All rights reserved.
Lesson: Describing an ABAP Objects Interface
Interfaces
Figure 86: Interfaces
An interface is a collection of formal and defined methods without any coding. This refers to the names of methods and their signatures. An interface can be integrated to a class known as the implementing class of the interface. In the class, you are able to implement all interface methods with their class-specific implementation. If you have several interface implementing classes with their class-specific coding, then you can have only one method of definition (in the interface), but several different functionalities (in the implementing classes). Reference Variables
Figure 87: Reference Variables
Instances were created during runtime and therefore have no name. This means you have to call an instance over its reference variable (pointer), which refers to the instance. You must define a reference variable in the declaration block of a program with the additional specification REF TO . This means that the reference variable appears during runtime to a specific instance of this class, which is not yet created. It does not mean that the pointer shows to the class, because a class is not anything physical; it is only a type description. To create an object of the class, use the defined reference variable. The reference variable then refers automatically to this object. You can then call instance components of the object using the reference variable as a prefix. To call class components (for example class methods), you do not need an object, because the class components are independent from any object of this class. For example, use therefore the class prefix to call a class method.
© Copyright . All rights reserved.
119
Unit 6: Classic Business Add-Ins
Interface Reference
Figure 88: Interface Reference
There is no way to instantiate an interface because interfaces do not have any coding. That is why you should not use the statement CREATE OBJECT to a reference defined to an interface. The implementation of an interface is given by a class, which is hierarchically under the interface. So a reference, which is linked to an interface, is able to refer to an object of the implementing class. Interface references are able to call only the interface components of an object of the implementing class. It depends on their static type definition. The functionality then runs in the context of this implementing class. So, if you have several implementing classes of an interface, you can use the same semantic of calling an interface method for the objects of these classes. A different functionality runs for each object. LESSON SUMMARY You should now be able to: ●
120
Describe an ABAP Objects interface
© Copyright . All rights reserved.
Unit 6 Lesson 2 119
Describing Classic Business Add-Ins (BAdIs)
LESSON OVERVIEW In this lesson, you learn how program and menu exits implemented using (BAdIs) work. You also learn how to find and use BAdIs. Business Example You have to enhance SAP software by using classical BAdIs delivered in the standard SAP system. For this reason, you require the following knowledge: ●
Search for available BAdIs in SAP programs
●
Use BAdIs to implement program enhancements
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Describe classic Business Add-Ins (BAdIs)
Classic Business Add-Ins
Figure 89: BAdIs – Architecture
BAdIs take into account the changes to the software delivery process. The upper section of the figure displays the typical delivery landscape and consists of a provider, a user, and a whole chain of intermediate providers.
© Copyright . All rights reserved.
121
Unit 6: Classic Business Add-Ins
The lower section of the figure explains how BAdIs function. An SAP application program provides the enhancement option. This requires at least one interface and a BAdIs class that implements it. The user can implement the interface. The advantages of this concept are as follows: A Badl is reusable.
●
●
●
A BAdI can be implemented many times, even by parties further towards the end of the software delivery chain. A BAdI enables each party to the software delivery chain to offer enhancements.
BAdIs – Components
Figure 90: BAdIs – Components
A BAdI contains the components of an enhancement. Each BAdI can contain the following components: Program enhancements
●
In the BAdI, the interfaces for program enhancements are defined in the form of interface methods. You use this interface to implement the enhancement. The SAP program calls the interface methods of the generated BAdI class. ●
Menu enhancements You can enter function codes in a BAdI. These menu options are available in the GUI definition and made visible when the BAdI is implemented.
●
Screen enhancements You can define and implement screen enhancements in a BAdI.
The components created when you define a BAdI are as follows: Interface
●
122
© Copyright . All rights reserved.
Lesson: Describing Classic Business Add-Ins (BAdIs)
●
Generated class (the BAdI class) that implements the interface
The generated BAdI class performs the following tasks: ● Filtering If you implement a filter-dependent BAdI, the add-in ensures that only the relevant implementations are called. ●
Control The BAdI class calls the active implementations.
BAdIs – Flow of a Program Exit
Figure 91: BAdIs – Flow of a Program Exit
The figure shows the process flow of a program that contains a BAdI call. You can see the possibilities and limitations inherent in BAdIs. You must declare a reference variable referring to the BAdI interface in the declaration section. An object reference is generated in the first step. This replaces the service class CL_EXITHANDLER provided by SAP. This generates the conditions for calling methods of program enhancements. When you define a BAdI, the system generates a BAdI class, which implements the interface. In the second call (2), the interface method of the BAdI class is called. The BAdI class searches for all the active implementations of the BAdI and calls the implemented methods.
© Copyright . All rights reserved.
123
Unit 6: Classic Business Add-Ins
BAdIs – Call Syntax in SAP Programs
Figure 92: BAdIs – Call Syntax in SAP Programs
The figure displays the syntax with which you call a BAdI. The numbered circles correspond to the calls. You must define a reference variable that refers to the BAdI interface. The name of the reference variable does not necessarily have to contain the name of the BAdI. In the first call (1), an object reference is created, which then creates an instance of the generated BAdI class. Using this object reference, only the methods of the interface can be contacted. You can use the object reference to call the required methods available with the second enhancement.
124
© Copyright . All rights reserved.
Lesson: Describing Classic Business Add-Ins (BAdIs)
Business Add-In Identification
Figure 93: Finding a BAdI
The various ways to search for BAdIs are as follows: ● You can search in a relevant application program for the string CL_EXITHANDLER. If a BAdI is called from the program, the GET_INSTANCE method of this class must be called. ●
●
●
You can then reach the definition of the BAdI using forward navigation. The definition also contains documentation and a guide for implementing the BAdI. Use the application hierarchy to restrict the components in which you want to search. Start Repository Information System and choose Enhancements → Business Add-Ins to start the relevant search program. You can use the entries in the relevant component of Implementation Guide. Demonstration: How to find Business Add-Ins To find Business Add-Ins, follow the steps below: Show scenario 1 1. Choose TA SPRO → SAP Reference Implementation Guide. 2. Search for the string BAdI. 3. From the list, choose the one to show the documentation in the Customizing environment. Show scenario 2 1. Choose TA SE81 → Financial Accounting → General Ledger Accounting → Basic Functions. 2. Mark it and choose Information System.
© Copyright . All rights reserved.
125
Unit 6: Classic Business Add-Ins
3. Choose Enhancements → Business Add- Ins → Definitions and select Execute. 4. From the results, choose the one to show the documentation in BAdI Definition Environment.
LESSON SUMMARY You should now be able to: ●
126
Describe classic Business Add-Ins (BAdIs)
© Copyright . All rights reserved.
Unit 6 Lesson 3 124
Enhancing Programs Using Classic BAdIs
LESSON OVERVIEW In this lesson, you will learn how program and menu exits, which are implemented using Business Add-Ins (BAdIs), work. You will also find out how to find and use BAdIs. Business Example You have to enhance your SAP software by using classic BAdIs delivered in the standard SAP system. For this reason, you require the following knowledge: ●
How to search for available BAdIs in SAP programs
●
How to use BAdIs to implement program enhancements
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Enhance programs using classic BAdIs
Business Add-In Implementation
Figure 94: Implementing BAdIs – Introduction
To implement BAdIs, use transaction SE19 and follow the steps below: 1. Go to Tools → ABAP Workbench → Utilities → Business Add-Ins → Implementation. 2. Enter a name for the implementation and choose the Create pushbutton. 3. A dialog box appears. Enter the name of the BAdI. The maintenance screen for the BAdI then appears.
© Copyright . All rights reserved.
127
Unit 6: Classic Business Add-Ins
Alternatively, you can use the BAdI definition transaction SE18 to reach its implementations. You can choose Implementation on the menu to get an overview of the existing implementations. You can also create new implementations from here.
Note: As of SAP NetWeaver Application Server 7.0, there are new BAdIs in addition to the older and classical ones. (The initial screen of transaction SE19 has been adjusted appropriately. To create an implementation for a classical BAdI, select Classical BAdI in the lower input area of the initial screen. Enter the BAdI name in the corresponding field. Choose Create Implementation. Implementing BAdIs – Methods
Figure 95: Implementing BAdIs – Methods
You can assign any name to the implementing class. However, you should observe the proposed naming convention. You can construct the suggested name as follows: ● Namespace prefix, Y, or Z ●
CL_ (for class)
●
IM_ (for implementation)
●
Name of the implementation (without namespace prefix)
To implement the method, double-click its name. The system starts the Class Builder editor. After finishing, you must activate the objects.
128
© Copyright . All rights reserved.
Lesson: Enhancing Programs Using Classic BAdIs
Implementing BAdIs – Private Methods
Figure 96: Implementing BAdIs – Private Methods
In the implementing class, you can create private methods that you call from the interface method. To do this, you must edit the implementing classes directly in the Class Builder. You can create the private methods including interfaces. Specify a visibility level for the method and implement the same. Implementing BAdIs – Activating Implementations
Figure 97: Implementing BAdIs – Activating Implementations
Use the icon to activate the implementation of a BAdI. The methods of the implementation are now executed when the relevant calling program is executed. If you deactivate the implementation, the system no longer calls the methods. However, the corresponding calls in the application program are still processed. The difference is that the instance of the adapter class no longer finds any active implementations. Unlike CALL
© Copyright . All rights reserved.
129
Unit 6: Classic Business Add-Ins
CUSTOMER-FUNCTION, the CALL_METHOD CL_EXITHANDLER=> GET_INSTANCE call is executed even when there are no implementations. The same applies to the method call that calls the method of the adapter class. You can only activate or deactivate an implementation in its original system without modification. However, this must be transported into the subsequent systems. If a BAdI can have only one implementation, there can still be more than one in the same system. However, only one can be active at one time. BAdIs – Menu Exits (Overview)
Figure 98: BAdIs – Menu Exits (Overview)
To use menu enhancements with BAdIs, you must ensure the following conditions are met: ● The developer of the program you want to enhance must have planned for the enhancement. ●
130
The menu enhancement must be implemented in a BAdI implementation.
© Copyright . All rights reserved.
Lesson: Enhancing Programs Using Classic BAdIs
BAdIs – Menu Exits (SAP Preparation)
Figure 99: BAdIs – Menu Exits (SAP Preparation)
Function codes of menu enhancements begin with a plus sign, +. The menu option appears only if there is an active BAdI implementation containing the corresponding enhancement. BAdIs – Menu Exits (Function Code Processing)
Figure 100: BAdIs – Menu Exits (Function Code Processing)
If the user chooses the menu option in the program to which the function code, + is assigned, the system processes the relevant method call. The method call and the menu enhancement are always performed together. For this reason, it’s important that the two enhancement components are combined in a single enhancement, the BAdI.
© Copyright . All rights reserved.
131
Unit 6: Classic Business Add-Ins
BAdIs – Menu Exits (Restrictions)
Figure 101: BAdIs – Menu Exits (Restrictions)
You can create only function codes for single use BAdIs. The BAdIs must not be filterdependent. These restrictions are necessary to ensure that there are no conflicts between two or more implementations. (“Which menu option should be displayed?”) Demonstration: How to Implement Business Add-Ins To implement BAdIs, perform the following steps: 1. Start program SAPBC425_BOOKING_00. 2. Point the additional data shown in the list. From the list, choose Menu System → Status. 3. Double-click the program name and search for the string CL_EXITHANDLER. 4. From the result list, find which BAdI definition is used for implementation in TA SE19. 5. To do this, double-click the result. In the ABAP editor, select the reference variable exit_book, which takes the BAdI Object from the CL_EXITHANDLER -> get_instance method. 6. Ignore IF_EX_ from the interface name and you will get the name of the BAdI. 7. Go to TA SE18 to read the documentation for this BAdI. Choose Menu Implementation → Create to implement the BAdI. 8. Implement the interface methods in the proposed customer class. Activate this and the implementation as well. 9. Start the program again and you will see the result.
132
© Copyright . All rights reserved.
Unit 6 Exercise 6 131
Implement a BAdI Program Exit
Business Example The customer service personnel in the agency want the list of bookings that you implemented in the exercise on menu exits to contain more information. The list should contain the name of the customer in addition to his or her customer number. Understanding the implementation of an enhancement with BAdIs. Task 1 Check if program SAPBC425_BOOKING_## (## = group number) can be enhanced. 1. Check the program for ways in which it can be enhanced. 2. Check if an enhancement option is suitable for outputting further information in the list.
Task 2 Implement the enhancement you found. Call your implementation ZBC425IM##. 1. Check what data is passed to the interfaces of the methods and if there already exists fields that should be displayed in the list. 2. Table SCUSTOM contains the information about the customers. Get the customer’s name from his customer number. Output the name.
Task 3 Format the list. 1. How to move the vertical line so that the additional fields are displayed within the frame. 2. If the CHANGE_VLINE method is suitable for changing the position of the vertical line, use it.
© Copyright . All rights reserved.
133
Unit 6 Solution 6 132
Implement a BAdI Program Exit
Business Example The customer service personnel in the agency want the list of bookings that you implemented in the exercise on menu exits to contain more information. The list should contain the name of the customer in addition to his or her customer number. Understanding the implementation of an enhancement with BAdIs. Task 1 Check if program SAPBC425_BOOKING_## (## = group number) can be enhanced. 1. Check the program for ways in which it can be enhanced. a) Place the cursor in the list and choose F1 → Technical Info. b) Double-click on the program name (You can also start directly in the ABAP Editor). c) Look for the character string CL_EXITHANDLER in the program. d) Double-click the transfer parameter exit_book. e) The name of the interface used to define the type of exit_book is if_cl_badi_book## and thus the name of the BAdI is BADI_BOOK##. 2. Check if an enhancement option is suitable for outputting further information in the list. a) Start transaction SE18. b) Read the documentation about this BAdI.
Task 2 Implement the enhancement you found. Call your implementation ZBC425IM##. 1. Check what data is passed to the interfaces of the methods and if there already exists fields that should be displayed in the list. a) Double-click the interface in transaction SE18. b) In the Class Builder, place the cursor on the required method and choose Parameter. c) The transfer structure does not contain the fields that you want to display in the list. You have to read the corresponding data separately. 2. Table SCUSTOM contains the information about the customers. Get the customer’s name from his customer number. Output the name.
134
© Copyright . All rights reserved.
Lesson: Enhancing Programs Using Classic BAdIs
a) Double-click on the method name to go to the Editor. A proposal for implementing the methods is given below (group 00): METHOD if_ex_badi_book00~output. DATA: name TYPE s_custname. SELECT SINGLE name FROM scustom INTO name WHERE id = i_booking– customid. WRITE: name. ENDMETHOD.
Task 3 Format the list. 1. How to move the vertical line so that the additional fields are displayed within the frame. a) Analyze method CHANGE_VLINE. b) Parameter c_pos defines the position of the right vertical line. 2. If the CHANGE_VLINE method is suitable for changing the position of the vertical line, use it. a) The method can be implemented as follows: METHOD if_ex_badi_book00~change_vline c_pos = c_pos + 25. ENDMETHOD. b) Check the results.
© Copyright . All rights reserved.
135
Unit 6: Classic Business Add-Ins
LESSON SUMMARY You should now be able to: ●
136
Enhance programs using classic BAdIs
© Copyright . All rights reserved.
Unit 6 Lesson 4 135
Implementing Classic BAdI Program Exits
LESSON OVERVIEW This lesson explains how to define Business Add-Ins (BAdIs). Business Example You have to define a Business Add-In (BAdI) that serves as an enhancement for later developments in your program. For this reason, you require the following knowledge: ●
An understanding of how to create BAdIs that serve as enhancements for later developments in your programs
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Implement classic BAdI program exits
Business Add-In Creation (BAdI Definition)
Figure 102: BAdI Definition – Introduction
To create a BAdI, use the BAdI Builder ( Tools → ABAP Workbench → Utilities → Business Add-Ins → Definition) or transaction SE18. Prior to SAP NetWeaver Application Server 7.0, the initial screen of transaction SE18 appears as shown in the figure. In SAP NetWeaver Application Server 7.0, new BAdIs also exist. They are contained in enhancement spots. To create an older (classical) BAdI from the new initial screen of transaction SE18, choose Utilities → Create classical BAdI.
© Copyright . All rights reserved.
137
Unit 6: Classic Business Add-Ins
Section: BAdI Definition – Attributes
Figure 103: BAdI Definition – Attributes
A BAdI has the following important attributes that you must define: Reusable
●
●
Filter-dependent
If you select the Reusable checkbox, many implementations can exist for the BAdI. The sequence in which the system processes implementations is not defined. Even if the BAdI does not support multiple uses, you can still have more than one implementation for it. However, only one implementation can be active at one time. If you make a BAdI Filter-dependent, you can make calls to it depending on certain conditions. Specify the filter type in the form of a data element or a structure present in the ABAP Dictionary. The data element uses the value table of the domain. This value table contains valid values for the implementation. Other than using structures as the filter type, you can use the single fields of the structure as well. When you call the enhancement method, a filter value must be passed to the interface. BAdI Definition – Restrictions for Menu Exits
Figure 104: BAdI Definition – Restrictions for Menu Exits
You can include function codes in a BAdI definition, for example, menu exits in customer exits. To do this, enter the program name, the function code, and a short description on the relevant tab page.
138
© Copyright . All rights reserved.
Lesson: Implementing Classic BAdI Program Exits
Restrictions for menu exits are as follows: It is currently not possible to create BAdIs that consist only of menu enhancements (function codes).
●
●
If you use menu enhancements, you cannot reuse a BAdI or make it filter-dependent.
BAdI Definition – Defining Interface Methods
Figure 105: BAdI Definition – Defining Interface Methods
The system proposes a name for the interface and the generated class. In principle, you can change the name of the interface. However, the BAdI is easier to understand if you retain the proposed name. The name of the generated class is composed of the following: ● Namespace prefix ●
CL_ (to signify a class in general)
●
EX_ (stands for exit)
●
BAdI name (without namespace prefix)
If you double-click the interface name, the system switches to the Class Builder, where you can define the interface methods. A BAdI interface can have several interface methods.
© Copyright . All rights reserved.
139
Unit 6: Classic Business Add-Ins
BAdI Definition – Method Interface Parameters
Figure 106: BAdI Definition – Method Interface Parameters
You can use all of the normal functions of the Class Builder. Some of the functions are as follows: ● Define interface methods. ●
Define interface parameters for the methods.
●
Declare the attributes of the interface.
If the BAdI is filter-dependent, you must define an import parameter flt_val for each method; otherwise, define the interface parameters needed for the enhancement. BAdI Definition – Activating the BAdI Interface
Figure 107: BAdI Definition – Activating the BAdI Interface
140
© Copyright . All rights reserved.
Lesson: Implementing Classic BAdI Program Exits
After working on the interface, you must activate it. This generates the BAdI class for the BAdI. If you change the interface, the system automatically regenerates the BAdI class. You can also generate the BAdI class explicitly at any time. To do so, choose Utilities → Regenerate from the initial screen of the BAdI maintenance transaction. BAdI Definition – Calls in the Program
Figure 108: BAdI Definition – Calls in the Program
To call BAdI methods in an application program, you must include the following statements in the program: 1. Declare a reference variable (1) with reference to the BAdI interface, for example, r_var. 2. Call the static method GET_INSTANCE of the service class CL_EXITHANDLER (2). This returns an instance of the required object. It involves an implicit down cast, so that you can call only the interface methods of the object with the reference variable r_var. 3. Call all of the methods of the BAdI (3). Ensure that you specify the method interfaces correctly.
© Copyright . All rights reserved.
141
Unit 6: Classic Business Add-Ins
Calling a Filter-Dependent BAdI
Figure 109: Calling a Filter-Dependent BAdI
If your BAdI is filter-dependent, you must pass an appropriate value to the parameter flt_val. Demonstration: How to Implement a BAdI To implement a BAdI, follow the steps below: 1. Prepare a small program to implement the BAdI you have defined. 2. Define a reference variable. 3. Instantiate the object with CALL METHOD CL_EXITHANDLER=>GET_INSTANCE. 4. Call the methods for your BAdI. 5. Create the BAdI implementation. 6. Point out that now you are on the implementing side. Distinguish the providing and the implementing sides very clearly.
142
© Copyright . All rights reserved.
Unit 6 Exercise 7 141
Create a BAdI Definition for a Program Exit
Business Example Develop your own supplementary components for the SAP system. You want to offer an enhancement that can implement subsequent software layers in a program. You deliver a program that outputs a list of flight connections. You can provide your customers with the following enhancement steps using a BAdI: 1. When the user double-clicks a row, developers at the customer’s site should be able to implement other actions. 2. Your customer should be able to build a details list. In the second part of the exercise, test your enhancement. The details list should show all the flights for a connection. Create a BAdI, and offer an enhancement in a program with the BAdI technology. Task 1 Create a program that outputs a list of flight connections. 1. Copy program SAPBC425_TEMPLATE given to the name ZBC425_BADI_##. 2. Assign your program to a package and a change request.
Task 2 Create a BAdI. 1. The name of the BAdI is ZBC425##. 2. Create a method. Define the interface. 3. Define the parameters to pass to the interface.
Task 3 Edit the program so that a user can double-click a line to output the details list. 1. Implement the AT LINE–SELECTION event. 2. Insert the appropriate statements in your program to call a BAdI as follows: Enter the source code of the program with the BAdI: *&–––––––––––––––––––––––––––––––––––––––––––––––––––––––––* *& Report SAPBC425_TEMPLATE* *&–––––––––––––––––––––––––––––––––––––––––––––––––––––––––* REPORT
© Copyright . All rights reserved.
143
Unit 6: Classic Business Add-Ins
sapbc425_badi. DATA: wa_spfli TYPE spfli, it_spfli TYPE TABLE OF spfli WITH KEY carrid connid. * Reference Variable for BAdI DATA: exit_ref TYPE REF TO zif_ex_bc42500. * Selection Screen SELECTION–SCREEN BEGIN OF BLOCK carrier WITH FRAME TITLE text–car. SELECT–OPTIONS: so_carr FOR wa_spfli–carrid. SELECTION–SCREEN END OF BLOCK carrier. *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––* *& Event START–OF–SELECTION *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––* START– OF–SELECTION. CALL METHOD cl_exithandler=>get_instance CHANGING instance = exit_ref. SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE it_spfli WHERE carrid IN so_carr. *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––* *& Event END–OF–SELECTION *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––* END– OF–SELECTION. LOOP AT it_spfli INTO wa_spfli. WRITE: / wa_spfli– carrid, wa_spfli–connid, wa_spfli–countryfr, wa_spfli–cityfrom, wa_spfli–countryto, wa_spfli–cityto, wa_spfli–deptime, wa_spfli– arrtime. HIDE: wa_spfli–carrid, wa_spfli–connid. ENDLOOP. CLEAR wa_spfli. *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––* *& Event AT LINE–SELECTION. *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––* AT LINE–SELECTION. CHECK NOT wa_spfli–carrid IS INITIAL. CALL METHOD exit_ref–>lineselection EXPORTING i_carrid = wa_spfli–carrid i_connid = wa_spfli–connid. CLEAR wa–spfli.
Task 4 Implement the enhancement. The name of the Implementation is ZB425##IM. 1. A details list should be output when you double-click a line of the list of the application program. The flight dates of the selected connection should be output in the details list. The SFLIGHT## table contains the flight dates. 2. Read the relevant data from table SFLIGHT## to an internal table with Array Fetch. Then, output selected fields of the internal table. 3. Which variables (attributes of the implementing class) do you have to declare? How do you declare an internal table? Where can you declare a table type?
144
© Copyright . All rights reserved.
Unit 6 Solution 7 143
Create a BAdI Definition for a Program Exit
Business Example Develop your own supplementary components for the SAP system. You want to offer an enhancement that can implement subsequent software layers in a program. You deliver a program that outputs a list of flight connections. You can provide your customers with the following enhancement steps using a BAdI: 1. When the user double-clicks a row, developers at the customer’s site should be able to implement other actions. 2. Your customer should be able to build a details list. In the second part of the exercise, test your enhancement. The details list should show all the flights for a connection. Create a BAdI, and offer an enhancement in a program with the BAdI technology. Task 1 Create a program that outputs a list of flight connections. 1. Copy program SAPBC425_TEMPLATE given to the name ZBC425_BADI_##. 2. Assign your program to a package and a change request.
Task 2 Create a BAdI. 1. The name of the BAdI is ZBC425##. a) Choose Utilities (M) → Create Classic BAdI. b) Enter ZBC425## as the name of the BAdI. c) Enter a short description and save your entries. 2. Create a method. Define the interface. a) Choose the Interface tab. b) Double-click on the name of the interface. This starts the Class Builder. c) Enter the name of a method, and give a short description. d) Choose Parameters to define the interface. 3. Define the parameters to pass to the interface.
© Copyright . All rights reserved.
145
Unit 6: Classic Business Add-Ins
a) Define two importing parameters whose types are defined with S_CARR_ID (airline) and S_CONN_ID (connection number). b) Activate the interface. This also generates the adapter class.
Task 3 Edit the program so that a user can double-click a line to output the details list. 1. Implement the AT LINE–SELECTION event. 2. Insert the appropriate statements in your program to call a BAdI as follows: a) Declare a reference variable. b) Instantiate an object of the BAdI class. c) Implement the call of the BAdI method at the right place in the program. Enter the source code of the program with the BAdI: *&–––––––––––––––––––––––––––––––––––––––––––––––––––––––––* *& Report SAPBC425_TEMPLATE* *&–––––––––––––––––––––––––––––––––––––––––––––––––––––––––* REPORT sapbc425_badi. DATA: wa_spfli TYPE spfli, it_spfli TYPE TABLE OF spfli WITH KEY carrid connid. * Reference Variable for BAdI DATA: exit_ref TYPE REF TO zif_ex_bc42500. * Selection Screen SELECTION–SCREEN BEGIN OF BLOCK carrier WITH FRAME TITLE text–car. SELECT–OPTIONS: so_carr FOR wa_spfli–carrid. SELECTION–SCREEN END OF BLOCK carrier. *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––* *& Event START–OF–SELECTION *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––* START– OF–SELECTION. CALL METHOD cl_exithandler=>get_instance CHANGING instance = exit_ref. SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE it_spfli WHERE carrid IN so_carr. *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––* *& Event END–OF–SELECTION *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––* END– OF–SELECTION. LOOP AT it_spfli INTO wa_spfli. WRITE: / wa_spfli– carrid, wa_spfli–connid, wa_spfli–countryfr, wa_spfli–cityfrom, wa_spfli–countryto, wa_spfli–cityto, wa_spfli–deptime, wa_spfli– arrtime. HIDE: wa_spfli–carrid, wa_spfli–connid. ENDLOOP. CLEAR wa_spfli. *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––* *& Event AT LINE–SELECTION. *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––* AT LINE–SELECTION. CHECK NOT wa_spfli–carrid IS INITIAL. CALL METHOD exit_ref–>lineselection EXPORTING i_carrid = wa_spfli–carrid i_connid = wa_spfli–connid. CLEAR wa–spfli.
Task 4 Implement the enhancement. The name of the Implementation is ZB425##IM.
146
© Copyright . All rights reserved.
Lesson: Implementing Classic BAdI Program Exits
1. A details list should be output when you double-click a line of the list of the application program. The flight dates of the selected connection should be output in the details list. The SFLIGHT## table contains the flight dates. 2. Read the relevant data from table SFLIGHT## to an internal table with Array Fetch. Then, output selected fields of the internal table. 3. Which variables (attributes of the implementing class) do you have to declare? How do you declare an internal table? Where can you declare a table type? a) Implement the BAdI. From transaction SE18, choose Create Implementations. b) Name the implementation as ZBC425##_IM. c) Choose the Interface tab. d) Double-click the name of the method. The Editor starts. e) Enter the source text here: METHOD zif_ex_bc42500~lineselection. it_flights TYPE TABLE OF sflight00, wa_flights TYPE sflight00.
DATA:
FORMAT COLOR COL_HEADING. WRITE: / text–hea, i_carrid, i_connid. FORMAT COLOR COL_NORMAL. SELECT * FROM sflight00 INTO CORRESPONDING FIELDS OF TABLE it_flights WHERE carrid = i_carrid AND connid = i_connid. LOOP AT it_flights INTO wa_flights. WRITE: / wa_flights–fldate, wa_flights–planetype, wa_flights–price CURRENCY wa_flights–currency, wa_flights–currency, wa_flights–seatsmax, wa_flights–seatsocc. ENDLOOP. ENDMETHOD. f) Activate the implementation. g) Check your results.
© Copyright . All rights reserved.
147
Unit 6: Classic Business Add-Ins
LESSON SUMMARY You should now be able to: ●
148
Implement classic BAdI program exits
© Copyright . All rights reserved.
Unit 6 Lesson 5 147
Implementing Classic BAdI Screen Exits
LESSON OVERVIEW This lesson shows how to create a program that provides a Business Add-In (BAdI) screen enhancement (screen exit). It also explains how to implement a screen exit that is based on the BAdI. Business Example You have to change a program in a way that a BAdI screen enhancement is provided. Next, you have to implement a screen exit that is based on the BAdI. For this reason, you require the following knowledge: ●
How to create a program that provides a BAdI screen enhancement (screen exit)
●
Implement BAdI screen enhancements (screen exits)
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Define classic BAdI screen exits
●
Implement classic BAdI screen exits
BAdI – Screen Exit Definition
Figure 110: BAdI Screen Exits – Basic Principles
© Copyright . All rights reserved.
149
Unit 6: Classic Business Add-Ins
The ABAP virtual machine does not recognize screens bound to classes. Thus, you can only use classical programs of types 1, F, or M as containers for screens. Screen enhancements must take this into consideration. When you create a BAdI screen enhancement, the provider reserves a subscreen area on the application program screen, which is then filled with the subscreen of the implementing class. However, the application program and the subscreen container program do not communicate directly. They communicate using the generated BAdI class. BAdI Screen Exits – Components
Figure 111: BAdI Screen Exits – Components
If a BAdI contains one or more screen enhancements, you cannot flag it as reusable. If it also contains menu enhancements, then it may not be filter-dependent too. In addition to the interface definition, enter the calling program, screen number, and subscreen area on the Subscreens tab page. Later, the implementing developer specifies the name of the implementing programand the number of the subscreen screen. BAdI Screen Exits – Subscreen Container Program’s PBO In the Subscreen Container Program’s Process Before Output (PBO), perform the following steps: 1. Generate the BAdI class instance. 2. Publish the instance so that implementing classes can access it. 3. Specify the program name and screen number of the implementation. 4. Make available the data for the subscreen screen. 5. Integrate the subscreen into the subscreen area. To use a BAdI for screen enhancement, you must implement the stepsin the application screen’s PBO.
150
© Copyright . All rights reserved.
Lesson: Implementing Classic BAdI Screen Exits
BAdI Screen Exits – Subscreen Container Program’s PAI In the Subscreen Container Program’s Process After Input (PAI), perform the following steps: 1. Call the subscreen. 2. Take user entries from the subscreen. In the subscreen container screen’s PAI, you must call the subscreen again. Depending on the enhancement design, the system loads the data that the user changed on the subscreen into the application program. PBO Steps (1) – Create BAdI Instance
Figure 112: PBO Steps (1) – Create BAdI Instance
You create an instance of the BAdI, just as in functional enhancements. You do this by calling the GET_INSTANCE factory method from the CL_EXITHANDLER class.
© Copyright . All rights reserved.
151
Unit 6: Classic Business Add-Ins
PBO Steps (2) – Publish Instance
Figure 113: PBO Steps (2) – Publish Instance
Later, the implementation will have to access the BAdI class instance. Therefore, it is necessary to publish the instance. To do so, call the SET_INSTANCE_FOR_SUBSCREENS static method of the CL_EXITHANDLER class. PBO Steps (3) – Provide Subscreen Number
Figure 114: PBO Steps (3) – Provide Subscreen Number
You must determine the subscreen screen number and the corresponding program for the implementation of the CALL SUBSCREEN statement in the container screen’s PBO. To do
152
© Copyright . All rights reserved.
Lesson: Implementing Classic BAdI Screen Exits
this, call the method with CALL METHOD CL_EXITHANDLER=>GET_PROG_AND_DYNP_FOR_SUBSCR. If there is no active implementation yet, the method returns an empty, dummy subscreen screen (0200) from an existing dummy function group (SAPLSEXM). If you want to use an active implementation for the BAdI definition, use the subscreen screen that you specified in the implementation. PBO Steps (4) – Provide Data
Figure 115: PBO Steps (4) – Provide Data
To provide data to the implementation, you need to pass it in the following steps: 1. Pass the data to the BAdI class. The system stores this data in the global attributes in the implementation of this method. It is advisable to provide sample code. The system passes the data by calling the method defined in the BAdI. 2. If there is an active implementation, the system automatically passes the data stored in the global attributes of the add-in class to the global attributes of the implementing class.
© Copyright . All rights reserved.
153
Unit 6: Classic Business Add-Ins
PBO Steps (5) – Integrate Subscreen
Figure 116: PBO Steps (5) – Integrate Subscreen
The application program calls the subscreen screen. PAI Steps – Call Subscreen and Load Data
Figure 117: PAI Steps– Call Subscreen and Load Data
If you need to load the entries made by the user on the subscreen into the application program for further processing, call the corresponding method (GET_DATA). Demonstration: How to Create a BAdI Screen Enhancement
154
© Copyright . All rights reserved.
Lesson: Implementing Classic BAdI Screen Exits
To create a BAdI screen enhancement, follow the steps below: 1. In package BC425_00, you will find a program SAPBC425_FLIGHT00, which you can copy into the customer namespace in order to create a BAdI screen enhancement. 2. Copy the program or create a new one. The program must have a screen. 3. Add a subscreen area. 4. Add the statements needed to call subscreens. 5. Add the modules needed for the subscreen calls. 6. Create a BAdI to provide the screen enhancement. 7. You have to create at least two methods: GET_DATA and PUT_DATA (choose any names).
BAdI Screen Exit Implementation To implement BAdI screen exits, perform the following steps: 1. Create the program (function group). 2. Create the subscreen screen. 3. In PBO, generate the BAdI class interface and provide the subscreen screen data. 4. In PAI, load the data changed on the subscreen. 5. Create BAdI implementation. To implement an add-in screen enhancement, perform the following steps: 1. Create the implementation for the add-in definition. Specify the program containing the subscreen screen and the subscreen number. 2. Create the program specified in the BAdI implementation. 3. Create and layout the subscreen screen. If you want to return the data you changed on the subscreen to the application program, you must call the corresponding method in the PAI of the subscreen screen.
© Copyright . All rights reserved.
155
Unit 6: Classic Business Add-Ins
PBO Steps (1) – Provide BAdI Instance
Figure 118: PBO Steps (1) – Provide BAdI Instance
To get the reference to the instance of the add-in, use the GET_INSTANCE_FOR_SUBSCREENS method in the CL_EXITHANDLER class. PBO Steps (2) – Provide Subscreen Data
Figure 119: PBO Steps (2) – Provide Subscreen Data
The implementing program obtains the data to be displayed on the subscreen by calling the corresponding method (in this instance, it is GET_DATA). The system stores the data in the global variables of the implementing program. The global variables fill the corresponding subscreen fields at the end of the PBO.
156
© Copyright . All rights reserved.
Lesson: Implementing Classic BAdI Screen Exits
PAI Step – Returning Data
Figure 120: PAI Step – Returning Data
If you want the data on the subscreen to be changeable, ensure that the changed data is returned to the application program so that it can be used for further processing. You can do this by calling the appropriate add-in method (in this instance, it is PUT_DATA). Demonstration: How to Implement a BAdI Screen Enhancement To implement a BAdI screen enhancement, perform the following steps: 1. Search for the program SAPBC425_FLIGHT_CHNG00 in package BC425_00 in your training system. There you will find a BAdI that has already been created. 2. Create a function group. 3. Create the subscreen. 4. Put two fields of the SFLIGHT00 table on the subscreen. 5. Implement the method calls in the flow logic of the subscreen. 6. Implement the BAdI. Alternately, you can also implement the screen enhancement created in the previous demonstration (Create BAdI Screen Enhancement).
© Copyright . All rights reserved.
157
Unit 6: Classic Business Add-Ins
158
© Copyright . All rights reserved.
Unit 6 Exercise 8 157
Implement a BAdI Screen Exit
Business Example Use a transaction of your own to record and change flight data. At present, this transaction offers only standard input fields. Your enterprise wants to record additional data for each flight. The transaction offers an enhancement possibility for this purpose that you will implement. Implement a screen enhancement using a BAdI. Task 1 Find out whether or not the program SAPBC425_FLIGHT_CHNG## offers an enhancement possibility, which you can use to extend the detail recording screen. 1. Choose System → Status to get the name of the program. 2. Double-click the program name. 3. Choose Goto → Object Catalog Entry. This tells you the package to which the application is assigned. 4. Double-click the package name to find out the application component containing this package.
Task 2 Look for BAdIs with which you can implement your requirements. 1. Search the application hierarchy. 2. Search the Repository Information System. 3. Search the Implementation Guide. 4. If you find a BAdI, read its documentation and decide whether or not it is suitable for enhancement.
Task 3 Implement the enhancement. 1. Create the function group ZBC425IM## in the Object Navigator. You need this function group to create a subscreen screen. 2. Create a subscreen screen in the function group and assign a number to it. 3. Add the appropriate fields to the screen.
© Copyright . All rights reserved.
159
Unit 6: Classic Business Add-Ins
4. Program the flow logic for the subscreen screen. At the PBO event, get the instance of the add-in class and the data that is passed from the SAP application. At the PAI event, the changed data must be returned to the SAP application.
Task 4 Create a BAdI implementation. Name your implementation ZBC425SIN##. 1. Implement the interface method. 2. Enter the necessary information on the Subscreens tab page. 3. Activate the implementation.
Task 5 1. Test the enhanced application.
160
© Copyright . All rights reserved.
Unit 6 Solution 8 159
Implement a BAdI Screen Exit
Business Example Use a transaction of your own to record and change flight data. At present, this transaction offers only standard input fields. Your enterprise wants to record additional data for each flight. The transaction offers an enhancement possibility for this purpose that you will implement. Implement a screen enhancement using a BAdI. Task 1 Find out whether or not the program SAPBC425_FLIGHT_CHNG## offers an enhancement possibility, which you can use to extend the detail recording screen. 1. Choose System → Status to get the name of the program. 2. Double-click the program name. 3. Choose Goto → Object Catalog Entry. This tells you the package to which the application is assigned. 4. Double-click the package name to find out the application component containing this package.
Task 2 Look for BAdIs with which you can implement your requirements. 1. Search the application hierarchy. a) In the repository, choose Enhancements → Business Add Ins → Definitionto search for BAdIs. 2. Search the Repository Information System. a) In the application hierarchy, select the application component. b) Choose Info System to navigate to the Repository Information System. c) All the packages contained in the application component you have selected are entered as search criteria. 3. Search the Implementation Guide. a) The system returns a list of BAdIs. Select any BAdI, for example, BC425_##FLIGHT2, and choose Display. You are now in Business Add-In Builder, where you will find the documentation for this add-in. b) Get to know the documentation.
© Copyright . All rights reserved.
161
Unit 6: Classic Business Add-Ins
4. If you find a BAdI, read its documentation and decide whether or not it is suitable for enhancement.
Task 3 Implement the enhancement. 1. Create the function group ZBC425IM## in the Object Navigator. You need this function group to create a subscreen screen. a) Display the object list for your package. b) Right-click the package name and choose Create → Function Group. c) Enter ZBC425IM## in the Name field and create a short description. d) Save your entries and assign them to a change request. 2. Create a subscreen screen in the function group and assign a number to it. a) Select the function group and choose Create → Screen from the context menu. b) Enter a short description and choose the type Subscreen. 3. Add the appropriate fields to the screen. a) Launch Layout Editor. b) Choose Goto → Secondary Window → Dict/Program Fields. c) Enter the ABAP Dictionary structure and choose Get from Dict. d) Select the fields you want and confirm your choice. e) Add the fields to the screen. 4. Program the flow logic for the subscreen screen. At the PBO event, get the instance of the add-in class and the data that is passed from the SAP application. At the PAI event, the changed data must be returned to the SAP application. a) Navigate to the flow logic for the subscreen screen. The flow logic should include a call to the following module: *–––––––––––––––––––––––––––––––––––––––––––– PROCESS BEFORE OUTPUT. MODULE get_instance. MODULE get_data. * *–––––––––––––––––––––––––––––––––––––––––––– PROCESS AFTER INPUT. MODULE put_data. *–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– ––––––* ***INCLUDE LZBC425_IMO01 . *–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– ––––––* *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– ––––––* *& Module get_instance OUTPUT *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– ––––––* MODULE get_instance OUTPUT. CALL METHOD cl_exithandler=>get_instance_for_subscreens CHANGING instance = r_var EXCEPTIONS OTHERS = 6. IF sy–subrc <> 0. MESSAGE ID sy– msgid TYPE sy–msgty NUMBER sy–msgno WITH sy–msgv1 sy–msgv2 sy– msgv3 sy–msgv4. ENDIF. ENDMODULE. " get_instance OUTPUT *&–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
162
© Copyright . All rights reserved.
Lesson: Implementing Classic BAdI Screen Exits
––––––* *& Module get_data OUTPUT *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– ––––––* MODULE get_data OUTPUT. CALL METHOD r_var–>get_data IMPORTING e_conn = sdyn_conn. ENDMODULE. " get_data OUTPUT *–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– ––––––* ***INCLUDE LZBC425_IMI01 . *–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– ––––––* *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– ––––––* *& Module put_data INPUT *&––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– ––––––* MODULE put_data INPUT. CALL METHOD r_var–>put_data EXPORTING i_conn = sdyn_conn. ENDMODULE. " put_data INPUT *–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– ––––––* ***INCLUDE LZBC425_IMTOP *–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– ––––––* FUNCTION–POOL kaura_im_bc425. "MESSAGE–ID .. TABLES: sdyn_conn. DATA: r_var TYPE REF TO if_ex_bc425_##flight2.
Task 4 Create a BAdI implementation. Name your implementation ZBC425SIN##. 1. Implement the interface method. a) To navigate to ABAP Editor, choose the Interface tab page and double-click the name of the method. METHOD if_ex_bc425_##flight2~get_data . MOVE–CORRESPONDING wa TO e_conn. ENDMETHOD."IF_EX_BC425_##FLIGHT2~GET_DATA METHOD if_ex_bc425_##flight2~put_data . MOVE–CORRESPONDING i_conn TO wa. ENDMETHOD."IF_EX_BC425_##FLIGHT2~PUT_DATA 2. Enter the necessary information on the Subscreens tab page. a) On the Subscreens tab page, enter the name of the program from your function group SAPLZBC425IM##. b) Enter the number of the subscreen screen you created. 3. Activate the implementation. a) Activate the implementation by choosing either Implementation → Activate or the appropriate button.
Task 5 1. Test the enhanced application. a) Execute the application and check that your enhancement is processed.
© Copyright . All rights reserved.
163
Unit 6: Classic Business Add-Ins
LESSON SUMMARY You should now be able to:
164
●
Define classic BAdI screen exits
●
Implement classic BAdI screen exits
© Copyright . All rights reserved.
Unit 6 Lesson 6 163
Explaining Advanced Details of BAdIs
LESSON OVERVIEW This lesson contains additional information on Business Add-Ins (BAdIs). Business Example You have to add new functions to a flight maintenance transaction in an SAP system. To minimize the inputs during the next upgrade, you want the implementation to contain as few modifications as possible. In particular, you want to use BAdIs made available by SAP. For this reason, you require the following knowledge: ●
Explain an extendible filter type
●
Explain the default and sample code
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Explain advanced details of BAdIs
Extendible Filter Types
Figure 121: Extendible Filter Types – Prerequisites
The assignment of the extendible attribute is subject to a few restrictions. The domain to which the extendible filter type refers must have the following properties:
© Copyright . All rights reserved.
165
Unit 6: Classic Business Add-Ins
●
●
●
The domain is linked to a cross-client value table. The value table has exactly one key field, which has the data element of the filter type as its field type. The domain has a text table with two key fields. A key field has the filter type as its field type, and a key field is a language field. To mark a field as a text field, the field must exist in this table that contains the string TEXT or TXT as a partial string. In the ABAP Dictionary, the text table must be assigned to the value table. The delivery class of both tables must be E or S.
Not all filter values that you created in the context of an extendible filter-dependent BAdI must occur in the value field. When you save the data, the system adds them to the value table. Similarly, when you delete the implementation or the entire BAdI, the system removes the values from the value table. The same situation applies to the text tables.
Default and Sample Code
Figure 122: Default Implementation
A default implementation is executed whenever no active implementation of a BAdI exists. The enhancement provider is used to create it. To create a default implementation in the BAdI definition, choose Goto → Default code. The system automatically generates a class with a predefined name. You need to implement the methods for generating the required default behavior. You can also create a sample implementation. This is a template that you need to insert into the methods of the implementation. To create a sample implementation, choose Goto → Sample Code. The system creates a class that implements the methods of the interface. The user can view the sample code as a template.
166
© Copyright . All rights reserved.
Lesson: Explaining Advanced Details of BAdIs
Comparison with Other Enhancement Techniques
Figure 123: Comparison with Other Enhancement Techniques
BAdIs are a natural further development of the conventional enhancement technique. They have taken over the administration layer from customer exits, along with the availability of the various enhancement components. BAdIs adopted the idea of reusability from business transaction events. You can implement this using a consistent object-oriented approach.
Naming Conventions ●
BAdI definition -
OR Z OR /../ (Choose any; comply with namespace)
●
Interface -
IF_EX_ OR ZIF_EX_ OR /../IF_EX_ (Choose any; comply with namespace)
●
Methods -
●
Choose any name you want
Generated BAdI Class (Adapter Class) -
CL_EX_ OR ZCL_EX_ OR /../CL_EX_ (Not changeable)
Naming Conventions (BAdI Implementations) ●
BAdI implementation -
OR Z OR /../ (Choose any; comply with namespace)
© Copyright . All rights reserved.
167
Unit 6: Classic Business Add-Ins
●
Interface -
IF_EX_ OR ZIF_EX_ OR /../IF_EX_ (Specified by the BAdI definition)
●
Methods -
●
Defined in BAdI definition
Implementing class -
CL_IM_ OR ZCL_IM_ OR /../CL_IM_ (Choose any; comply with namespace)
LESSON SUMMARY You should now be able to: ●
168
Explain advanced details of BAdIs
© Copyright . All rights reserved.
Unit 6
167
Learning Assessment
1. What does ABAP Objects consist of? Choose the correct answers. X
A Classes
X
B Codes
X
C Objects
X
D Reference Variables
2. Which of the following components is a part of Business Add-In? Choose the correct answers. X
A Program enhancements
X
B Screen enhancements
X
C Filtering enhancements
X
D Menu enhancements
3. In which field must you edit the implementing classes directly? Choose the correct answer. X
A Function Builder
X
B Function Module
X
C Class Builder
X
D Class Module
© Copyright . All rights reserved.
169
Unit 6: Learning Assessment
4. Which of the following statements can be used to call a BAdI in an application program? Choose the correct answers. X
A Define a reference variable.
X
B Instantiate the object with CALL METHOD CL_EXITHANDLER=>GET_INSTANCE.
X
C Call the methods for your BAdI.
X
D Define parameters to pass it to the interface.
5. Which of the following includes the steps to implement a BAdI screen enhancement? Choose the correct answers. X
A Create the implementation for the BAdI definition.
X
B Create the program specified in the BAdI implementation.
X
C Create and layout the subscreen screen.
X
D Create a new interface of the BAdI implementation.
6. What are the advantages of Business Add-Ins in comparison to customer exits? Choose the correct answers.
170
X
A Menu Exit
X
B Reusable
X
C Screen Exit
X
D Filter-dependent
© Copyright . All rights reserved.
Unit 6
169
Learning Assessment- Answers
1. What does ABAP Objects consist of? Choose the correct answers. X
A Classes
X
B Codes
X
C Objects
X
D Reference Variables
2. Which of the following components is a part of Business Add-In? Choose the correct answers. X
A Program enhancements
X
B Screen enhancements
X
C Filtering enhancements
X
D Menu enhancements
3. In which field must you edit the implementing classes directly? Choose the correct answer. X
A Function Builder
X
B Function Module
X
C Class Builder
X
D Class Module
© Copyright . All rights reserved.
171
Unit 6: Learning Assessment- Answers
4. Which of the following statements can be used to call a BAdI in an application program? Choose the correct answers. X
A Define a reference variable.
X
B Instantiate the object with CALL METHOD CL_EXITHANDLER=>GET_INSTANCE.
X
C Call the methods for your BAdI.
X
D Define parameters to pass it to the interface.
5. Which of the following includes the steps to implement a BAdI screen enhancement? Choose the correct answers. X
A Create the implementation for the BAdI definition.
X
B Create the program specified in the BAdI implementation.
X
C Create and layout the subscreen screen.
X
D Create a new interface of the BAdI implementation.
6. What are the advantages of Business Add-Ins in comparison to customer exits? Choose the correct answers.
172
X
A Menu Exit
X
B Reusable
X
C Screen Exit
X
D Filter-dependent
© Copyright . All rights reserved.
UNIT 7
Modifications of the SAP Standard
Lesson 1 Modifiying the SAP Standard Software
174
Lesson 2 Modifying with the Modification Assistant Exercise 9: Implement Modifications
183 191
Lesson 3 Implementing User Exits
196
Lesson 4 Adjusting Modifications
200
UNIT OBJECTIVES ●
Implement modifications
●
Implement modifications using the Modifications Assistant
●
Implement modifications using user exits
●
Adjust modifications
© Copyright . All rights reserved.
173
Unit 7 Lesson 1 172
Modifiying the SAP Standard Software
LESSON OVERVIEW This lesson explains you about modifications, and the basic terms in the modification environment. In addition, the lesson shows you what you should bear in mind while making changes. Business Example You would like to know what you must bear in mind while implementing modifications. For this reason, you require the following knowledge: ●
What to pay attention to when modifying program objects
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Implement modifications
Modifications – Overview
Figure 124: Modifications – Overview Diagram
This figure explains the modifications in the SAP Standard Software.
174
© Copyright . All rights reserved.
Lesson: Modifiying the SAP Standard Software
Originals and Copies
Figure 125: Originals and Copies
An object is original in only one system. In the case of objects delivered by SAP, the original system belongs to SAP. In customer systems, these objects are only available as copies. This applies to your development system and all other systems which come after it. If you write your own applications, the objects that you create are original in your development system. You assign your developments to a change request, which has the type Development/Correction. This request ensures that the system transports objects from the development system to the subsequent systems. Corrections and Repairs
Figure 126: Corrections and Repairs
© Copyright . All rights reserved.
175
Unit 7: Modifications of the SAP Standard
Changes to an original are called corrections. They are recorded in a change request whose tasks have the type Development/Correction. If you change a copy (an object outside its own original system), the change is recorded in a task with the type Repair. Repairs to SAP objects are called modifications. When you repair your own objects (for example, if something goes wrong in your production system), you can correct the original in the development system. When you change copies, you must correct the original immediately. However, you cannot do this with SAP objects, because they are not original in any of your systems. You should only modify the SAP standard if the modifications you want to make are absolutely necessary for optimizing workflow in your company. Good background knowledge of application structure and flow are essential prerequisites for deciding what kind of modifications to make and how to design them. Modifications and Upgrades
Figure 127: Modifications and Upgrades
Whenever you upgrade your system, apply a support package or import a transport request. Conflicts can occur with modified objects. Conflicts occur when you change an SAP object and SAP also delivers a new version of it. Then, the new object delivered by SAP becomes an active object in the Repository of your system. If you want to save the changes, you must perform a modification adjustment for the objects. If you have a lot of modified SAP objects, the system slows down the upgrade considerably. To ensure consistency between your development system and subsequent systems, you should only perform modification adjustments in your development system. The objects from the adjustment can then be transported into other systems.
176
© Copyright . All rights reserved.
Lesson: Modifiying the SAP Standard Software
Modification Implementation
Figure 128: Registering Modification in SSCR
A registered development user registers changes in SAP sources and manual changes of ABAP Dictionary objects. Exceptions to such registration are matchcodes, database indexes, buffer settings, customer objects, patches, and objects, whose changes are based on automatic generation (for example, in Customizing). If you change the object again later, the system does not make any new query for the registration key. After you register an object, the system stores the related key locally and copies it automatically for later changes, regardless of which registered developer is making the change. Till then, these keys remain valid even after a release upgrade. Following are the benefits of SSCR (SAP Software Change Registration): ● Quick error resolution and high availability of modified systems SAP logs all objects you changed. Based on this information, SAP’s first level customer service can quickly locate and fix problems. This increases the availability of your ERP system. ●
Dependable operation Registering your modifications prevents unintended modification. This, in turn, promotes the dependable operation of your ERP software.
●
Simplification of upgrades Upgrades and release upgrades become considerably easier due to the smaller number of modifications.
© Copyright . All rights reserved.
177
Unit 7: Modifications of the SAP Standard
Carrying Out a Registered Modification
Figure 129: Carrying Out a Registered Modification
If you want to change an SAP Repository object, you must provide the following information to the Workbench Organizer: ● SSCR key ●
Change request
The figure above explains how to obtain an SSCR key. If you now continue to change the object, you must confirm a few warning dialogs. At this point, you can still cancel the action without repairing the object. The workbench organizer prompts you to enter a change request similar to your own objects. The system adds this object automatically to a repair task. The change request has the following functions: Change lock
●
After you assign the task, only its owner can change the object. ●
Import lock The object cannot be overwritten by an import (upgrade or support package).
●
Version creation The system generates a new version of the object.
178
© Copyright . All rights reserved.
Lesson: Modifiying the SAP Standard Software
After Finishing Modification
Figure 130: When the Modification is finished
After completing the development, the programmer releases the task. At this point, the programmer must document the changes made. The system transfers objects and object locks valid in the task to the change request. If the developer confirms the repair, while releasing the task, the import lock passes to the change request. If he does not, the import lock remains in place. Note that only the developer can release this lock. After completing the project, you release the change request. This removes all the change request’s object locks. This applies both to the change and import locks. When you release the change request, the system copies the objects from the database of the SAP system and stores in a directory at operating system level. The system administrator then imports them into subsequent systems. After importing the modifications into the quality system, the developer must test and check the import log of the request.
© Copyright . All rights reserved.
179
Unit 7: Modifications of the SAP Standard
Versions
Figure 131: Versions
When you release a change request, a complete version of all objects contained in it is written to the versions database. If you transport the repository object again later, the current object becomes a complete copy. The system stores the differences between the old and the new object in the versions database as a backwards delta. When you assign a repository object to a task, the system checks whether the current version matches the complete copy in the versions database. If not, it creates a complete copy. The system also initiates this process the first time you change an object, since SAP does not deliver versions of repository objects. The versions of a repository object provide the basis for modification adjustment. To support the adjustment, the system stores the information on whether SAP created the version or the customer.
180
© Copyright . All rights reserved.
Lesson: Modifiying the SAP Standard Software
Critical Success Factors (1)
Figure 132: Critical Success Factors (1)
Encapsulate customer source code in modularization units instead of inserting it directly into SAP source code. For example, customer function module calls in program source code, or customer subscreen calls for additional screen fields. Be careful to use narrow interfaces when you encapsulate customer-specific functions, in order to ensure good data control. Critical Success Factors (2) Following are the critical success factors: ● Use standardized in line documentation (supported by the Modification Assistant) ●
●
●
●
Do not delete any SAP source code – comment it out (supported by the Modification Assistant) Keep a modification logbook (Possibly using the modification log from SE95 as a basis) Do not modify any central basis Dictionary Objects (Unless directed to by an SAP Note or the SAP Hotline) Release all requests that contain repairs
Define a company-wide standard for managing the documentation in the source code. You should also maintain a list of all modifications (a modification log) in your system. Any modifications that you make to ABAP Dictionary objects that belong to SAP Basis components, such as ABAP Workbench, are lost at upgrade. These objects revert to their earlier form and the system does not offer any adjustment help. This can lead to the loss of the content of certain tables. The system releases all requests that contain repairs before an upgrade/Support Package import so that the system can write all relevant customer versions to the versions database. The system compares versions during adjustment.
© Copyright . All rights reserved.
181
Unit 7: Modifications of the SAP Standard
Modification Logs (Example)
Figure 133: Modification Logs (Example)
SAP recommends that you keep a record of all modifications that have been made to your system. This includes all the changes that you have made to repository objects in the SAP namespace. Record the information in a list with the following columns: Object type such as program, screen, GUI status, and so on
●
●
Object name
●
Routine (if applicable)
●
Subject area (according to process design blueprint or technical design)
●
Repair number
●
Change date
●
Changed by
●
Preliminary correction-Yes or No
●
SAP Note number, valid until Release X.Y
●
Estimated time to restore the modification during the adjustment
LESSON SUMMARY You should now be able to: ●
182
Implement modifications
© Copyright . All rights reserved.
Unit 7 Lesson 2 181
Modifying with the Modification Assistant
LESSON OVERVIEW This lesson describes how the Modification Assistant and the Modification Browser work. It also explains how to use these tools. Business Example You would like to use the Modification Assistant to make changes in an orderly manner, to ensure that you can display an exact list of changes at a later stage, and make it easier to carry out modification adjustment. For this reason, you require the following knowledge: ●
Implement modifications using the Modification Assistant
●
Describe how the Modification Assistant works
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Implement modifications using the Modifications Assistant
The Modification Assistant Modification adjustments help in simplifying the following: Finer granularity
●
●
Modules
●
Routines
●
Function modules
The aim of the Modification Assistant is to make adjustments easier. Previously, the granularity of modifications was only at include program level. Now, a finer granularity is available and the system records modifications at the subroutine or module level. This is because the modifications are registered in a different layer. As a result, you can reset modifications as the original version is not changed.
© Copyright . All rights reserved.
183
Unit 7: Modifications of the SAP Standard
How the Modification Assistant Works
Figure 134: How the Modification Assistant Works
The Modification Assistant records changes in a separate layer. This means that the original source code of the object does not change. The system does not adopt modifications until the load is generated. After the load is generated, the system creates the executable object from both the parts of the original SAP program and modifications. Modification Adjustments – Then and Now THEN: ● Granularity: Include program ●
Modification adjustment: Line by line
●
Modification: To be included in the new SAP version manually (cut and paste)
NOW (using the Modification Assistant): Granularity: Module (such as subroutine)
●
●
Modification adjustment: At module level (modification exit)
Earlier, if you modified an include program for which SAP provided a new version in an upgrade, a modification adjustment was necessary. You can perform the modification adjustment line by line and the system did not provide much support. The Modification Assistant changes that situation. The granularity of the change recording has been refined. For example, if you modify a subroutine, the rest of the include program remains unchanged. If SAP delivers a new version of the include program, the system checks if there is also a new version of that subroutine. If this is not the case, the system incorporates your changes into the new version, automatically.
184
© Copyright . All rights reserved.
Lesson: Modifying with the Modification Assistant
Modification Assistant – Software Layers
Figure 135: Modification Assistant – Software Layers
The original version of each software layer consists of the originals from the previous layer plus the current modifications. A list of the tools supported by the Modification Assistant is as follows: ● ABAP Editor -
●
Modification mode
Screen Painter -
Layout
-
Flow logic
●
Menu Painter
●
Text Elements
●
Class Builder
●
Function Builder
●
●
-
Adding function modules
-
Compatible interface enhancements
ABAP Dictionary -
Append structures are registered
-
Data elements: Field labels can be changed
Documentation -
Substituting documentation objects
In the ABAP Editor, you can use modification mode to change source code. Only a restricted range of functions is available in this mode. You can add, replace, or comment out source code; all under the control of the Modification Assistant. Following are recorded by the Modification Assistant:
© Copyright . All rights reserved.
185
Unit 7: Modifications of the SAP Standard
●
Changes to layout
●
Flow logic in the Screen Painter
●
Changes in the Menu Painter and text elements
●
Addition of new function modules to an existing group
●
Table appends (in order to avoid conflicts in the upgrade)
Modification Assistant – Prerequisites
Figure 136: Modification Assistant – Prerequisites
If you want to change an SAP object, you must provide the following information: SAP Software Change Registration (SSCR) key
●
●
Change request
The system informs you that the object is under the control of the Modification Assistant. Only restricted functions are available in the editor. You can switch the Modification Assistant on or off for the entire system using the profile parameter eu/controlled_modification. SAP recommends that you always work with the Modification Assistant. You can switch off the Modification Assistant for single repository objects. On doing so, the system does not use the fine granularity as in the Modification Assistant.
186
© Copyright . All rights reserved.
Lesson: Modifying with the Modification Assistant
Modification Assistant Icons
Figure 137: Modification Assistant Icons
In modification mode, you cannot use all the normal functions of the tool, which you are working on. You can access them using the appropriate pushbuttons. The following shows the actions to be performed in the ABAP Editor: ● Insert The system generates a framework of comment lines between which you can enter your source code. ●
Replace Position the cursor on a line and choose Replace. The system comments out the corresponding line and another line appears in which you can enter coding. If you want to replace several lines, mark them as a block first.
●
Delete Select a line or a block of source code to comment out the lines.
●
Undo modifications You can undo the selected modification you have made to this object.
●
Display modification overview Choose this function to display an overview of all modifications belonging to this object.
© Copyright . All rights reserved.
187
Unit 7: Modifications of the SAP Standard
Modification Assistant – ABAP Editor Example
Figure 138: Modification Assistant – ABAP Editor Example
The figure shows the result of changes that you made using the Modification Assistant. The Modification Assistant automatically generates a framework of comment lines describing the action. The comment also contains the number of the change request to which you assign the change and an internal administration number. Modification Overview
Figure 139: Modification Overview
188
© Copyright . All rights reserved.
Lesson: Modifying with the Modification Assistant
The Modification Overview icon provides you with an overview of the modifications made in the current program. The display is divided according to the various modularization units. This corresponds to the structure used by the Modification Assistant to record the modifications. Restoring the Original
Figure 140: Restoring the Original
To undo a modification, place the cursor on it and choose Undo. The system deletes the record of this modification which cannot be restored.
© Copyright . All rights reserved.
189
Unit 7: Modifications of the SAP Standard
Modification Browser
Figure 141: Modification Browser
The Modification Browser provides an overview of all of the modified objects in the system. The Modification Browser differentiates between modifications that you made using the Modification Browser and those you made without it. On the initial screen of the Modification Browser, you can restrict the selection according to various criteria. This allows you to find modifications in a particular area. The Modification Browser displays the list in tree form. The system arranges objects as follows: ● Modification type (with or without Assistant) ●
Object type ( PROG, DOMA, DTEL, TABL, ...)
In addition to the simple display functions, you can also use the Modification Browser to undo entire groups of modifications. To do this, select the desired subtree, and choose Reset to Original. Demonstration: How to work with the Modification Assistant To work with the Modification Assistant, follow the steps below: 1. Modify a program. 2. Take one of the demo programs. 3. Show the modification in the editor. 4. Show screen modifications. 5. Show how to create a new text for a data element. There are two alternatives. Perform this in parallel.
190
© Copyright . All rights reserved.
Unit 7 Exercise 9 189
Implement Modifications
Business Example In addition to the large range of functions in the SAP System, you also want to implement further functions. Functions containing errors are very occasionally delivered. This requires inserting corrections before the corresponding support package can be imported. The Modification Assistant does not allow certain modifications. If you want to implement them, deactivate the Modification Assistant. Implementing modifications using the Modification Assistant and implementing non registered modifications. Task 1 1. Modify SAP objects. Use the Modification Assistant, where possible.
Task 2 Modify the program SAPBC425_BOOKING_##. 1. Enhance the header so that the column with the customer’s name also has a header. 2. Create a new variable for counting the data records. Output the counter in the last column of the list. 3. Read the fields LUGGWEIGHT and WUNIT in the table SBOOK too, and output them in the list.
Task 3 Modify the program SAPBC425_FLIGHT##. 1. Change the layout of screen 0100: Insert a frame around the three input fields. Create a pushbutton and assign the function code MORE to it.
Task 4 Modify the data element S_CARRID##. 1. Change the field labels to the following: Short text
© Copyright . All rights reserved.
Carr
191
Unit 7: Modifications of the SAP Standard
Medium
Carrier
2. Modify the documentation for this data element. Create a meaningful text.
Task 5 1. Check your modifications in the Modification Browser.
192
© Copyright . All rights reserved.
Unit 7 Solution 9 191
Implement Modifications
Business Example In addition to the large range of functions in the SAP System, you also want to implement further functions. Functions containing errors are very occasionally delivered. This requires inserting corrections before the corresponding support package can be imported. The Modification Assistant does not allow certain modifications. If you want to implement them, deactivate the Modification Assistant. Implementing modifications using the Modification Assistant and implementing non registered modifications. Task 1 1. Modify SAP objects. Use the Modification Assistant, where possible. a) Modify SAP objects using the Modification Assistant.
Task 2 Modify the program SAPBC425_BOOKING_##. 1. Enhance the header so that the column with the customer’s name also has a header. a) Change the header either directly from the list (System → List → List Header) or in the Editor. 2. Create a new variable for counting the data records. Output the counter in the last column of the list. a) Create a new variable directly in the SAP program. b) Use the Insert function in the Modification Assistant. Ideally, you keep the changes locally in the data_output subroutine. c) Output the counter. Alternatively, you can implement this function in the enhancement, which would not require a modification. 3. Read the fields LUGGWEIGHT and WUNIT in the table SBOOK too, and output them in the list. a) Extend the SELECT statement to include LUGGWEIGHT and WUNIT fields. b) Output the fields in the data_output subroutine.
Task 3
© Copyright . All rights reserved.
193
Unit 7: Modifications of the SAP Standard
Modify the program SAPBC425_FLIGHT##. 1. Change the layout of screen 0100: Insert a frame around the three input fields. Create a pushbutton and assign the function code MORE to it. a) Use the Screen Painter to change the layout of screen 0100.
Task 4 Modify the data element S_CARRID##. 1. Change the field labels to the following: Short text
Carr
Medium
Carrier
a) Call the maintenance transaction for data elements. b) Place the cursor on the corresponding object and choose the modification icon. c) Enter new text in the next dialog box. 2. Modify the documentation for this data element. Create a meaningful text. a) Choose the Documentation pushbutton and enter new text.
Task 5 1. Check your modifications in the Modification Browser. a) To check the modification, use transaction SE95 to start the Modification Browser. b) Limit the selection with the user name or change request or task.
194
© Copyright . All rights reserved.
Lesson: Modifying with the Modification Assistant
LESSON SUMMARY You should now be able to: ●
Implement modifications using the Modifications Assistant
© Copyright . All rights reserved.
195
Unit 7 Lesson 3 194
Implementing User Exits
LESSON OVERVIEW This lesson explains you how user exits work and how can you find and use them to enhance functions. Business Example You have to find user exits in the system and use them to enhance SAP software. For this reason, you require the following knowledge: ●
Explain what user exits are
●
Describe how to find user exits in the system and use them to enhance SAP Software
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Implement modifications using user exits
User Exits
Figure 142: User Exits – Structure of a Module Pool
A module pool is organized as a collection of include programs. This is particularly good for making the program easier to understand. The organization is similar to that of function groups. The naming convention by which the last three letters of the name of the include program identify its contents is identical.
196
© Copyright . All rights reserved.
Lesson: Implementing User Exits
The main program contains the include statements for all include programs that belong to the module pool. They include programs described as special. These are not different, they are only delivered once. User Exits – Implementation
Figure 143: User Exits – Implementation
User exits are a type of system enhancement that was originally developed for the Sales and Distribution (SD) component. The original purpose of user exits was to allow the user to avoid modification adjustment. Using a user exit is a modification, as it requires you to change objects in the SAP namespace. SAP developers create a special include in a module pool. These include programs contain one or more subroutines which satisfy the naming convention USER EXIT_. The calls for these subroutines have already been implemented in your program. Usually, global variables are used. After delivering them, SAP never alters includes created in this manner. If a new user exits has to be delivered in a new release, they are placed in a new include program.
© Copyright . All rights reserved.
197
Unit 7: Modifications of the SAP Standard
User Exits – Example
Figure 144: User Exits – Example
User exits are actually empty subroutines that SAP developers provide you with. You can fill them with your source code. The purpose behind this type of system is to keep all changes well away from program source code and store them in include programs instead. To this end, SAP developers create various includes that fulfill the naming conventions for programs and function groups. The last two characters of the include name indicate that the customer will use the include program. Normally, there is a Z here. Example: Program SAPMV45A Include MV45AFZB This naming convention guarantees that SAP developers will not change this include, in the future. Therefore, includes of this nature are never listed in the modification adjustment. If any new user exits are delivered by SAP with a new release, they are bundled into new includes that adhere to the same naming convention.
198
© Copyright . All rights reserved.
Lesson: Implementing User Exits
User Exits – Search
Figure 145: User Exits – Search
You can find a list of all user exits in the SAP Reference Implementation Guide. Here, you can also find documentation explaining why SAP developers have created a particular user exit. For this, follow the steps described in the Implementation Guide. LESSON SUMMARY You should now be able to: ●
Implement modifications using user exits
© Copyright . All rights reserved.
199
Unit 7 Lesson 4 198
Adjusting Modifications
LESSON OVERVIEW This lesson explains you how to implement a modification adjustment. Business Example You have to carry out modification adjustment after you have implemented an upgrade/ Support Package. For this reason, you require the following knowledge: ●
Steps taken during a modification adjustment
●
List, which objects must be adjusted and when
●
How to perform modification adjustment in subsequent systems
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Adjust modifications
Modification Adjustment
Figure 146: Objects for Adjustment
You can derive the set of objects for adjustment from the set of new objects that SAP delivered in a new release. This is compared with the set of modified objects. The intersection of these two sets is the set of objects that you must adjust when importing an upgrade/Support Package.
200
© Copyright . All rights reserved.
Lesson: Adjusting Modifications
Modification Adjustment – SPDD and SPAU
Figure 147: Modification Adjustment – SPDD and SPAU
During modification adjustment, you can compare the old and new versions of ABAP repository objects using transactions SPDD and SPAU. You do not have to call transaction SPDD to adjust Dictionary objects in the following cases: ●
●
You did not make any changes to SAP standard objects in the Dictionary. You have only added customer objects to your system. You must adjust only SAP objects that you changed using this transaction.
You can adjust all other ABAP repository objects using transaction SPAU. Upgrade program R3up prompts you start the transaction after you finish the upgrade. You have 30 days to use transaction SPAU after an upgrade. After 30 days, you must apply for a SAP Software Change Registration (SSCR) key for each object that you want to adjust. Transaction SPAU first identifies which objects have you modified and then ascertains for which of the modified objects, did you import a new version during the current upgrade. Modification adjustment allows you to transfer the modifications you have made in your system to your new System Release.
© Copyright . All rights reserved.
201
Unit 7: Modifications of the SAP Standard
Modification Adjustment – Objects
Figure 148: Modification Adjustment – Objects
During the modification adjustment, use transaction SPDD to adjust the ABAP Dictionary objects. You can adjust the following ABAP Dictionary objects: Domains
●
●
●
Data Elements Tables (structures, transparent tables, pool, and cluster tables, together with their technical settings)
You can adjust these three object types directly after the Dictionary object import and before the main import. Until now, the system has not yet generated the new versions of the ABAP Dictionary objects. To ensure that no data is lost, it is important that you make any customer modifications to domains, data elements, or tables before you generate them. Changes to other ABAP Dictionary objects, such as lock objects, matchcodes, or views, cannot result in loss of data. Therefore, you need to adjust these ABAP Dictionary objects using transaction SPAU after completing both main import and object generation. Use transaction SPAU to adjust the following object types: ABAP programs
●
202
●
Interfaces (menus)
●
Screens
●
Matchcode objects
●
Views
●
Lock objects
© Copyright . All rights reserved.
Lesson: Adjusting Modifications
Transporting Adjustments between Systems
Figure 149: Transporting Adjustments Between Systems
During the modification adjustment, you should carry out your object processing using two separate change requests, one for the SPDD adjustment and one for the SPAU adjustment. The system transports these change requests into other SAP systems you want to adjust. This guarantees that all actual adjustment work takes place solely in your development system. When upgrading additional SAP systems, the system displays all adjustments exported from the first system upgrade during the ADJUSTCHK phase. You decide which adjustments you want to accept into your additional systems and then the system integrates them into the current upgrade. Afterwards, the system checks to see if the change requests created during the first system upgrade covers all modifications in the current SAP system. If this is the case, you cannot make any adjustments during the current upgrade.
Note: For an effective process, it is important that all systems involved have identical system landscapes. You can guarantee this by first making modifications in your development system and then transporting them to later systems, before you upgrade the development system. You can also guarantee that all of your systems have an identical system landscape by creating your development system, before upgrade, as a copy of your production system and then refraining from modifying the production system again.
© Copyright . All rights reserved.
203
Unit 7: Modifications of the SAP Standard
Modification Adjustment – Introduction
Figure 150: Modification Adjustment – Introduction
When you start the modification adjustment using transaction SPAU, you can restrict the hit list on a selection screen. You can decide whether you want to display all objects to be adjusted or only those which the system is yet to process. You can use the following criteria to restrict the selection: Last changed by
●
●
Package
●
Request numbers/Task numbers
The system displays a list of the objects to be adjusted. The list is sorted by the following: ● With or without Modification Assistant ●
204
Object type
© Copyright . All rights reserved.
Lesson: Adjusting Modifications
Modification Assistant Icons
Figure 151: Modification Assistant Icons
The icons in front of the individual objects that need adjustment show how they can be adjusted. Following are the possible methods: Automatically
●
The system could not find any conflicts. You can automatically adopt changes by choosing the appropriate icon or menu option. ●
Semiautomatically The individual tools support you in adjusting the objects. When you adjust programs so as to make changes, the system displays the split screen editor.
●
Manually You must process your modifications with no special support from the system. In this case, the modification adjustment allows you to jump directly into the relevant tool.
The system identifies the adjusted objects by a green tick. If you want to use the new SAP standard version, use Reset to Original. If you do this, you have no further adjustment work in future. Demonstration: How to Adjust a Modification Shows how modification adjustments work. There are enough programs in the system even without applying your Support Package that can serve for demonstration purposes.
LESSON SUMMARY You should now be able to: ●
Adjust modifications
© Copyright . All rights reserved.
205
Unit 7: Modifications of the SAP Standard
206
© Copyright . All rights reserved.
Unit 7
205
Learning Assessment
1. List a few benefits of SSCR (SAP Software Change Registration) while registering modifications. Choose the correct answers. X
A Quick error resolution
X
B Simplification of upgrades
X
C Dependable operation
X
D SSCR key given to an object, needs to be given again and again for each modification
2. Which components can be simplified using Modification Assistant? Choose the correct answers. X
A Finer granularity
X
B Modules
X
C Routines
X
D Table Changes
X
E Field label changes
3. What was the purpose of developing user exits? Choose the correct answer. X
A Sales and Distribution component
X
B Enhancement without changing the original pattern
X
C Individual enhancements
X
D Easy during upgrades
© Copyright . All rights reserved.
207
Unit 7: Learning Assessment
4. Which ABAP dictionary objects can be adjusted by the user? Choose the correct answer.
208
X
A Domains
X
B Tables
X
C Matchcode objects
X
D Data Elements
© Copyright . All rights reserved.
Unit 7
207
Learning Assessment- Answers
1. List a few benefits of SSCR (SAP Software Change Registration) while registering modifications. Choose the correct answers. X
A Quick error resolution
X
B Simplification of upgrades
X
C Dependable operation
X
D SSCR key given to an object, needs to be given again and again for each modification
2. Which components can be simplified using Modification Assistant? Choose the correct answers. X
A Finer granularity
X
B Modules
X
C Routines
X
D Table Changes
X
E Field label changes
3. What was the purpose of developing user exits? Choose the correct answer. X
A Sales and Distribution component
X
B Enhancement without changing the original pattern
X
C Individual enhancements
X
D Easy during upgrades
© Copyright . All rights reserved.
209
Unit 7: Learning Assessment- Answers
4. Which ABAP dictionary objects can be adjusted by the user? Choose the correct answer.
210
X
A Domains
X
B Tables
X
C Matchcode objects
X
D Data Elements
© Copyright . All rights reserved.
UNIT 8
Classic Enhancements and New Enhancement Framework
Lesson 1 Identifying Classic Enhancements
212
Lesson 2 Identifying the New Enhancement Framework
221
UNIT OBJECTIVES ●
Identify classic enhancements
●
Identify the new enhancement framework
© Copyright . All rights reserved.
211
Unit 8 Lesson 1 210
Identifying Classic Enhancements
LESSON OVERVIEW This lesson compares and evaluates all classic concepts that can be used to adapt repository objects. Business Example You have to identify classic enhancements in an SAP system. For this reason, you require the following knowledge: ●
How to proceed when changing the SAP standard
●
The advantages and disadvantages of modifications
●
The alternatives to modifications
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Identify classic enhancements
Classic Enhancement Possibilities Summary of classic enhancement concepts is as follows: ● SAP objects are not changed. ●
There is no adjustment during the upgrade.
●
Support Packages are imported from the Online Correction Services (OCS).
●
Return to the SAP standard: Version database and entries in the Workbench Organizer (WBO) and transport system are not changed.
You do not need to make modification adjustment if you avoid making changes to SAP objects. Use program enhancements and appends with SAP tables to enhance SAP objects so that SAP cannot overwrite your changes, at upgrade. As of Release 3.0, you can use OCS to automatically import and cancel hot packages and patches (instead of inserting preliminary corrections manually).
212
© Copyright . All rights reserved.
Lesson: Identifying Classic Enhancements
Table Enhancements
Figure 152: Table Enhancements
SAP provides the following ways to enhance tables and structures with fields: ● Append structures ●
Customizing Includes (CI)
Both the techniques allow you to attach fields to a table without having to modify the table itself. An append structure is a structure which is assigned to exactly one table. There can be several append structures for a table. During activation, the system searches for all active append structures and attaches them to that table. Append structures differ from include structures in how they refer to their tables. To include fields from an include structure in a table; you must add an ’.INCLUDE...’ line. In this case, the table refers to the substructure. Append structures refer to their tables. In this case, the tables are not altered in any way by the reference.
© Copyright . All rights reserved.
213
Unit 8: Classic Enhancements and New Enhancement Framework
Program Exits – Architecture
Figure 153: Program Exits – Architecture
The figure shows the flow of a program providing an enhancement in the form of a program exit. The exit function module is called at a point in the source text defined by the SAP application developer. Within the function module, users can add a function to the customer namespace using an include program. Flow Diagram to Show How Business Transaction Events Functions Work
Figure 154: Flow Diagram to Show How Business Transaction Events Work
The figure shows the process flow of an SAP program. The program contains an enhancement in the form of a Business Transaction Event (BTE). A function module is called
214
© Copyright . All rights reserved.
Lesson: Identifying Classic Enhancements
in the SAP program, which determines and processes the active implementations. The names of the event function modules begin with OPEN_FI_PERFORM_ or OUTBOUND_CALL_. The event function module OPEN_FI_PERFORM_<> or OUTBOUND_CALL_<> determines the active implementations for each enhancement and stores them in an internal table. Function modules are implemented in the sequence defined by the internal table. At this point, the system also considers the conditions under which the function module is processed in the customer namespace. For example, a country or an application can be entered as a condition (filter value). Business Add-Ins – Flow of a Program Exit
Figure 155: Business Add-ins – Flow of a Program Exit
The figure shows the process flow of a program that contains a Business Add-in (BAdI) call. It enables the user to see the possibilities and limitations inherent in BAdIs. You must declare a reference variable referring to the BAdI interface in the declaration section. The user generates an object reference. This replaces the service class CL_EXITHANDLER provided by SAP. This generates the conditions for calling methods of program enhancements. ●
●
●
When you define a BAdI, the system generates a BAdI class, which implements the interface. In call (2), the interface method of the BAdI class is called. The BAdI class searches for all of the active implementations of the BAdI and calls the implemented methods .
© Copyright . All rights reserved.
215
Unit 8: Classic Enhancements and New Enhancement Framework
Menu Exits Overview
Figure 156: Menu Exits Overview
Menu exits allow you to attach your functions to menu options in SAP menus. SAP application programmers reserve certain menu options in the graphical user interface (GUI) for this. Here, you can specify the entry text. Once you activate menu exits, they become visible in the SAP menu. When you choose the corresponding menu option, the system changes to a program exit which contains the customer-specific functions. BAdIs – Menu Exits Overview
Figure 157: BAdIs – Menu Exits Overview
With customer exits, you can use menu enhancements with BAdIs provided the following conditions are met:
216
© Copyright . All rights reserved.
Lesson: Identifying Classic Enhancements
●
●
The developer of the program you want to enhance must have planned for the enhancement. The menu enhancement must be implemented in a BAdI implementation.
Screen Exits Overview
Figure 158: Screen Exits Overview
Screen exits allow you to make use of reserved sections of a main screen (subscreen areas). You can either display additional information in these areas or input data. You define the necessary input and output fields on a customer screen (subscreen). BAdI Screen Exits – Basic Principles
Figure 159: BAdI Screen Exits – Basic Principles
© Copyright . All rights reserved.
217
Unit 8: Classic Enhancements and New Enhancement Framework
The ABAP virtual machine does not recognize screens bound to classes. Thus, only classical programs (of types 1, F, or M) can be used as containers for screens. Screen enhancements must take this into consideration. When you create a BAdI screen enhancement, the provider reserves a subscreen area on the application program screen, which is then filled with the subscreen of the implementing class. However, the application program and the subscreen container program do not communicate directly. They communicate using the generated BAdI class.
Evaluation of Classic Enhancement Concept
Figure 160: Modifying versus Copying
Modifying has the advantage that the productive repository objects do not lose their connection to the SAP standard. Copying has the advantage that no modification adjustment will be necessary for your productive repository objects during subsequent upgrades. Choose copying instead of modifying in case of the following conditions: ● If you have to make numerous changes to an SAP program. ●
Your requirements are not met by the standard in future releases of your SAP system.
During copying, pay attention to a repository object’s environment as well. You should only decide whether to modify or copy after verifying the consequences for the main program and for all of the include programs. This is also true for function groups and modules. Evaluation of ABAP Development Projects Questions prior to development project are as follows: Implementation costs
●
●
●
218
Consequences -
Performance
-
Costs during an upgrade
Alternatives -
Customizing
-
Personalization
© Copyright . All rights reserved.
Lesson: Identifying Classic Enhancements
●
Enhancement techniques -
Customer Exits
-
BTEs
-
BAdIs
ABAP development projects can be evaluated according to the following criteria: Implementation cost measured in manpower (creating the concept, implementation and testing)
●
●
Effect of ABAP development project on the following: -
Production operation performance
-
Amount of adjustment at upgrade
By calling SAP objects in your own repository object, the amount of effort needed to implement the object. However, any changes that SAP makes to the repository object you choose to call may make extra adjustment necessary after an upgrade. SAP could conceivably change the user interface of a screen for which you have written a batch input program. Naming Conventions for Repository Objects
Figure 161: Naming Conventions for Repository Objects
Naming conventions allow you to avoid naming conflicts and give your repository objects meaningful names that can be understood by others. The following naming conflicts can occur: An SAP repository object and a customer repository object conflict.
●
You should separate SAP repository objects and customer repository objects from each other by strict adherence to SAP naming conventions. SAP Note 16466 gives you an overview of the current naming conventions for customer repository objects, usually names that begin with either Y or Z.
© Copyright . All rights reserved.
219
Unit 8: Classic Enhancements and New Enhancement Framework
●
Two customer repository objects conflict. You can avoid naming conflicts between customer repository objects in decentralized development scenarios where more than one development system is being used by reserving a special namespace for development areas within the customer namespace. The Workbench Organizer checks to make sure that you adhere to these conventions by making entries in view V_TRESN.
●
Complementary software and customer repository objects conflict. You can avoid naming conflicts when importing complementary software from SAP partners by reserving special namespaces. In addition, SAP partners can apply for prefixes that they can add to the beginning of their repository objects' names (For additional information, refer to SAP Notes 84282 and 91032, or the white paper ”Development Namespaces in the SAP System”, order number E:50021723 [English] and D:50021751 [German]).
LESSON SUMMARY You should now be able to: ●
220
Identify classic enhancements
© Copyright . All rights reserved.
Unit 8 Lesson 2 219
Identifying the New Enhancement Framework
LESSON OVERVIEW This lesson describes the advantages and use of the new enhancement options as well as the new Business Add-In (BAdI) technology, which have been introduced as of SAP NetWeaver Application Server 7.0. Business Example You have to identify the new enhancement framework in an SAP system. For this reason, you require the following knowledge: ●
Enhancement options
●
Advantages and disadvantages of enhancements
●
Classic Business Add-Ins (BAdIs)
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Identify the new enhancement framework
Enhancement Points
Figure 162: New Enhancement Concept – Overview
© Copyright . All rights reserved.
221
Unit 8: Classic Enhancements and New Enhancement Framework
As of SAP NetWeaver Application Server 7.0, new enhancement options have been added as follows: ● Enhancement points ●
Enhancement sections
Enhancements that use implicit enhancement points, unlike enhancements implemented using previous enhancement technology require no preparation from SAP. SAP has also introduced a new BAdI technology as of SAP NetWeaver Application Server 7.0, for performance and other reasons. The figure displays how enhancement points, sections and BAdIs are grouped together and managed using enhancement spots. Collected enhancement spots comprise both simple and other collected enhancement spots. They serve to semantically bundle enhancement spots. Previous BAdIs (classical BAdIs) exist in the system as before. However, SAP will only implement BAdIs using the new technology in future. Note that the elements of the central SAP Basis cannot be enhanced. Documentation about the new enhancement concept is available as follows: Choose the Information pushbutton in the ABAP Editor.
●
●
In the Glossary Entry field, enter Enhancement Concept as a search term.
Enhancement Points
Figure 163: Enhancement Points
An enhancement point is an option that allows you to add the following declarations to SAP programs without making a modification: ● Source code
222
●
Variable declarations
●
Function and parameters
© Copyright . All rights reserved.
Lesson: Identifying the New Enhancement Framework
●
Function modules
●
Classes
Explicit enhancement points are insertion options that SAP prepares. Implicit enhancement points are present at particular points in SAP objects, by default, without any particular preparation by SAP. Implicit Enhancement Points (1) Implicit Enhancement Points are as follows: ● At the end of a structure (type) declaration before “END OF…” (To include additional field) ●
At the beginning and end of -
Subprograms
-
Function modules
-
Methods of local classes or global classes (To insert additional functions)
●
At the end of the IMPORTING/EXPORTING/CHANGING declaration block of methods of local classes (To include additional interface parameters)
●
In interface definitions of -
Function modules
-
Methods of global classes (To include additional interface parameters)
The mapping (partial) in the figure shows at what points implicit enhancement points are present. To use an implicit enhancement point, you implement an enhancement implementation. Perform the following steps to use implicit enhancement points, which you can use to insert source code (implicit source code plug-ins): 1. Display the SAP object (program, function module, method). 2. Choose the Enhancement pushbutton in the graphical user interface (GUI) status. 3. Choose Edit → Enhancement Operations → Show Implicit Enhancement Options. Perform the following steps to display the implicit enhancement options: 1. Use the editor’s context menu to create an enhancement implementation. Enter the source code. 2. Choose the Activate pushbutton in the GUI status. Note: When you enhance a structure or structure type declaration immediately before END OF ..., you must use the syntax DATA TYPE .
© Copyright . All rights reserved.
223
Unit 8: Classic Enhancements and New Enhancement Framework
Perform the following steps for interface enhancement of SAP function modules and methods of global classes: 1. Open the Function Builder or Class Builder. 2. Choose the menu option Function Module → Enhance Interface or Class → Enhance to add a new interface parameter as well as type assignment. Note: Interface parameters added in this way are usually optional. They can be addressed in source code enhancements to the corresponding function module or method. Implicit Enhancement Points (2) Other enhancement points are as follows: ● At the end of the public, protected or private section of a local class (Define additional attributes and methods) ●
●
You can define any of the following for global classes: -
Additional attributes
-
Additional methods
You can define either one or both of the following: -
Pre method
-
Post method For a method of a global class: Automatic execution when method starts or ends Alternative: Define an overwrite method (replaces the SAP method)
●
At the end of the IMPLEMETATION block of a local class (To implement additional declared methods)
●
At the end of the includes (To implement additional functions)
Perform the following steps for defining additional attributes and methods of global classes: 1. In the Class Builder, choose Class → Enhance. 2. Double-click an additional method to open the method editor in order to implement it. Such additional attributes or methods can be addressed in source code enhancements of methods of the global class. Perform the following steps for defining a pre/post/overwrite method for the method of a global class: 1. Open change mode in the Class Builder by choosing Class → Enhance. 2. Select the desired SAP method. 3. Choose Edit → Enhancement Operations → Insert (Pre or Post) Method or Add Overwrite Method.
224
© Copyright . All rights reserved.
Lesson: Identifying the New Enhancement Framework
4. Click the new pushbutton in the column Pre/Post/Overwrite Exit to implement the corresponding method. You can define a pre or post method for each SAP method. As an alternative, you can create an overwrite method, which can replace it. Such methods are called automatically at the described points. They are instance methods of an automatically generated local class, and possess an attribute called CORE_OBJECT which is a reference to the current instance of the SAP application. Explicit Enhancement Points and Sections
Figure 164: Explicit Enhancement Points and Sections
An explicit enhancement point is an option provided in advance by SAP to allow you to enhance and replace the SAP source code without making a modification. Implicit enhancement sections do not exist. Explicit enhancement points and sections are always embedded in enhancement spots. Those that enable source code changes or replacements are called dynamic whereas those which enable declaration enhancements or replacements are called static. To use explicit enhancement points and sections, you implement an enhancement implementation, that is an implementation of the higher-level enhancement spot. The following step sequence describes the procedure for using explicit enhancement points and sections: 1. Display the SAP object such as program, function module, and method. 2. Find the desired enhancement point(s) or sections(s). 3. Choose the Enhancement pushbutton in the GUI status. 4. Create the enhancement implementation for the enhancement points and sections using the context menu. 5. Specify the enhancement implementation name. 6. Enter the source code. 7. Choose the Activate Enhancements pushbutton in the GUI status.
New BAdIs New BAdI Technology was implemented due to the following:
© Copyright . All rights reserved.
225
Unit 8: Classic Enhancements and New Enhancement Framework
●
Performance improvement
●
Implementation of additional functions -
-
●
●
Enhanced filter concept Option to inherit attributes from sample implementation classes (selective method redefinition)
Integration into the new enhancement framework together with enhancement points and enhancement section Integration into the Switch Framework
SAP introduced the new BAdI technology in SAP NetWeaver Application Server 7.0 primarily to improve performance and enhance functions. The individual reasons are listed. The integration of the new BAdIs as well as enhancement points and sections into the enhancement framework enables you to use the new enhancement options within a single, unified tool. By integrating the new enhancement technology into the Switch Framework, SAP enables you to use switches to activate and deactivate the BAdI implementations that industry solutions implement. Older BAdIs, which were created using the classical technology, remain in the system. In future, new enhancements are only implemented using the new BAdI technology or using explicit enhancement points and sections. Classical BAdIs – Architecture
Figure 165: Classical BAdIs – Architecture
In the classical BAdI technology, the BAdI adapter class is automatically generated when you define the BAdI or the BAdI interface. At runtime, an instance of the adapter class is created in the SAP application program. The interface method(s) are called from the adapter class instance. The interface methods then call the identically-named methods of active implementations, sequentially.
226
© Copyright . All rights reserved.
Lesson: Identifying the New Enhancement Framework
Classical BAdIs – Call Syntax in SAP Objects
Figure 166: Classical BAdIs – Call Syntax in SAP Objects
The figure displays the call syntax of classical BAdIs in SAP programs. New BAdIs – Architecture
Figure 167: New BAdIs – Architecture
The new BAdI technology works in the same way as the old. However, you no longer require adapter classes. This saves the SAP application program from having to instantiate them. Instead, at the application program’s runtime, the system generates a BAdI handle in the kernel. It performs the same function as the adapter class, but calls the available implementation methods much more efficiently.
© Copyright . All rights reserved.
227
Unit 8: Classic Enhancements and New Enhancement Framework
New BAdIs – Call Syntax in SAP Objects
Figure 168: New BAdIs – Call Syntax in SAP Objects
The figure displays the call syntax of classical BAdIs in SAP programs. If GET BADI finds no active implementation of the BAdI, it triggers the exception CX_BADI_NOT_IMPLEMENTED. If the handle reference is initial for CALL BADI (for example, because GET BADI failed), the exception CX_BADI_INITIAL_REFERENCE is triggered. Searching for BAdIs The procedure for searching for BAdIs is as follows: ● Free Search: SE84 -
List of freely selected BAdIs or enhancement spots
●
Application-related search: SE81 -> SE84
●
Program-related search can be as follows: -
Search for "GET BADI" globally. You may also search in called function modules and methods.
-
Double-click the reference variable to navigate to the variable definition.
-
Double-click the BAdI name to navigate to the display for the corresponding spot.
The figure displays the procedure for searching for BAdIs. Using Business Application Programming Interfaces In order to use Business Application Programming Interface (BAPI), perform the following steps: 1. Display the corresponding enhancement spot.
228
© Copyright . All rights reserved.
Lesson: Identifying the New Enhancement Framework
2. Choose Implement Enhancement Spot (F6) and create the enhancement implementation. 3. Enter a name for the enhancement implementation. 4. Enter a name for the BAdI implementation(s). 5. Maintain the attributes for the BAdI implementation(s). 6. In the BAdIs navigation area, click on the corresponding component implementing class. 7. Enter the name of the implementing class and choose the Change pushbutton. This can be inherited from the sample classes, or you can copy the example classes. 8. Double-click on the method (s) to implement or adjust them. 9. Activate the method and enhancement implementation. To use a BAdI that you have found, you must implement an enhancement implementation (an implementation of the higher-level enhancement spot). This implements a BAdI implementation for each BAdI in the enhancement spot. The directions for searching for and using BAdIs relate to program exits (the most common exit type). You can search for and implement menu and screen exits in exactly the same way as the classical BAdI technique, or using the method described.. To obtain the BAdI handle for data transport, you need to use the statement GET BADI instead of the method GET_INSTANCE_FOR_SUBSCREENS in the Process Before Output (PBO) of the customer subscreen screen for screen exits. Filter-dependent BAdIs
Figure 169: Filter-dependent BAdIs
The figure displays the concept of filter-dependent BAdIs, which corresponds to the classical BAdI concept. However, the functions have been enhanced. Numerical filters can now also be used. You can now specify for implementations not only individual filter values, but also filter conditions, by using the operators <>, >, <, >=, <=, CP, or NP.
© Copyright . All rights reserved.
229
Unit 8: Classic Enhancements and New Enhancement Framework
You can also define many filters for a given BAdI.
Switch Framework
Figure 170: Switch Framework
The Switch Framework was conceived to give SAP customers the option to activate industry solutions for enterprise add-ons in order to use them, rather than having to install them. The figure displays the relationship between individual repository objects, switches, business functions, and business function sets (industry solutions). You can use transaction SFW5 to activate industry solutions for enterprise add-ons. Only then, the corresponding repository objects are available. If a switchable package contains enhancement implementations, the effect in conjunction with the new enhancement options is that they only become active in the system when you activate the corresponding business function. LESSON SUMMARY You should now be able to: ●
230
Identify the new enhancement framework
© Copyright . All rights reserved.
Unit 8
229
Learning Assessment
1. Identify the classic enhancements. Choose the correct answers. X
A Table enhancements
X
B Program enhancements
X
C Screen exits
X
D Menu exits
2. What are the new enhancements options in SAP Netweaver Server 7.0? Choose the correct answers. X
A Enhancement Points
X
B Enhancement Modules
X
C Enhancement Sections
X
D Individual Enhancements
© Copyright . All rights reserved.
231
Unit 8
230
Learning Assessment- Answers
1. Identify the classic enhancements. Choose the correct answers. X
A Table enhancements
X
B Program enhancements
X
C Screen exits
X
D Menu exits
2. What are the new enhancements options in SAP Netweaver Server 7.0? Choose the correct answers.
232
X
A Enhancement Points
X
B Enhancement Modules
X
C Enhancement Sections
X
D Individual Enhancements
© Copyright . All rights reserved.
UNIT 9
Outdated Enhancement Techniques
Lesson 1 Identifying Outdated Enhancement Techniques
234
UNIT OBJECTIVES ●
Identify outdated enhancement techniques
© Copyright . All rights reserved.
233
Unit 9 Lesson 1 232
Identifying Outdated Enhancement Techniques
LESSON OVERVIEW This lesson helps you in using field exits to apply checks to a screen field. This lesson also describes the enhancement options offered by the Business Data Toolset. Business Example To use the field exit enhancement technique, you will need to understand some basic concepts. For this reason, you require the following knowledge: ●
Use field exits to apply checks to a screen field
●
Describe the enhancement options offered by the Business Data Toolset
LESSON OBJECTIVES After completing this lesson, you will be able to: ●
Identify outdated enhancement techniques
Field Exits to Enhance Screens
Figure 171: Global Enhancements
SAP application programmers define keywords in different lengths and a short description for each data element. You create field exits in Project Management. The system processes them when the user leaves a screen that contains a field that refers to a data element containing a field exit.
234
© Copyright . All rights reserved.
Lesson: Identifying Outdated Enhancement Techniques
Field Exits
Figure 172: Field Exits
SAP makes it possible for you to create a field exit for every input-ready screen field that the user created with reference to the ABAP Dictionary. The system stores in a function module additional program logic and is executed at a specific point at the Process After Input (PAI) event. The figure clarifies the sequence of processing. The sequence of processing field exits is as follows: 1. Before the system executes the modules defined in the screen’s PAI, it checks if you have filled all obligatory fields. If a required field is empty, the screen is shown again. 2. The system then checks whether the data you entered is in the correct format. 3. Any defined field exits are executed next. For example, by sending an error message, you can have the screen displayed again. When the user checks all the field exits, the system processes the screen as normal. The screen is processed in the following order: ●
Field transport
●
Foreign key check
●
Processing the screen’s PAI module
© Copyright . All rights reserved.
235
Unit 9: Outdated Enhancement Techniques
Global and Local Field Exits
Figure 173: Global and Local Field Exits
Field exits take you from a screen field with a data element reference to a function module. They can be either global or local. Global field exits are not limited to a particular screen. If you use global exit’s data element on several screens, the system goes to the function module for all these screens after activating the field exit. Here you can, for example, edit the contents, force a new entry to be made by outputting an error message, or prohibit certain users from proceeding further. Local field exits are valid for one screen only. If you assign a screen from a specific program to a field exit, the system processes the appropriate function module from this screen after the system activates the exit. You can either create one global field exit or up to 36 local field exits for a data element, but not both. Each exit number refers to a different function module. Field exit function modules adhere to the following naming convention:
236
●
Prefix: FIELD_EXIT_
●
Name:
●
Suffix (for local field exit): _0 to _9, _A to _Z
© Copyright . All rights reserved.
Lesson: Identifying Outdated Enhancement Techniques
Creating Field Exits
Figure 174: Creating Field Exits
To create field exits, perform the following steps: 1. Choose Utilities in the ABAP Workbench. 2. Choose Enhancements. 3. Select Project Management to edit field exits and to implement customer exits. To start the transaction for maintaining field exits, choose Goto → Global enhancements → Field exit. To create a new enhancement, choose Text Enhancements → Create. Enter the name of the data element to which your screen field refers in the modal dialog box. The Function Builder is started. The system specifies the name of the field exit. Do not change this name. Create the function module in a customer function group. The function module interface is fixed and you cannot change it. The function module has an import parameter INPUT and export parameter OUTPUT. The parameter INPUT stores the contents of the screen field. The system returns the contents of OUTPUT in the screen field when you leave the function module. Source Code for Field Exits
Figure 175: Source Code for Field Exits
© Copyright . All rights reserved.
237
Unit 9: Outdated Enhancement Techniques
In the source text, you must assign a value to the export parameter OUTPUT of the function module. The system transports back this value to the screen field. Otherwise, the screen field would be initial after executing the field exit. The following ABAP statements are not allowed in field exit function modules: 1. CALL SCREEN, CALL DIALOG, CALL TRANSACTION, SUBMIT 2. COMMIT WORK, ROLLBACK WORK 3. COMMUNICATION RECEIVE 4. EXIT FROM STEP-LOOP 5. MESSAGE I, MESSAGE W 6. STOP, REJECT When you debug a screen that a field exit references, the debugger ignores the field exit code. As with any normal function module, you can debug the field exit code in the Function Builder’s test environment. Local Field Exits
Figure 176: Local Field Exits
You can create local field exits that relate to a specific screen. Create a local field exit. A global field exit must already exist. Edit the local field exit based on the global field exit. You can create up to 36 local field exits, each of which carries a unique suffix. You should use the name that the system proposes for the function module. Defining local field exits signifies that the function module of the global field exits created initially is no longer used. However, you must not delete the global function module. If you delete the global function module of the field exit from the list, the system deletes the field exits.
238
© Copyright . All rights reserved.
Lesson: Identifying Outdated Enhancement Techniques
Activating Field Exits
Figure 177: Activating Field Exits
You must activate the field exit as well as the function module. The field exits are only taken into account during screen execution, if the profile parameter "ABAP/FIELD EXIT = YES" has been set for all application servers. This profile parameter is set to NO, by default. If you declare field exits for multiple screen fields, you have no control over the order in which the system processes it. In particular, you cannot access the contents of other screen fields in a field exit. Read note 29377 about field exits.
Append Search Helps to Enhance Search Helps
Figure 178: Append Search Helps
The set of search paths meaningful for an object greatly depends on the particular circumstances of the SAP customer. The customers often like to enhance the standard SAP collective search helps with their own elementary search helps. Release 4.6 provides an
© Copyright . All rights reserved.
239
Unit 9: Outdated Enhancement Techniques
append technique that permits the enhancement of collective search helps without modifications. An append search help is a collective search help that is assigned to another collective search help, which is its appending object and that enhances it with the search helps, it includes. The append search help uses the interface of its appending objects. It lies in the customer namespace. However, the required elementary search help might already be provided by SAP. In such a case, the customers only have to add it to their own append search help. It is used with SAP to improve component separation. Some SAP collective search helps therefore already have one or more append search helps in the standard search help. Customer enhancements should always be made by creating a separate append search help. SAP collective search helps often contain elementary search helps that are not required by all customers. The search helps you do not need can be hidden using an Append search help. To do this, the corresponding search help must be included in the Append search help and the hidden flag must be set.
Business Data Toolset Definition: ● Toolset for master data and simple transaction data Its design goals are as follows: Extensibility
●
●
Configurability
●
Divisibility
●
Alternative user interfaces
●
Usability
●
Faster development
●
Generic object services
Business Data Toolset (BDT), formerly known as master data administration or business partner administration, is the main administration tool. You can use the BDT for the following: To maintain master data and simple transaction data using dialogs, direct input, or function modules.
●
●
●
●
●
●
240
To provide generic objects services for consistent recurring requests, such as changing document lists, field modifications, and the deletion program. Managing generic parts of these objects and calls the applications using predefined interfaces (control tables and events), such as writing to and reading from the application tables in the database. To maintain different application objects. Development partners and customers use BDT interfaces to enhance these objects without modifying the source code. To use alternative user interfaces by separating them from the programming logic.
© Copyright . All rights reserved.
Lesson: Identifying Outdated Enhancement Techniques
●
To provide generic services like direct input and field administration.
Development Without the BDT
Figure 179: Development Without the BDT
You need the same functions in both development and implementation projects. The application server ABAP provides some service functions, but most of them still need to be developed. Field modification, change document evaluation, and screen checks from the ABAP Dictionary are examples of such services. Speeding Up Development with the BDT
Figure 180: Speeding Up Development with the BDT
As the BDT controls dialog processes, the applications only need to implement business functions. The BDT also provides services in which you can integrate applications. These factors considerably reduce the development time.
© Copyright . All rights reserved.
241
Unit 9: Outdated Enhancement Techniques
The applications lose a little of their individual character but, in return, gain the benefits of reduced object maintenance, standardized dialogs, generic object services, and more rapid development. Usability with Various Objects
Figure 181: Usability with Various Objects
The following are some examples of objects developed using the BDT: Central Business Partner ●
Partner maintenance
●
Relationship maintenance
Contract Accounts Receivable and Payable ●
Contract Account
IBU Banking ●
Bank account
●
Standing order
●
Financial product
●
Financial conditions
●
Risk object
●
Variable transactions
IBU Insurance
242
●
Insurance: Claims
●
Insurance: Loss event
© Copyright . All rights reserved.
Lesson: Identifying Outdated Enhancement Techniques
●
Commissions: Remuneration agreement
IS-RE (Industry Solutions-Real Estate management) ●
Real estate contract
●
Cost efficiency analysis
Events and Program Flow
Figure 182: Events and Program Flow
Within the program flow, applications can take events defined by the BDT and define their own program logic for them in function modules. These function modules can be defined for any event and are then called dynamically by the BDT. The starting point is a normal transaction code. This code always launches the program BUSSTART in the Business Partner. The BDT reads all the necessary information from the control tables along with the name of the transaction code. The program flow is fully specified. All function modules that belong to the part of the object executed are called in the appropriate event.
© Copyright . All rights reserved.
243
Unit 9: Outdated Enhancement Techniques
BDT Development and the ABAP Workbench
Figure 183: BDT Development and the ABAP Workbench
Each application develops within a separate function group. Subscreens, Process Before Output (PBO) modules, PAI modules, and function modules are created for the events like application, table, and view in this function group. The PBO module calls only one BDT service function module to set the field attributes, while the PAI module calls only one BDT service function module to get the cursor position. Program logic consists of the following: ● Events for applications (reading, checking, saving data). ●
Events for tables (communication between applications and function groups).
●
Events for views.
Events for views are further divide into: Process budgeting and control (PBC) - event for formatting a table such as sorting
●
●
PBO - event before output such as reading text descriptions from Customizing tables
●
PAI - event after input such as checking input values
Note: The same code is executed in maintenance modes without dialogs. You need not program this code again.
LESSON SUMMARY You should now be able to: ●
244
Identify outdated enhancement techniques
© Copyright . All rights reserved.
Unit 9
243
Learning Assessment
1. What are the design goals of Business Data Toolset? Choose the correct answers. X
A Extensibility
X
B Configurability
X
C Usability
X
D Application objects
© Copyright . All rights reserved.
245
Unit 9
244
Learning Assessment- Answers
1. What are the design goals of Business Data Toolset? Choose the correct answers.
246
X
A Extensibility
X
B Configurability
X
C Usability
X
D Application objects
© Copyright . All rights reserved.