TAW10_1
ABAP Workbench Fundamentals
SAP NetWeaver 2004
Date Training Center Instructors Education Website
Instructor Handbook
Course Version: 2005/Q4 Course Duration: 15 Days Material Number: 50077030 Owner: Mario Gohlke (D023031)
An SAP Compass course - use it to learn, reference it for work
Copyright
Copyright © 2005 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.
Trademarks
• • • • • • Microsoft®, WINDOWS®, NT®, EXCEL®, Word®, PowerPoint® and SQL Server® are registered trademarks of Microsoft Corporation. IBM®, DB2®, OS/2®, DB2/6000®, Parallel Sysplex®, MVS/ESA®, RS/6000®, AIX®, S/390®, AS/400®, OS/390®, and OS/400® are registered trademarks of IBM Corporation. ORACLE® is a registered trademark of ORACLE Corporation. INFORMIX®-OnLine for SAP and INFORMIX® Dynamic ServerTM are registered trademarks of Informix Software Incorporated. UNIX®, X/Open®, OSF/1®, and Motif® are registered trademarks of the Open Group. Citrix®, the Citrix logo, ICA®, Program Neighborhood®, MetaFrame®, WinFrame®, VideoFrame®, MultiWin® and other Citrix product names referenced herein are trademarks of Citrix Systems, Inc. HTML, DHTML, XML, XHTML 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, SAP Logo, R/2, RIVA, R/3, SAP ArchiveLink, SAP Business Workflow, WebFlow, SAP EarlyWatch, BAPI, SAPPHIRE, Management Cockpit, mySAP.com Logo and mySAP.com are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other products mentioned are trademarks or registered trademarks of their respective companies.
• • • •
Disclaimer
THESE MATERIALS ARE PROVIDED BY SAP ON AN "AS IS" BASIS, AND SAP EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR APPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THESE MATERIALS AND THE SERVICE, INFORMATION, TEXT, GRAPHICS, LINKS, OR ANY OTHER MATERIALS AND PRODUCTS CONTAINED HEREIN. IN NO EVENT SHALL SAP BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES OF ANY KIND WHATSOEVER, INCLUDING WITHOUT LIMITATION LOST REVENUES OR LOST PROFITS, WHICH MAY RESULT FROM THE USE OF THESE MATERIALS OR INCLUDED SOFTWARE COMPONENTS.
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. Type Style Example text Description Words or characters that appear on the screen. These include field names, screen titles, pushbuttons as well as menu names, paths, and options. Also used for cross-references to other documentation both internal (in this documentation) and external (in other locations, such as SAPNet). Example text EXAMPLE TEXT Emphasized words or phrases in body text, titles of graphics, and tables Names of elements in the system. These include report names, program names, transaction codes, table names, and individual key words of a programming language, when surrounded by body text, for example SELECT and INCLUDE. Screen output. This includes file and directory names and their paths, messages, names of variables and parameters, and passages of the source text of a program. Exact user entry. These are words and characters that you enter in the system exactly as they appear in the documentation. Variable user entry. Pointed brackets indicate that you replace these words and characters with appropriate entries.
Example text
Example text
2005/Q4
© 2005 SAP AG. All rights reserved.
iii
About This Handbook
TAW10_1
Icons in Body Text
The following icons are used in this handbook. Icon Meaning For more information, tips, or background Note or further explanation of previous point Exception or caution Procedures
Indicates that the item is displayed in the instructor’s presentation.
iv
© 2005 SAP AG. All rights reserved.
2005/Q4
Contents
Course Overview ............................................................................. vii
Course Goals.................................................................................vii Course Objectives ........................................................................... ix
Unit 1: SAP Solutions .........................................................................1
mySAP Business Suite and mySAP ERP ................................................. 2 SAP NetWeaver – An Overview ............................................................ 9
Unit 2: Navigation ............................................................................ 51
Navigation in General ..................................................................... 53 Advanced Navigation in the SAP GUI ................................................... 68 Appendix - Personalizing the User Interface ............................................ 95
Unit 3: The System Kernel.................................................................105
Principal Architecture of the SAP Web Application Server ......................... 107 Dialog Processing in the SAP System .................................................. 136 Communication with the Database ...................................................... 144
Unit 4: Communication and Integration Technologies .............................155
Cross-System Business Processes ..................................................... 157 Remote Function Calls and BAPIs ...................................................... 162 Web Services .............................................................................. 172 SAP Business Workflow .................................................................. 178
Unit 5: Sources of Information for Developers .......................................195
SAP Service Marketplace ................................................................ 196 SAP Developer Network ................................................................. 207
Unit 6: ABAP Program Process ..........................................................217
System Architecture and ABAP Program Using Example of Selection Screen and List ....................................................................................... 218
Unit 7: Introduction to ABAP Workbench..............................................233
Repository and Object Navigator ........................................................ 235 Developing Programs and Organizing Developments ................................ 247
2005/Q4
© 2005 SAP AG. All rights reserved.
v
Contents
TAW10_1
Unit 8: Basic ABAP Language Elements...............................................281
Working with Elementary Data Objects ................................................. 282 Working with Structures................................................................... 307 Working with Internal Tables ............................................................. 321
Unit 9: Data Retrieval .......................................................................345
Reading Database Tables ................................................................ 346 Authorization Check ....................................................................... 375
Unit 10: Subprograms in ABAP ..........................................................391
Subroutines................................................................................. 392
Unit 11: Introduction to ABAP Events ..................................................413
ABAP Events ............................................................................... 414
Unit 12: Classic List Processing .........................................................425
List ........................................................................................... 427 Selection Screen........................................................................... 449 Generating and Designing the Selection Screen ...................................... 469 Introduction to Logical Databases ....................................................... 489 Logical Database Subobjects and Data Retrieval ..................................... 497
Unit 13: Creating and Calling Function Groups and Function Modules ........525
Function Groups ........................................................................... 527 Function Modules.......................................................................... 536 Calling Function Modules................................................................. 557
Unit 14: Programs Calls and Data Storage Management ..........................577
Program Calls and Memory Management.............................................. 578
Glossary .......................................................................................609 Index ............................................................................................615
vi
© 2005 SAP AG. All rights reserved.
2005/Q4
Course Overview
This training course, lasting three weeks, provides a comprehensive and detailed introduction to the basics of ABAP/ABAP object-oriented programming and the ABAP Workbench tools. This course also prepares you for certification as a Development Consultant SAP NetWeaver - ABAP Workbench 2004.
Target Audience
This course is intended for the following audiences: • Development consultants and developers who are responsible for adapting and developing ABAP/ABAP Objects programs
Course Prerequisites
Required Knowledge
• • Solid EDP basic knowledge Good programming experience in a different programming language
Course Duration Details
Unit 1: SAP Solutions mySAP Business Suite and mySAP ERP SAP NetWeaver – An Overview Unit 2: Navigation Navigation in General Exercise 1: Logon and Screen Design Advanced Navigation in the SAP GUI Exercise 2: Selecting Functions, Searching and Filtering Data Appendix - Personalizing the User Interface Exercise 3: Appendix - Personalizing the User Interface Unit 3: The System Kernel Principal Architecture of the SAP Web Application Server Exercise 4: Structure of an Instance 60 Minutes 90 Minutes 40 Minutes 10 Minutes 60 Minutes 30 Minutes 0 Minutes 10 Minutes
75 Minutes 10 Minutes
2005/Q4
© 2005 SAP AG. All rights reserved.
vii
Course Overview
TAW10_1
Dialog Processing in the SAP System Exercise 5: Dialog Processing Communication with the Database Unit 4: Communication and Integration Technologies Cross-System Business Processes Remote Function Calls and BAPIs Exercise 6: Remote Function Calls and BAPIs Web Services SAP Business Workflow Exercise 7: Leave Request as Workflow Unit 5: Sources of Information for Developers SAP Service Marketplace Exercise 8: SAP Service Marketplace (Optional) SAP Developer Network Exercise 9: SAP Developer Network (Optional) Unit 6: ABAP Program Process System Architecture and ABAP Program Using Example of Selection Screen and List Unit 7: Introduction to ABAP Workbench Repository and Object Navigator Developing Programs and Organizing Developments Exercise 10: Organizing Developments Exercise 11: Developing ABAP Programs Exercise 12: Creating Transactions Unit 8: Basic ABAP Language Elements Working with Elementary Data Objects Exercise 13: Basic ABAP Statements Working with Structures Exercise 14: Working with Structures Working with Internal Tables Exercise 15: Working with Internal Tables Unit 9: Data Retrieval Reading Database Tables Exercise 16: Data Retrieval Using a SELECT Loop Exercise 17: Data Retrieval and Buffering in an Internal Table Authorization Check Exercise 18: Authorization Check
30 Minutes 5 Minutes 30 Minutes 30 Minutes 30 Minutes 10 Minutes 30 Minutes 30 Minutes 10 Minutes 30 Minutes 10 Minutes 30 Minutes 10 Minutes
20 Minutes 45 Minutes 95 Minutes 5 Minutes 20 Minutes 10 Minutes 75 Minutes 30 Minutes 75 Minutes 30 Minutes 90 Minutes 30 Minutes 110 Minutes 30 Minutes 35 Minutes 60 Minutes 20 Minutes
viii
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Course Overview
Unit 10: Subprograms in ABAP Subroutines Exercise 19: Subroutines Unit 11: Introduction to ABAP Events ABAP Events Unit 12: Classic List Processing List Exercise 20: List Selection Screen Exercise 21: Selection Screen Generating and Designing the Selection Screen Exercise 22: Designing, Initializing, and Checking a Selection Screen Introduction to Logical Databases Logical Database Subobjects and Data Retrieval Exercise 23: GET Events Exercise 24: GET LATE Events and Checks from Internal Program Selections
70 Minutes 30 Minutes 20 Minutes 110 Minutes 50 Minutes 80 Minutes 30 Minutes 40 Minutes 25 30 50 30 Minutes Minutes Minutes Minutes
20 Minutes
Unit 13: Creating and Calling Function Groups and Function Modules 20 Minutes Function Groups 10 Minutes Exercise 25: Creating a Function Group 60 Minutes Function Modules 15 Minutes Exercise 26: Creating Function Modules 50 Minutes Calling Function Modules Exercise 27: Implementing and Calling Function 25 Minutes Modules Exercise 28: Using Global Data of a Function Group 20 Minutes Unit 14: Programs Calls and Data Storage Management 40 Minutes Program Calls and Memory Management 30 Minutes Exercise 29: ABAP Memory
Course Goals
This course will prepare you to: • • • Work with the ABAP Workbench tools Write your own simple ABAP programs Program object-oriented ABAP Objects
2005/Q4
© 2005 SAP AG. All rights reserved.
ix
Course Overview
TAW10_1
Course Objectives
After completing this course, you will be able to: • • • • • • • • Describe the data structure of SAP systems Use the ABAP Workbench tools Create lists using classic reports Create and call function groups and function modules Work with the ABAP Dictionary Program in a performance-sensitive manner Describe the concepts behind object-oriented programming Create lists using ALV Grid Control
SAP Software Component Information
The information in this course pertains to the following SAP Software Components and releases: This version of TAW10 has been extended from two to three weeks. Topics previously part of TAW12, ABAP Dictionary and List Processing, are now covered in full in TAW10. It now also includes parts of the new course on “Advanced ABAP”, BC402. As we did not want the ABAP certification (for TAW10 and TAW12) to exceed five weeks, we removed superfluous parts of the existing ABAP track. In the first week of the previous version of TAW10, lists and screen programming were introduced. These topics were then covered in more detail in the following weeks. List processing (classic method) is now looked at in more detail in week one. List processing (classic method) will not be covered in more detail in the remainder of the course. In the third week of TAW10, you are taught how to create lists using the ALV grid control. As previously outlined, the brief introduction to ABAP Dictionary and screen programming has been removed from the first week of TAW10. ABAP Dictionary is explained in detail in week two of TAW10 and screen programming is now only covered in TAW12. At the end of the third part of TAW10, you will find the certification unit which states the weighting of various topics in the certification test.
x
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 1
1
SAP Solutions
For more information, see the introductory instructor notes in the lesson.
Unit Overview
The beginning of the course introduces you to mySAP Business Suite and its contents. You will also receive a brief overview of the integration and technology platform SAP NetWeaver.
Unit Objectives
After completing this unit, you will be able to: • • • Name some of the options for using mySAP Business Suite and mySAP ERP in your company. Name the integration aspects of SAP NetWeaver Explain the basic concepts of the individual integration levels of SAP NetWeaver
Unit Contents
Lesson: mySAP Business Suite and mySAP ERP ................................ 2 Lesson: SAP NetWeaver – An Overview ........................................... 9
2005/Q4
© 2005 SAP AG. All rights reserved.
1
Unit 1: SAP Solutions
TAW10_1
Lesson:
2
mySAP Business Suite and mySAP ERP
Lesson Duration: 60 Minutes
Lesson Overview
This unit provides an introduction to the structure of SAP's software solutions, at the center of which is the mySAP Business Suite.
Lesson Objectives
After completing this lesson, you will be able to: • Name some of the options for using mySAP Business Suite and mySAP ERP in your company.
This introductory lesson aims to give the participants an overview of the benefits available to companies using the mySAP Business Suite and mySAP ERP. Only some of these benefits are presented here. You must make sure that you show the participants the SAP homepage as part of this lesson: http://www.sap.com.
Business Example
As your company is about to implement SAP software, you wish to get an overview of the SAP solutions. You urgently require this information to prepare for the planned meetings with the SAP consultants.
The SAP Software Portfolio
SAP's software portfolio is constantly extended, optimized, and tailored to the needs of the market and of customers. SAP has therefore, for example, developed many industry-specific solutions over the years. The topic of integrating different business systems (even from different vendors and across company boundaries) has become increasingly important recently. SAP's software portfolio has been adapted to this trend. Products for small to midsize businesses have also been added to SAP's family of software solutions. The graphic provides you with an overview of the structure of SAP solutions.
2
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: mySAP Business Suite and mySAP ERP
Figure 1: SAP product strategy
The basic elements of SAP solutions are listed below. • • • • • SAP NetWeaver mySAP Business Suite SAP Smart Business Solutions SAP xApps (SAP Collaborative Cross Applications) Industry Solutions
Each element is introduced briefly in the following. SAP NetWeaver SAP NetWeaver is the technological infrastructure for all SAP solutions. For more information, see http://www.sap.com/netweaver. mySAP Business Suite mySAP Business Suite bundles all cross-industry, SAP NetWeaver-based SAP solutions. For more information, see http://www.sap.com/solutions.
2005/Q4
© 2005 SAP AG. All rights reserved.
3
Unit 1: SAP Solutions
TAW10_1
SAP Smart Business Solutions SAP Smart Business Solutions are SAP solutions for small and midsize businesses. The mySAP All-in-One solution is an SAP R/3-based system that has been extended with business functions from other SAP solutions. This means that each combination of functions results in a different “mySAP All-in-One package”. This product is suitable for customers with a few dozen to a few hundred end users. SAP Packaged Solutions offer a similar approach. These solutions are packages of functions from different solutions of the mySAP Business Suite combined individually for each customer. SAP Packaged Solutions are not shown in the above graphic. SAP Business One is a completely new product that can be easily linked to existing SAP landscapes (by XML). The software is programmed in C++ and can be installed under various Microsoft Windows operating systems. SAP Business One contains functions important for running your business, such as financial accounting, customer management, purchasing, and warehouse management. Even the smallest companies can use this software profitably. For more information on SAP Smart Business Solutions, see http://www.sap.com/smb. SAP xApps SAP xApps (Collaborative Cross Applications) allow you to integrate existing applications with each other by accessing existing datasets and functions using open interfaces. This means that you can implement new applications based on an existing infrastructure. For more information, see http://www.sap.com/xapps. Industry Solutions Industry Solutions provide business functions for selected industries. These functions are implemented in an SAP R/3 (Enterprise) System and are available as Add-Ons. For more information, see http://www.sap.com/industry.
Functions of mySAP Business Suite
mySAP Business Suite, previously known as mySAP.com, is a complete package of open enterprise solutions that link all people involved, information, and processes, and can therefore improve the effectiveness of your business relationships. The various SAP solutions are combined into the mySAP Business Suite and individually developed further. For more information about all SAP solutions, see
4
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: mySAP Business Suite and mySAP ERP
http://www.sap.com/solutions. The mySAP ERP is based on an SAP ECC System with functions from mySAP HR and mySAP Financials. All SAP solutions, including mySAP ERP, are based on the complete SAP NetWeaver. mySAP Business Suite provides: • • • • • A complete spectrum of business solutions A technological infrastructure that combines openness and flexibility with maturity and stability Interfaces for integrating non-SAP products Components that can be adapted to meet multiple business requirements Numerous industry-specific functions
Context of Solutions and Components
Numerous solutions for business challenges are provided in the context of the mySAP Business Suite. However, many solutions have similar or identical requirements for business functions in subareas. Different solutions therefore contain, in part, similar components. Components refer to, for example, an SAP ECC system, an SAP SCM system or also an SAP Business Information Warehouse system. The graphic for the example of the mySAP SCM solution provides an overview of this hierarchy (components as building blocks of solutions).
Figure 2: Solutions and components
2005/Q4
© 2005 SAP AG. All rights reserved.
5
Unit 1: SAP Solutions
TAW10_1
Possibilities with mySAP Business Suite
To give you a clearer impression of the possibilities of the mySAP Business Suite, you can see some of the business scenarios that are possible using mySAP Business Suite from the following graphic.
Figure 3: Possible Business Scenarios with mySAP Business Suite
mySAP Business Suite offers many options for integrating your company-internal business processes and, likewise, integrating business partners' systems. You can implement the integration of cross-enterprise processes using different technologies, such as with Application Link Enabling, using Electronic Data Interchange (EDI), through XML data exchange, or also using Collaborative Cross-Applications (xApps) and Web Services.
6
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: mySAP Business Suite and mySAP ERP
Facilitated Discussion
Highlight the possibilities offered by mySAP Business Suite.
Discussion Questions
Use the following questions to engage the participants in the discussion. Feel free to use your own additional questions. Which of the opportunities offered by mySAP Business Suite will you actually use in your company?
2005/Q4
© 2005 SAP AG. All rights reserved.
7
Unit 1: SAP Solutions
TAW10_1
Lesson Summary
You should now be able to: • Name some of the options for using mySAP Business Suite and mySAP ERP in your company.
Related Information
For more information, see the following SAP Internet sites. All of these sites are freely available, a few require you to register free of charge. Please draw the participants' attention to the Web site of your local SAP subsidiary, for example: http://www.sap.de.
• • • • •
Global SAP Homepage, http://www.sap.com SAP Help Portal, http://help.sap.com SAP Service Marketplace, http://service.sap.com SAP Info, http://www.sap.info SAP Insider Online, http://www.sapinsideronline.com
8
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
Lesson:
8
SAP NetWeaver – An Overview
Lesson Duration: 90 Minutes
Lesson Overview
This lesson introduces the central role of SAP Web Application Server in the context of SAP NetWeaver.
Lesson Objectives
After completing this lesson, you will be able to: • • Name the integration aspects of SAP NetWeaver Explain the basic concepts of the individual integration levels of SAP NetWeaver
This lesson briefly introduces all NetWeaver components (except for the actual Web Application Server). Exercises and system demonstrations are not planned here. Caution: The content covered brushes on topics for which multi-day seminars are required for merely acquiring the basic knowledge. Do not underestimate this. If necessary, always refer to course SAPNW or to the introductory seminars for the individual components, such as SAPBI, SAPEP, BIT100, BIT400, and so on. The instructor notes contain much background information for instructors, which is to help especially if there are questions. The contents of the notes should not be part of the presentation in any case.
Business Example
After a merger with Rubble AG & Co. KG, which specializes in smaller markets, globally active Flintstone Industries Ltd. has a very heterogeneous IT infrastructure. To map business processes not only SAP systems are used but also software components from other providers as well as business applications that have been developed internally. After the merger, Flintstone Industries wants to map the changed business processes to the existing IT landscape as efficiently as possible. In doing so, as much flexibility as possible should be ensured for the future. Furthermore, the very high costs of interface maintenance between the individual software components should also be drastically reduced at the same time. The master data of the formerly separate companies is to be managed centrally in future. Top management also demands uniform reporting across all areas. Finally, sales employees are to receive a central portal that always shows them the current status of the sales orders and always supplies employees with the latest information.
2005/Q4
© 2005 SAP AG. All rights reserved.
9
Unit 1: SAP Solutions
TAW10_1
Current Challenges for Companies with IT Landscapes that have Grown over a Number of Years
These days, companies want to reduce costs, find new ways of increasing turnover and profitability and be able to flexibly adjust to all types of changes. In this context, the question of how to adjust or integrate existing applications and flexibly implement new applications plays a central role. Existing investments shall be used optimally, at the same time new business processes have to be supported quicker and in a more intelligent way. Cisco Systems GmbH, with more than 60 acquisitions is an example of this. Cisco must be able to provide its customers with consistent information on the order status across all product lines and structures of business units. The information for this is kept in numerous old and new software applications. If business structures and customer requirements change, the effort and costs involved in maintaining such a service can become immensely high. Legal requirements demanding a higher degree of traceability as well as changes to processes are a good example of the external “pressure to conform” affecting companies. The following could be mentioned here: Sarbanes-Oxley Act for US listed companies (proof of processes for creating the balance sheet) or requirements in the area of deregulation (for example, E.ON may not put other suppliers in a worse position than itself) or Basel 2 in financial accounting (proof of the own stability by banking institutions). These days, realistic system landscapes often consist of many systems. The business processes that are to be mapped in these complex system landscapes contain process steps running on different systems. For all system transitions, sending systems are connected to receiving systems by means of interfaces (point to point connection). Different interfaces are often implemented using the technology that is considered to be ideal for the respective interface. Due to this, administrators not only have to take care of a complex system environment but must also know many different technologies. In the following graphic, every interface is represented by a connecting line. This illustrates the complexity of an integration solution.
10
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
Figure 4: Challenges of Current IT landscapes
Studies on how long it takes to change existing business processes or introduce new processes still determine times ranging from months to years, depending on the process. People asked attribute about a third of this to the inflexibility of IT. With SAP NetWeaver it is much quicker, easier and more flexible to implement and adjust complex business scenarios. For example, using SAP NetWeaver reduces the complexity of system landscapes by • • • • being a single platform for integrating information and systems providing functions that make time-consuming, expensive integration projects unnecessary ensuring compatibility with .NET and WebSphere making it possible to increase the flexibility of business processes with the new Enterprise Services Architecture concept
There are certain standards that regulate how certain components work together. For example, there is a standard for the data exchange between BW systems or standard for the communication between portals. But there is currently no standard regulating how a BW system can be connected to a portal (more or less) at the push of a button. And that is the solution approach of SAP NetWeaver and that is the advantage of the SAP integration solution.
2005/Q4
© 2005 SAP AG. All rights reserved.
11
Unit 1: SAP Solutions
TAW10_1
Figure 5: Integrated System Infrastructure
Caution: SAP NetWeaver consists of a number of modules that can also be regarded separately. The most important thing though is that the whole is more than the sum of its individual components. SAP NetWeaver enables you to flexibly develop business processes on tailored components without having to give up existing investments.
You should always point out the increased flexibility offered by the SAP NetWeaver Platform, if possible based on scenarios given by the participants.
SAP NetWeaver
SAP NetWeaver is the technical foundation on which almost all mySAP solutions are currently based. SAP NetWeaver is the functionally enhanced successor of the SAP application platform mySAP Technology and serves as the basis for the Enterprise Services Architecture, in order to meet requests for flexibility and integration between systems, interfaces, users and processes. It connects information, business processes and people across system and organizational boundaries. It is the central tool for reducing the total cost of ownership (TCO) of complex system infrastructures.
12
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
Note: Not all SAP solutions are based on SAP NetWeaver, in particular SAP Business One.
Figure 6: SAP NetWeaver - Overview of Components
On the following four integration levels SAP NetWeaver provides the core functions for the technical infrastructure of business solutions: • • • • People Integration Information Integration Process Integration Application Platform
SAP NetWeaver also supports cross-application software, so-called composite applications or xApps (xApps connect heterogeneous systems in continuous cross-function processes so that the underlying applications can be more or less ignored). Furthermore, different software interfaces ensure full interoperability of applications that are running on Microsoft .NET and IBM WebSphere.
2005/Q4
© 2005 SAP AG. All rights reserved.
13
Unit 1: SAP Solutions
TAW10_1
The following additional slide is very handy for mapping the integration levels to software components. At the same time, it introduces most important courses on the respective topics.
Figure: SAP NetWeaver: Who, What and How...
Figure 7: SAP NetWeaver - Interoperability
14
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
Examples of xApps are SAP xRPM (Resource and Program Management), SAP xPD (Product Definition), SAP xEM (Emissions Management) or SAP GTS (Global Trade Services). If requested, you can deal with xRPM in more detail. xRPM is used for multi-project management, that is the cross-administration of different projects in different project systems. SAP xApp Resource and Program Management integrates data from existing systems for project management, human resources, financial accounting, cost accounting and time recording to provide management, project manager, resource manager and project members with an overview of the project portfolio including a simple drilldown function. Due to the complete integration of the different levels, SAP xRPM is a really good example of what ESA and NetWeaver mean. SAP xRPM enables the effective monitoring and analysis of large projects. This includes risk recognition and rating. Customers can define their own risk factors and then analyze all current projects in the operational systems according to these factors. xRPM provides a type of resource management with which it is possible to specifically search for employees with certain expertise. These employees can then be requested immediately for a project and once the supervisor has given his approval (obtained via the workflow), both the HR data of the employees is maintained and appropriate costs are posted to the project. Of course, this assumes that the employees have been maintained accordingly in the xRPM system. This only has to be done once. Information on SAP xRPM is available in the help portal or on a CD that can be purchased. You can purchase the CD from Tanja Foerster. It contains an offline demonstration in English. Refer also to the following link: http://www.sap.com/germany/solutions/xapps/xrpm/index.aspx The following covers the individual integration levels in more detail, starting with people integration.
Integration Level People Integration: Using an Enterprise Portal
Possible introduction to the following section: Modern companies typically use many different applications. Every employee has to log on to and log off from these applications several times a day. This is both time consuming and annoying. In addition, forgotten passwords make work more difficult, both for the employees themselves as well as for the IT department. Furthermore, there is often an “information overload”: Too many intranet pages, too many local
2005/Q4
© 2005 SAP AG. All rights reserved.
15
Unit 1: SAP Solutions
TAW10_1
servers with too many files. As a response to this, a central view of applications is often requested for management as well as employees. SAP Enterprise Portal provides the solution to this.
Figure 8: People Integration
An enterprise portal is the gateway to the end user. Based on the end user view, this section illustrates, how a user-friendly interface makes it possible to access relevant data from very different systems. Furthermore, it illustrates the meaning of role-based user and content management and shows that using business packages can significantly reduce the amount of resources required for implementing a portal. An enterprise portal offers a central point of access to information, applications and services in your enterprise. All SAP and non-SAP systems, data warehouses, desktop documents as well as web contents and web services are brought together on one uniform interface. By using the single sign-on, users benefit from the convenient authentication and communication between IT systems. Knowledge management in the portal turns unstructured data into important information (for the enterprise), collaboration facilitates the collaboration of people across enterprise borders and personalization adapts the structure to individual user requirements.
16
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
Figure 9: SAP Enterprise Portal
You can use the catchphrase that a portal should and can provide the right information and the right functions to the right processor at any time and from any location. To do this, SAP Enterprise Portal provides an infrastructure you can use to retrieve and edit data from information sources in your company and the Internet by means of iViews. SAP provides iView templates but you can also create customer-specific iViews. Furthermore, the SAP Enterprise Portal provides powerful search functions with which you can selectively and intuitively retrieve files and documents from different sources of information such as local database applications, websites or pools of enterprise documents. Collaboration functions allow you to use common resources and common content. The individual tools and services include virtual project rooms and tools for real-time interaction, irrespective of the geographical distance. You can use discussion forums to exchange data and information with colleagues whose workplace is not in the same spot or maybe even in a different time zone. The core functions of SAP Enterprise Portal are written in Java. Hence, you need a J2EE runtime environment such as the one provided by the SAP Web Application Server Java. SAP Enterprise Portal uses an open architecture. The standards it
2005/Q4
© 2005 SAP AG. All rights reserved.
17
Unit 1: SAP Solutions
TAW10_1
supports include SOAP, UDDI, XML. The portal has powerful security functions including extensive support of directory services, digital certificates and SSL protocol (Secure Socket Layer). SAP Enterprise Portal is highly scalable and is thus also designed for large numbers of users. Mobile devices are also supported. Roles in the SAP Enterprise Portal Roles determine, which navigation paths (specified using the file structure) can be used to access which content (specified using the integrated iViews and pages). Roles can be assigned to individual users or groups of users. Note: The term content covers all contents that are available to a user in his/her role-based portal view. The most important content objects are: iView Program that determines data from different sources of the enterprise or Internet, displays it in the SAP Enterprise Portal and, if applicable, makes it available for processing. Page Layout of one or more iViews. Workset Collection of tasks, services and information that can be used to create roles. Worksets consist of iViews and pages, arranged in a folder structure that determines the navigation paths. Users use the portal either as their central workplace with access to different applications or the portal serves them as the user interface within a specific application. For example, this is the case in SAP Master Data Management (SAP MDM) as well as in xApp SAP xRPM for multi project management for the employee or manager self service work center. These roles for administering users and content are generally separated. Administrators for users and roles define both objects according to the enterprise requirements in the system and assign roles to users. Content administrators define which content is available in the system, ensure that it is administered properly and decide which roles can work with which content.
18
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
You have to distinguish between the role maintenance in the portal and the authorizations in connected systems. The portal uses the procedure authorizations of the respective application and thus does not have to transfer authorization profiles to the enterprise portal. This increases security and reduces the amount of work required to administer authorizations. At the same time, it ensures that users can only access data and information according to their authorization profile. In order to avoid duplicate work, it is possible to exchange roles between the portal and an SAP system. Here, only the menu of the role is stored on the portal side but not the corresponding authorization data from the SAP system, which remain in the back end.
Figure 10: Look&Feel of the SAP Enterprise Portal
The portal view can be customized. All UI elements are in turn iViews and can be moved to where the user wants them. For example, you can move the detail view to the right part of the screen. If a demo is requested: http://idesportals.wdf.sap.corp:1080/ There, you can access portals with predefined users in different releases and SP levels.
2005/Q4
© 2005 SAP AG. All rights reserved.
19
Unit 1: SAP Solutions
TAW10_1
The following graphic provides an overview of the architecture of the SAP Enterprise Portal.
Figure: The Architecture of the SAP Enterprise Portal
Discuss the graphic using the following memos. The Portal Runtime (PRT) is the core of the portal. From a technical point of view it is a Java application running on the J2EE engine. It forms the runtime environment for all portal components and services. All portal cost components are HTML creating Java applications, such as the Page Builder, which constructs the portal pages and sends them to the portal client or the admin tools used to administer roles, users, business packages and so on. Portal services act as an interface to other portal components or services for exchanging procedures or data. The Portal Content Directory (PCD) for example, serves as an interface to the Portal System Database (in which all portal“data” is stored). The User Management Service is another example. It serves as the interface between PRT and the User Management Engine (UME), a separate software component that stores the user data in the User Persistence Store.
20
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
You must distinguish the user management in the portal from that in other SAP applications such as SAP R/3, CRM and so on. Portal users can be “stored” in very different locations - in the portal database, on the LDAP servers or in SAP systems. Business Packages In addition to about 100 roles, SAP also provides standard content in Business Packages. Business Packages contain predefined portal content, that can be used to call up transactions and reports from all sorts of systems. Furthermore, it also contains documents and information, based on the roles for users, managers and specialists. Business Packages facilitate the work of your content manager and significantly reduce the implementation time of your enterprise portal as they enable portals to be created without additional development work. So while your competitors are still busy programming their enterprise portal platform, you are already enjoying the advantages of using the SAP Enterprise Portal.
Figure 11: Target Groups of Business Packages
Business Packages are classified according to the following target groups: end users, specialists and managers.
2005/Q4
© 2005 SAP AG. All rights reserved.
21
Unit 1: SAP Solutions
TAW10_1
Business packages for users Contains the tasks that a portal user may carry out in the portal, irrespective of his other role in the enterprise. The tasks help beginners to familiarize themselves with the portal as quickly as possible and thus increase the acceptance of the enterprise portal. The content includes functions regarding e-mailing, task lists, calendar administration, travel expense settlement, administration of benefits, employee self services, e-learning and the search in the employee directory. Business packages for managers Decision makers can use the content of these packages for efficient analyses and for gaining decision-relevant information. Furthermore, they offer extensive tools for planning and administering the portal use and the budget. Line managers, team managers and project managers can thus reduce the time they have to spend on administrative tasks and focus on strategic tasks. The most wide-spread business packages for managers include the Manager Self-Services (MSS). Business packages for specialists These business packages are aimed at the experts from different departments in the enterprise such as sales, human resources, marketing, finance and production. They provide appropriate analysis tools, which enable them to act quickly based on the right information. But they can also provide operational tools, such as campaign management for marketing employees. You can buy Business Packages from the iView Studio , a central marketplace for portal content. You find the iView Studio at the following address www.sdn.sap.com. As a registered user, you will find the individual packages there. You can display and download contents under the corresponding roles. Mobile Infrastructure
22
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
Figure 12: Mobile Infrastructure
SAP Mobile Infrastructure (SAP MI) is a technology solution of SAP NetWeaver, which is the basis for the “SAP Solutions for Mobile Business”. They are usually an enhancement to an existing SAP application, as demonstrated by the following graphic. For example, there is an enhancement for SAP Human Resources, with which travel data and working times can be entered on the go. In the same way, service employees can be directly informed of new orders via a mobile device and they can confirm data directly at the customers instead of writing down data on sheets of paper and entering them into the back end system later on.
2005/Q4
© 2005 SAP AG. All rights reserved.
23
Unit 1: SAP Solutions
TAW10_1
Figure 13: Architecture of the SAP Mobile Infrastructure
Mobile business increases flexibility as well as making it easier to provide information to field sales representatives. A sales employee can dynamically access customer and order data without having to download and save it from the backend before visiting a customer. A third point is getting rid of “piles of paper” where data has to be entered into the IT systems afterwards. This speeds up processes, reduce the amount of work required for field sales representatives and is less error-prone as the data is entered when it is created. However, you can also use SAP MI to “mobilize” non-SAP based applications. SAP MI is locally installed on a mobile device and is equipped with a web server, database layer and a dedicated business logic. Hence, remotely working employees never have to wait for a network connection to complete time-critical business transactions but can work offline. To synchronize the data on the mobile device with the back end, SAP MI provides tools for synchronization and data replication. SAP MI is equipped with a Java Virtual Machine and provides an open programming model with which developers can develop mobile applications. This open system architecture facilitates platform independence of mobile devices as well as networks and supports mobile devices such as personal digital assistants (PDAs), laptops and smart phones.
24
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
The technology of CRM mobile clients (CRM Field Sales) has nothing to do with SAP MI. It only runs in SAP CRM, is .NET based and is focused on working with large amounts of data on laptops. Mobile Infrastructure in SAP NetWeaver in contrast, is aimed at tasks that require less data and can be stored on PDAs. SAP MI wants to offer introductory courses for Mobile Intelligence from quarter 04 2004. One course is on the administration and the other is on developing customer-defined mobile solutions. See also SAPNet quick link nw-mi and rkt-mi. See the following link regarding current MI scenarios: http://www.sap.com/solutions/mobilebusiness/index.aspx
Integration Level Information Integration
Figure 14: Information Integration
This section shall explain the basic idea of SAP Business Intelligence and illustrate the meaning of the business content provided by SAP.
For each solution supplied by SAP, there are options of reporting via the data of the respective application. Usually, the application provides a large number of standard reports for this purpose, but user-defined reporting is also possible. Customers can
2005/Q4
© 2005 SAP AG. All rights reserved.
25
Unit 1: SAP Solutions
TAW10_1
use the query interface or program their own reports in the ABAP Workbench and thus read the data of the production system as they want. This type of reporting can also still be used with SAP NetWeaver. By now, more than 6000 customers successfully use the software solution SAP Business Intelligence (system component SAP BW) either in parallel to this or exclusively. The reasons for that include the increasing requirements for integrated solutions for the enterprise-wide analysis of data. In times of globalization and market expansion, it is important to have access to the relevant information from one's own enterprise at any time and to be able to analyze it flexibly, including in aggregated form and without placing a performance strain on the transactional system. Make sure you make the techies amongst the participants well aware of the performance aspect: Increasingly complex queries via the business data in the OLTP system, increase the load on these systems, which were not set up for extensive data warehousing originally. In addition to this, the BW also offers functions that do not exist in the “old” form of reporting (such as complex hierarchies). Release 6.40 implicitly contains the SAP BW component in SAP Web AS, that is, it is available after the installation of the SAP Web AS. In particular for smaller installations and simple reporting tasks, BW reporting could thus be executed directly on the OLTP system, that is, on the database that the OLTP uses. Depending on the database, the performance is better or worse. Oracle, for example, meets the different requirements (performance relevant settings) for OLTP and OLAP systems by using different user schemas. In heterogeneous system infrastructures, the extraction and preparation of consolidated transaction and master data from SAP systems and source systems by other suppliers are particularly challenging. Apart from integrated data procurement, options for detailed data analysis and the multi-media display of the analysis results are required to meet the increasing quality requirements for enterprise information. Collaboration of OLTP and OLAP You have to look at the transaction-oriented OLTP (Online Transaction Processing) and the analysis-oriented OLAP environment (online analytical processing) as integrated. Huge amounts of information are created from the data for business processes, which are not easily used for practical analysis. Hence, the data is cleaned first (cleansing) and, due to its different origins, it is technically and semantically formatted (homogenized). The resulting analyses can, in turn, be used to generate knowledge that can help enterprise management to define its enterprise strategy and the business processes derived thereof. The following graphic illustrates this cycle:
26
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
Figure 15: Delimitation: Operational/Informational Environment
OLAP stands for Online Analytical Processing. Typical OLAP applications are data warehouse systems such as the SAP BW. OLTP is the abbreviation of Online Transaction Processing. Typical OLTP applications are enterprise resource planning systems such as mySAP ERP. There are fundamental differences between OLTP environments and OLAP environments. This can be illustrated with the following terms: • Degree of detail While the OLTP level stores data at a very high level of detail, the data in the data warehouse is aggregated for performant access. • History By means of archiving data in the OLTP area, data is kept with a minimal history. In the data warehouse area, comprehensive historic data is required. • Changeability Frequent changes of data distinguishes the operational area, whereas the data for the analyses is "frozen" from a certain point in time. • Integration In contrast to the OLTP environment, the requirements on general, integrated information for analysis are very high.
2005/Q4
© 2005 SAP AG. All rights reserved.
27
Unit 1: SAP Solutions
TAW10_1
•
Normalization Due to the reduction of the data redundancy by normalizing tables, the number of tables is very high in operational use. Data retrieval and performance are the reasons for the rather limited normalization in the data warehouse. Normalization means that a characteristic for an object within a database is only stored once in a specific table. It is easier to keep the contents of databases with normalized tables consistent as only one entry has to be changed when changes are made. Example: All personal data for a customer are stored in a customer table and a customer is clearly identified by a customer number. If other tables, such as invoice tables, refer to the customer, then his customer data is not stored again, only the customer number. If the address data is to be output as well, the customer table also has to be read.
•
Optimized access An OLAP environment is optimized for read access. For operational OLTP applications, functions such as change, insert and delete also have to be implemented in similarly performant ways.
The following graphic provides an overview of the architecture of the SAP BW in a heterogeneous system infrastructure.
28
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
Figure 16: The 3 level architecture of the SAP BW
Discuss the graphic using the following memos.
The lowest level of the slide shows the source systems. SAP provides extraction mechanisms for production data from SAP systems. For non-SAP system, there are the BW BAPI interface, the interfaces for accessing relational database systems and multi-dimensional applications and an interface for processing XML files. You can also load data from flat files. Metadata and application data (master and transaction data) is managed in the Business Information Warehouse server. When a report (query) is executed, the OLAP processor reads the data. The third level shows the different reporting tools: BEx Analyzer, embedded in Microsoft Excel, and BEx Web Analyzer, embedded in BEx Web. You can use it to execute queries in the browser. In general, data can be transferred to a cell phone and, in particular, it is possible to run and display analyses on portal interfaces.
2005/Q4
© 2005 SAP AG. All rights reserved.
29
Unit 1: SAP Solutions
TAW10_1
The structuring and visualization of all information is ensured by the fact that, based on the requirements and expectations on reporting, suitable data is provided in the SAP BW. This data can originate from SAP systems as well as non-SAP systems, a large portion of the users of SAP BW extracts and analyzes non-SAP data. There are consulting statements claiming that 80 to 85 percent of the data in customer SAP BWs originates from external systems.
The Business Information Warehouse Server administers application and metadata. The OLAP processor analyzes the data when it is accessed via the reporting interface. The physical model of the SAP BW is based on a schema in which, put simply, the master data (customer numbers, customer names, product names, status, country indicator, base units of measure...) is stored in master data tables and the transaction data (sales, stocks, quantities...) is stored in a fact table and in dimension tables. In addition to all other dimension tables, there are always two special dimension tables for reference to times and units. Dimension tables are linked to the central fact table by means of foreign key dependencies. There, the dimension attribute with the finest level of detail of the respective dimension table is a foreign key in the fact table. This way, all data records of the fact table can be identified uniquely. The link between the central fact table and the surrounding dimension tables that is thus created is also referred to a star schema because, in graphical depictions, the dimension tables are usually grouped around the central fact table in a star shape. The SAP BW star schema is an enhancement of this simpler, classical star schema. Part of the enhancement is that the dimension tables do not contain any master data information. This is contained in separate master data tables that are, in turn, linked to the key figures of the fact tables via SID tables (SID = surrogate ID = generated surrogate key). On the one hand, this is done for performance reasons (because the use of generated INT4 keys enables faster data access than access via long string alphanumeric keys). On the other hand, it facilitates the multi-language capability of the system as well as, for example, the historization of dimensions. In order to get the actual value of a field, the SAP BW uses the keys in the dimension tables to read the corresponding master data tables. The system determines the transaction data from the fact table.
30
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
Both the fact table and the master data tables are based on InfoObjects, more precisely, the required characteristics and key figures that have to be created in the data warehouse. Hint: In the BW, business evaluation objects (customers, sales and so on) are called InfoObjects. InfoObjects are subdivided into characteristics, key figures, units, time characteristics and so on. InfoObjects are thus the smallest modules in the SAP BW. Fact tables are created in the context of defining BasisCubes, a special form of InfoCube. InfoCubes are the central objects, on which reports and analyses are based from a data perspective. SAP knows several forms of InfoCubes: • BasisCubes InfoCubes that are physical data stores, that is, tables on the Data Warehouse Server • Virtual InfoCubes InfoCubes that do not contain any data but are a layer on a physical dataset From a reporting perspective, an InfoCube describes a self-contained data set of a business area on which queries can be defined. From a technical perspective the BasisCube consists of a set of relational databases that are composed multidimensionally, that is from a central fact table and several dimension tables that surround it. Apart from InfoCubes there are also other objects that can be used for reporting (such as ODS objects, operational data store objects, which are generally used to store consolidated data at document level). In contrast to the star-shaped arrangement of tables in an InfoCube, ODS objects are implemented in flat tables. All objects that can be used for reporting are called Info Providers. From a reporting perspective, there is no difference between physical and virtual InfoCubes How does data get into InfoCubes? Physical data stores are supplied with data from the requested source systems by means of extraction runs. The following graphic illustrates all relevant terms in the context of extraction. The data is stored in an SAP system. A BW plug-in must be installed so that an SAP system can be used as a source system.
2005/Q4
© 2005 SAP AG. All rights reserved.
31
Unit 1: SAP Solutions
TAW10_1
Figure: SAP BW: Data Flow regarding a Basis Cube
Source systems provide data that is replicated into the BW system via DataSources. In the BW system, you define data flow from the DataSource to an InfoSource, which is the actual source for the BasisCube or the master data tables. You can define rules affecting the data transfer both during the data transfer from DataSource to the InfoSource as well as during the data transfer from the InfoSource to the tables. (Definition of conditions that have to be met so that data can be transferred, execution of currency conversions, enhancing master data fields, for example to delimitate different systems after corporate takeovers...) The SAP BW also provides solutions for the data transfer from non-SAP systems:
• • • • • •
Data transfer with third party tools Data transfer with XML or SOAP documents Data transfer via DB connect Data transfer from flat files Data transfer using UD-Connect (as of SAP BW 3.5) Data transfer by means of the SAP Exchange Infrastructure (as of SAP BW 3.5)
UD-Connect makes it possible to access data from any relational database. As sources, DB connect only permits those databases that collaborate with SAP systems by default.
32
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
For more information on data flows and their definition, refer to the various BW courses, such as BW310, BW340, BW350. Business Content Business Content (BC) contains preconfigured, role and task related information models that can be adapted to individual enterprise requirements. For example, this could be the area of cost center accounting or travel expense processing. The structure of the Business Content is based on application components and consists of roles, workbooks, queries, InfoCubes, InfoObjects, InfoSources, update rules as well as extractors for SAP R/3, SAP New Dimension Applications and other selected applications. Queries are defined queries in the reporting of the SAP BW (corresponding to ABAP reports and queries in an SAP system) and you can display the result of a query in different Business Explorer (BEx)components: as a workbook in BEx Analyzer (Microsoft Excel-based) or as a Web application in BEx Web (browser-based). An InfoSource is a set of logically related InfoObjects that contains all available information on a business process (such as cost center accounting). You fill the InfoCubes in the SAP BW from the InfoSource according to certain update rules. A DataSource in the SAP BW always describes a business unit of master data (such as material master data) as well as transaction data (such as sales data). From a source system perspective, every DataSource has meta-information, such as the field or field descriptions for the master and transaction data as well as programs that describe how the extraction is carried out. This information is source system specific, that is, a DataSource depends on the source system. All these objects are summarized in roles. A role corresponds to certain functions in the enterprise (purchasing manager, head of finance...) and a need for information resulting therefrom.
2005/Q4
© 2005 SAP AG. All rights reserved.
33
Unit 1: SAP Solutions
TAW10_1
Figure 17: SAP BW: Business Content
The Business Content is shipped as an add-on to the SAP BW. The documentation provides detailed information on the business content of the individual applications. The distinct advantage of the Business Content is that it is based on a data model and you can thus activate all required and related objects at the same time. As the Business Content also contains objects of the data flow you load the corresponding data from the SAP source systems very quickly and, if necessary, analyze is using predefined queries. In general, the objects in the Business Content are shipped in an inactive version that has to be explicitly transferred, that is copied and activated. SAP provides extractors for transferring data from an SAP source system to an SAP BW in almost all applications. They are usually preprogrammed and are shipped with the Business Content. If you are asked what has to be considered if an already applied data model (for example, from the Business Content delivered by SAP) has to be changed retrospectively: Analyses in the BW are based on InfoCubes. InfoCubes are based on a data model. Even though all care is taken during modeling, customers regularly notice at some stage that the data model is insufficient and that they have to enhance it. Enhancing a data model means that the data has to be loaded again. And then it can happen that the data is no longer available in the OLTP system in the way that it is required. For this, the SAP BW provides the function of the Enterprise Data Warehouse Layer.
34
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
Customers can use it to store all records that are loaded into the SAP BW at some stage in non-aggregated form for subsequent loading. But such a procedure produces significant datasets, that is, archiving is an issue for customers using this function. Information on archiving the SAP BW: For NetWeaver 04 data is written from the BW to files and has to be reloaded to the SAP BW for analysis. For NetWeaver 05, queries will not only be able to include online data but also data that is no longer stored in the BW. Knowledge Management Knowledge Management is to enable users to access all sorts of internal and external contents by using intelligent search functions. Furthermore, there are also publication and registration options available. But users can also just browse, classify or manage contents. The publication cycle of documents can be controlled by means of online communication or workflow functions. Access to information is controlled by means of authorization profiles. Knowledge Management also allows experts to be assigned to certain subject areas. • • Content Management support for the entire life cycle of documents, from the creation to the archiving of a document Search & Classification (search engine TREX) full text search across all types of documents and their automatic classification
There are various possible information sources: Desktop documents, websites, spreadsheets, database tables, design drawings from PLM (DVS), powerpoint presentations or text files. Integrated master data management with SAP MDM
2005/Q4
© 2005 SAP AG. All rights reserved.
35
Unit 1: SAP Solutions
TAW10_1
Figure 18: SAP Master Data Management
If an enterprise stores master data in different locations and systems at the same time, then this multiple storage can lead to redundancies and variances, which might significantly disrupt business processes. SAP Master Data Management (SAP MDM) enables you to create master data that is uniform across the enterprise and to distribute it to different dependent systems. SAP MDM uses the technological basis of the SAP Exchange Infrastructure (SAP XI) to distribute the data. It not only distributes the data but for new master data, it always checks whether identical master data objects are already available and generates comprehensive information on duplicates, which can in turn be transferred into the SAP BW or used in analyses. This reduces data management costs and significantly simplifies the correction of data errors. Everyone who knows the central user management can use this as an analogous example from the Basis technology. Shell is a good real live example for the benefits of MDM. At Shell, there are operational units (similar to SAP business units), which basically have contracts with suppliers like a company within the company. It was only by means of MDM that it was found out that Shell is one of the main customers of Coca Cola brand soft drinks. By means of the Content Integrator it was possible to find out that the different names for Cola (Coke, Cola, Coca Cola, and so on) and the different suppliers (local suppliers of Coca Cola), which appeared in the orders, were actually identical. The data was loaded into the BW and assigned correctly. This revealed the actual purchase quantity. Of course, that gave Shell a lot more leverage for negotiating discounts...
36
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
If there are questions regarding the software components: MDM does not only require XI and BW, but also Enterprise Portal as the user interface, even though some settings can still be made in the SAP GUI for Windows.
Figure 19: Integrated master data management with SAP MDM
MDM structure A central MDM system gets master data from local systems. The communication between the systems happens via RFC connections. An SAP BW is required for reporting across centralized master data. Master data has to be matched so that reporting can run properly. For example, identical products have different material key figures in the local systems. The data is analyzed according to the matching rules. Depending on matches in certain data fields, points are assigned and entered in a matching table. Threshold values are then used to distinguish whether or not this refers to the same product. If an identical product is determined that was maintained differently in local systems, a synchronization takes place. If required, this synchronization can also happen manually. MDM scenarios
2005/Q4
© 2005 SAP AG. All rights reserved.
37
Unit 1: SAP Solutions
TAW10_1
With regard to locally maintained data, you have to distinguish between different scenarios. Scenario 1 means the master data is only maintained locally. In this case, only a matching takes place, no synchronization. Scenario 2 means the master data is maintained locally but harmonized/matched via the central system. In scenario 3 the master data is only maintained centrally and distributed to local systems.
Integration Level of Process Integration
Figure 20: Process Integration
The aim of this lesson is to introduce the fundamental modules of SAP XI: SLD, Integration Repository, Integration Directory, logical and technical routing and so on.) Participants should get an idea of the levels involved and understand the difference between design time (general definition of the objects) and configuration time (combining objects in concrete scenarios with concrete systems). Caution: Note on the terminology At the end of June 2004, the following terminology changes were decided: Business Scenario -> integration scenario Business process -> integration process Scenario (in the integration directory) -> configuration scenario, plural: configuration scenarios
38
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
The course material already uses the new terminology. The SAP Exchange Infrastructure (SAP XI) can be used to implement cross-system business processes. Within the overall architecture of SAP NetWeaver, SAP XI takes care of the process integration. In detail, it enables the connection of non-SAP and SAP systems from different suppliers in different versions on different platforms (Java, ABAP and so on). SAP XI is based on an open architecture, mainly uses open standards (especially from the realm of XML and Java) and offers services that are essential in a heterogeneous and complex system infrastructure: runtime infrastructure for exchanging messages, configuration options for controlling business processes and the flow of messages as well as options for transforming message contents between sender and receiver. With SAP XI 3.0 the scope of functions of SAP XI was enhanced mainly in the area of business-to-business communication and cross-system business process management. In general, the SAP Exchange Infrastructure includes the following components:
2005/Q4
© 2005 SAP AG. All rights reserved.
39
Unit 1: SAP Solutions
TAW10_1
Figure 21: Components of the SAP Exchange Infrastructure
• •
In the System Landscape Directory , system landscapes are mapped, that is, the different systems are defined with which the business processes are handled. In the Integration Repository a description of all required interfaces is entered in the design phase, irrespective of the platform. Based on this description, a mapping has to be defined in the Integration Repository if the structure and format of the data to be exchanged are not suitable. So far, this does not affect the systems and processes. In a configuration phase, the data types, message types, interfaces and mappings that are defined in the Integration Repository are then selected and assigned to each other based on the system infrastructure and business processes in question (Technical and Logical Routing). The result is stored in the Integration Directory. The application specific contents are transferred from the sender to the receiver by means of messages in a freely-definable XML schema. The interface used (IDoc, file, database...) by the data structures determines the structure of the message. At runtime, the Integration Engine of the Integration Server analyzes the configuration of incoming messages in the Integration Directory. Based on the data available there, it determines the recipient(s) of the message, maps the incoming message to the interface structure of the recipient and forwards it. The Integration Server is thus the central communication and distribution machine for XML messages.
•
•
40
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
In the SLD environment there are some important terms that are not only relevant to SAP XI: product, product version, software component and software component version. In the SAP environment, a product in SLD corresponds to a technical SAP component. It consists of one or more software components and the customer can see, install and update it. A product is shipped in a product version, which in turn contains software component versions. For example, the product SAP APO with version 3.1 includes the software components of the SAP Basis in the software components version 4.6D, SAPBW in version 2.1, SAP ABA in version 4.6D, SAP APO in version 3.1, and so on. All operational systems of the system infrastructure are recorded in SLD. Apart from the respective host name and other technical attributes this also includes the information on which software components are installed on a server. Each operational system is assigned one or more business system names. This business system name is required for configuring the scenarios for sending and receiving systems (basically the “postal address” for mail). For SAP systems as the operational system, there can be one business system for each client. In general, the business system name for SAP systems is identical to the term logical system that you know from the ALE world. As of SAP XI 3.0 it will be possible to already register a system in the System Landscape Directory when it is set up, that is, manual maintenance tasks are no longer necessary. For a developer who processes objects in the Integration Repository, the software component version is decisive as the development happens in the context of the software component version. At the beginning of the development, a namespace for the objects, that belong together semantically (comparable to an ABAP or Java package) is set up in the Integration Repository. Objects are thus clearly identified by their names and namespace. At first, a namespace is a freely selectable constant. Namespaces must be globally unique, that is, across software component versions. One option is to use the company name. When you create a namespace, parts of the name must never start with a number. You cannot change namespaces retrospectively without restrictions. Connection of different systems to the SAP Exchange Infrastructure If an involved system is an external system or if existing interfaces from SAP systems with Basis Release = 6.20, then SAP XI provides a new programming model. This can be used to define the interface descriptions in the Integration Repository irrespective of the platform. These descriptions can be used to generate proxies in the different application systems for JAVA applications or SAP systems. In the application system proxies represent the interface from the Integration Repository.
42
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
From a technical perspective, proxy objects are classes and methods in a programming language (ABAP or Java) that can generate and process messages for a file format defined in the Integration Repository. SAP provides executable proxies for all cross-platform message interfaces. However, customers must first generate these proxies before they can use them for their own interfaces. An application of a business system calls a proxy to send a message. The generated proxy generates a message in SAP XI format from the interface parameters and the proxy runtime sends it to the Integration Server, which processes it further and then forwards it. In order to process messages in a receiving business system, the proxy runtime on the receiving system accepts the message and calls the ABAP class that implements the corresponding proxy. The form of processing presumes a local SAP Integration Engine on the connected business systems, the implementation of which is part of the configuration of scenarios with SAP Exchange Infrastructure. A new programming model is applied here: the central definition of interfaces, based on message interfaces. You know the basic idea of creating an RFC-enable function module with its interface and the method source code for the planned functions in system A, so that this module can then be called externally. In the same example, if you use the SAP Exchange Infrastructure, you define the message format centrally in the Integration Repository. That means, you basically define the interface that is used. In system A you then only have to generate the method source code for processing the message data. In contrast, if you use adaptors the interfaces are still developed decentrally in the business system and the interfaces are then transported into the Integration Repository. There are no current plans to make it possible to program proxies in languages other than ABAP and Java. For more information, please refer to courses BIT400 and BIT450.
2005/Q4
© 2005 SAP AG. All rights reserved.
43
Unit 1: SAP Solutions
TAW10_1
How the SAP Exchange Infrastructure works - the SAP XI Pipeline In general, the SAP XI runtime consists of the following components: • Integration Engine Executes the integration logic of the Integration Server. The purpose of the Integration-Engine is to correctly and consistently process the Pipelines, that is, to receive, process and forward XML messages. • Integration Server Is basically the software component SAP Web AS with XI specific enhancements. As soon as the Integration Server receives a message in SAP XI format, the processing takes place in the pipeline of the Integration Server by means of the Integration Engine. • Proxy runtime Is required to use proxies to exchange messages with the Integration Server. Proxies are based on a specific programming model. • Adaptor engine Is required to use the RFC adaptor and external adaptors to exchange messages with the Integration Server. • The actual adaptors This is about those adaptors that are connected to the adaptor engine or are operated independently of it, such as the IDoc adaptor or the plain HTTP adaptor. • Monitoring Central monitoring supports the monitoring of the SAP XI runtime components, the message flow and the performance. Note: The pipeline refers to all the steps that have to be executed while an XML message is processed, that is a defined sequence of services that a message has to go through. The run through the pipeline always happens in the same form as as soon as a message reaches the Integration Server. First, the receiver of the message and its input interface are determined by means of the configuration data of receiver and interface determination. This step is called logical routing.
44
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
Following that, the pipeline determines how the receiver can be physically reached using technical routing. If required by the configuration (as in: the structure of the message to be transferred differs between the sender and the receiver), then the assigned mapping program is executed that maps the output interface to the input interface. At the end, the Integration Server sends the message to the target system.
Figure: Pipeline of the Integration Server
2005/Q4
© 2005 SAP AG. All rights reserved.
45
Unit 1: SAP Solutions
TAW10_1
Facilitated Discussion
The discussion should demonstrate the power of SAP NetWeaver and its advantages.
Discussion Questions
Use the following questions to engage the participants in the discussion. Feel free to use your own additional questions. What advantages do SAP customers gain from using SAP NetWeaver?
46
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP NetWeaver – An Overview
Lesson Summary
You should now be able to: • Name the integration aspects of SAP NetWeaver • Explain the basic concepts of the individual integration levels of SAP NetWeaver
Related Information
• Refer to http://www.sap.com/netweaver for more information.
2005/Q4
© 2005 SAP AG. All rights reserved.
47
Unit Summary
TAW10_1
Unit Summary
You should now be able to: • Name some of the options for using mySAP Business Suite and mySAP ERP in your company. • Name the integration aspects of SAP NetWeaver • Explain the basic concepts of the individual integration levels of SAP NetWeaver
48
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Test Your Knowledge
31
Test Your Knowledge
1. The following solutions are provided by SAP:
Choose the correct answer(s).
□ □ □ □ □
A B C D E
mySAP Business Change Enabler (mySAP BCE) mySAP Product Lifecycle Management (mySAP PLM) mySAP Customer Relationship Management (mySAP CRM) mySAP Supply Chain Management (mySAP SCM) mySAP Strategic Organization Planning (mySAP SOP)
2005/Q4
© 2005 SAP AG. All rights reserved.
49
Test Your Knowledge
TAW10_1
32
Answers
1. The following solutions are provided by SAP: Answer: B, C, D mySAP BCE and mySAP SOP are ficticious products. The others are real SAP solutions.
50
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 2
33
Navigation
For more information, see the introductory instructor notes in the lesson.
Unit Overview
In this unit you learn how to navigate in SAP systems using SAP GUI. You will also learn how to personalize the SAP system and get help when you are working in the SAP system.
Unit Objectives
After completing this unit, you will be able to: • • • • • • • • • • • • Log on to the system successfully List some variants of the SAP GUI Name and use elements of a SAP GUI screen Log off from the system successfully Use various methods to start SAP system functions Create a list of favorites Use the help functions Carry out complex, selective searches Sort and filter listed data Execute a where-used list Describe the standard menus System and Help. Use the various options for personalizing the SAP system
2005/Q4
© 2005 SAP AG. All rights reserved.
51
Unit 2: Navigation
TAW10_1
Unit Contents
Lesson: Navigation in General ..................................................... 53 Procedure: Changing the Initial Password ................................... 59 Procedure: Changing the Changed Password Again....................... 60 Procedure: Log off via the Menu Bar ......................................... 64 Exercise 1: Logon and Screen Design ....................................... 65 Lesson: Advanced Navigation in the SAP GUI .................................. 68 Exercise 2: Selecting Functions, Searching and Filtering Data ........... 87 Lesson: Appendix - Personalizing the User Interface........................... 95 Exercise 3: Appendix - Personalizing the User Interface .................. 99
52
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Navigation in General
Lesson:
35
Navigation in General
Lesson Duration: 40 Minutes
Lesson Overview
In this lesson, you will learn about logging on to the system and about the significance of the various SAP GUI screen elements.
Lesson Objectives
After completing this lesson, you will be able to: • • • • Log on to the system successfully List some variants of the SAP GUI Name and use elements of a SAP GUI screen Log off from the system successfully
After completing this lesson, the participants should be able to log on to the system without errors and name and use the basic elements of an SAP GUI screen as well as log off from the system correctly. Course ADM100 covers how to configure SAP logon.
Business Example
You want to find out which options are generally available to your users to log on to the SAP system. What does the interface look like and what is the significance of the different screen elements of the SAP GUI?
Different SAP GUI Variants
The presentation interface, SAP GUI (Graphical User Interface) enables the user to interact with the SAP system and enter or display data. SAP GUI implements the graphical user interface using the functions provided by the relevant presentation environment. SAP GUI is based on the Windows Style Guide and is available for several platforms, providing the same functions for each. If you learned to use SAP GUI on one platform, you can use the system on another platform exactly the same as before, with the exception of a few small platform-specific GUI attributes.
2005/Q4
© 2005 SAP AG. All rights reserved.
53
Unit 2: Navigation
TAW10_1
The following types of SAP GUI are available: • • • SAP GUI for the Windows environment SAP GUI for the Java Environment SAP GUI for HTML
SAP GUI for the Windows environment (abbreviated to SAP GUI for Windows) is the SAP GUI implementation in a Microsoft Windows environment. SAP GUI for Windows is written in C or C++, runs on Windows-based platforms, and supports all transactions in an SAP system. The flow of data between the presentation layer and the application layer does not consist of prepared screens, but rather logical, compact information about control elements and user input (DIAG protocol). The volume of data transferred for each screen change is generally a few KB. You can therefore also easily connect presentation servers over WANs. SAP GUI for the Java Environment (abbreviated to: SAP GUI for Java) is written in Java and is the platform-independent implementation of SAP GUI. Like SAP GUI for the Windows environment, this GUI also uses the DIAG protocol, so the volume of data transferred for each screen change is also generally only a few KB and you can easily connect presentation servers over WANs. You can either install SAP GUI on the front end, or alternatively you can install it on a terminal server and access it using terminal clients. SAP GUI for HTML consists of the Internet Transaction Server (ITS) on the server side and a Web browser on the client side. The ITS is required to convert the SAP GUI data flow from the SAP Web Application Server into HTML and back. An HTML data flow is exchanged (using the Web server) between the WGate of the ITS and the front end. The primary advantage of SAP GUI for HTML is that almost no installation is required on the front end, all you need is a browser (currently: Microsoft Internet Explorer, Version 4.0 or higher). SAP GUI for HTML does not support all the functions in an SAP system, it is, however, sufficient for the majority of users in a company. The following graphic shows the various alternatives and the flow of communication with the SAP Web Application Server dispatcher. If it is available and you know how to access it, you could at this point call up SAP GUI for the Java Environment (for example on a WTS) for the training system you are using and, once you have logged on, carry out a transaction in it (for example, SM50). You could do the same for the HTML GUI in the browser, so that the participants get to see the various types of GUI.
54
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Navigation in General
Figure 23: Alternative types of SAP GUI
Note: You can find further information on the various SAP GUI alternatives in the following SAP Notes: • • • • SAP Note 66971: front-end platforms supported SAP Note 314568: functions not available with SAP GUI for HTML SAP Note 146505: SAP GUI for the Java environment SAP Note 138869: SAP GUI on the Windows Terminal Server
Logging on to the System
All SAP solutions are accessible using a general front end program, the SAP GUI (SAP Graphical User Interface). For the sake of simplicity, further descriptions refer to the SAP GUI for the Windows environment. Hint: You can also access certain SAP system via specially designed front end programs. For example, the SAP Business Information Warehouse (SAP BW) has the Business Explorer (BEx) as a BW-specific front end.
2005/Q4
© 2005 SAP AG. All rights reserved.
55
Unit 2: Navigation
TAW10_1
The SAP GUI program connects the front end computer with SAP systems. Theoretically you can specify the SAP system required at the command-line level when calling the SAP GUI; in practice, you never need to do this. This is a possible command line for logging on to system I20: sapgui /M/iwdf4020/G/SPACE/S/sapmsI20 (load balancing) and sapgui /H/iwdf4020/S/sapdp00 (server selection) For starting SAP GUI, SAP provides another program: SAP Logon. When you call up SAP Logon, it displays a list of SAP systems for which you can start the logon process. This list is taken from a file on the front end: saplogon.ini. This file is usually centrally preconfigured and provided for end users. Hint: You can also store links and logon entries on the front end PC. The links have the form of an icon allow the targeted access to transactions in the SAP system. During logon, the SAP Logon program also enables logon load distribution using the resources available for the system selected.
Figure 24: The SAP Logon program
56
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Navigation in General
When logging on to an SAP system, you will be prompted to enter the user and password, among other things. If you have implemented a Single Sign-On (SSO) solution, you may not need to enter this information. You also have the option of specifying a client when logging on; the client field usually already contains an appropriate default value. Hint: A client usually represents a company in an SAP system. This means that if an SAP system has several clients, then several companies can be represented and simultaneously active in that system. The client has a corresponding key field in the tables of the database used by that SAP system. If you are in a client, you can only access data for that specific client. Clients therefore correspond to independent business entities. When logging on, you can select a logon language supported by that system. SAP systems can support a large number of languages, the minimum being English and one other selected language. The number of installed languages determines which languages your system supports. On the logon screen, you also have the option of using the New password pushbutton to change your password, at the most once per day. Your system administrator can add additional text to your logon screen. For more information on how to do this, see SAP Note 205487. Note: SAP Notes contain detailed information on certain functions or corrections for known errors in SAP products. You can access SAP Notes through, for example, the SAP Service Marketplace on the Internet, using a valid user (S-user) and password: http://service.sap.com/notes. In the course of one logon to a system, you can work in several sessions (processing windows of an SAP system) simultaneously. Your system administrator can use a system parameter to define how many sessions are permissible for each logon to the SAP system. Parameter rdisp/max_alt_modes can be set to values from two to nine; the standard setting is six windows. The parameter cannot be set user-specifically but applies for all users of the system or the logon instance.
For SAP Web AS 6.20 you could increase the number to 16(!); from Web AS 6.40 nine sessions are the upper limit. Six windows, the old upper limit, is now the default setting.
2005/Q4
© 2005 SAP AG. All rights reserved.
57
Unit 2: Navigation
TAW10_1
Figure 25: The logon screen for an SAP system
User data is stored in the system by client, that is, you can, for instance, log on to client 100 in your system, but you will not have a user for client 200, even if your system has a client 200. The data for a particular user within a client is called the user master record. Multiple logons are logged as of SAP R/3 4.6. This is for reasons of both security and licensing. If the same user logs on more than once, then for each subsequent logon, the system displays a warning message that offers the user the following three options: Multiple logons are logged in table USR41_MLD.
• • •
Continue with this logon and end any other logons in the system Continue with this logon without ending any other logons in the system (this is logged) Terminate this logon
Changing the Password
Use the initial password assigned to you when you log on to the system for the first time. During the first login, you are prompted to save a changed password. For security reasons it makes sense to change the password occasionally.
58
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Navigation in General
41
Changing the Initial Password
1. Enter your new password twice, whereby you activate both input fields in sequence by means of mouse-click or tab button.
Figure 26: Dialog Box for Changing the Password
2.
Finally, choose
to save your new password.
2005/Q4
© 2005 SAP AG. All rights reserved.
59
Unit 2: Navigation
TAW10_1
42
Changing the Changed Password Again
Prerequisites
Hint: Users can change their password no more than once a day on the initial screen. In contrast, user administrators with authorization for transaction SU01 can change a user’s password as often as they want. Actually, the administrator can only assign new initial passwords.
Procedure
1. 2. 3. On the logon screen of the SAP system, enter your data and your current password. On the top left, click the New Password pushbutton. Change your password as described above and save your data.
Different system parameters with the prefix login/* influence the password response in the SAP system. Parameter login/password_expiration_time, for example, specifies after which number of days the user has to change his password.
Screen Structure
You can, for example, use transaction GUIT to demonstrate the different screen elements. On the individual screens of this transaction, examples of input fields, pushbuttons, radio buttons and checkboxes are illustrated. Screen 700 shows frequently used icons in the SAP system. System table ICON contains all icons and their technical names. The behavior of the navigational arrows in transaction GUIT is also instructive: The green arrow (Back) is not active whereas the yellow and red arrows still work. You can also close transaction GUIT by entering command /n. The instructor can also use other transactions to demonstrate the screen elements. Once you have logged on successfully, the initial screen of the SAP system appears; this screen is also known as the SAP Easy Access screen.
60
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Navigation in General
The SAP Easy Access screen is the default initial screen in SAP systems. The left side of the screen contains a tree hierarchy of the menus available to you in the SAP system; you can use the right side of the screen to display your company logo. This graphic is made available centrally by your system administrator and cannot be customized by individual users.
Figure 27: SAP Easy Access
You can find a detailed description of how to configure the graphic in SAP Easy Access under Extras → Administration information (if you have the correct authorization). Please note that the graphic is stored in the system and transported to the front end every time a user logs on. Although it is transported in compressed form, the graphic should not exceed 20 KB. You can also prevent the graphic from being displayed by either choosing the setting Low Speed Connection in the SAP Logon program (see SAP Note 161053), or by using Tools → Settings in the SAP Easy Access screen. You can view a typical screen (with various elements) by choosing System → User profile → Own data and choose the Defaults tab page. You will then see this screen with the data for your own user:
2005/Q4
© 2005 SAP AG. All rights reserved.
61
Unit 2: Navigation
TAW10_1
Figure 28: Maintaining your User Profile
An SAP screen can contain the following simple screen elements: • • • • • Command field Menu bar, system function bar, title bar, application toolbar, status bar Check boxes Radio buttons Tab
You can start applications directly by entering their transaction code in the command field, which is usually hidden. Find transaction code. You can find the transaction code for an application either in the overview menu on the SAP Easy Access screen, in the status bar (see below), or in the application itself under System → Status. The Menu bar is the top line of any dialog window in the SAP system. The menus shown here depend on which application you are in. These menus may also contain cascading menus.
62
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Navigation in General
The pushbuttons in the standard toolbar are shown on every SAP screen. If they are not available in an application, pushbuttons that you cannot use on that screen are deactivated. If you place the cursor over a pushbutton for a short time, the system displays a flag with the name or function of the pushbutton. If appropriate, the corresponding function key setting is also displayed. The title bar is the function that you are currently in. The application toolbar shows the pushbuttons available in the application that you are currently in. The Status bar displays information on the current system status, such as warnings and errors. You can also change the display variant to show, for example, the transaction code of the transaction you are currently in. Within a field group check boxes allow to select several options at the same time. With radio buttons you can only select one option. A tab organizes several subscreens to improve clarity. Input fields and pushbuttons are additional screen elements.
Logging off from the System
You should log off the system when you have finished your work in the SAP system. You have several options for doing this:
2005/Q4
© 2005 SAP AG. All rights reserved.
63
Unit 2: Navigation
TAW10_1
46
Log off via the Menu Bar
1. In the menu bar, select System → Log off. in the SAP Easy Access Hint: Alternatively, click the yellow arrow menu or enter the /nend command in the command field. If several sessions are open, the yellow arrow only closes the active window. The dialog field for logging off only appears in the last window. Caution: The /nex command immediately terminates your logon without querying the dialog windows first. All sessions of your terminal session are closed and entries that have not been saved are lost! 2. A Log off Dialog Box appears and tells you that you will lose data that has not been saved when you log off.
Figure 29: Log off Dialog Box
3.
To log off, choose Yes. Hint: From the perspective of the Windows operating system, an SAP session is a normal application. Hence, you can also close SAP sessions with the means of the operating system, such as by using the key combination Alt+F4. When you close the last window of your session, the dialog box is also displayed.
64
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Navigation in General
47
Exercise 1: Logon and Screen Design
Exercise Duration: 10 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Logon to the SAP system and navigate
Business Example
You want to work in an SAP system.
System Data
System: Client: User ID: as SAPTEC-##) Password: the relevant user. Set up instructions: The training system assigned to you (such as I30) The client assigned to you (such as 802) The user name that you have given the participants (such The password that you have given the participants for None
Task: Logging on to the System and Initial Tasks
Log on to the training system and carry out some basic exercises in the system. The menu paths refer to the SAP standard menu. 1. Start the SAP Logon program and choose the entry for the SAP system specified by your instructor. Choose the Logon pushbutton. Enter the client, user name, initial password, and the logon language specified by the instructor. When you log on for the first time, enter a new password of your choice twice in the window that appears. 2. 3. What is the maximum number of parallel sessions (windows of the SAP system) that you can open using System → Create Session? What is the name of the function you reach if you choose Tools → Administration → Monitor → System Monitoring → User Overview? What transaction code could you use to call this transaction instead of the menu?
2005/Q4
© 2005 SAP AG. All rights reserved.
65
Unit 2: Navigation
TAW10_1
Solution 1: Logon and Screen Design
Task: Logging on to the System and Initial Tasks
Log on to the training system and carry out some basic exercises in the system. The menu paths refer to the SAP standard menu. 1. Start the SAP Logon program and choose the entry for the SAP system specified by your instructor. Choose the Logon pushbutton. Enter the client, user name, initial password, and the logon language specified by the instructor. When you log on for the first time, enter a new password of your choice twice in the window that appears. a) 2. Follow the instructions in the exercise. What is the maximum number of parallel sessions (windows of the SAP system) that you can open using System → Create Session? a) Depending on the relevant system parameter setting, you can open between 2 and 9 sessions. This training system should allow you to open up to 6 sessions.
3.
What is the name of the function you reach if you choose Tools → Administration → Monitor → System Monitoring → User Overview? What transaction code could you use to call this transaction instead of the menu? a) The function is called User List (see the entry in the title bar). You can find the relevant transaction code using System → Status; in this case, the code is SM04. You can also choose to display the transaction code for an active transaction in the status bar. Alternatively, you can permanently display the transaction codes in the menu. Choose Menu bar → Extras → Settings and activate the field Display Technical Names. A fourth option would be to display the details by choosing Menu Bar → Extras → Technical Details. For this, the corresponding menu entry would first have to be selected with the mouse.
66
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Navigation in General
Lesson Summary
You should now be able to: • Log on to the system successfully • List some variants of the SAP GUI • Name and use elements of a SAP GUI screen • Log off from the system successfully
Related Information
• For more information, refer to the online documentation in Help → SAP Library → Getting Started.
2005/Q4
© 2005 SAP AG. All rights reserved.
67
Unit 2: Navigation
TAW10_1
Lesson:
50
Advanced Navigation in the SAP GUI
Lesson Duration: 60 Minutes
Lesson Overview
In this lesson you will learn about various ways of calling functions in SAP systems. In addition, different selection options and help functions are introduced. Finally, you will learn about how to work with list outputs.
Lesson Objectives
After completing this lesson, you will be able to: • • • • • • • Use various methods to start SAP system functions Create a list of favorites Use the help functions Carry out complex, selective searches Sort and filter listed data Execute a where-used list Describe the standard menus System and Help.
During the course of this lesson, you should explain to the participants the various options for calling functions using either the mouse or the keyboard. Pay particular attention to navigation using transaction codes. There is a simple method for administrators to create their own lists of transaction codes: select the entries required for the list from the table TSTCT and save them in Excel. The easiest way of doing this is to use the function System → List → Save → Local file. Participants frequently ask about transaction code lists: this is one of the simpler answers to that question. End users do not need to create transaction code lists in this way, since they have their role-based menus at their disposal, which contain the functions required for that role, normally about 10 to 15. The significance of the user menus and the option of switching to the SAP menu are also covered in this lesson.
Business Example
You want to know how functions can be started in the SAP system and what help the system provides you with.
68
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
User Menu and SAP Menu
Since release R/3 4.6, the SAP Access Menu starts automatically after login and is thereby the standard entry into the system. The left-hand navigation bar contains a clear tree structure, consisting of menu entries and favorites’ entries. You can adjust the favorites’ area in particular to your needs. The entries of the SAP menus and the user menus can only be changed by system administrators with certain authorizations. SAP and area menus can be processed using SE43. The user menus are bound to authorization roles. The latter are processed using PFCG.
Figure 30: Favorites list and user menu
The end user can switch from the role-based user menu to the SAP standard menu (if the system settings allow this). Hint: System administrators can use table USERS_SSM to determine whether or not users are allowed to switch between the SAP menu and their user menus. If both menus are disallowed, then the user menu is still displayed. The availability of the user or SAP menu does not affect a user’s authorizations. This means that a user can always call authorized functions using a transaction code, independent of the menu structure.
2005/Q4
© 2005 SAP AG. All rights reserved.
69
Unit 2: Navigation
TAW10_1
The role-based user menu is created on the basis of the role(s) assigned to the user and transferred to the front end. This means that it makes sense to keep roles as small as possible because large roles could take a long time to transfer to the front end in certain circumstances. If a user has several roles assigned, then some functions can be repeated in different parts of the role-based user menu. If you want to prevent this, please see SAP Note 357693 (and the other SAP Notes to which it refers) for information on finding and deleting duplicates, and on other related matters. Hint: As long as you have the appropriate authorization, you can also display user menus other than the ones assigned to you in your user master record. To do this, choose Other menu. Use Create role to start the role maintenance transaction, PFCG. The user and SAP menus can be structured in a pretty complex way. It is then difficult to remember the exact path for the transaction you are looking for. As long as the transaction has not been copied into the favorite area, you can find it more easily with special search transactions. The transactions SEARCH_SAP_MENU and SEARCH_USER_MENU search the corresponding menus for the predefined text pattern. The search result is prepared in a list view from which you can take the navigation path. The transactions found cannot be started directly with a double-click. A further search option for SAP menu entries is the transaction SDMO, which also allows you to search for a text pattern. A (technically out-of-date) dynamic menu is generated, from which the transactions found can be started with a double-click.
Favorites Management
In addition to the area menu or SAP menu, the user is also provided with functions in the favorites’ area. Often used transactions, web links or files can be stored in the favorites’ area. The users’ favorites’ entries are in the system tables SMEN_BUFFC and SMEN_BUFFI. Administrators can access these table to make changes and thereby change or delete the favorites of large user groups.
70
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
The favorites list thus contains SAP system functions or links to Internet content or to files on the end user’s front-end computer. The favorites list, which is initially empty, can be edited by each end user in accordance with his or her preferences; you can only view your own favorites list. Since data on the favorites is stored within the SAP system, each user might have different collections of favorites in different systems. Possible instructor demo: Demonstrate the download of your own favorites menu. Save the data, for example, under C:\temp\fav.txt on your front-end PC. After that, delete the complete favorites list. Now upload the favorites from the file you have just saved into the system again.
Hint: Complete favorites menus, incl. the folder structures, can be easily copied by uploading or downloading from one SAP system to another. The downloaded favorites menus are stored temporarily on the front-end PC.
The upload and download of favorites requires the corresponding authorizations for the authorization object S_GUI. It could be that the user does not have authorization in the productive customer system to upload. To improve the structuring, sort the favorites in own folders. You can edit favorites in the SAP Easy Access screen using the menu entry Favorites. The Favorites menu gives you the option of adding a function from the user (or SAP) menu to your personal favorites list by selecting the function and choosing Favorites → Add. Here, the menu path is also written with the text of the favorites entry to a limited extent. If you have highlighted a menu entry using the mouse, you can copy the selected node in the favorites’ area by right-hand mouse click. Alternatively, you can also drag the elements from the menu area using the mouse and store them in the favorites’ area (Drag&Drop). You can add URLs or links to files to your list of favorites by choosing Favorites → Add other objects. Click on the triangle symbol to the left of the file symbol to expand or collapse the list of favorites. Hint: To change the name of a transaction in Favorites, highlight the corresponding favorites entry and select the menu path Favorites → Change. You can change and save the text in the dialog box that opens.
2005/Q4
© 2005 SAP AG. All rights reserved.
71
Unit 2: Navigation
TAW10_1
You can delete favorites’ entries that you no longer need. Here, only the Favorite is deleted, not the original transaction! If you want to delete the entire Favorites menu, highlight the entry Favorites and click with the right-hand mouse button. Choose Delete all favorites.
Calling Up Functions
You have several options for navigating in an SAP system: • • • by entering transaction codes in the command field By choosing items from menus in the menu bar By choosing items from the favorites list or from the user or SAP menus
Figure 31: Various navigation options
You can reach the menus in the menu bar simply using the key combination Alt+E (the underlined letter of the selected menu item) or Alt and cursor navigation using the arrow keys on the keyboard.
72
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
You can use the keyboard to get to the SAP Easy Access screen or the command field and call system functions from there. Hint: Use the following keys to navigate using the keyboard: • • • TAB moves from one field element to the next within a field group. Ctrl + TAB goes from one field group to the first element of the next field group. Ctrl + / goes directly to the command field.
You can find further shortcuts using Customizing of local layout (Alt+F12)→ SAP GUI Help. When the command field is active, you can use the F1 key to display possible entries for this important field. The following entries are possible: • • • • • • • /n to cancel the current transaction /nXXXX to call transaction XXXX directly from another transaction. Without the prefix you can only call XXXX from the SAP Easy Access screen. /o to display an overview of sessions /oXXXX to call transaction XXXX in a new session directly from another transaction /nend to end the logon session with a confirmation dialog box /nex to end the logon session without a confirmation dialog box /i to delete the session you are currently using Note: The command field is an exception in that choosing the F4 key does not display the input help. The F4 key in the command field lists the last 15 different entries in the command field. This list is stored in the registry on the front end and is valid for all sessions on the front end (regardless of the system used).
Help Options
The SAP system provides you with various help options, which will be introduced in the following section.
2005/Q4
© 2005 SAP AG. All rights reserved.
73
Unit 2: Navigation
TAW10_1
F1 Help
You can use the F1 key to display an explanation of fields, menus, functions and messages. The F1 help also displays technical information on the relevant field. There you will find the parameter ID that you can use when setting user-specific default values for input fields that are also linked to the parameter ID. You can also display interesting information by, for example, calling the F1 help for the command field.
Figure 32: The F1 help
You can also use other buttons in the Performance Assistant dialog box to display information on the selected field. One of the most important pieces of information, besides the link to the context-sensitive Application Help, is the link to the Technical Information. Choose this to display detailed information, such as the parameter ID assigned to the field. You can use parameters to set defaults for frequently used input fields; to do this, the parameters are stored with the desired values in the user master record. Note: You may need to activate the Performance Assistant first using the menu Help → Settings → F1 Help.
74
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
F4 Help
You can choose F4 to display possible input values. You can also call up the F4 help for a field using the button immediately to the right of the selected field. If a field contains a checkmark symbol, you can only proceed to the next step in that application after entering a permitted value (required entry). You can use transaction or screen variants, or Customizing to mark fields as mandatory or optional, hidden or filled with hidden standard values.
Figure 33: The F4 help
The F4 help displays a list of possible entries for a field. If there are a large number of possible entries, a separate selection screen is displayed. If there is a long hit list, the F4 help only displays as many entries as the user has specified on the F4 Help tab page under Help → Settings. The default value for the maximum number of displayed hits is 500. Take the time to familiarize yourself with the other settings you can make here. Hint: Users can also create personal values lists. An S&D employee who is only responsible for Munich, for example, only wants to see the Munich clients and defines a corresponding personal value list. However, despite this, the employee still has the option at all times of switching to the total view of all customers or of updating or completely deleting the values list.
2005/Q4
© 2005 SAP AG. All rights reserved.
75
Unit 2: Navigation
TAW10_1
Demonstrate how you create a personal list of values using SU3 as an example for the possible entries of the logon language, Fixed values tab page. Enter DE and EN in your personal values list. Demonstrate the effect when you call up the possible entries again after creating the personal list.
SAP Library (Online Documentation)
The SAP Library is a useful aid to getting to know system functions. It allows you to access the online documentation. The information stored here does not simply describe how to use system functions, it also explains system architecture concepts, gives examples of how you can configure various processes, and warns you about possible user errors and their consequences. The online documentation also contains several tips and tricks to help you carry out common tasks more easily and quickly.
Figure 34: The SAP Library
Hint: You can also access the SAP Library on the Internet. To do this, go to http://help.sap.com, or go to http://www.sap.com and choose Education → SAP Help Portal. You can access the full product documentation for all releases here; a user-friendly full-text search by solution is also available.
The System and Help Menus
The System and Help menus are always available with the same options on every screen in an SAP system.
76
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
The System menu allows you to access various system functions. This menu also contains functions that you can only access using this menu (and not in any other way). You can log off using System → Log off, and display useful information on your system and the function you are currently using, such as the transaction code, by choosing System → Status.
Figure 35: The System and Help menus
You can use the Help menu to access the online documentation. You can also display the Release Notes and configure the standard settings for your F4 Help. You will probably find that the most useful option for you here is the context-sensitive link to the section of the online documentation relevant to the function you are using. The context-sensitive help is also called Application Help. The tool for accessing the online documentation as a whole is the SAP Library.
Appendix: Selection Screens
The following three sections are seen as an appendix. Depending on the time situation and what the participants already know, the instructor can explain these points more briefly or in more detail. Even when these subjects are only to be explained briefly, you must emphasize that every SAP user has to have a command of these.
2005/Q4
© 2005 SAP AG. All rights reserved.
77
Unit 2: Navigation
TAW10_1
When preparing data in your system, only certain data should be displayed selectively. Various selection options are available for this. • Search for individual values An exact search for the specified individual values is made.
Figure 36: Selection according to individual values (appendix)
•
Search for value areas A closed interval can also be specified; the interval limits here are included in the search.
Figure 37: Selection of intervals (appendix)
•
Search using selection options Here, search operators are specified meaning that searches for intervals that are upwardly or downwardly open are possible. Selection options can usually be called up via the menu entry Edit → Selection options, alternatively via the F2 is often used to call up the selection options, as then the key. A special icon access to the menu bar is not possible.
78
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
Figure 38: Setting selection options (appendix)
•
Excluding individual values Works like the search for individual values, bit with the difference that the specified individual values can no longer exist in the data records.
2005/Q4
© 2005 SAP AG. All rights reserved.
79
Unit 2: Navigation
TAW10_1
Figure 39: Calling up the exclusion selection option (appendix)
•
Exclusion from value ranges The specified value ranges can not exist in the data records. As with the search for intervals, the interval limits are also affected by the exclusion selection.
• •
Exclusion via the corresponding selection options. The exclusion of open intervals is possible here. Multiple selection All search and exclusion options can also be used as part of a multiple selection at the same time. Therefore, you cannot only look for several individual values or intervals at the same time, but can freely combine the various searches and exclusions. You should try to first find the data you want with a pure search selection, because the logical structure of a positive search can always be more easily reproduced than the one for exclusions. If the positive serach is not sufficient, the search criteria can be enhanced by exclusions. In principle, a positive search can always be mapped by a complementary exclusion selection.
80
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
Figure 40: Calling up a multiple selection (appendix)
Hint: A good search strategy decides on the data found. Avoid logical errors, as otherwise you will only find a limited number of data records and, in extreme cases, none will be found. Selection options that are too broad are also bad, beacuse then too many data records are found and this is inefficient and makes the evaluation difficult. In the manual search, a hit list that is too large will oversee relevant entries. Therefore, invest enough time in formulating your search strategy. With complex selection screens, it is advisable to save own search entries as own variants.
The trainer can show how entry variants are created in a transaction of his/her choice.
If you have made the selection criteria too extensive and the search has already been running for several minutes, you can interrupt the already started transaction as long as in the upper left-hand you can see the hour glass. To do so, click the SAP symbol corner of your mode and choose the entry Stop transaction. The selection is stopped and you go back to the SAP initial screen.
2005/Q4
© 2005 SAP AG. All rights reserved.
81
Unit 2: Navigation
TAW10_1
Figure 41: Stop running selection (appendix)
Appendix: List Editing
The instructor should be able to call up various list displays to display the navigation and editing options. For example, you can call up diverse system tables in using transaction SE16, such as T100, TSTC(T), SMEN_BUFFC, USR10, etc., in order to display their contents in a list output. You can also display a list of system parameters using transaction RSPFPAR. Of course, data from the application transactions can also be used, as long as the instructor is familiar enough with the transaction. After successfully calling up a selection, the data records found are displayed in a list display. Various navigation and editing options are available. • • • Searching for definitions or values using the search function provided with a search repeat Page by page scrolling in the list Navigation in the list using the scrollbar ; you are also
Hint: If you are searching for only one certain data record, but have several dozen data records in the list display, then you have made the selection criteria too broad. In this case it is better to formulate a more precise search and to reselect instead of wasting too much time searching in the list.
82
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
Figure 42: List display and navigation options (appendix)
•
Sort according to individual columns The data records of a column can be sorted in ascending or descending order. Here, you highlight the header line of the column and press the keys Sort in Ascending/Descending Order.
•
Filtering The filtering is a subsequent selection in the list display via the entries of selected key; columns. To do this, you highlight the column you want and press the then you define additional selection options.
•
Editing the list layout Every user can activate the SAP List Viewer in SE16. To do this, press User parameters Then you select the ALV grid display and save the setting.
The SAP List Viewer (ALV grid display) is a tool, with which the layout of the table can be individually designed. In this way, for example, you can display additional columns and calculate totals and subtotals. You can even save a layout variant. • Printout of the List Start the printout using the pushbutton in the standard toolbar.
2005/Q4
© 2005 SAP AG. All rights reserved.
83
Unit 2: Navigation
TAW10_1
•
Downloading the List The list download can also be started using the %pc command which has to be entered in the command field.
As a rule, the application programmer stores a download pushbutton in the application toolbar, as long as downloading the list is planned. The download can also be started at all times via the menu bar entry List → Export → Local file. Alternatively, you can also use the menu bar entry System → List → Save → Local file. Hint: Not all lists in the SAP system use the complete function of the SAP List Viewer. Other lists, by comparison, provide special functions, which go far beyond the functional scope of theSAP List Viewer.
Appendix: The Where-Used List
A good demonstration is the where-used list for an authorization object. In the Repository Information System, transaction SE84, the authorization objects are displayed under Other objects. You make your selection on the authorization object S_USER_PRO. You can keep the where-used list on the individual record view. Depending on the selection, the programs or transactions are displayed, in which an authorization check on the object is programmed. The where-used list is a basic navigation technique, which every SAP user should know, even if it is not needed every day. As long as this function has been implemented in the application transaction, you can find out the use of a program element, for example, a data field in tables or structures.
84
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
Figure 43: Calling up a where-used list for a data element (appendix)
2005/Q4
© 2005 SAP AG. All rights reserved.
85
Unit 2: Navigation
TAW10_1
86
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
67
Exercise 2: Selecting Functions, Searching and Filtering Data
Exercise Duration: 30 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Familiarize yourself with various ways of calling functions and navigating in the system
Business Example
You want to call functions.
System Data
System: Client: User ID: Password: the relevant user. Set up instructions: The training system assigned to you (such as I30) The client assigned to you (such as 802) The user name you have been given (such as SAPTEC-##) The password that you have given the participants for None
Task 1: Various Ways of Calling Up the User Overview
Who is currently logged on to the training system? 1. Call the transaction for displaying a list of users who are logged on. Select from the SAP standard menu Tools → Administration → Monitor → System Monitoring → User Overview. Quit the user overview by using either the F3 key or the Back button in the standard toolbar. Now enter sm04 in the command field on the SAP Easy Access screen. This takes you directly to the user overview. Enter transaction SM04 as the start transaction, so that it is always called up according to the logon.
2.
3.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
87
Unit 2: Navigation
TAW10_1
Task 2: Creating a Favorites Menu
Save often-used transactions in a favorites menu. 1. Expand the SAP menu to the user overview: Tools → Administration → Monitor → System Monitoring → User Overview. Highlight the transaction entry with the mouse. Then select Favorites → Addin the menu bar. The transaction is saved in the favorites' area. Add the following transactions to the favorites menu without expanding previously in the SAP menu: RSPFPAR, SEARCH_SAP_MENU, SEARCH_USER_MENU Can you distinguish between favorites' entries by the method used to insert them? Create a folder with the title Search Options in which you can store both search transactions. Find out how often and where in the SAP menu the transaction for the user overview is stored. Transaction SM04 SM04 SM04 Path in the SAP menu
2.
3. 4. 5.
Task 3: Using F1 and F4 Help
You can gain additional information on ABAP objects using the F1 and F4 helps. 1. Find out which system table the transaction codes of your SAP system are stored in! To do this, use the dialog input field to enter a start transaction in the SAP Easy Access menu settings. (Menu bar → Extras → Set start transaction) You already know transaction SM04. Are there other transactions whose technical name also begins with “SMO”? Research this in the TSTC table with the help of the Data Browser, transaction SE16.
2.
Task 4: Searching for Data Records
You should search for a dataset directly. For example, you want to list certain authorization profiles delivered by SAP. 1. In the USR10 table, search for all profiles delivered by SAP. Continued on next page
88
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
Task 5: Filtering Data (Optional)
You want to subsequently restrict or filter a large number of hits in the list display. 1. 2. In the USR10 table, display all of the composite profiles delivered by SAP that have been changed since 1999. Filter the data in such a way that only the profiles from the year 2000 are shown.
Task 6: Where-Used List for a Data Element (Optional)
You want to research which tables and structure fields a certain data element can be found in. 1. In which tables and structures is the data element P_Action found? Begin your search in the Repository Information System, transaction SE84.
2005/Q4
© 2005 SAP AG. All rights reserved.
89
Unit 2: Navigation
TAW10_1
Solution 2: Selecting Functions, Searching and Filtering Data
Task 1: Various Ways of Calling Up the User Overview
Who is currently logged on to the training system? 1. Call the transaction for displaying a list of users who are logged on. Select from the SAP standard menu Tools → Administration → Monitor → System Monitoring → User Overview. a) 2. See exercise for solution Quit the user overview by using either the F3 key or the Back button in the standard toolbar. Now enter sm04 in the command field on the SAP Easy Access screen. This takes you directly to the user overview. a) 3. See exercise for solution Enter transaction SM04 as the start transaction, so that it is always called up according to the logon. a) Call up the following functions in the menu bar: Extras → Set start transaction. In the following dialog box, enter the technical name of the start transaction you want. Then save your entry.
Task 2: Creating a Favorites Menu
Save often-used transactions in a favorites menu. 1. Expand the SAP menu to the user overview: Tools → Administration → Monitor → System Monitoring → User Overview. Highlight the transaction entry with the mouse. Then select Favorites → Addin the menu bar. The transaction is saved in the favorites' area. a) See exercise text. Hint: Alternatively, you can use Drag&Drop or the context menu to copy transactions into the favorites' area. The context menu is opened by a right-hand mouse click.
Continued on next page
90
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
2.
Add the following transactions to the favorites menu without expanding previously in the SAP menu: RSPFPAR, SEARCH_SAP_MENU, SEARCH_USER_MENU a) Then select Favorites → Insert transactionin the menu bar. Enter the desired transaction in the dialog box and save the data. This process must be executed for every transaction individually. Yes, when inserting with previous selection in the menu, a part of the path information of the menu access is stored as a favorites text.
3.
Can you distinguish between favorites' entries by the method used to insert them? a)
4.
Create a folder with the title Search Options in which you can store both search transactions. a) Choose Favorites → Insert file. Name the file Search Options. Then, drag both search transactions into the file using the mouse.
5.
Find out how often and where in the SAP menu the transaction for the user overview is stored. Transaction SM04 SM04 SM04 a) Start the search transaction SEARCH_SAP_MENU. In the dialog box, enter SM04 and start the search. Transaction SM04 is stored a total of three times in the SAP menu. In the same way, you can now search in the user menu. Transaction SM04 SM04 SM04 Path in the SAP menu Tools → Administration → Monitor → System Monitoring → User Overview Tools → Administration → Monitor → Performance → Exceptions/User → Active User → Local User Tools → CCMS → Control/Monitoring → Performance → Exceptions/User → Active User → Local User Path in the SAP menu
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
91
Unit 2: Navigation
TAW10_1
Task 3: Using F1 and F4 Help
You can gain additional information on ABAP objects using the F1 and F4 helps. 1. Find out which system table the transaction codes of your SAP system are stored in! To do this, use the dialog input field to enter a start transaction in the SAP Easy Access menu settings. (Menu bar → Extras → Set start transaction) a) You can get this information by calling up the F1 help in the dialog box to enter the start transaction. Then branch to the technical information. The table is called TSTC.
2.
You already know transaction SM04. Are there other transactions whose technical name also begins with “SMO”? Research this in the TSTC table with the help of the Data Browser, transaction SE16. a) Start transaction SE16. Enter TSTC as the table name. Start the display of contents using function key F7. In the input field TCODE type in “SM0*” and call up the F4 help. You will find two other hits apart from SM04. SM01 and SM02
Task 4: Searching for Data Records
You should search for a dataset directly. For example, you want to list certain authorization profiles delivered by SAP. 1. In the USR10 table, search for all profiles delivered by SAP. a) Start transaction SE16 and display the USR10 table. The (last) processor is shown in the MODBE field. Enter SAP* and DDIC there as multiple selection on single values. Display the number of entries by activating the press button Number of Entries. You will find several hundred entries. Hint: The display of the number of hits is mostly limited to a certain value, for example, a maximum of 250 or 500 hits. If you want to display more entries, increase the value in the Maximum no. of hits field.
Continued on next page
92
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Advanced Navigation in the SAP GUI
Task 5: Filtering Data (Optional)
You want to subsequently restrict or filter a large number of hits in the list display. 1. In the USR10 table, display all of the composite profiles delivered by SAP that have been changed since 1999. a) Start transaction SE16. Call up the user parameters from the application function list; alternatively, you can also use the F6 function key. On the Data Browser tab page, activate the ALV grid display. Save this setting. Now call up the USR10 table. Carry out a multiple selection on the changers DDIC and SAP*. In the Type field, enter “C” for “Composite Profile” and display all associated data records. Highlight the header line of the MODDA column. Then set a filter over this key in the application function list. In the date field, column, use the enter the date 1.1.2000 as the lower limit. This alone would only search for profiles from 1.1.2000. Therefore, set a selection operator. Call up the selection options using F2 key. Select the operator greater than or equal. Now you see only the profiles, which have been changed since 2000. Typically, you see at least both profiles SAP_ALL and SAP_NEW.
2.
Filter the data in such a way that only the profiles from the year 2000 are shown. a)
Task 6: Where-Used List for a Data Element (Optional)
You want to research which tables and structure fields a certain data element can be found in. 1. In which tables and structures is the data element P_Action found? Begin your search in the Repository Information System, transaction SE84. a) Start transaction SE84. Use a mouse click to open the ABAP Dictionary file. Double-click the entry Data elements. A selection screen appears on the right-hand side of the screen. In the Data element field, enter key or function key F8. In P_Action and start the search using the the hit list, select the single entry and activate the Display icon. Start the where-used list using Utilities → Where-Used List. Make your selection using table fields and structure fields. You will get exactly one hit. The data element P_Action is used in the AUTHB structure.
2005/Q4
© 2005 SAP AG. All rights reserved.
93
Unit 2: Navigation
TAW10_1
Lesson Summary
You should now be able to: • Use various methods to start SAP system functions • Create a list of favorites • Use the help functions • Carry out complex, selective searches • Sort and filter listed data • Execute a where-used list • Describe the standard menus System and Help.
Related Information
• Online documentation: You can find extended help for SAP Easy Access under Help → Application help.
94
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Appendix - Personalizing the User Interface
Lesson:
74
Appendix - Personalizing the User Interface
Lesson Duration: 0 Minutes
Lesson Overview
During this lesson, you will learn about various options for personalizing the appearance of the SAP GUI.
Lesson Objectives
After completing this lesson, you will be able to: • Use the various options for personalizing the SAP system
There are many options available for personalizing the system and the appearance of the front end. You need to be aware which settings depend on the front end and which depend on the user. Generally speaking, everything you can set up without user logon is a change of the local layout and thus a personalization in the SAP GUI on the front end PC. All other activities (such as creating a favorites list, entering the start transaction) that become possible after logging on, are user specific.
Business Example
You want to personalize your access to SAP systems.
Methods for Personalizing the SAP GUI
End users have several personalization options at their disposal. Some are described here. You can use Extras → Settings to change the appearance of the initial screen, for example, by turning off the graphics display on the right side of the screen, or by displaying technical names (transaction codes) on the SAP Easy Access screen. In the standard toolbar, use the button Customizing of local layout:
Using the Customizing of local layout pushbutton, you can manage the input history by choosing Options... → → Local data. When the input history is active, it builds a small front end database that contains the last n number of entries made in input fields in transactions. You can define the value of “n” yourself. These entries are then provided as input help for fields that are appropriately declared. There is a certain delay for the entries in the input history. You can minimize this delay by choosing Options... → Local Data → History → Immediately.
2005/Q4
© 2005 SAP AG. All rights reserved.
95
Unit 2: Navigation
TAW10_1
The Options... also enable you to set the speed of quick info, and to display system messages in dialog boxes (Options... → Messages ). Various other aids and settings are available here, for instance, you can choose a color scheme for your GUI. Demonstrate the options mentioned. Show the class how to display system messages in dialog boxes (popups). This setting comes up again in one of the exercises.
Note: Under Customizing of local layout, you can also choose New Visual Design... → General to have the option of changing the font size in your SAP GUI window. However, you will need to close the SAP Logon program, call it up and log on to the system again before your changes to the settings take effect.
Figure 44: Two of the many personalization options
96
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Appendix - Personalizing the User Interface
You can set personal standard values using System → User Profile → Own Data. You can do this on the tab pages Address, Defaults, and Parameters. Hint: Use parameters to fill frequently-used input fields with default values. The prerequisite for you to be able to do this is that the input field has been assigned a parameter ID. To find the parameter ID, select the input field for which you want to define a default value and choose the F1 help, followed by the Technical Information pushbutton. This calls up a dialog box that displays the corresponding parameter ID under Field data (as long as a parameter ID is assigned to the field). Enter this parameter ID XUS, in the Parameters tab page in your user data, and assign a value to it, in this case, your user name. The result of this is that all fields with XUS as their parameter ID now have the value you entered as a default.
System table TPARA contains all parameter IDs.
The favorites list on the SAP Easy Access screen and the status bar display variants provide additional personalization options. Hint: Use the information displayed in the status bar on the bottom right edge of the GUI window. There, you can, for example, always display the transaction code of the transaction that is currently being executed.
2005/Q4
© 2005 SAP AG. All rights reserved.
97
Unit 2: Navigation
TAW10_1
98
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Appendix - Personalizing the User Interface
77
Exercise 3: Appendix - Personalizing the User Interface
Exercise Duration: 10 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Using basic personalization options.
Business Example
You want to personalize your interface, that is, you want to adapt it to your requirements.
System Data
System: Client: User ID: as SAPTEC-##) Password: the relevant user. Set up instructions: The training system assigned to you (such as I30) The client assigned to you (such as 802) The user name that you have given the participants (such The password that you have given the participants for None
Task: Easy Personalization Options
Carry out some simple adaptations to your front end. 1. Choose the Customizing of local layout pushbutton and activate Quick Cut and Paste function. Now test this function on some fields in your User Profile (SU3). You can then use the same method to deactivate this function. Display the transaction code of the active transaction on the status bar.
2.
2005/Q4
© 2005 SAP AG. All rights reserved.
99
Unit 2: Navigation
TAW10_1
Solution 3: Appendix - Personalizing the User Interface
Task: Easy Personalization Options
Carry out some simple adaptations to your front end. 1. Choose the Customizing of local layout pushbutton and activate Quick Cut and Paste function. Now test this function on some fields in your User Profile (SU3). You can then use the same method to deactivate this function. a) 2. Press the layout menu pushbutton and choose Quick Cut and Paste. An explanation of how to use this function appears in the status bar. Choose the button for selecting the display variant in the status bar and select Transaction. The transaction code of every transaction that you now call is displayed in the status bar of this session.
Display the transaction code of the active transaction on the status bar. a)
100
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Appendix - Personalizing the User Interface
Lesson Summary
You should now be able to: • Use the various options for personalizing the SAP system
Related Information
• You can find additional information in the online documentation, in the “Getting Started” section.
2005/Q4
© 2005 SAP AG. All rights reserved.
101
Unit Summary
TAW10_1
Unit Summary
You should now be able to: • Log on to the system successfully • List some variants of the SAP GUI • Name and use elements of a SAP GUI screen • Log off from the system successfully • Use various methods to start SAP system functions • Create a list of favorites • Use the help functions • Carry out complex, selective searches • Sort and filter listed data • Execute a where-used list • Describe the standard menus System and Help. • Use the various options for personalizing the SAP system
102
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Test Your Knowledge
81
Test Your Knowledge
1. You can only work in one window (session) at a time in an SAP system.
Determine whether this statement is true or false.
□ □ 2.
True False
Which of the following statements accurately describe a client in an SAP system?
Choose the correct answer(s).
□ □ □ □ 3.
A B C D
A client represents a completely independent business entity. A client has its own database. A client corresponds to a customer. A client may represent an entire company.
The following strings are valid entries in the command field:
Choose the correct answer(s).
□ □ □ □ □ □ 4.
A B C D E F
/nend /nex ?SM04 /nsm04 From SAP Easy Access: SM04 From SAP Easy Access: search_sap_menu
The following personalization options are available in the SAP GUI:
Choose the correct answer(s).
□ □ □ □ □ □
A B C D E F
You can change the font size (within limits) in the SAP GUI You can have system messages displayed in a dialog box You can change the size of input fields You can suppress the display of pictures in the SAP GUI Every user can display a picture of his or her choice on the SAP Easy Access screen You can use a personal input history on your front end
2005/Q4
© 2005 SAP AG. All rights reserved.
103
Test Your Knowledge
TAW10_1
82
Answers
1. You can only work in one window (session) at a time in an SAP system. Answer: False You can work in up to 16 windows (sessions) simultaneously per logon (as of SAP Web AS 6.20). 2. Which of the following statements accurately describe a client in an SAP system? Answer: A, D The data for all clients in an SAP system is stored within a single common database. This data is nevertheless divided by client so that different companies can be administered and controlled in different clients. A client is “not” a customer within an SAP system. 3. The following strings are valid entries in the command field: Answer: A, B, D, E, F You can enter valid transaction codes directly on the SAP Easy Access screen. If you are in another function, you need to enter /n in front of the transaction code. /nend and /nex are two different logoff options. ?SM04 is not a valid entry. search_sap_menu is a valid entry; it creates a search screen for entries in the SAP menu. 4. The following personalization options are available in the SAP GUI: Answer: A, B, D, F Numerous personalization options are available, using the Extras menu, the Customizing of local layout pushbutton, and using the status bar and Help → Settings.... End users cannot, however, change the size of input fields. You also cannot use the SAP GUI to display a screen of your choice on the SAP Easy Access screen.
104
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 3
83
The System Kernel
For more information, see the introductory instructor notes in the lesson.
Unit Overview
This unit gives you a detailed insight into how the SAP system processes user requests – from SAP GUI via the SAP Web Application Server to the database and back to SAP GUI. The various process types and interfaces of the SAP Web Application Server are introduced and their significance is explained.
Unit Objectives
After completing this unit, you will be able to: • • • • • • • • Outline simple client/server configurations Name the most important processes on an SAP Web Application Server Define the term instance and recognize the characteristics of a central instance Describe the processing flow for user requests in SAP systems Outline the processing flow for a dialog step in the SAP system Describe the concept of work process multiplexing Describe how the SAP system communicates with the database List the advantages of open SQL statements
Unit Contents
Lesson: Principal Architecture of the SAP Web Application Server ......... 107 Exercise 4: Structure of an Instance ......................................... 131 Lesson: Dialog Processing in the SAP System ................................. 136 Exercise 5: Dialog Processing ................................................ 141
2005/Q4
© 2005 SAP AG. All rights reserved.
105
Unit 3: The System Kernel
TAW10_1
Lesson: Communication with the Database..................................... 144
106
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
Lesson:
84
Principal Architecture of the SAP Web Application Server
Lesson Duration: 75 Minutes
Lesson Overview
This lesson introduces the principal architecture of SAP systems. Based on simple client/server configurations, the individual processes of the SAP Web Application Server are introduced and the term of the SAP instance is defined. Following that, you will get an overview of how user requests are processed in SAP systems. This lesson concludes with an overview of the different installation options of an SAP Web AS.
Lesson Objectives
After completing this lesson, you will be able to: • • • • Outline simple client/server configurations Name the most important processes on an SAP Web Application Server Define the term instance and recognize the characteristics of a central instance Describe the processing flow for user requests in SAP systems
The lesson is intended as an introduction to the processes on an SAP Web Application Server. To clarify the processes, you may find it helpful to configure an SAP system on a pin-board using prepared labels (you can find further information on this in the instructor guide area at http://intranet.sap.com/epf-adm, in the Additional Material area). First you could, for example, set up a three-tier client/server architecture with several (ABAP) instances on different hosts. You can then assign an ABAP dispatcher to each instance. Then you can give an overview of all the work process types and the services with the tasks they perform. You could let the participants decide which processes to configure on which instance. Once you have completed the configuration on the pin board, you can discuss the configuration that the participants have chosen (for example, taking downtime prevention into account), demonstrating the advantages of configuring a central instance (if the participants have not already configured the system in this way). This scenario can then be transferred to the Java stack and the central service instance can be explained.
Business Example
In the course of implementing an SAP system, you need to establish the architecture of SAP systems and how you are going to distribute the required SAP system processes among the available hardware.
2005/Q4
© 2005 SAP AG. All rights reserved.
107
Unit 3: The System Kernel
TAW10_1
Introduction
SAP systems are used for mapping business processes or business applications. These applications should be implemented independent of the hardware environment used (operating system, database) to the greatest extent possible. For this, the SAP Web Application Server provides two runtime environments: the ABAP runtime environment and (as of SAP Web AS 6.20) also a Java runtime environment. ABAP (Advanced Business Application Programming) is a programming language developed by SAP. Many business applications of an SAP system are written in ABAP. ABAP has been optimized for developing highly-scalable business applications. Customers can use the ABAP Workbench for developing completely new applications as well as enhancing and modifying SAP standard applications. In doing so, the entire, mighty infrastructure of the SAP Web AS can be used, which also supports the creation of the most complex applications by large groups of developers. The SAP Web Application Server ABAP provides the runtime environment of the programs written in ABAP. Since SAP Web Application Server 6.20 SAP not only provides an ABAP runtime environment for ABAP but also a runtime environment for Java programs. The integrated Java Web application server is a Java 2 Enterprise Edition (J2EE) application server called SAP Web AS Java. The Java programming language was first introduced by Sun Microsystems Inc.™ in 1995. Java is an object-oriented and platform-independent programming language that has spread across many areas. The Java concept enables the development of a large range of different application types - from classical applications to applets used in websites to client/server applications. Java 2 Platform Enterprise Edition (J2EE) is a manufacturer’s standard for a whole range of software components that are primarily created in the Java programming language. Sun uses the J2EE compatibility test to ensure that the specifications of Java 2 Enterprise Edition are observed. Hint: The purpose of this specification is to have a generally accepted framework for using modular components to develop distributed, multi-level applications. With the J2EE specification, Sun wants to ensure that conform Web applications run on all J2EE compatible servers. According to the J2EE specification the application logic is packaged in components, Enterprise Java Beans (EJB). They represent Java program components. A container implicitly provides the components with the services of the runtime environment.
108
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
The SAP Web Application Server 6.40 contains a 1.3 compliant J2EE Server.
Client and Server: Terminology Definition
The participants need to be able to differentiate between hardware-oriented and software-oriented views. To ensure that the participants have completely understood this section, you could, at the end, ask if the sentence “Several application servers can run on one application server” makes sense, and what exactly it means. Before we discuss various client/server configurations in the context of SAP systems, we first need to define the concepts client and server. There are basically two ways of doing this. In the hardware-oriented view, the term server means the central server in a network that provides data, memory, and resources for the workstations (clients). In the software-oriented view, client and server are both defined at the process level (service). A service in this context is a service provided by a software component. This software component can consist of a process (such as a work process) or a group of processes (such as a SAP Web Application Server) and is then called a server for that service. Software components that use this service are called clients. At the same time, clients can also be servers for other specific services. The following graphic clarifies the two approaches to the definitions.
2005/Q4
© 2005 SAP AG. All rights reserved.
109
Unit 3: The System Kernel
TAW10_1
Figure 45: Hardware-oriented View and Software-oriented View
In the context of SAP systems, the terms client and server are generally used as defined in the software-oriented view.
Client/Server Configuration for SAP Systems
The participants should get to know the various configuration options; specifically, they should understand the uses of a special hardware layer for application processes (scalability, logon load balancing). You may also want to include a brief summary of the concept of logon groups (in the ABAP environment). The following processes are required for operating business application software: • • • Presentation processes (for example, for displaying screens) Application processes (for example, for executing application programs) Database processes (for example, for managing and organizing database data)
When you are configuring an SAP system, you need to decide how you are going to distribute the required processes among the available hardware. There are various ways of doing this, some of which are described in more detail below. Configurations
110
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
are either single-level or multilevel, depending on the number of computer layers used (see the following graphic). The SAP R/3 system is an example of business application software. • In single-tier configurations, all processing tasks (database, application and presentation processes) are performed by one computer. This is classic mainframe processing. Two-tier configurations are usually implemented using special presentation servers that are responsible solely for formatting the graphical interface. For example, many SAP users run SAP GUI processes on Windows PCs. In a three-tier configuration, each layer runs on its own host. Many different application servers can simultaneously work with the data of a database server.
•
•
Figure 46: Simple Client/Server Configurations
Single-tier configurations are generally used for tests and demonstrations (for example, an SAP system on a laptop). If many users want to work on a system configured in this way, then the extra hardware costs for each additional user become greater than the costs associated with implementing additional hardware levels (for example, moving the presentation processes to other hosts). The two-tier configuration with distributed presentation processes (as shown in the previous graphic) can maintain good performance for a significantly higher number of users, without substantially increasing the hardware costs. The load resulting from the presentation processes is distributed to the various front-end computers and so does not influence the performance of the database host.
2005/Q4
© 2005 SAP AG. All rights reserved.
111
Unit 3: The System Kernel
TAW10_1
However, if the number of users exceeds a certain upper limit, the central host, on which both application and database processes run, risks becoming a bottleneck. To prevent this, you can improve the performance of the SAP system by distributing the application-layer processes to several hosts. Another advantage of adding a hardware layer specifically for application processes is that it facilitates scalability. If the number of SAP users in a system increases over time, negatively affecting system performance, then this problem can, in most cases, be solved simply by adding another host for application processes. An alternative two-tier configuration is to install powerful desktop systems and to use these for presentation and applications (two-tier client/server). These configurations are especially suited to applications with high processor demands (for example, simulations or for software developers), but are not implemented in the SAP environment, other than for test purposes, due to the additional administration required. In the mySAP Business Suite environment, more complex client/server configurations consisting of more than three tiers are both theoretically possible and used in practice. An additional level could be a web server, for example. At this point you could show the participants which configuration is used for the course (normally a two-tier configuration with distributed presentation). To do this, use transaction SM51 followed by the menu path System → Status, and the message that the SAP GUI process is running locally on the front end, for example. You could also discuss the uses of logon groups in the ABAP stack at this point. It is also helpful for participants if you draw their attention to the following fact: if there are several application servers (from the software point of view) available, then the system (or rather, the ABAP message server, which the participants do not yet know about) establishes at logon which of these servers the user is logged on to. The user remains logged on to the server selected until he/she logs off. According to the ABAP programming model, multi-layer architectures can be implemented for enterprise applications, whereby the application logic is executed on the (ABAP) application server.
112
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
Figure 47: Architecture of ABAP Applications
The J2EE application server processes the queries of the clients, executes the application logic and returns the results to the clients. The application data is accessed at database level. The application logic is, for example, implemented in the form of ABAP programs or function modules, the server-side presentation logic consists of dynpros/screens (dynamic programs, consisting of a screen and its flow logic) or business server pages. Hint: For developing, designing and implementing Web applications the SAP Web Application Server offers a page-based programming model with server-side scripting analogous to the well-known server-page technology, Business Server Pages (BSP). Server-side scripting allows direct access to all elements on the application server (for example, function modules, database tables, ABAP objects,...). Here, the presentation is separated from the business logic. This enables the use of alternative front-end technologies.
2005/Q4
© 2005 SAP AG. All rights reserved.
113
Unit 3: The System Kernel
TAW10_1
Figure 48: Architecture of Java Applications
According to the J2EE specifications, three-level client/server architectures for business applications can be implemented, the core of which is the J2EE Application Server (see graphic “Architecture of J2EE applications”). At this stage, point out that for J2EE applications the server-side presentation is strictly separated from the application logic. This is a difference to “classical” ABAP programming, where the table in which the input values are written (application logic) can be specified at the same time as definition of the input fields of the screens (presentation logic). The J2EE application server processes the queries of the clients, executes the application logic and returns the results to the clients. The application data is accessed at database level. The application logic is implemented in the form of Enterprise Java Beans. These are executed in a EJB Container, which is part of the J2EE Application Server. The communication between the client and the J2EE server is based on Web standards such as HTTP, HTML and XML. The J2EE-Server uses Java Server Pages (JSP) and Java Servlets, to generate HTML pages and XML data. Java Server Pages and Java Servlets are executed in a Web Container, which in turn is part of the J2EE Application Server. Within the HTML pages that are sent to the Web browser, Java applets can be integrated; these applets are executed in the browser.
114
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
Java Server Pages (JSP) is a technology developed by Sun, which is basically used for the simple dynamic generation of HTML and XML outputs of a Web server. The technology makes it possible to integrate Java code and special JSP actions into static content. That has the advantage that for this technology, the logic can be implemented independent of the design. Java Server Pages are converted to Java source code by means of a special JSP compiler. The Java compiler then converts this source code, which corresponds to a Java servlet, to byte code.
SAP Web Application Server Processes
The SAP runtime system consists of a number of parallel processes that work together. The following graphic illustrates the most important processes. Here, you can distinguish between the runtime environment for ABAP and the runtime environment for Java.
Figure 49: SAP Web Application Server Processes
2005/Q4
© 2005 SAP AG. All rights reserved.
115
Unit 3: The System Kernel
TAW10_1
In the ABAP environment, these processes on every application server include the dispatcher as well as a number of work processes depending on the hardware resources: • • The ABAP dispatcher distributes the user requests to ABAP work processes. Dialog work processes fulfill all requests for the execution of dialog steps triggered by an active user. Every dispatcher requires at least two dialog work processes. Spool work processes pass sequential data flows on to printers. Every SAP system requires at least one spool work process, you can also have more than one spool work process per dispatcher. This spool work process is also required if there is no printing in the system, for example, to store lists generated in the context of background process in TemSe.
•
•
•
Update work processes execute update requests. Similarly to spool work processes, you need at least one update work process per SAP system, and you can have more than one per dispatcher. Background work processes execute programs that run without interacting with the user. You need at least two background work processes for each SAP system. You can configure more than one background work process for each dispatcher. For the “normal” operation of the SAP system, a single background process would suffice. However, for an upgrade or during an import of ABAP transport requests, two background work processes are required.
•
The enqueue work process administers the lock table in the shared memory. The lock table contains the logical database locks of the ABAP stack of the SAP system. Only one enqueue work process is needed for each system. If more than one enqueue work process has to be configured, this should be configured on the same instance as the first enqueue work process as both work processes have to access the same lock table.
116
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
To sum it up: The dispatcher of an ABAP instance manages different types of work processes: dialog, update, background, lock and spool work processes. These work processes take on appropriate tasks when executing the business procedures in the SAP system. Hint: The type and number of the work processes to be started for each instance is configured using the SAP system profile parameter. The following table summarizes the relevant profile parameters. Type DIA UPD UPD2 BGD SPO ENQ Use Responsible for dialog requests Responsible for update Exclusively responsible for less time-critical update (optional) Executes background jobs Processes output requests Responsible for locks Profile parameter rdisp/wp_no_dia rdisp/wp_no_vb rdisp/wp_no_vb2 rdisp/wp_no_btc rdisp/wp_no_spo rdisp/wp_no_enq
Point out that this is only a selection of relevant dispatcher parameters. For lock mechanisms, for example, there are dedicated enque/* parameters.
2005/Q4
© 2005 SAP AG. All rights reserved.
117
Unit 3: The System Kernel
TAW10_1
In addition to these work processes, the (ABAP) runtime system provides additional services (these are not work processes) for internal and external communication: • The message server (MS) handles the communication between the distributed dispatchers within the ABAP stack of an SAP system, thereby enabling scalability of several parallel application servers. The message server is configured only once per SAP system. The gateway server (GW) enables communication between SAP systems, or between SAP systems and external application systems. There is one per dispatcher. The Internet Communication Manager (ICM) enables SAP systems to communicate directly with the Internet. The ICM receives requests from the Internet and forwards them to the SAP system for processing. In doing so, it recognizes whether the request is a call of a business server page or a Java application and forwards this request to the ABAP runtime environment or the Java runtime environment. It can also direct HTTP requests from an SAP system to a Web server and send the response back to the SAP system. You can configure a maximum of one ICM process per application server (software-based view).
•
•
118
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
The following processes exist in the Java environment: • • The Java dispatcher distributes new incoming Java requests to the Java server processes. The Java server process executes the Java applications. The server processes are implemented in the form of a Multi Threaded Server and can (in contrast to the ABAP work processes) process several queries in parallel. It is for this reason that generally there are a lot less Java server processes configured per Java dispatcher than work processes are configured for each ABAP dispatcher. Due to port reasons a maximum of 16 Java server processes can be configured for each instance. • • The Java message service manages a list of Java dispatchers and server processes. It is responsible for the communication within the Java runtime environment. The Java enqueue service manages logical locks that are set by the executed Java application program in a server process. Just like in the ABAP environment, every developer is responsible for requesting locks from the enqueue service and releasing them in the Java environment.
•
The SAP Java Connector (JCo, not illustrated in the graphic) is responsible for the communication between the ABAP stack and the Java stack; it enables calls of the ABAP stack from the Java stack as well as vice versa. Note: You can use the transaction SM50 (work process overview) to display an overview of the ABAP work processes on the SAP Web Application Server that you are logged on to; you can also display this overview by choosing Tools → Administration → Monitor → System Monitoring → Process Overview on the SAP Easy Access Screen. You can get an overview of started Java processes (Java dispatcher and Java server processes as well as SDM) in the same way, via the system information of the Java runtime environment (http://:, for example http://twdfxxxx.wdf.sap.corp:50000→ System Information)
2005/Q4
© 2005 SAP AG. All rights reserved.
119
Unit 3: The System Kernel
TAW10_1
At this point you can demonstrate the current configuration of the local ABAP instance using transaction SM50. You could also, if appropriate, give a brief explanation of the (optional) V2 update work process. In the same way you can also demonstrate the configuration of the Java instance (optional). You require an appropriately authorized user in the Java stack to display the system information. More precisely: On the client to which the SAPJSF user created during the installation points, there must be a user, which has been assigned the SAP_J2EE_ADMIN role in transaction SU01 (This role only exists for an SAP system that has an ABAP stack and a Java stack). For the SAPTEC course, the user javauser with password java has been set up for the demonstration.
The Instance
The section begins with the definition of the term instance for the SAP Web AS ABAP. Clearly define the term central instance. Make sure participants have understood this term before extending the instance to the SAPWeb AS ABAP+Java environment. An instance is an administrative unit that combines SAP system components providing one or more services. The services provided by an instance are started or stopped together. You use a common instance profile to set parameters for all components of an instance. Each instance has its own buffer areas. Hint: The terms (SAP) instance and Application Server are often used as synonyms.
The Instance in the ABAP Environment
The application layer of an SAP system (from the software point of view) generally consists of several instances; a dispatcher, work processes and the services listed above are configured on each of these instances. If, however, the application layer of an SAP system consists of a single instance, then all processes required to operate the SAP system must be configured on this instance. A system with this configuration is known as a central system. The graphic “The instance” shows all the processes that are required for error-free operation of an SAP system, collected on one instance. This instance is distinguished from all other instances of the SAP system and is also called central instance. This
120
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
graphic also shows other configured instances. These instances, which provide specific services, generally run on separate servers, but can also run on the same server, if required. The services that an application server can provide are determined by the type of work processes it has. An application server can then take on several roles, for example, as a dialog server and simultaneously as a background server, if it provides several dialog work processes and at least one background work process.
Figure 50: The Instance (using the ABAP Runtime Environment)
At this point you could show the participants transaction SM51 and briefly discuss the SAP Web Application Servers available, or, if appropriate, you could draw the participants’ attention to the link from SM51 to SM04 and SM50. The ABAP message server provides the SAP Web Application Server with a central message service for internal communication (for example, for starting updates, requesting and removing locks, triggering background requests). The (ABAP) dispatchers for the individual SAP Web Application Server communicate via the (ABAP) message server that is installed once in each SAP system (it is configured in the system profile files).
2005/Q4
© 2005 SAP AG. All rights reserved.
121
Unit 3: The System Kernel
TAW10_1
Presentation servers use the (ABAP) message server to log on to an SAP Web Application Server. This means that you can use the message server performance database for automatic load distribution. This load distribution, which takes place during the logon procedure, is also known as logon load balancing. Note: You can find an overview of all instances configured in your SAP system in the SAP Easy Access menu under Tools → Administration → Monitor → System Monitoring → SAP Server (Transaction SM51). From here, pushbutton also provide links to the user overview (transaction SM04) and to the work process overview (transaction SM50) for the respective SAP Web Application Server.
The Instance in the ABAP+Java Environment
After the instance in the ABAP environment has been explained in the preceding chapter, this chapter now describes the integrated version of the SAP Web Application Server with ABAP and Java runtime environment. In this case, the term instance refers to ABAP processes as well as Java processes. The instance includes the ABAP dispatcher and its work processes and the Internet Communication Manager as well as the Java dispatcher with its Java server processes. Note: The integrated version of the SAP Web Application Server is also called “Add-In Installation”. The following graphics illustrate the architecture of such a system.
122
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
Figure 51: The Instance in SAP Web AS ABAP+Java
The following graphic shows the architecture of an SAP system with several instances as well as ABAP and Java runtime environment.
2005/Q4
© 2005 SAP AG. All rights reserved.
123
Unit 3: The System Kernel
TAW10_1
Figure 52: Structure of an SAP Web Application Server with Several Instances
In an SAP Web AS ABAP+Java with several instances, each of the integrated instances of the SAP Web AS can contain the (ABAP) dispatcher and its work processes as well as the Java dispatcher with its server processes. One of the instances is generally installed as a (ABAP) central instance, so it also contains the enqueue work process. Alternatively, the system can be set up without the central instance but with the stand-alone enqueue server. Furthermore, a common database contains a schema for each of the applications and data for ABAP and Java. Stress that the database of the SAP Web AS has two different schemas: The ABAP schema, which can be accessed by the ABAP work processes and the Java schema, which can be accessed by the Java processes. The ABAP and Java runtime environment communicate by means of the AP Java Connectors (JCo) between work processes and Java server processes. The Software Deployment Manager (SDM) is the standard tool with which the J2EE components are installed on SAP Web AS Java. It is part of the Java runtime environment and is always installed on the Java part of the central instance.
124
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
The central services run on one computer and form a separate instance. They consist of the message service as well as the enqueue service and represent the basis of communication and synchronization for the Java runtime environment: As background information for you: As a preparation, look at the file structure of the training system (e.g. by means of transaction AL11) • • The SAP Web AS Java is, for example, stored in directory G:\usr\sap\. The instances (ABAP+Java) are each stored in a separate directory: – Central instance: z.B. G:\usr\sap\\DVEBMGS00 – Dialog instance: z.B. G:\usr\sap\\D01 The Java part of an instance is relative to these instance directories in directory ~/j2ee The Java dispatcher and the server processes are in directory ~/j2ee/cluster in directories dispatcher and server. Note: The term cluster has grown historically and is not correctly used in the place of the directory name. In SAP Web AS 6.40, a Java cluster refers to all Java components of an SAP system. • The central services (previously SAP central services) are in the directory, for example: G:\usr\sap\\SCS07.
• •
Types of the SAP Web AS
Depending on the requirements on the SAP Web Application Server there are different possible features, depending on which installation routine is used (see the following graphic).
2005/Q4
© 2005 SAP AG. All rights reserved.
125
Unit 3: The System Kernel
TAW10_1
Figure 53: Possible Types of the SAP Web AS
Quickly point out the different installation options of the SAP Web AS. Stress that the option chosen generally depends on the SAP system to be installed. Therefore, when an enterprise portal is installed, an SAP Web AS Java is installed, whereas when an exchange infrastructure is installed, you need to install an ABAP stack as well as a Java stack. In contrast, when you install an SAP Business Information Warehouse the ABAP stack is mandatory while the Java stack is optional. The graphic only shows the minimal configuration (that is, one instance). • • • SAP Web Application Server ABAP System: Complete infrastructure in which ABAP-based applications can be developed and used. SAP Web Application Server Java System: Complete infrastructure for developing and using J2EE-based applications. SAP Web Application Server ABAP + Java System (Add-In Installation):Complete infrastructure in which ABAP-based and J2EE-based applications can be developed and used. This installation emphasizes the seamless Java ABAP integration.
126
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
One of the main characteristics of the SAP Web AS is that ABAP tables, programs and application data are stored in the ABAP schema of the database while Java data is stored in the Java schema. Here, the ABAP runtime environment can access the ABAP schema of the database, and the Java runtime environment can access the Java schema. The SAP Java Connector is used for integrating the ABAP environment and the Java environment. (JCo).
Processing User Requests in the SAP System
Clearly point out to participants who already know about the classical ABAP runtime environment that classical transactions, such as the displaying of customers by means of transaction FD03 still happen exclusively via the ABAP runtime. The existence of a Java runtime environment does not mean that precisely this function is now implemented by means of the SAP GUI as well as in a Java-based way. It always depends on the chosen function, which runtime environment (ABAP or Java) and which user interface (SAP GUI or BSP / JSP) have to be used in order to be able to access the desired function. Users can logon to the SAP system either via the SAP GUI or via a Web client (browser). When logging on via the SAP GUI, user requests are processed by the ABAP runtime environment, when logging on via a browser, processing can be done by the ABAP or the JAVA runtime environment, depending on the request.
Processing Requests by the SAP GUI
If necessary, you can also talk about the necessity of buffer synchronization and the applied procedure when you introduce the buffers and their significance. The participants should learn about the general procedure for a user request in the SAP system. In doing, only the case of an internal user (with SAP GUI) is discussed here. The integration of Internet users via the ICM is not the subject of this section. Users logon via the (ABAP) message server (load balancing) or they logon directly on the ABAP dispatcher, the work processes execute the user entries. Another task of the message server is to transfer requests in the ABAP world. The processing of a user request in the SAP system, as outlined in the graphic, involves different processes on all three layers (presentation, application and database layer):
2005/Q4
© 2005 SAP AG. All rights reserved.
127
Unit 3: The System Kernel
TAW10_1
Figure 54: Processing a User Request
Explain that this graphic is a (detailed) excerpt from the above graphic on the structure of an SAP Web AS with several instances.
The screen entries of a user are accepted by the SAP presentation program SAP GUI (SAP Graphical User Interface), converted to an internal format and forwarded to the SAP Web Application Server (software-oriented view). The (ABAP-) Dispatcher is the central process of the SAP Web Application Server ABAP. It manages the resources for the applications written in ABAP in coordination with the respective operating system. The main tasks of the ABAP dispatcher include the distribution of the transaction load to the work processes, the integration of the presentation layer and the organization of communication transactions. The processing requests are first saved in request queues, and processed according to the “first in, first out” principle. The ABAP dispatcher distributes the requests one after the other to the available work processes. Data is actually processed in the work process, although the user who created the request using the SAP GUI is not always assigned the same work
128
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
process. There is no fixed assignment of work processes to users. To process user requests it might be necessary to read data from the ABAP schema of the database or to write to it. For this, every work process is connected directly to the ABAP schema of the database. Once the process is complete, the processing result from the work process is sent via the dispatcher back to the SAP GUI. The SAP GUI interprets the received data and generates the output screen for the user with the help of the operating system on the front end computer. The buffers help to speed up processing of user requests. Data that is often read but seldom changed (for example, programs or Customizing data such as clients, currencies or company codes) can be kept as a copy of the database content in the shared memory of the application server. This means that the data does not have to be read from the database every time it is needed, but can be called very quickly from the buffer. During initialization of the SAP system, the dispatcher executes the following actions (amongst others): Read system profile parameters, start work processes, logon to the message server.
Processing Web Requests
Web requests are accepted by an Internet Communication Manager (ICM). These HTTP(S) requests can either be processed in the ABAP work process (such as BSP applications) or they can be requests for SAP Web AS Java. The ICM can use the URL to decide to where it forwards the request (if it cannot reply to the request from its cache). You can describe the processing of Web request step-by-step using the above graphic “The Instance in SAP Web AS ABAP+Java”.
If the request is for the Java runtime environment, then it is sent to the Java dispatcher that forwards it to a Java server process. If necessary, the Java server process addresses the Java schema of the database and uses the Java dispatcher process to return its reply to the Internet Communication Manager. In the end, the ICM sends the reply of the SAP system back to the requesting user.
2005/Q4
© 2005 SAP AG. All rights reserved.
129
Unit 3: The System Kernel
TAW10_1
In contrast to ABAP, where there are different types of work processes (dialog, update, background...) for different types of tasks, the Java server process offers several services simultaneously (for example, HTTP provider service, JDBC connector service, locking adapter service). Depending on the type of user request, the Java dispatcher of an instance chooses a Java server process on which “suitable” services are configured. In case of a request to the ABAP runtime environment the ICM forwards the request to the ABAP dispatcher, which treats this request like a classical request of a SAP GUI (see previous subsection). The response of the ABAP runtime environment is in turn, returned to the requesting user via the ICM. If the participants ask at this point whether several computer/port combinations have to be released for external access in case of several instances, you can refer to the SAP Web dispatcher. The distribution of the HTTP(S) requests across all instances of an SAP system happens via the SAP Web dispatcher. It is a central entry point to the SAP system from the Internet. For every incoming request it has to decide to which instance to forward it. This lesson does not cover the architecture and configuration of the SAP Web dispatcher.
130
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
103
Exercise 4: Structure of an Instance
Exercise Duration: 10 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • List important functions of transaction SM51, which displays an overview of the active instances and the work processes configured on them.
Business Example
As the system administrator, you need to have an overview of the instances and processes of your SAP system.
System Data
System: Client: User ID: as SAPTEC-##) Password: the relevant user. Set up instructions: 1. . The training system assigned to you (such as DEV) The client assigned to you (such as 100) The user name that you have given the participants (such The password that you have given the participants for
The participants must have the authorization to execute transaction SM51.
Task 1: Overview of the Instances Configured on the Training System
Use transaction SM51 to answer the following questions (Tools → Administration → Monitor → System Monitoring → SAP Servers). 1. 2. Which instance are you working in? (Hint: Instance and [SAP Web Application] Server [software oriented view] are used synonymously here) Which work process types are configured on your SAP Web Application Server?
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
131
Unit 3: The System Kernel
TAW10_1
Task 2: Research System Parameters
Find out what parameter rdisp/wp_no_dia means. What is its default value? 1. Start transaction RZ11 and display the parameter. Call up the documentation using the documentation pushbutton or function key F6.
Task 3: Research on the Internet Communication Manager
Find out about the configuration of the Internet Communication Manager on your instance. 1. Check whether the Internet Communication Manager of your SAP instance has been started. The Internet Communication Manager is started by means of parameter rdisp/start_icman. Check, which protocols have been configured for your Internet Communication Manager. Protocol Port
2.
132
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
Solution 4: Structure of an Instance
Task 1: Overview of the Instances Configured on the Training System
Use transaction SM51 to answer the following questions (Tools → Administration → Monitor → System Monitoring → SAP Servers). 1. Which instance are you working in? (Hint: Instance and [SAP Web Application] Server [software oriented view] are used synonymously here) a) The name of your instance is displayed as an entry in the Server Names column. The Host name column shows the name of the host computer on which the SAP Web Application Server is configured. If several instances are displayed in transaction SM51, then you can also find which instance you are logged on to using the menu path System → Status, followed by the Server name field. The work process types are displayed in transaction SM51, in the Type column. Please note that the Internet Communication Manager (ICM) is a service, not a work process. Alternatively, you can answer the question using transaction SM50 (if you are in transaction SM51, you can use the Processes pushbutton), which lists the work processes in detail.
2.
Which work process types are configured on your SAP Web Application Server? a)
Task 2: Research System Parameters
Find out what parameter rdisp/wp_no_dia means. What is its default value? 1. Start transaction RZ11 and display the parameter. Call up the documentation using the documentation pushbutton or function key F6. a) Call transaction RZ11 and, in the Parameter name field, enter the profile parameter (rdisp/wp_no_dia) you are looking for. Choose Display. The default value specified by the system is 2. However, your system administrator might have set another value in your SAP system (see Current value field). Now choose Documentation. You get a description of the meaning of the profile parameter (number of configured dialog work processes of the respective instance).
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
133
Unit 3: The System Kernel
TAW10_1
Task 3: Research on the Internet Communication Manager
Find out about the configuration of the Internet Communication Manager on your instance. 1. Check whether the Internet Communication Manager of your SAP instance has been started. The Internet Communication Manager is started by means of parameter rdisp/start_icman. a) 2. Start transaction RSPFPAR and select the parameter you are looking for. The process is started if the value is true.
Check, which protocols have been configured for your Internet Communication Manager. Protocol Port
a)
Start transaction SMICM. If the ICM is started, display the configured protocols using the Services button in the application toolbar or choose Goto → Parameters → Display Protocols HTTP, HTTPS and SMTP are displayed with the configured TCP ports.
134
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Principal Architecture of the SAP Web Application Server
Lesson Summary
You should now be able to: • Outline simple client/server configurations • Name the most important processes on an SAP Web Application Server • Define the term instance and recognize the characteristics of a central instance • Describe the processing flow for user requests in SAP systems
Related Information
SAP Note 39412 contains additional information on the topic of how many ABAP work processes you can and should configure.
2005/Q4
© 2005 SAP AG. All rights reserved.
135
Unit 3: The System Kernel
TAW10_1
Lesson:
108
Dialog Processing in the SAP System
Lesson Duration: 30 Minutes
Lesson Overview
In this unit, you learn how your (dialog) requests are processed by the SAP system, step-by-step. The process for a dialog transaction that consists of several screens is also outlined.
Lesson Objectives
After completing this lesson, you will be able to: • • Outline the processing flow for a dialog step in the SAP system Describe the concept of work process multiplexing
You need to explain the basic process for a dialog step to the participants (what happens, in what order, in the system when the user sees the hourglass in SAP GUI). You should emphasize that during the course of one transaction that consists of several screens, various work processes can be active for a single user. If your course also covers asynchronous updates, then you need to point out here that every work process generates an implicit Commit at the end of the dialog step. Caution: This lesson does not cover the connection to the Internet through the ICM.
Business Example
You want to be able to understand how dialog processing functions in the SAP system.
Distribution of User Requests to Dialog Work Processes
Each SAP Web Application Server has its own dispatcher. The dispatcher is the link between the work processes and the users logged on to the SAP Web Application Server (or rather, their SAP GUIs). Its tasks include distributing all the user requests it receives to the dialog work processes on the SAP Web Application Server. Every time a user sends a (dialog) request to the SAP system (resulting in the hourglass being displayed), this request is sent to the SAP Web Application Server that the user is logged on to. On the server, the request is first placed in a request queue for dialog requests. Requests in this queue are distributed by the dispatcher to available dialog work processes on a “first in, first out” (FIFO) basis.
136
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Dialog Processing in the SAP System
The dialog work process selected by the dispatcher first "rolls in" the user context (that is, the dataset that contains both the current processing status of an active program and data that characterizes the user). It then processes the user request, which may involve, for example, requesting data from the database or from the buffers in the shared memory. Once the dialog work process has processed the dialog step, the work process returns the result to the dispatcher, rolls the context back out to the shared memory, and is now available again for a new user request from the request queue. Finally, the dispatcher returns the result to SAP GUI, and the new screen is displayed for the user. Note: Memory management and the roll-in/roll-out process: The memory management system differentiates between main memory areas that are available exclusively to one particular work process, and memory areas that can be used by all work processes. The memory space used exclusively by a work process stores session-specific data that must be kept for longer than the duration of a work step. This data is automatically made available to the process at the start of a dialog step (rolled in) and saved at the end of the dialog step (rolled out). This data includes data that characterizes the user (user context), such as authorizations, administrative information, and other data for the ABAP and screen processors that has been collected in previous dialog steps for the active transaction. There are also additional memory areas for all processes in the shared memory for, among other things, the factory calendar and screen, table, and program buffers. The execution of dialog transactions is characterized by the following : • • A program dialog step is assigned to one specific dialog work process during execution. The individual dialog steps for a program consisting of several screens can be executed by different dialog work processes during program runtime. This is called work process multiplexing. A dialog work process sequentially processes dialog steps for various users and programs.
•
The following graphic illustrates this:
2005/Q4
© 2005 SAP AG. All rights reserved.
137
Unit 3: The System Kernel
TAW10_1
Figure 55: Work Process Multiplexing
Structure of a Work Process
At this point it could be helpful for the participants if you point out that all work processes are based on the same kernel file, disp+work.exe, that is, all work processes – regardless of their type – have an identical structure. As components of SAP Web Application Servers, work processes execute dialog steps for application programs. In addition to internal memory, a work process has a task handler that coordinates the actions within a work process, two software processors (see below), and a database interface. SAP application programs differentiate between user interaction and processing logic. The user actions are technically realized using screens, also called dynpros (from dynamic programs), which consist of a screen image and the underlying flow logic. The screen processor executes the screen flow logic of the application program, calls processing logic modules, and transfers field content to the processing logic. The screen flow logic itself is further divided into PBO (Process Before Output), which is processed before the screen image is sent, and PAI (Process After Input), which is
138
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Dialog Processing in the SAP System
processed after a user interaction on the screen. The PAI part of a dialog step logically belongs to the preceding screen image, while the PBO part logically belongs to the subsequent screen image (see “Work process multiplexing” graphic). The actual processing logic of application programs written in SAP's programming language, ABAP, is executed by the ABAP Interpreter. The screen processor tells the ABAP processor which subprogram needs to be executed, depending on the processing status of the screen flow logic.
Figure 56: Processing flow for dialog steps
If, during a dialog step, data needs to be exchanged with the database or the buffers, then this exchange takes place through the database interface, which enables access to database tables, ABAP programs, the ABAP Dictionary, and screens, among other things. If appropriate, you can roughly calculate, together with the participants, how many dialog processes can usefully be configured in an SAP system (taking into account the number of active users, the average processing time for a dialog step in the system and the frequency with which users send requests to the system).
2005/Q4
© 2005 SAP AG. All rights reserved.
139
Unit 3: The System Kernel
TAW10_1
140
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Dialog Processing in the SAP System
113
Exercise 5: Dialog Processing
Exercise Duration: 5 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • The participants gain an overview of the work processes configured on an instance.
Business Example
As system administrator, you want to gain an overview of the configured work processes and their loads.
System Data
System: Client: User ID: as SAPTEC-##) Password: the relevant user. Set up instructions: 1. The training system assigned to you (such as I30) The client assigned to you (such as 802) The user name that you have given the participants (such The password that you have given the participants for
The participants must have the authorization to execute transaction SM50
Task: Overview of the configured work processes
Answer the following question using transaction SM50 (menu path: Tools → Administration → Monitor → System monitoring → Process overview ): 1. 2. How many dialog work processes are there on the instance that you are logged on to? Choose Refresh several times in the process overview. Are your queries always processed by the same work process?
2005/Q4
© 2005 SAP AG. All rights reserved.
141
Unit 3: The System Kernel
TAW10_1
Solution 5: Dialog Processing
Task: Overview of the configured work processes
Answer the following question using transaction SM50 (menu path: Tools → Administration → Monitor → System monitoring → Process overview ): 1. How many dialog work processes are there on the instance that you are logged on to? a) You can find the number of dialog work processes on your instance by using transaction SM50, then counting the work processes of type “DIA”. Transaction SM50 displays the work processes on an instance. If you want to display the work processes of the entire SAP system, select transaction SM66 (here you have to make the correct settings using pushbuttons process selection and settings).
2.
Choose Refresh several times in the process overview. Are your queries always processed by the same work process? a) In transaction SM50, choose the Refresh (F8) pushbutton. Find “your” work process by finding your user name in the User column. You may find – although you might not – that your queries are processed by different work processes. Note: Be aware that in this case you are executing “complete activities” and can therefore not see work process multiplexing in action.
142
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Dialog Processing in the SAP System
Lesson Summary
You should now be able to: • Outline the processing flow for a dialog step in the SAP system • Describe the concept of work process multiplexing
2005/Q4
© 2005 SAP AG. All rights reserved.
143
Unit 3: The System Kernel
TAW10_1
Lesson:
116
Communication with the Database
Lesson Duration: 30 Minutes
Lesson Overview
SAP systems can be used with a variety of operating systems and databases made by different manufacturers. The application data in the SAP system is accessed in the ABAP stack via platform-independent ABAP programs. But the data is stored database-specifically. Hence, the database queries from the ABAP programs have to be translated into the respective dialect of the database. This is taken care of by the database interface. If in doubt, point out that this lesson explicitly covers the ABAP stack (and not the Java stack) of the SAP system. If there are any questions here, the Java stack of the SAP Web AS also provides options for platform independent development these days. Keywords: Open SQL for Java.
Lesson Objectives
After completing this lesson, you will be able to: • • Describe how the SAP system communicates with the database List the advantages of open SQL statements
Try to go into as little detail as possible when it comes to individual database types. This lesson should be kept as general as possible.
Business Example
You want to find out how to access the database using Open SQL statements.
The SAP Web Application Server Database Interface
This section should give the participants an understanding of Open SQL as platform-independent SQL. You must draw their attention to the fact that anything they write using native SQL will be platform-dependent (see also the facilitate discussion at the end of this lesson).
144
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Communication with the Database
Relational Database Management Systems (RDBMS) are generally used to manage large sets of data. An RDBMS saves data and relationships between data in the form of two-dimensional tables. These are known for their logical simplicity. Data, tables, and table relationships are defined at database level in the database catalog (the data dictionary) of the RDBMS. Within the SAP programming language ABAP, you can use SAP Open SQL (SQL = Structured Query Language, database query language) to access the application data in the database, regardless of the RDBMS used. The database interface, which is part of every work process on the SAP Web Application Server, translates Open SQL statements from ABAP into the corresponding SQL statements for the specific database used (“Native SQL”). This allows ABAP programs to be database-independent. Note: Open SQL is a database query language based on the (ISO) SQL standard that also contains enhancements that are not included in the standard. When interpreting Open SQL statements, the SAP database interface checks the syntax of these statements and automatically ensures optimal utilization of the SAP buffers that are in the shared memory of every SAP Web Application Server. Data that is frequently required by the applications is stored in these buffers so that the system does not have to access the database server to read this data. In particular, all technical data, such as ABAP programs, screens, and ABAP Dictionary information, as well as a number of business administration parameters, usually remain unchanged in an operational system and are therefore ideally suited to buffering.
Figure 57: Database Query Flow
2005/Q4
© 2005 SAP AG. All rights reserved.
145
Unit 3: The System Kernel
TAW10_1
Furthermore, "native" SQL commands can be used directly in ABAP, that is, without using the local buffers and without the database interface interpreting the commands. You can do this by including the commands in a EXEC SQL. - END EXEC. bracket in the ABAP program. The ABAP Interpreter does not check the syntax of any commands within this bracket. If you use native SQL, you can no longer maintain the platform independence of the affected programs. If there is more than one instance then there is also more than one buffer. You may therefore need synchronize buffers from time to time. You can discuss the issue of buffer synchronization with the participants at this point (optional): what causes inconsistencies between buffers? How often should you synchronize the buffers? What possible solutions are there? (Only buffer data that is changed rarely and also read frequently, if at all.)
146
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Communication with the Database
Facilitated Discussion
Participants should understand the effects of programming using native SQL commands. You need to ensure that the participants understand that if they use native SQL commands in the programs they write, then they will lose the platform independence of the ABAP coding.
Discussion Questions
Use the following questions to engage the participants in the discussion. Feel free to use your own additional questions. Do you use Native SQL in your application programs? What are the consequences, for example, during a database migration?
2005/Q4
© 2005 SAP AG. All rights reserved.
147
Unit 3: The System Kernel
TAW10_1
Lesson Summary
You should now be able to: • Describe how the SAP system communicates with the database • List the advantages of open SQL statements
148
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Unit Summary
Unit Summary
You should now be able to: • Outline simple client/server configurations • Name the most important processes on an SAP Web Application Server • Define the term instance and recognize the characteristics of a central instance • Describe the processing flow for user requests in SAP systems • Outline the processing flow for a dialog step in the SAP system • Describe the concept of work process multiplexing • Describe how the SAP system communicates with the database • List the advantages of open SQL statements
2005/Q4
© 2005 SAP AG. All rights reserved.
149
Unit Summary
TAW10_1
150
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Test Your Knowledge
121
Test Your Knowledge
1. What are the advantages of a three-tier client/server configuration as compared to a single-tier or two-tier configuration?
Choose the correct answer(s).
□ □ □ □ 2.
A B C D
Simpler scalability Simpler administration Load balancing possible None of the above
Which process at the application server level receives the user request?
Choose the correct answer(s).
□ □ □ □ 3.
A B C D
Work process Dispatcher Buffer SAP GUI
Which work process types can you find on an SAP Web Application Server?
Choose the correct answer(s).
□ □ □ □ □ □ □ 4.
A B C D E F G
Dialog work process Message server work process Update work process ICM work process Background work process Enqueue work process Spool work process
The term central instance describes the instance
Choose the correct answer(s).
□ □ □ □ □
A B C D E
That you are logged on to while working in the system On which all application processes required for operating an SAP system are configured On which the gateway process is configured On which the majority of work processes are configured On which the majority of dialog work processes are configured
2005/Q4
© 2005 SAP AG. All rights reserved.
151
Test Your Knowledge
TAW10_1
5.
What tasks does the task handler carry out?
Choose the correct answer(s).
□ □ □ □ 6.
A B C D
Communicates with SAP GUI Coordinates activities within the work process Accesses the database Processes the ABAP coding on which a transaction is based
Is the assignment of users to dialog work processes fixed?
Choose the correct answer(s).
□ □ □ □ 7.
A B C D
Yes, it is fixed for the entire time that the user is logged on to the SAP system Yes, it exists for the entire duration of a transaction consisting of several screens No. Each dialog step of a transaction, consisting of several screens, can theoretically be processed by a different work process None of the above
The SAP Web Application Server database interface enables you to:
Choose the correct answer(s).
□ □ □ □
A B C D
Enhance performance using the local buffers Access online databases on the Internet Use database-independent Open SQL in ABAP programs Access file content on the SAP Web Application Server
152
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Test Your Knowledge
123
Answers
1. What are the advantages of a three-tier client/server configuration as compared to a single-tier or two-tier configuration? Answer: A, C Implementing an additional hardware layer for application processes makes it easier to adapt an SAP system if the number of users changes (scalability), and to assign user groups to specific application servers (software-oriented view), (load balancing). The additional hardware layer does not, however, reduce the administrative workload. 2. Which process at the application server level receives the user request? Answer: B The dispatcher receives the user request on the application server and passes it on to an available work process. The SAP presentation program, SAP GUI, is not part of the application server (software-oriented view), and the buffer enables quicker processing of user requests. 3. Which work process types can you find on an SAP Web Application Server? Answer: A, C, E, F, G All of the above processes can in theory be configured on an SAP Web Application Server. However, not all of the above processes are work processes. The message server and ICM process are not work processes. 4. The term central instance describes the instance Answer: B The central instance is the instance on which all application processes required for operating an SAP system are configured. Specifically, the central instance therefore also contains processes that are only present once per system (such as the message server). Every instance has a gateway process, the existence of a gateway process does not therefore denote the central instance. The number of dialog work processes, or the total number of work processes configured on the central instance is not relevant in this context.
2005/Q4
© 2005 SAP AG. All rights reserved.
153
Test Your Knowledge
TAW10_1
5.
What tasks does the task handler carry out? Answer: B The task handler coordinates activities within a work process. The work process and the user's SAP GUI do not communicate directly, but through the dispatcher. The database is accessed through the database interface and the ABAP coding is executed by the ABAP processor.
6.
Is the assignment of users to dialog work processes fixed? Answer: C The dispatcher reassigns the user to a dialog work process for each dialog step in a transaction. The assignment of users to dialog work processes is therefore not fixed. (The only exception to this rule is the debugging mode, in which one dialog process is assigned to one specific user.)
7.
The SAP Web Application Server database interface enables you to: Answer: A, C When the ABAP Interpreter sends a query to the database, the database interface reads the data from the SAP Web Application Server's local buffer, if possible. If the data required is not present in the buffer, then the interface turns the Open SQL statement from the ABAP coding into database-specific native SQL coding. The database interface is not used to access the content of online databases on the Internet or files on the SAP Web Application Server.
154
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 4
125
Communication and Integration Technologies
For more information, see the introductory instructor notes in the lesson.
Unit Overview
There is a vast array of methods for connecting SAP systems with other systems, and optimizing processes within a system. Many of the available technologies are briefly introduced in this unit, and you will get an idea of the various uses for each.
Unit Objectives
After completing this unit, you will be able to: • • • • • • • • • • • • Name various cross-system business processes Explain the ideas behind the ALE concept List various interface technologies used by SAP systems Describe the process for a Remote Function Call Explain the significance and use of business objects and their BAPIs Make a Remote Function Call Explain Web Services Describe UDDI and WSDL Describe the SAP Business Workflow concept Explain the flow of a workflow process Submit a leave request within the SAP Business Workflow Describe additional application areas for the SAP Business Workflow concept
2005/Q4
© 2005 SAP AG. All rights reserved.
155
Unit 4: Communication and Integration Technologies
TAW10_1
Unit Contents
Lesson: Cross-System Business Processes .................................... 157 Lesson: Remote Function Calls and BAPIs ..................................... 162 Exercise 6: Remote Function Calls and BAPIs............................. 169 Lesson: Web Services ............................................................. 172 Lesson: SAP Business Workflow ................................................. 178 Exercise 7: Leave Request as Workflow .................................... 185
156
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Cross-System Business Processes
Lesson:
127
Cross-System Business Processes
Lesson Duration: 30 Minutes
Lesson Overview
This lesson explains the fundamentals of the Application Link Enabling (ALE) concept.
Lesson Objectives
After completing this lesson, you will be able to: • • Name various cross-system business processes Explain the ideas behind the ALE concept
This lesson aims to give the participants an understanding of the significance of cross-system business processes and the need to link them using ALE.
Business Example
A company wants to implement an Internet sales scenario in the context of the mySAP CRM solution.
The Significance of Cross-System Business Processes
Let's start by defining cross-system business processes, using common situations as examples. For example, it may be the case that within a company, the human resources system is separate from the rest of the business software system. Obviously, the systems cannot be completely separate, since the accounting system needs the employees' wage data. In this situation, you need cross-system business processes to exchange the relevant data. Cross-system business processes are used, for example, if two companies collaborate closely and send joint orders to a vendor. The companies' business IT systems need to communicate with each other to consolidate the quantities to be ordered. In this case, the business process does not just cross system boundaries, but also company boundaries. An additional example is the transfer of a limited quantity of specific data, for example, the electronic transfer of account statement data from a bank to a company.
2005/Q4
© 2005 SAP AG. All rights reserved.
157
Unit 4: Communication and Integration Technologies
TAW10_1
Recent developments suggest that the significance of cross-system business processes will continue to increase rapidly.
Application Link Enabling (ALE)
Application Link Enabling is a means of creating and operating distributed applications. The basic concept of Application Link Enabling is to ensure operation of a distributed, yet integrated system landscape. This involves business-controlled message exchange using consistent data across loosely linked application systems. The applications are integrated through synchronous and asynchronous communication, not through a central database. Systems that use ALE to exchange data can be located at the same company, or they may belong to different companies. One of the characteristics of ALE is that different systems are linked in business terms through secure and consistent data transfer.
Figure 58: Business process distribution using ALE
You could also describe ALE as being composed of the elements: who exchanges which data when, with whom, and by what means.
158
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Cross-System Business Processes
Implementing ALE therefore requires that you clarify the following points in detail: 1. 2. 3. 4. 5. 6. Identify the business process and the objects involved Identify the information to be transmitted Specify the format for the data to be transferred Decide on the transfer technology to be used Decide on the transfer type Specify the destination of the data transfer
The following table contains examples for implementing ALE: Process Identify the information to be transmitted Format of the data Transfer technology Transfer type Objective Internet Sales with mySAP CRM Order data from the SAP CRM System, which is to be passed to an ERP backend IDoc format by RFC asynchronously, every 60 seconds Provide goods and/or services for sale in the Internet
The data is often identified within the SAP system using a business object and its Business Application Programming Interfaces (BAPIs). A BAPI is a method of a business object, for example, the material master record. A permissible method could be creating or changing the material master data. BAPIs normally enable you to edit all data belonging to the object. The IDoc format describes the structure of “intermediate documents”. There are various kinds of IDoc formats for different types of data to be exchanged. Alternatively, you can use ALE to transfer data in an agreed XML format. You can select your preferred data transfer technology within the constraints imposed by the system. For example, you can transfer data by Remote Function Call (RFC) or using HTTP or HTTPS. There are two basic transfer types: synchronous and asynchronous. Synchronous transfer means that the data is transferred at the time of creation or change. You can start asynchronous transfers at intervals of your choice. There are very few restrictions on the systems that can be linked. The systems involved must have the technical capability to receive the communications (RFC-enabled, HTTP-enabled) and interpret the format transferred (IDoc, XML). SAP systems of different releases can be linked using ALE.
2005/Q4
© 2005 SAP AG. All rights reserved.
159
Unit 4: Communication and Integration Technologies
TAW10_1
Facilitated Discussion
The aim of this discussion is to make customers aware of cross-system business processes in their own companies.
Discussion Questions
Use the following questions to engage the participants in the discussion. Feel free to use your own additional questions. Which cross-system business processes do you (the participants) use?
160
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Cross-System Business Processes
Lesson Summary
You should now be able to: • Name various cross-system business processes • Explain the ideas behind the ALE concept
Related Information
• • More advanced training courses on ALE are BIT300, BIT320 and BIT350. You can find additional information on the topic of ALE on the SAP Service Marketplace using the quick link /ibf (and then under Integration Scenarios).
2005/Q4
© 2005 SAP AG. All rights reserved.
161
Unit 4: Communication and Integration Technologies
TAW10_1
Lesson:
131
Remote Function Calls and BAPIs
Lesson Duration: 30 Minutes
Lesson Overview
This lesson provides an overview of the interface technologies available to you in the SAP system, while focusing on the significance of RFCs and BAPIs.
Lesson Objectives
After completing this lesson, you will be able to: • • • • List various interface technologies used by SAP systems Describe the process for a Remote Function Call Explain the significance and use of business objects and their BAPIs Make a Remote Function Call
This lesson gives the participants an overview of the various interface technologies available. You need a thorough understanding of RFCs (transactions SE37 and SM59), and of the BOR and BAPIs.
Business Example
You need to integrate existing applications with SAP applications. The interfaces available in the standard system are of particular interest here.
Overview of Interfaces
SAP systems have interfaces at different communication levels. These range from highly technical connection options, for example, using the TCP/IP protocol or CPI-C, to highly specialized interfaces designed for business objects, such as BAPIs or the IDoc interface used in the ALE environment. All higher interfaces, that is, those that access business objects or processes, use the same technology, the Remote Function Call (RFC).
162
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Remote Function Calls and BAPIs
Figure 59: Interfaces technologies used in SAP systems
SAP systems use the following interface technologies that are listed in the above graphic: • • • • • • • • • • • • ALE: Application Link Enabling BAPI: Business Application Programming Interface CPI-C: Common Program Interface Communication EDI: Electronic Data Interchange HTTP: HyperText Transfer Protocol LU 6.2: Logical Unit Type 6.2 RFC: Remote Function Call OLE: Object Linking and Embedding SMTP: Simple Mail Transfer Protocol SOAP: Simple Object Access Protocol TCP/IP: Transmission Control Protocol / Internet Protocol XML: Extensible Markup Language
2005/Q4
© 2005 SAP AG. All rights reserved.
163
Unit 4: Communication and Integration Technologies
TAW10_1
Remote Function Call
The Remote Function Call interface is an SAP interface protocol based on CPI-C and TCP/IP. It simplifies the programming of communication processes between different systems. RFCs enable you to call and execute predefined functions in a remote system – or within the same system. RFCs manage the communication process, parameter transfer and error handling. RFC describes an interface, not the programming language in which the function runs. You can also use RFCs to call functions in non-SAP systems. The procedure for RFC communication between two SAP systems is that the calling system uses an RFC definition in the system called to access a specific function. This function is normally a remote-enabled function module. You can also, depending on the release, use RFC to call functions in SAP R/2 systems.
Figure 60: RFC connection possibilities
If you want to start external programs remotely, you need an RFC interface outside the SAP system. This could be, for example, a simple Dynamic Link Library (DLL). Every RFC interface is bidirectional, so external programs can also use RFC to access functions in SAP systems. Note: All function modules (including those that are remote-enabled) are created, together with their import and export parameters, using the Function Builder. You can call the Function Builder using Tools → ABAP Workbench → Development → Function Builder or using transaction code SE37.
164
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Remote Function Calls and BAPIs
To call an RFC module from an SAP system, you need to know the import and export parameters (defined in the Function Builder), and there must be a technical connection between the two systems. This connection is called an RFC connection or an RFC destination. You can manage your RFC connections using Tools → Administration → Administration → Network → RFC Destinations or using transaction SM59.
Figure 61: Remote Function Call in detail
In the above graphic you can see, on the left side, the calling system, in which an RFC destination named DEST has been created. An RFC destination in transaction SM59 should not be confused with an SAP system, since an RFC connection can only point to one specific client in an SAP system. These are therefore also referred to as connections between logical systems; this term is used, above all, in the ALE environment. This also means that you can have at least as many RFC connections between two systems as there are clients in the target system. Since you can specify a logon user for the destination in each RFC connection, you can therefore also access clients in the target system several times, for example, with a different logon user each time. If you
2005/Q4
© 2005 SAP AG. All rights reserved.
165
Unit 4: Communication and Integration Technologies
TAW10_1
need a bidirectional RFC connection between two systems, that is, that the system called can also execute RFC modules in the calling system, then you need to set up an equivalent second RFC connection in the system called. Hint: When you are defining RFC destinations, RFC connections are • • Addressed to one client, when they are pointing at an SAP system Accessible from all clients in the system
In ABAP, you use RFCs to call a function module in another system as follows: CALL FUNCTION DESTINATION EXPORTING ... IMPORTING ... The function to be executed in the target system is named. The name of the target must refer to one of the RFC connections available. When you are creating an RFC connection, you can specify logon data for the target system; if you do not do this, you need to enter logon parameters when you start the RFC. Exporting and Importing are used to pass parameters to the target function and to receive the returned parameters. The function called in the target system is executed using the user ID entered for the connection. Note: You can also create RFC connections for which the user of the user making the call is used in the target system. That means different users can use the same connection in the target system. This procedure is also called Trusted RFC. It is, of course, a prerequisite that identical users are created in the source and target systems. Trusted RFC is explained in the course ADM960 - Security in SAP System Environments. The RFC has become the most important interface in the SAP environment. Some special RFC modules, which follow certain conventions, are also known as BAPIs (Business Application Programming Interfaces).
BOR and BAPIs
A Business Application Programming Interface (BAPI) is a standardized programming interface that facilitates internal and external access to business processes and data in SAP systems. BAPIs are defined in the Business Object Repository as methods of SAP business objects and enable an object-oriented view of business data in an SAP system. Functions that can be called using BAPIs are normally implemented and stored in the ABAP Workbench Function Builder as RFC-enabled function modules.
166
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Remote Function Calls and BAPIs
You can display an overview of available BAPIs in the BOR, for example, using the Business Object Repository pushbutton in the Business Object Builder (Tools → ABAP Workbench → Development → Business Object Builder), transaction SWO1. You can access the BOR directly using transaction code BAPI.
Figure 62: BOR and BAPIs
BAPIs, which represent methods for business objects in an SAP system, are used in a variety of contexts. Here are some possible uses for BAPIs: • • • • • To link business processes across system boundaries (for example, when using ALE) Used by SAP to integrate various solutions in the framework of mySAP Business Suite To connect an SAP system to the Internet Used in conjunction with SAP Business Workflow To connect to external programs
2005/Q4
© 2005 SAP AG. All rights reserved.
167
Unit 4: Communication and Integration Technologies
TAW10_1
You must make sure beforehand that you are familiar with the execution of the following demonstration. If possible, avoid executing this function using the dummy RFC connection “NONE”; instead, with the participants, create a connection in transaction SM59. You could also prepare this beforehand. Hint: This demonstration consists of two parts that the participants will then do themselves in the exercises. The first part concerns itself with a simple presentation of the BOR using a documentation call for a BAPI as an example. The second part is rather more complex, as it introduces BAPI usage with the Function Builder. 1. 2. 3. 4. 5. 6. Follow the path mentioned above for the BOR, or call transaction BAPI directly. Choose the Alphabetical tab page. Search for the business object “USER”. From the BAPIs available for this business object, select the “Change” BAPI. Display the documentation for this BAPI. Now switch to the USER.Display BAPI. Go to the Tools tab page and choose the Function Builder. Then choose Display. You can now see the source code for the BAPI in the Function Builder. 7. Press Test/Execute (or the F8 key). Specify NONE as the RFC target system entry; this refers to your own system. Enter your own user name. Choose Execute (or the F8 key). As a result, your user data, requested by the RFC from the BAPI, is displayed. 8. Once you have confirmed this screen, the result screen for the query is displayed. You can view the return code and the response time for your query. This response time includes the time you took to view the user data display. Note: BAPIs are created and tested in exactly the same way as other function modules, using the Function Builder, transaction SE37, and are then defined as BAPIs in the BOR.
168
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Remote Function Calls and BAPIs
137
Exercise 6: Remote Function Calls and BAPIs
Exercise Duration: 10 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Use BAPIs
Business Example
You need data from another system.
System Data
System: Client: User ID: as SAPTEC-##) Password: the relevant user. Set up instructions: The training system assigned to you (such as I30) The client assigned to you (such as 802) The user name that you have given the participants (such The password that you have given the participants for None
Task: Using a BAPI
Use a BAPI to display the address data for your user in the system. 1. 2. 3. 4. 5. Start the overview transaction for the Business Object Repository. Find the method USER.Change. Display the documentation for this method. Call the Function Builder for the USER.Display method. You can now see the source code for the BAPI in the Function Builder. Execute this BAPI for your user with the RFC destination NONE. Once you have confirmed the dialog box, the result screen for the query is displayed. You can view the return code and the response time for your query.
Result
In this example, the export parameter for the calling side was the user “in the other system”, the import parameter was the receipt of the dialog box. From the point of view of the function called, the import parameter was the user name and the export parameter was the dialog box.
2005/Q4
© 2005 SAP AG. All rights reserved.
169
Unit 4: Communication and Integration Technologies
TAW10_1
Solution 6: Remote Function Calls and BAPIs
Task: Using a BAPI
Use a BAPI to display the address data for your user in the system. 1. Start the overview transaction for the Business Object Repository. a) Choose Tools → ABAP Workbench → Development → Business Object Builder and choose Business Object Repository (Transaction BAPI). If you are following the Business Object Builder menu path, then select BAPI in the dialog box. Use the Alphabetical tab page and look for the User business object. From the BAPIs available for this business object, select the USER.Change BAPI. Use the appropriate tab page to display the documentation for this BAPI on the right side of the screen. 3. Call the Function Builder for the USER.Display method. You can now see the source code for the BAPI in the Function Builder. a) 4. Switch to the USER.Display BAPI. Choose the Tools tab page, followed by the Function Builder. Then choose Display. Press Test/Execute (F8). Specify NONE as the RFC target system entry; this refers to your own system. Enter your user name on the query screen. Select Execute. As a result, your user data, requested by the RFC from the BAPI, is displayed. 5. Once you have confirmed the dialog box, the result screen for the query is displayed. You can view the return code and the response time for your query. a) The return code for your query is displayed as the value for the export parameter Return.
2.
Find the method USER.Change. Display the documentation for this method. a)
Execute this BAPI for your user with the RFC destination NONE. a)
Result
In this example, the export parameter for the calling side was the user “in the other system”, the import parameter was the receipt of the dialog box. From the point of view of the function called, the import parameter was the user name and the export parameter was the dialog box.
170
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Remote Function Calls and BAPIs
Lesson Summary
You should now be able to: • List various interface technologies used by SAP systems • Describe the process for a Remote Function Call • Explain the significance and use of business objects and their BAPIs • Make a Remote Function Call
Related Information
• • You can find all SAP interfaces on the Internet at: http://ifr.sap.com For information about other interfaces, see the Interface Adviser: http://service.sap.com/interfaceadviser
2005/Q4
© 2005 SAP AG. All rights reserved.
171
Unit 4: Communication and Integration Technologies
TAW10_1
Lesson:
140
Web Services
Lesson Duration: 30 Minutes
Lesson Overview
This lesson provides you with an introduction to the subject of Web Services.
Lesson Objectives
After completing this lesson, you will be able to: • • Explain Web Services Describe UDDI and WSDL
Web Services are modular function programs that can be combined flexibly. Web Services, together with WSDL, can be described as software interfaces, and not so much as web-capable applications. However, Web Services can also be used from the Web Browser, but this on its own is not their main characteristic. In the instructor’s demo the Web Service system information, for example, is called up in an ABAP program. SAP prefers the development of Enterprise Services that can be the total or combination of individual Web Services. Flexible, modular programming will complement monolithic software architectures to a great extent in the future, at least that is the opinion of consultancies based on current surveys.
Business Example
Your company wants to technically realize online services using Web Services.
Web Services - A Short Introduction
The SAP Web Application Server is also a development platform for Web Services. A Web Service is a service, which is made available via Internet protocols and, as a rule, it can be operated using an Internet browser. Web Services are the technical basis for making individual functions of an applications directly available. Here, the existing function of an application can be addressed via standardized access protocols and contents can also be exchanged in a structured form. In this way, cross-application functions, which are sold by SAP as complete units for the business process under the name of Packaged Composite Application (SAP xApps) can also be developed
172
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Web Services
flexibly. The combination of several granular services, in the sense of self-contained business scenarios, is called an Enterprise Service. In the SAP Web Application Server the following, basic standards for Web Services are implemented: • • eXtensible Markup Language (XML) Simple Object Access Protocol (SOAP) SOAP describes a protocol, which you can use to call up Web Services in distributed system landscapes. SOAP uses HTTP as a transport protocol. A SOAP message has a header with the additional information and a body with the actual message. • Web Service Description Language (WSDL) WSDL is a meta language, which is used to describe the function of a Web Service. Functions, parameters and return codes in particular are described in a machine-readable form. WSDL is standardized by the World Wide Web Consortium (W3C), see the following URL: http://www.w3c.org/TR/wsdl.html • Universal Description, Discovery, and Integration (UDDI) is a directory service for dynamic Web Services. A directory of Web Services is provided via a SOAP interface. The information here is highlighted in white, yellow and green pages. You can find more information on UDDI at the following address: http://www.uddi.org. SAP itself also operates a UDDI server at http://uddi.sap.com, on which Web Services can be registered and searched for.
Web Services and the SAP Web Application Server
Web Services can already be developed in the SAP system from release SAP Web Application Server 6.20, however, the development tools have been considerably enhanced for release 6.40. Thus, an existing, remote-capable function module from the Function Builder can be transformed (transaction SE37) into a Web Service. A Web Service is a module that can be used flexibly in different applications. The creator publishes the Service in a publicly accessible UDDI directory. The customer can then search directly for Web Services in the UDDI directory. The demo scenario does not go into the publishing of the Web Service in a UDDI directory for reasons of clarity.
2005/Q4
© 2005 SAP AG. All rights reserved.
173
Unit 4: Communication and Integration Technologies
TAW10_1
Figure 63: Outline of a Web Service scenario
Technically, the once defined Web Service can be called up in different ways, for example, from an ABAP program or from a Business Server Page. The instructor can present the Web Service Z_WS_SYSINFO as a demonstration, which shows you the following system data: SID, Host name of the DB server and operating system of the DB server. This Web Service can be called up from a) the ABAP program Z_SYSINFO and b) from the Business Server Page Z_BSP_SYSINFO. The BSP is not public, please logon with the group user SAPTEC-##. The following outlines how a Web Server is created from an RFC-capable ABAP function module. The exact instruction for setting up the Web Service is not necessary in SAPTEC, as the Web Service has already been set up in the training system. However, the interested trainer should look at the courses SAPNW and BC416 or the online documentation for the necessary setup procedures. All important details shall be mentioned here, so that the settings can also be checked in case of errors. For the function module RFC_SYSTEM_INFO, in transaction SE37 (display mode: Utilities → Other Utilities→ Generate Web Service → From Function Module), the Web Service Z_WS_SYSINFO has been created. The virtual interface is called Z_WS_INTF_SYSINFO. In transaction SICF, you can display the ICF node /sap/bc/srt/rfc/sap/Z_WS_systeminfo generated for the Web
174
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Web Services
Service, and if necessary, you can activate it manually. In transaction WSADMIN the WSDL file is generated (highlight Web Service and choose the path Web Service → WSDL (whereby SAP Features can be included in the WSDL file); in some cases a renewed logon to the SAP system is necessary here). In the SE80, the Client Proxy Object ZREF_CO_Z_WS_SYSINFO (if necessary, under the local objects of the internal user; using the right-hand mouse button, click the path Create → Enterprise Service/WebService → Proxy Object as source URL/HTTP Definition and enter the URL of the WSDL page), the ABAP program Z_SYSINFO and the Business Server Page Z_BSP_SYSINFO are entered. In transaction LPCONFIG, the logical port ZSYSINFO for proxy class ZREF_CO_Z_WS_SYSINFO is defined and activated as a default port. • • The Service Provider, for example, generates the Web Service from a function module. Furthermore, a URL and the WSDL file are generated. The Service Requester creates a proxy object, which refers to the URL of the Web Service. Next, an ABAP class that matches the proxy object is generated and a logical port is assigned. The proxy object is written in and integrated into an executable program, for example, in ABAP, and called up there.
•
2005/Q4
© 2005 SAP AG. All rights reserved.
175
Unit 4: Communication and Integration Technologies
TAW10_1
Facilitated Discussion
Show the significance of Web Services for the future IT landscape and for future business scenarios.
Discussion Questions
Use the following questions to engage the participants in the discussion. Feel free to use your own additional questions. Do you intend to use Web Services soon? What implementation options do you see for Web Services in your company?
176
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Web Services
Lesson Summary
You should now be able to: • Explain Web Services • Describe UDDI and WSDL
2005/Q4
© 2005 SAP AG. All rights reserved.
177
Unit 4: Communication and Integration Technologies
TAW10_1
Lesson:
144
SAP Business Workflow
Lesson Duration: 30 Minutes
Lesson Overview
This lesson provides an overview of the concept and capabilities of the SAP Business Workflow (referred to simply as workflow).
Lesson Objectives
After completing this lesson, you will be able to: • • • • Describe the SAP Business Workflow concept Explain the flow of a workflow process Submit a leave request within the SAP Business Workflow Describe additional application areas for the SAP Business Workflow concept
The example of employee absence processing is used to illustrate the workflow topic. If you have in-depth knowledge of workflow, you can demonstrate the standard example with the FORMABSENC business object. You can find further information on this subject in the SAP Business Workflow training courses.
Business Example
The leave request process is a good example of how workflow can be used.
SAP Business Workflow Basics
Conveniently, transaction SWUI_DEMO can be used to start different demo workflows without preparations. Simply start the demo for the leave request. The participants will carry out an exercise for this. Caution: When the course was created, transactionSWUI_DEMO still showed an error in the 6.40 system, the Start pushbutton could note be used and produced an error message. But the demo workflow can be started without problems using the alternative button Start with Details. On the next screen, simply press Start Workflow or F8.
178
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Business Workflow
The first call of the demo workflow takes a very long time because the program buffer has not been filled yet and the program load might still have to be compiled. Often, the executing work process even switches to PRIV mode. The instructor should call up the workflow in the preceding break in order to speed up the demonstration. Workflow in SAP systems (or even between SAP systems) aims to increase the speed and transparency of business processes. A workflow model breaks a process down to its individual steps, which are then assigned to various people, or rather, to their roles within the company. The automated sequence of steps ensures that tasks are rapidly assigned to the appropriate employees. This lesson describes two views of the same workflow. One is the view of the people participating in the workflow, the other is a more technical view designed to clarify the process in the system.
A Workflow and its Participants
The process “an employee requests leave of absence” is used as a typical example.
Figure 64: Example of an SAP Business Workflow process
Two people are involved: the person who creates the request (requester) and his or her assigned supervisor. The requester fills out the form and saves his or her entries. The save action triggers a workflow event, for example, “leave requested”.
2005/Q4
© 2005 SAP AG. All rights reserved.
179
Unit 4: Communication and Integration Technologies
TAW10_1
This event is received by an appropriately configured workflow and passed to an approver in accordance with predefined rules. The supervisor (or approver) receives a corresponding workflow item in his or her Office Inbox (Office → Workplace → Inbox or transaction SBWP).. A workflow event therefore creates a link between an activity in the SAP system and the people involved. When the approver calls up the workflow item, the approver is automatically referred to the function Approve/reject request. There are now two scenarios to consider: 1. 2. The request is approved The request is rejected
If the request is approved (which triggers a workflow event), the requester is informed and the workflow is complete. If the request is rejected, the requester is also informed and has in turn two options: 1. 2. Accept the rejection Change the leave request
If the requester accepts the rejection, the workflow is also complete; if the requester changes the leave request, another workflow item is sent to the approver's Office Inbox.
A Workflow and its Technology
A workflow creates a link between the people who participate in a process and the program steps that belong to this process.
180
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Business Workflow
Figure 65: The workflow environment
Different authorizations enable employees in a company to carry out different tasks in one or more systems. Some of these tasks trigger events that are in turn assigned to steps in a workflow model. In other words, when an employee uses his or her authorizations to carry out a task that triggers a workflow event assigned to it, then, for example, a specific method of the relevant business object is called in the system. An employee's authorizations typically grant access to individual steps in a more comprehensive process. A process works on a particular business object, for example, that is accessed using the methods assigned to it. These methods are defined as BAPIs in the system.
Workflow Application Areas
Since an unlimited number of workflow steps can be assigned to a workflow event, and complex workflow sequences can be assigned to a process, the workflow function is used in a wide variety of business areas in SAP systems. For example, complex process flows in the mySAP CRM or mySAP SCM solutions would hardly be possible without workflow integration.
2005/Q4
© 2005 SAP AG. All rights reserved.
181
Unit 4: Communication and Integration Technologies
TAW10_1
Figure 66: Workflow application areas
Workflow is also particularly well suited to automating the distribution of information on work in progress (for example, information on the status of a purchase order) to all those concerned. Workflow can additionally use generated XML messages to trigger cross-system activities in remote systems. Defining appropriate events and assigning them to business object methods enables you to use workflow in almost any area.
182
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Business Workflow
Facilitated Discussion
Exploring the possibilities of the SAP Business Workflow
Discussion Questions
Use the following questions to engage the participants in the discussion. Feel free to use your own additional questions. What other specific uses for workflow are the participants aware of, or can they think of any other situations in which workflow could be used?
2005/Q4
© 2005 SAP AG. All rights reserved.
183
Unit 4: Communication and Integration Technologies
TAW10_1
184
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Business Workflow
149
Exercise 7: Leave Request as Workflow
Exercise Duration: 10 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Describe the SAP Business Workflow concept
Business Example
In your production SAP system, the procedures are to be implemented using the SAP Business Workflow, hence, you are interested in the concept and possible uses of the workflow.
System Data
System: The training system assigned to you. Client: The training client assigned to you. User ID: This exercise is carried out with course users SAPTEC-##, whereby ## refers to the respective group number. Password: The initial password issued by you or the password that has already been changed by the users. Set up instructions: 1. You use standard transaction SWUI_DEMO. Hence, no special preparations are required.
2005/Q4
© 2005 SAP AG. All rights reserved.
185
Unit 4: Communication and Integration Technologies
TAW10_1
Task: Management of Leave Requests using SAP Business Workflow
Use SAP Business Workflow to generate and process a leave request. When the course was created, transaction SWUI_DEMO still had an error in the 6.40 system. The Start button cannot be used, instead an error message is output: “Error: tipsStart is undefined” If the error still appears in the training system use the Start with Details button. On the following screen you simple press function key F8. Then you continue the exercise as described.
Before participants do the exercise, the instructor should have already called up the demo workflow during a break. This fills the program buffers and compiles loads that might be missing so that the calls are quicker for the participants. 1. 2. 3. Your user SAPTEC-## generates a leave request for today. Check whether the leave request you just entered has arrived in the inbox of the SAP Business Workplace. The supervisor approves the leave request.
186
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Business Workflow
Solution 7: Leave Request as Workflow
Task: Management of Leave Requests using SAP Business Workflow
Use SAP Business Workflow to generate and process a leave request. When the course was created, transaction SWUI_DEMO still had an error in the 6.40 system. The Start button cannot be used, instead an error message is output: “Error: tipsStart is undefined” If the error still appears in the training system use the Start with Details button. On the following screen you simple press function key F8. Then you continue the exercise as described.
Before participants do the exercise, the instructor should have already called up the demo workflow during a break. This fills the program buffers and compiles loads that might be missing so that the calls are quicker for the participants. 1. Your user SAPTEC-## generates a leave request for today. a) Start transaction SWUI_DEMO. In the left navigation area, choose the Demo for leave request process entry. Choose Start. You see an input template. Please enter Training as the department and specify an absence of eight hours; the current date is already entered in the date field but you can still change the entry. Furthermore, enter Special reasons as the reason for the absence. Choose pushbutton Save.
2.
Check whether the leave request you just entered has arrived in the inbox of the SAP Business Workplace. a) Start transaction SBWP. Open the Inbox folder. When you double-click the Workflow folder, the workflow list of open workflow items is displayed. Your leave request should be displayed there. Hint: In the context of the demo workflow you are both employee and supervisor in one person. In a real workflow scenario, only your supervisor would see the generated leave request.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
187
Unit 4: Communication and Integration Technologies
TAW10_1
3.
The supervisor approves the leave request. a) Start transaction SBWP. Open the Inbox folder. By double-clicking the Workflow folder a list of open workflow items is displayed. Choose your leave request and process it. You start processing using the Execute button. Choose Approve. Use the green arrow or the F3 button to return to the previous screen. Choose Close Work Item to close the workflow. Hint: In a real workflow the employee would be notified by express mail that his leave request has been approved. This express mail is not sent in the demo workflow.
188
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Business Workflow
Lesson Summary
You should now be able to: • Describe the SAP Business Workflow concept • Explain the flow of a workflow process • Submit a leave request within the SAP Business Workflow • Describe additional application areas for the SAP Business Workflow concept
Related Information
For more information, see the SAP Library under SAP Web Application Server → Business Management → WebFlow Engine (BC-BMT-WFM) and in more advanced courses on the SAP Business Workflow: BIT600, BIT601, BIT603, and BIT610.
2005/Q4
© 2005 SAP AG. All rights reserved.
189
Unit Summary
TAW10_1
Unit Summary
You should now be able to: • Name various cross-system business processes • Explain the ideas behind the ALE concept • List various interface technologies used by SAP systems • Describe the process for a Remote Function Call • Explain the significance and use of business objects and their BAPIs • Make a Remote Function Call • Explain Web Services • Describe UDDI and WSDL • Describe the SAP Business Workflow concept • Explain the flow of a workflow process • Submit a leave request within the SAP Business Workflow • Describe additional application areas for the SAP Business Workflow concept
190
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Test Your Knowledge
153
Test Your Knowledge
1. Application Link Enabling (ALE) allows you to:
Choose the correct answer(s).
□ □ □ □ □
A B C D E
Exchange data only between SAP systems, as long as they have the same release status Exchange data across system boundaries, but only for SAP applications Exchange data between collaborating enterprises, using certain formats and technologies The communication between different systems of your system landscape Update your order data using the appropriate BAPI, only once every 24 hours
2.
The following interfaces or communication options are supported by SAP systems:
Choose the correct answer(s).
□ □ □ □ □ □ 3.
A B C D E F
HTTP (HyperText Transfer Protocol) SMTP (Simple Mail Transfer Protocol) RFC (Remote Function Call) BAPIs (Business Application Programming Interfaces) XDTP (Extended Data Transfer Protocol) STP (SAP Transfer Protocol)
You can use BAPIs to:
Choose the correct answer(s).
□ □ □ □ 4.
A B C D
Request data from an SAP system Pass data to an SAP system Transfer SAP screen images to third-party applications (such as Microsoft Word) Access business processes in SAP systems
You access BAPIs in SAP systems using an RFC interface.
Determine whether this statement is true or false.
□ □
True False
2005/Q4
© 2005 SAP AG. All rights reserved.
191
Test Your Knowledge
TAW10_1
5.
Business
Programming Interfaces are specialized modules. They are accessed using the interface. They are created and managed using the Builder.
Fill in the blanks to complete the sentence.
6.
SAP Business Workflow ensures that:
Choose the correct answer(s).
□ □ □ □ □
A B C D E
Appropriately configured business processes can be partially automated Appropriately configured business processes are executed in consistent sequences The right employee receives the right work at the right time Your workflow-supported business processes are handled more efficiently All your company processes that have been implemented in ABAP run without errors
7.
You can also use SAP Business Workflow functions (for example, with XML) to trigger functions in other systems.
Determine whether this statement is true or false.
□ □
True False
192
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Test Your Knowledge
155
Answers
1. Application Link Enabling (ALE) allows you to: Answer: C, D ALE is a very powerful method of exchanging data between systems. These systems may be located within the same company, or they may be distributed between several companies. The data is transferred by RFC in a previously defined format. The transfer type may be synchronous or asynchronous. 2. The following interfaces or communication options are supported by SAP systems: Answer: A, B, C, D From an SAP system, you can communicate with other systems using, for example, HTTP, SMTP, RFC, or BAPIs. XDTP and STP do not exist. 3. You can use BAPIs to: Answer: A, B, D You can use BAPIs to access business processes in an SAP system and to request and transfer data between systems. GUI functions cannot be transferred to third-party products. 4. You access BAPIs in SAP systems using an RFC interface. Answer: True BAPIs are nothing other than special, remote-enabled function modules. They can therefore also be addressed using RFCs. 5. Business Application Programming Interfaces are specialized function modules. They are accessed using the RFC interface. They are created and managed using the Function Builder. Answer: Application, function, RFC, Function You can start the Business Object Repository using transaction code BAPI, and the Function Builder using transaction code SE37.
2005/Q4
© 2005 SAP AG. All rights reserved.
193
Test Your Knowledge
TAW10_1
6.
SAP Business Workflow ensures that: Answer: A, B, C, D Supporting business processes with workflow enables the work steps that belong to these processes to be handled on a partially automated basis. These steps are assigned in consistent sequences to the appropriate employee at the right point in time. This enhances processing efficiency. Using workflow obviously does not guarantee that the programs you write will always run without errors.
7.
You can also use SAP Business Workflow functions (for example, with XML) to trigger functions in other systems. Answer: True You can use workflow to send XML messages that then trigger subsequent actions in other systems, as long as they are appropriately configured.
194
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 5
157
Sources of Information for Developers
For more information, see the introductory instructor notes in the lesson.
Unit Overview
You also gain an insight into SAP Service Marketplace and SAP Developer Network and what they have to offer, such as detailed information about a broad range of topics as well as access to the SAP Notes database.
Unit Objectives
After completing this unit, you will be able to: • • • • List some of the services provided on the SAP Service Marketplace Find and use SAP Notes in the SAP Service Marketplace List some of the services of the SAP Developer Network Find development news in the SAP Developer Network
Unit Contents
Lesson: SAP Service Marketplace ............................................... 196 Exercise 8: SAP Service Marketplace (Optional) .......................... 201 Lesson: SAP Developer Network ................................................. 207 Exercise 9: SAP Developer Network (Optional)............................ 211
2005/Q4
© 2005 SAP AG. All rights reserved.
195
Unit 5: Sources of Information for Developers
TAW10_1
Lesson:
158
SAP Service Marketplace
Lesson Duration: 30 Minutes
Lesson Overview
This lesson introduces you to the central point of entry for all SAP services, the SAP Service Marketplace. A few services that are particularly relevant to mySAP Business Suite are presented as examples.
Lesson Objectives
After completing this lesson, you will be able to: • • List some of the services provided on the SAP Service Marketplace Find and use SAP Notes in the SAP Service Marketplace
Don't get bogged down in the details. The focal point is that the participants need to know that the SAP Service Marketplace is the portal for services provided by SAP (and SAP partners). Every customer should know the SAP Service Marketplace URL by heart. An SAP Service Marketplace user is a vital survival aid for every SAP customer (though you can have more than one).
Business Example
The system administrator has established that there is a problem in an SAP system and is looking for a solution.
SAP Service Marketplace Target Group
You can find information on all SAP solutions and on SAP as a company at http://www.sap.com. This website is open to the general public. The SAP Service Marketplace on the other hand, at http://service.sap.com, is directed specifically at SAP's customers and partners. The SAP Service Marketplace enables you to access various services, special information and additional offers.
Logging on, Personalizing, and Navigating
To log on, you must be registered as an SAP Service Marketplace user (formerly known as OSS user or SAPNet user). There is normally a contact person in each company who creates users for employees as required and sets authorizations. Access to the SAP Service Marketplace is free of charge to customers (apart from the Internet access required).
196
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Service Marketplace
Once you have logged on to the SAP Service Marketplace, you have a range of topics to choose from. You can personalize your homepage, that is, set up your own pages with topics that are of particular interest to you. Quick Links enable you to quickly access specific areas of the SAP Service Marketplace. To call up a Quick Link, simply add it to the Web address, preceded by a “/” (for example: http://service.sap.com/ui). After logging on to the SAP Service Marketplace, you can access a selection of “Quick Links”. Log on to the SAP Service Marketplace using a valid user (such as your own user). Caution: Internal (D or I) users can see content in some sections that is not accessible to customers. Demonstrate how to call up a Quick Link. Demonstrate also how to navigate with the Quick Link appended to the URL. The list under “Quick Links” (unfortunately) does not contain all available Quick Links! The “Search for Content Area” only searches by Quick Links and their descriptions (status: September 2001). What is now known as a “Quick Link on the SAP Service Marketplace” used to be called an “alias in SAPNet”.
2005/Q4
© 2005 SAP AG. All rights reserved.
197
Unit 5: Sources of Information for Developers
TAW10_1
Important Services Provided on the SAP Service Marketplace
Figure 67: service.sap.com – the SAP Service Marketplace
Some SAP Service Marketplace functions are named below. The focus here is on services that are particularly relevant to SAP Web Application Server. Administering users As an SAP Service Marketplace user with the appropriate authorizations, you can request and administer other SAP Service Marketplace users at /user-admin. SAP Service Marketplace users are also subject to an authorization concept. You can, for example, withhold authorization to create SAP messages (see below). Developer key A developer needs a developer key to be able to create or change objects in an SAP system. You can request this key using the Quick Link /sscr (“SAP Software Change Registration”). Changes to SAP objects (such as ABAP programs) are called modifications and require an object key, which you can also request at /sscr.
198
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Service Marketplace
Notes Database You can access the comprehensive Notes Database using the Quick Link /notes. You can access specific SAP Notes either by entering the Note number directly, or using search criteria (such as the name of a transaction or an error code). Note Assistant All SAP systems as of the SAP Web AS 6.10 include the Note Assistant. This is a tool (transaction SNOTE) that can automatically import corrections to ABAP code from SAP Notes into SAP systems. /noteassistant provides information on how to implement the Note Assistant in SAP systems with earlier releases, as well as other information on the tool. Corrections and messages SAP regularly provides corrections for known problems (for example, as Support Packages, kernel patches, or front-end patches). You can download them at /patches. SAP recommends that you keep your correction status as up-to-date as possible. It may happen that an error occurs for which there is no relevant SAP Note or correction available. If this does happen, you can enter a message to SAP under /message. This message is then processed by SAP Support. Access to your SAP system and to other services If an SAP employee needs access to your SAP system to work on a problem, then you can release the connection using /serviceconnection. Other services, such as Remote Consulting (/remoteconsulting: SAP consulting services without consultant site visits) or EarlyWatch (/earlywatch: SAP experts proactively analyze your SAP systems to ensure optimum performance and availability), also require this type of access. You can find and order services provided by SAP in the Service Catalog (Quick Link /servicecat). Software requirements Are you looking for information on software requirements (operating system release or database release) for a specific SAP solution? You can find the answer using the Quick Link /platforms. Information on the latest developments You can find information on the latest developments in the SAP NetWeaver area using /netweaver. For information about SAP Web AS, use the quick link /webas Quick link /enterprise points to news about SAP R/3 Enterprise
2005/Q4
© 2005 SAP AG. All rights reserved.
199
Unit 5: Sources of Information for Developers
TAW10_1
Planing hardware investments The Quick Sizer (/quicksizer) is a tool that helps you to plan your hardware investment. Your expected hardware requirements (such as disk space and main memory) are determined on the basis of your load profile. Standardized SAP benchmarks carried out by SAP's hardware partners at regular intervals on their servers help you to size your hardware correctly. Contacts If you need to get in touch with an SAP partner, you can find their contact details in the Partner Directory at /partnerdir. Training offer /education provides details of SAP's current Education Services. You can find out which courses in your country still have free places, or even book them online.
200
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Service Marketplace
163
Exercise 8: SAP Service Marketplace (Optional)
Exercise Duration: 10 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Logon to the SAP Service Marketplace call up some function.
Business Example
Your system administrator needs some answers on specific issues.
System Data
System: Client: User ID: as SAPTEC-##) Password: the relevant user. Set up instructions: The training system assigned to you (such as I30) The client assigned to you (such as 802) The user name that you have given the participants (such The password that you have given the participants for None
Task 1: Using the SAP Service Marketplace
Participants must have own S users for logging on.
Log on to the SAP Service Marketplace: 1. 2. 3. 4. Start a Web browser. Go to the SAP Service Marketplace. Start the Notes search by double-clicking the SAP Search Notes quick link in the SAP Support Portal area. Logon to the SAP Service Marketplace with your own S user.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
201
Unit 5: Sources of Information for Developers
TAW10_1
There is no generic S user, which you can give to course participants at this point.
Task 2:
Display specific information: 1. 2. Display SAP Note 81069. What is this SAP Note about? With which databases can you use the SAP Web Application Server 6.40 kernel?
202
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Service Marketplace
Solution 8: SAP Service Marketplace (Optional)
Task 1: Using the SAP Service Marketplace
Participants must have own S users for logging on.
Log on to the SAP Service Marketplace: 1. Start a Web browser. a) 2. You can normally access the Web browser (for example, Microsoft Internet Explorer) as an icon on your desktop or using an entry in the Start menu. Enter the URL of the SAP Service Marketplace, http://service.sap.com, in the address field of your Web Browsers.
Go to the SAP Service Marketplace. a)
3.
Start the Notes search by double-clicking the SAP Search Notes quick link in the SAP Support Portal area. a) Solve the task as described. A dialog box is displayed for the logon. Logon to the SAP Service Marketplace with your own S user. There is no generic S user, which you can give to course participants at this point.
4.
a)
Enter the logon data of your S-user.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
203
Unit 5: Sources of Information for Developers
TAW10_1
Task 2:
Display specific information: 1. Display SAP Note 81069. What is this SAP Note about? a) You may find a link to SAP Notes on the homepage. Otherwise you can use the /notes Quick Link: • • b) c) By suffixing notes to the address line https://...sap.../ in your browser or By choosing the entry “Quick Links” in the header bar and selecting NOTES from the list
Enter the Note number 81069 and start the search for the SAP Note. Display the whole SAP Note by selecting the title. SAP Note 81069 contains information on the Web browser settings required to access the SAP Service Marketplace.
Continued on next page
204
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Service Marketplace
2.
With which databases can you use the SAP Web Application Server 6.40 kernel? a) There are various ways of answering questions about platform availability. Two approaches are outlined below: • Enter the search criteria Kernel 6.x 6.40 to restrict the Notes search (Quick Link /notes). To reduce the number of hits, also enter the application component XX-SER-SWREL. The other approach uses the Quick Link /platforms. You can use the link OS/DB combinations for downward compatible SAP Web AS 6.40 kernel to navigate to the document on the SAP Web AS 6.40 availability.
•
You can find details on the operating systems released for the 6.40 kernel in the following SAP Notes: SAP Note 407320 407322 407325 410783 407317 407328 407314 727683 Database SAP DB DB2 UDB DB2 on OS390 DB2 on AS400 Informix SQL Server Oracle MaxDB
2005/Q4
© 2005 SAP AG. All rights reserved.
205
Unit 5: Sources of Information for Developers
TAW10_1
Lesson Summary
You should now be able to: • List some of the services provided on the SAP Service Marketplace • Find and use SAP Notes in the SAP Service Marketplace
Related Information
You can find additional information on the SAP Service Marketplace using the SAP Service Marketplace URL: http://service.sap.com.
206
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Developer Network
Lesson:
167
SAP Developer Network
Lesson Duration: 30 Minutes
Lesson Overview
This lesson introduces you to the SAP Developer Network and the offers that can be found there.
Lesson Objectives
After completing this lesson, you will be able to: • • List some of the services of the SAP Developer Network Find development news in the SAP Developer Network
The SAP Developer Network was created in the context of the SAP NetWeaver initiative. The content of SDN is mainly aimed at developers and consultants. The SAP DN is an important enhancement to the already existing online information offer of SAP.
Business Example
As a developer of SAP software, you are interested in information on current developments and trends. The SAP Developer Network is a source of information that is available on the Internet.
The Target Audience of the SAP Developer Network
The SAP Developer Network (SDN) in an online community of developers, consultants and IT architects and integrators. In short, it provides and excellent meeting point for SAP experts. Registered members of the SDN can access information from many technical areas. However, the focus is on topics from the SAP NetWeaver area.
2005/Q4
© 2005 SAP AG. All rights reserved.
207
Unit 5: Sources of Information for Developers
TAW10_1
Figure 68: SDN Logon Screen
Services in the SAP Developer Network
SAP offers its customers a range of information options on the Internet. The following websites should be listed as examples: • • • • The online documentation at http://help.sap.com The SAP Service Marketplace at http://service.sap.com The information portals SAP Info (http://www.sap.info) and SAP InsiderOnline (http://www.sapinsideronline.com) The SAP Developer Network at http://sdn.sap.com
The SAP Developer Network is the latest addition to the SAP online information portals. Es ergänzt die bestehenden Informationsquellen, speziell um Themen aus dem Bereich des SAP NetWeaver. Why should you join SDN, what are the advantages and offers? The function of the SAP Developer Network can be summarized as follows:
208
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Developer Network
Figure 69: sdn.sap.com, the SAP Developer Network
• • • • • • • •
Access to technical articles and reviews Access to e-learning material SDN online forum Web logs Webinars SDN newsletter, distributed every two months NetWeaver Business Content, such as Enterprise Portal Business Content Access to download zones
The SAP Developer Network is thus a valuable addition to the existing online information sources of SAP.
2005/Q4
© 2005 SAP AG. All rights reserved.
209
Unit 5: Sources of Information for Developers
TAW10_1
210
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Developer Network
171
Exercise 9: SAP Developer Network (Optional)
Exercise Duration: 10 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Log on to the SAP Developer Network and systematically search for contents
Business Example
You require current information on secure RFC connections.
System Data
System: Client: User ID: Password: Set up instructions: The SDN on the Internet, the URL is http://sdn.sap.com. Not required. Please use your own SDN user. The password is individual and you should know it.
Task: Logon and Navigation in SDN
You want to find out about setting up secure RFC connections. You can also search for developer notes without logging on as an SDN user.
1.
Please log on to SDN with your own SDN user and search for documents on the subject of Secure RFC.
Result
You see a hit list with relevant documents, including the PDF file called Securing RFC Connections.
2005/Q4
© 2005 SAP AG. All rights reserved.
211
Unit 5: Sources of Information for Developers
TAW10_1
Solution 9: SAP Developer Network (Optional)
Task: Logon and Navigation in SDN
You want to find out about setting up secure RFC connections. You can also search for developer notes without logging on as an SDN user.
1.
Please log on to SDN with your own SDN user and search for documents on the subject of Secure RFC. a) In the web browser, open URL http://sdn.sap.com and log on with your SDN user. Enter the search text Secure RFC and start the search.
Result
You see a hit list with relevant documents, including the PDF file called Securing RFC Connections.
212
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: SAP Developer Network
Lesson Summary
You should now be able to: • List some of the services of the SAP Developer Network • Find development news in the SAP Developer Network
2005/Q4
© 2005 SAP AG. All rights reserved.
213
Unit Summary
TAW10_1
Unit Summary
You should now be able to: • List some of the services provided on the SAP Service Marketplace • Find and use SAP Notes in the SAP Service Marketplace • List some of the services of the SAP Developer Network • Find development news in the SAP Developer Network
214
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Test Your Knowledge
175
Test Your Knowledge
1. The SAP Service Marketplace is directed at which of the following?
Choose the correct answer(s).
□ □ □ □ □ 2.
A B C D E
Everyone who is interested in SAP SAP employees SAP partners SAP customers SAP competitors
You can download developer keys from SDN.
Determine whether this statement is true or false.
□ □
True False
2005/Q4
© 2005 SAP AG. All rights reserved.
215
Test Your Knowledge
TAW10_1
176
Answers
1. The SAP Service Marketplace is directed at which of the following? Answer: C, D The SAP Service Marketplace is directed at SAP customers and SAP partners. 2. You can download developer keys from SDN. Answer: False You apply for developer keys using the SAP Service Marketplace not in SDN.
216
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 6
177
ABAP Program Process
Skip the final slide (Topic Overview). This does not apply to TAW10!
Unit Overview
The unit overview lists the individual lessons that make up this unit.
Unit Objectives
After completing this unit, you will be able to: • • Describe the architecture of the SAP Web Application Server Describe how a simple dialog program is executed by the ABAP runtime system
Unit Contents
Lesson: System Architecture and ABAP Program Using Example of Selection Screen and List...................................................................... 218
2005/Q4
© 2005 SAP AG. All rights reserved.
217
Unit 6: ABAP Program Process
TAW10_1
Lesson:
178
System Architecture and ABAP Program Using Example of Selection Screen and List
Lesson Duration: 20 Minutes
Lesson Overview
In this lesson you will learn how a simple dialog program is executed by the SAP Web Application Server.
Lesson Objectives
After completing this lesson, you will be able to: • • Describe the architecture of the SAP Web Application Server Describe how a simple dialog program is executed by the ABAP runtime system
The idea is to give the participants a first impression of how the ABAP runtime system works, using two demonstration programs, and at the same time explain at what time during the course the individual aspects should be discussed in more detail.
Business Example
You are to explain the architecture of the SAP Web Application Servers as well as the execution of ABAP programs.
218
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: System Architecture and ABAP Program Using Example of Selection Screen and List
System Architecture and ABAP Program
Figure 70: Client/Server Architecture of the SAP Web Application Server
The SAP Web Application Server has a modular architecture that follows the software-oriented client/server principle. In the SAP Web Application Server, presentations, application logic, and data storage can be assigned to different systems. This serves as the basis for the scalability of the system. The lowest level is the database level. Here data is managed with the help of a relational database management system (RDBMS). This data includes, apart from application data, the programs and the metadata that the SAP System requires for self-management. The ABAP programs run at the application server level, that is, both the applications provided by SAP and the ones you develop yourself. The ABAP programs read data from the database, process the data, and possibly store data. The third level is the presentation server level. This level contains the user interface where each user can access the program, enter new data, and receive the results of a work process.
2005/Q4
© 2005 SAP AG. All rights reserved.
219
Unit 6: ABAP Program Process
TAW10_1
The technical distribution of software is independent of its physical location on the hardware. Vertically, all levels can be installed on top of each other on one computer or each level on a separate computer. Horizontally, the presentation and application servers can be divided among any number of computers. The horizontal distribution of database components, however, depends on the type of database installed.
Figure 71: Excerpt for an ABAP Program
This graphic can be simplified for most topics discussed during this course. The interaction between one user and one ABAP program will be of primary interest to us during this course. The exact processes involved in user dispatching on an application server are secondary to understanding how to write an ABAP program. Therefore, we will be working with a simplified graphic that does not explicitly show the dispatcher and the work process. Certain slides will, however, be enhanced to include these details whenever they are relevant to ABAP programming. ABAP programs are processed on the application server. The design of user dialogs and database accesses is of particular importance when writing application programs.
220
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: System Architecture and ABAP Program Using Example of Selection Screen and List
Figure 72: View for the User
The user is only interested in how his or her business transaction flows and how data can be entered and output within the transaction. The technical aspects of programming are less interesting for the user. The user does not need to know the precise flow of the ABAP program on the application server. To the average user, the SAP System is like a "Black Box". But from a technical point of view, there are, for example, three screen types: screens, selection screens and lists. Each type of screen provides different services to the user. Here the task of the developer is to select for each user dialog exactly those types that are most suitable for the accomplishment of the tasks concerned. For this purpose, the exact knowledge of the technical aspects is very helpful.
2005/Q4
© 2005 SAP AG. All rights reserved.
221
Unit 6: ABAP Program Process
TAW10_1
Figure 73: Interaction Between Server Layers
Once the user performs a user action, for example by choosing Enter, a function key, a menu function, or a pushbutton, control is passed from the presentation server to the application server. Only certain parts of the ABAP program will then be processed. If a further user dialog is triggered from within the ABAP program, the system transmits the screen, and control is once again passed to the presentation server.
222
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: System Architecture and ABAP Program Using Example of Selection Screen and List
Runtime Architecture of a Program with Selection Screen and List
Figure 74: Program Start
Whenever a user logs on to the system, a screen is displayed. From this screen, the user can start an ABAP program through the menu path.
2005/Q4
© 2005 SAP AG. All rights reserved.
223
Unit 6: ABAP Program Process
TAW10_1
Figure 75: System Loads Program Context
In this case, the system first loads the program context onto the application server. The program context contains memory areas for variables and complex data objects, information on the screens for user dialogs, and ABAP processing blocks. The runtime system gets all this program information from the Repository, which is a special part of the database. The sample program has a selection screen as the user dialog, a variable and a structure as data objects, and one ABAP processing block. The list used to display the data is created dynamically at runtime. The ABAP runtime system controls the subsequent program flow.
224
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: System Architecture and ABAP Program Using Example of Selection Screen and List
Figure 76: Runtime System Sends Selection Screen
Since the program contains a selection screen, the ABAP runtime system sends it to the presentation server. The presentation server controls the program flow for as long as the user has not finished entering data in the input fields. Selection screens allow users to enter selection criteria required by the program for it to continue.
2005/Q4
© 2005 SAP AG. All rights reserved.
225
Unit 6: ABAP Program Process
TAW10_1
Figure 77: Input Values Are Inserted into Data Objects
As soon as the user has finished entering data on the selection screen, he or she can trigger further processing of the program by choosing Execute. The entered data is automatically placed in its corresponding data objects in the program and the ABAP runtime system resumes control of processing. In our simple program example there is only one ABAP processing block. The ABAP runtime system triggers sequential processing of this ABAP processing block. If the entries made by the user do not have the correct type, then an error message is automatically triggered. The user must correct his/her entries.
226
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: System Architecture and ABAP Program Using Example of Selection Screen and List
Figure 78: Program Requests Data Record from Database
In the example program, read access to the database is programmed in the ABAP processing block. Therefore, information about which database table is accessed and which row in the table is read is passed to the database.
Figure 79: Database Returns Data Record to Program
2005/Q4
© 2005 SAP AG. All rights reserved.
227
Unit 6: ABAP Program Process
TAW10_1
The database returns the requested data record to the program and the runtime system ensures that this data is placed in the appropriate data objects. If a single record is accessed, this data object is usually a structure that contains relevant components for all the required database fields.
Figure 80: Runtime System Sends List
The layout of the subsequent list display is programmed into the processing block. After its completion, the runtime system sends this list to the presentation server as a screen.
Topic Overview
The above-described example program already demonstrates numerous concepts that make up the content of this course. The following table of contents, which shows which topics are dealt with in which units, serves as an aid to orientation for the further process of this course. Unit 1 Flow of an ABAP Program Unit 2 Introduction to the ABAP Workbench
228
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: System Architecture and ABAP Program Using Example of Selection Screen and List
Unit 3 Introduction to the ABAP Dictionary Unit 4 Basic ABAP Language Elements Unit 5 Data Retrieval Unit 6 Tools for Program Analysis Unit 7 Subroutines in ABAP Unit 8 Introduction to ABAP Events Unit 9 User Dialogs (Lists, Selection Screens, Screens, User Interface) Unit 10 Reuse Components Unit 11 Adjusting the SAP Standard Software (Overview)
2005/Q4
© 2005 SAP AG. All rights reserved.
229
Unit 6: ABAP Program Process
TAW10_1
Facilitated Discussion
You now have the opportunity to discuss any questions.
Discussion Questions
Use the following questions to engage the participants in the discussion. Feel free to use your own additional questions. See list of course objectives.
230
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: System Architecture and ABAP Program Using Example of Selection Screen and List
Lesson Summary
You should now be able to: • Describe the architecture of the SAP Web Application Server • Describe how a simple dialog program is executed by the ABAP runtime system
2005/Q4
© 2005 SAP AG. All rights reserved.
231
Unit Summary
TAW10_1
Unit Summary
You should now be able to: • Describe the architecture of the SAP Web Application Server • Describe how a simple dialog program is executed by the ABAP runtime system
232
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 7
191
Introduction to ABAP Workbench
For more information, see the introductory instructor notes in the lesson.
Unit Overview
The unit overview lists the individual lessons that make up this unit.
Unit Objectives
After completing this unit, you will be able to: • • • • • • • Describe the structure of the Repository Name and use the search tools of the Repository Use the Object Navigator for displaying Repository objects Name and use the utilities for orderly software development Create packages Create programs Create transactions
Unit Contents
Lesson: Repository and Object Navigator ....................................... 235 Lesson: Developing Programs and Organizing Developments............... 247 Procedure: Creating Packages ............................................... 251 Procedure: Creating an ABAP Program..................................... 260 Procedure: Creating Transactions ........................................... 264 Procedure: Adding Transactions to your Personal Favorites ............. 265 Exercise 10: Organizing Developments ..................................... 269 Exercise 11: Developing ABAP Programs .................................. 273
2005/Q4
© 2005 SAP AG. All rights reserved.
233
Unit 7: Introduction to ABAP Workbench
TAW10_1
Exercise 12: Creating Transactions.......................................... 277
234
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Repository and Object Navigator
Lesson:
192
Repository and Object Navigator
Lesson Duration: 45 Minutes
Lesson Overview
This lesson gives a short description of the Repository and a brief overview of the most important components of the ABAP Workbench. It presents the Object Navigator as a central development tool.
Lesson Objectives
After completing this lesson, you will be able to: • • • Describe the structure of the Repository Name and use the search tools of the Repository Use the Object Navigator for displaying Repository objects
In this lesson, two different aspects should be watched out for: On the one hand, the participants quickly learn many new SAP-specific terms. On the other hand, they also learn how to handle the search tools of the ABAP Workbench. Both aspects affect the entire remainder of the course: Terms and working techniques constantly come up during the course.
Business Example
You are to describe the structure of the Repository, use suitable tools to search for Repository objects and analyze their structure.
2005/Q4
© 2005 SAP AG. All rights reserved.
235
Unit 7: Introduction to ABAP Workbench
TAW10_1
Introduction to the Repository
Figure 81: The Cross-Client Capability of the Repository
The Repository consists of all development objects of the system: the programs, function modules, definitions of database tables and other objects. The Repository is used to keep both objects defined by SAP as well as objects defined by customers. The Repository is in the database and is always independent of the client, meaning a Repository object can be accessed from any client. Apart from the Repository, the database also contains application and Customizing tables, which are usually client-specific, that is, they have a client column.
236
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Repository and Object Navigator
Figure 82: Structure of the Repository
The Repository is subdivided according to application components. Within an application component (e.g., MM) there are several packages containing relevant objects for a more detailed logical subdivision. Whenever a Repository object is created, it must be assigned to a package. Repository objects are often made up of sub-objects that are also referred to as Repository objects.
Search Tools of the Repository
The Repository Information System is suitable for the random (i.e., not application-specific) search for Repository objects, such as all programs by a certain developer or all function modules that were changed after a certain date.
2005/Q4
© 2005 SAP AG. All rights reserved.
237
Unit 7: Introduction to ABAP Workbench
TAW10_1
Figure 83: The Repository Information System
You get to the Repository Information System from the SAP Easy Access Menu by choosing Tools → ABAP Workbench → Overview → Information System. When you double-click a certain object type, a selection screen appears allowing you to limit your search.
238
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Repository and Object Navigator
Figure 84: SAP Application Hierarchy
You use the application hierarchy for the application-specific search for Repository objects. There, the hierarchy of the application components is depicted in the form of a tree structure. From the SAP Easy Access Menu, you can easily branch to the SAP application hierarchy by choosing Tools→ ABAP Workbench → Overview → Application Hierarchy → SAP. Expanding a component node displays all the packages that are assigned to the corresponding component. You can now select any subtree using the Select button and then navigate directly to the Repository Information System using the Information System button. The system remembers all relevant packages of the selected subtrees and automatically enters them in the selection screen of the information system. This allows you to carry out a search in the previously selected applications.
2005/Q4
© 2005 SAP AG. All rights reserved.
239
Unit 7: Introduction to ABAP Workbench
TAW10_1
Working with the Object Navigator
Figure 85: ABAP Workbench Tools
The ABAP Workbench includes all tools required for creating and editing Repository objects. These tools cover the entire software development cycle. The most important tools are: • • • • • • The ABAP Editor for editing source code The ABAP Dictionary for editing database table definitions, central data types, and so on The Screen Painter for configuring screens (screens together with functions for user dialogs) The Menu Painter for designing user interfaces (menu bar, standard toolbar, application toolbar, function key settings) The Function Builder for maintaining function modules The Class Builder for maintaining global classes and interfaces
You can call each of these tools explicitly and then load a Repository object for processing. But it is much more elegant and convenient to access them using the Object Navigator. You can have the requested Repository objects listed in this central development tool. All you have to do to edit one of them is to double-click to select it. The corresponding tool is called automatically and includes the selected Repository for displaying or editing.
240
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Repository and Object Navigator
Figure 86: Screen Layout in the Object Navigator
The Object Navigator screen is split into two areas: • • The navigation area for displaying an hierarchical object list A tool area for displaying and editing a development object using the appropiate tool
You can display or hide the navigation area. (“Full screen on/off”) In both areas, you can choose the functions using a context menu, which you access using the right mouse button (the left mouse button, if you have set your mouse up for left-handedness). The context menu offers only those functions which have been designed for the respective object.
2005/Q4
© 2005 SAP AG. All rights reserved.
241
Unit 7: Introduction to ABAP Workbench
TAW10_1
Figure 87: Working with the Navigation Area
Object lists are displayed in the navigation area. For example, if you choose to display a package there, all of the Repository objects belonging to the specified package are listed. Double-clicking a listed object lets you display or edit it. You can navigate between the object lists that have been previously displayed in the current Object Navigator session (blue arrows). You can add frequently used object lists to your favorites.
242
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Repository and Object Navigator
Figure 88: Functions in the Tool Area
In the tool area, a Repository object is displayed in the corresponding tool. You can navigate between the objects that have been previously displayed in the current Object Navigator session (blue arrows). Furthermore, you can also display a subwindow with the previous navigation history. When you double-click an object in the navigation history, it is displayed in the tool area.
2005/Q4
© 2005 SAP AG. All rights reserved.
243
Unit 7: Introduction to ABAP Workbench
TAW10_1
Figure 89: Synchronizing the Navigation and Tool Areas
Navigation in the navigation area is independent of navigation in the tools area. This allows both areas to be used in a flexible manner. If necessary, you can synchronize both areas as follows: • • You get to display an object in the tool area by double-cklicking in the navigation area or by using the corresponding context menu function of the object. You can display the object list of an object that you are currently editing in the tool area by choosing Display Object List in the navigation area.
To create a new object, you can use the context menu for an object type in the corresponding object list. Alternatively, you can use the Edit Object or Other Object ... buttons to create any objects you want.
244
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Repository and Object Navigator
Facilitated Discussion
You now have the opportunity to discuss any questions.
Discussion Questions
Use the following questions to engage the participants in the discussion. Feel free to use your own additional questions. See list of course objectives.
2005/Q4
© 2005 SAP AG. All rights reserved.
245
Unit 7: Introduction to ABAP Workbench
TAW10_1
Lesson Summary
You should now be able to: • Describe the structure of the Repository • Name and use the search tools of the Repository • Use the Object Navigator for displaying Repository objects
246
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
Lesson:
203
Developing Programs and Organizing Developments
Lesson Duration: 95 Minutes
Lesson Overview
In this lesson you will learn how to create programs, transaction codes and packages and how to assign a Repository object to a package. You will also learn how development packages are implemented in the SAP environment using the ABAP Workbench.
Lesson Objectives
After completing this lesson, you will be able to: • • • • Name and use the utilities for orderly software development Create packages Create programs Create transactions
We believe that you learn how to work with the development environment most effectively by doing actual development.
Business Example
You are to create a new package and ABAP programs within the framework of a development project.
2005/Q4
© 2005 SAP AG. All rights reserved.
247
Unit 7: Introduction to ABAP Workbench
TAW10_1
Organizing Developments
Figure 90: Transporting Development Objects
Development projects are carried out in a development system. The development objects edited or created in a project are transported to subsequent systems (test and/or production system) on project completion. At the start of a development project the project manager creates a change request, in which he or she names the employees of this project, in the Transport Organizer or directly in the ABAP Workbench. The Transport Organizer then creates a task for each project employee in the change request. When a development object is edited or created, the relevant employee assigns this to the change request. The object is entered into the task of the employee. Thus, all repository objects that an employee works on during a development project are collected within his or her task.
248
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
Figure 91: Organization of a Development Project in the Change Request
Organizing a development project using a change request offers the following advantages: • • Each employee can track and check his or her project-specific activities. The respective development objects can be processed by all employees involved in the project. For those developers who do not belong to the project team, the repository objects remain locked until the project is completed (=change request is released). The joint transport of the development objects processed in the project at the time of project completion (= release of the change request) is automatically ensured by assigning the objects to the change request. The transport route of the involved packages (in which development took place) specifies to which subsequent system they are transported.
•
Unlike the functional divisions that separate Repository objects using packages, change requests are project-related and therefore have a limitation with regard to the time schedule of the objects involved. Thus, although a program always belongs to only one package, it can - at different times - belong to different projects.
2005/Q4
© 2005 SAP AG. All rights reserved.
249
Unit 7: Introduction to ABAP Workbench
TAW10_1
Show the request that was created for the course as an example.
250
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
206
Creating Packages
1. Navigate to the Object Navigator. You now have two options: a) In the navigation area, choose the object type Package and enter the name of the package in the input field below. (Make sure you comply with the customer namespace conventions.) Choose Enter. If the specified package does not already exist, the system branches to a dialog for creating a package. b) Choose Edit Object on the initial screen of the Object Navigator. In the dialog box, search for the option of specifying a package and enter the name of the package. Afterwards, click the button for creating the object (F5). Hint: In SAP R/3 Release 4.6, packages are still called development classes. They are handled in the same way as described here. There is one minor limitation under Release 4.6a/b: The only option you have for creating a development class is that described in 1b).
2.
Create the attributes of the package to be created.
Figure 92: Setting Package Attributes (Example)
The attributes have the following meaning (detailed information can be obtained by using the field help (F1)): Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
251
Unit 7: Introduction to ABAP Workbench
TAW10_1
Application Component Determine the location of the package within the application hierarchy by specifying the corresponding application component. Software Component For customer developments you should enter HOME as the software component. Transport Layer If you are executing your own developments, you must set up a transport layer for customer developments, which must be specified here. The transport layer determines if the objects of this package are to be transported to a subsequent system and, if so, to which system. Package Type You can choose between three package types: • • • Standard package (Can contain Repository objects and other packages) Main package (Can only contain other packages) Structure package (Can only contain main packages)
Continued on next page
252
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
Figure 93: Specifying a Transport Route
3.
Assign the package to a change request. You can display all change requests in which you have a task using the My Tasks pushbutton. Simply select the relevant request by double-clicking.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
253
Unit 7: Introduction to ABAP Workbench
TAW10_1
Figure 94: Assignment to a Change Request
Note: The system takes care of the exact assignment for your task. Hint: All repository objects that are created or changed must be assigned to the change request of the respective project. A change request has already been created for the project “Exercises for Training Participants BC400” in this training course. Each group of the course has a task within this change request.
Create a package with the name ZBC400_00 and assign it to a new, small change request with 2 tasks. Then you can do the corresponding exercise.
254
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
Introduction to the ABAP Programming Language
The ABAP programming language ... • • • • • • Is typed Enables multi-language applications Enables SQL access Has been enhanced as an object-oriented language Is platform-independent Is upward-compatible
It is especially designed for dialog-based business applications. To support the type-specific processing of data, type conversions and type casting are supported. Using translatable text elements, you can develop multi-language applications. The Open SQL standard embedded in ABAP allows direct database accesses. ABAP Objects is the object-oriented enhancement of the ABAP programming language. The ABAP syntax is platform-independent. That means it always has the same meaning or function, irrespective of the relational database system and operating system of the application and presentation server. Applications implemented in ABAP will also be able to run in future releases. (Upward compatibility of the language)
2005/Q4
© 2005 SAP AG. All rights reserved.
255
Unit 7: Introduction to ABAP Workbench
TAW10_1
Figure 95: General ABAP Syntax I
ABAP programs are made up of individual statements. The first word in a statement is called an ABAP keyword. Words must always be separated by at least one space. Each statement must end with a period. Statements can be indented. Statements can take up more than one line. You can have multiple statements in a single line. The ABAP runtime system does not distinguish between uppercase and lowercase letters for keywords, additions, and operands. In order to keep a better overview in this course, we will display all keywords and their additions in uppercase letters, and all operands in lowercase letters. For indentations and for converting uppercase/lowercase letters, you can use the Pretty Printer (the correspondingly labeled button in the Editor). You can use the following menu path in the Object Navigator to make a user-specific setting to the Pretty Printer: Tools → Settings → ABAP Editor → Pretty Printer.
256
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
Figure 96: General ABAP Syntax II
Comment lines are introduced with an asterisk *. The code generator recognizes the corresponding line as a comment so that it will be ignored by the runtime system. If you wish to have the rest of a line set as a comment, you must use double quotation marks ". You can combine consecutive statements with an identical beginning into a chained statement: • • • • Write the identical beginning part of the records followed by a colon. After the colon, list the end parts of the statements (separated by commas). Blank spaces and line breaks are allowed before and after the separators (colons, commas, periods). Note that this summarizing short hand is only a syntax help, it does not improve performance as the ABAP runtime system still processes the corresponding single statements.
2005/Q4
© 2005 SAP AG. All rights reserved.
257
Unit 7: Introduction to ABAP Workbench
TAW10_1
Figure 97: Return Code of the ABAP Statements
If there are several ABAP statements, the ABAP runtime system writes the corresponding return code into the system field SY-SUBRC in order to provide information as to how successfully the particular statement was executed. The value zero means that the statement was successful. Read the keyword documentation for the respective statements to find out if and how this return value is set in individual cases.
258
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
Figure 98: Keyword Documentation in the ABAP Editor
There are various ways of navigating to the documentation for an ABAP statement: • • The F1 key takes you directly to the documentation for the statement on which the cursor is positioned. The i button with the description Help on ... takes you to a dialog box where you can enter the required ABAP statement.
Create a small WRITE ’Hello World’ program. Assign it to your demo package and to the small demo request. You can use this program to demonstrate the following topics such as “active/inactive source”.
Developing an ABAP Program
In this section you will learn how to create programs and transactions in the ABAP Workbench. You will also learn about the purpose of program activation.
2005/Q4
© 2005 SAP AG. All rights reserved.
259
Unit 7: Introduction to ABAP Workbench
TAW10_1
215
Creating an ABAP Program
1. Navigate to the Object Navigator. Three options are available: a) In the navigation area, choose the object type Program and enter the name of the program in the input field below. (Comply with the customer namespace conventions.) Confirm with Enter. If the program does not exist, the system goes to the dialog that lets you create a program. b) Display the package where you want to create the program. You can branch to the dialog for creating a program via the context menu for the package or the Programs node. c) Choose Edit Object on the initial screen of the Object Navigator. In the dialog box, look for the option for specifying a program and enter the name of the program. Afterwards, click the button for creating the object (F5). 2. 3. In this training course, remove the flag for With TOP Include. (Otherwise, your source code would be distributed to several programs.) Change the title to a self-explanatory short text and, within this course, always choose Executable Program as the program type. All other program attributes are optional. Refer to F1 help for details.
Figure 99: Creating an ABAP Program
260
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
Activating Programs
Figure 100: Inactive and Active Development Objects
Whenever you create a development object, or change and then save it, the system first stores only one inactive version in the Repository. After that, you have an active version and an inactive version of the object. At the end of your object development, you have to activate the inactive “editing version” of the object. This version becomes the new active version of the object. Note that the request release and hence the transport of the developed objects are only possible if all objects in the request have been activated. If your program is available in both versions (active and inactive) then you can switch between the display of these two versions by using the corresponding button in the editor. Whenever you activate a program, the system displays a list of all inactive objects that you have processed: Your worklist. Choose those objects that you wish to activate with your current activation transaction.
2005/Q4
© 2005 SAP AG. All rights reserved.
261
Unit 7: Introduction to ABAP Workbench
TAW10_1
The activation of an object includes the following functions: • • • • Saving the object as an inactive version Syntax or consistency check of the inactive version Overwriting the previously active version with the inactive version (only after a successful check) Generating the relevant runtime object for later executions, if it is a program.
Figure 101: Generating Runtime Objects
When you generate a development object, the system creates a separate runtime object (LOAD compilation) and also stores it in the Repository. This generated version is the version that is executed (interpreted) at runtime. If your program has an inactive version as well as an active version, then you can get both versions to run as follows: • If you start your program using the context menu of the navigation area or by means of a transaction, then the active version is used. That is, the LOAD generated for the last activation is executed. In contrast, if you start the inactive version loaded to the editor using the F8 button, then a temporary runtime object is generated from it and executed.
•
262
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
This way it is possible to continue the development of a repository object without changing the current system status. All changes to the development object become “visible” system-wide only when the object is activated. Use the previously created program to illustrate the above-described in the form of a demo and then have the participants do the corresponding exercise.
Creating Transactions
Only transactions can be included in a role menu as well as the favorites of a user. Hence, if you want to place a program there, you must create a transaction that represents the program and integrate this in the menu. Alternatively, you can then start the program by entering the transaction code in the command field.
2005/Q4
© 2005 SAP AG. All rights reserved.
263
Unit 7: Introduction to ABAP Workbench
TAW10_1
219
Creating Transactions
1. 2. 3. In the Object Navigator, display the object list for your program. In the navigation area, use the context menu of the program to choose Create → More → Transaction. Enter the required transaction code. (Make sure you comply with the customer namespace conventions!) Assign a short text and choose the label Program and Selection Screen (Report Transaction) . 4. On the next screen, enter the name of the program and choose Professional User Transaction. Under GUI enabled set the indicator SAP GUI for Windows.
Figure 102: Creating a Transaction
5. 6.
Save the transaction. Since each transaction is a Repository object, you must assign it to a package and to a change request on the following screens.
264
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
220
Adding Transactions to your Personal Favorites
1. 2. 3. Navigate to the initial screen (SAP Easy Access Menu). In the Favorites context menu, choose Insert Transaction. In the dialog box that appears, enter the required transaction code.
Figure 103: Inserting a Transaction Code into the Personal Favorites
Result
The short text of the transaction now appears under the Favorites and you can start the corresponding program by double-clicking. Create a transaction for your SELECT program and add it to your personal favorites. Make the participants do the corresponding exercise.
Closing Development Projects
Once a project employee has completed his development task, he carries out a quality check and releases his task within the change request.
2005/Q4
© 2005 SAP AG. All rights reserved.
265
Unit 7: Introduction to ABAP Workbench
TAW10_1
Figure 104: The Developer Releases his Task
The corresponding object entries as well as the change locks of the object for third parties that were automatically set at the start of project are transferred from the task to the request. However, all project employees can still edit these objects. Once all tasks of a change request have been released, the project manager carries out the final check for the objects and releases the change request. This concludes the project.
266
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
Figure 105: Closing the Project by Releasing the Request (Project Manager)
When the request is released, all object locks that belong to the request are removed. Copies of the developed objects are exported to the system’s own transport directory where they stay until the system administrator imports them to their intended target system. Another copy of the exported development objects is stored in the system’s own version database. Release your Little Demo Request.
2005/Q4
© 2005 SAP AG. All rights reserved.
267
Unit 7: Introduction to ABAP Workbench
TAW10_1
268
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
223
Exercise 10: Organizing Developments
Exercise Duration: 5 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Create packages • Assign changes in Repository objects to a change request
Business Example
You are a developer for an airline group and you are given the task of developing evaluation programs for several airline companies. To group the repository objects together logically and also transport them, you must create a package.
System Data
System: Client: User ID: Password: Set up instructions: system Will be assigned Will be assigned Will be assigned Will be assigned No special instructions when using a standard training
Task 1:
Logon to the training system 1. 2. Log on to the operating system and then to the specified training system using the user name the instructor has given you. Enter a new personal password.
Task 2:
Create Package 1. Create the package ZBC400_##. Assign it to the change request the instructor has given you.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
269
Unit 7: Introduction to ABAP Workbench
TAW10_1
2.
Assign all your repository objects in the following exercises to this package and this change request. Hint: It is best if you always work with the Object Navigator tool. It provides you with an overview of all Repository objects in your package. From here, you can edit each object directly by selecting it from this list.
270
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
Solution 10: Organizing Developments
Task 1:
Logon to the training system 1. Log on to the operating system and then to the specified training system using the user name the instructor has given you. a) 2. a) Carry out this step as usual. Carry out this step as usual. Enter a new personal password.
Task 2:
Create Package 1. Create the package ZBC400_##. Assign it to the change request the instructor has given you. a) 2. Carry out this step as described in the training material. Assign all your repository objects in the following exercises to this package and this change request. Hint: It is best if you always work with the Object Navigator tool. It provides you with an overview of all Repository objects in your package. From here, you can edit each object directly by selecting it from this list. a) Carry out this step as described in the training material.
2005/Q4
© 2005 SAP AG. All rights reserved.
271
Unit 7: Introduction to ABAP Workbench
TAW10_1
272
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
225
Exercise 11: Developing ABAP Programs
Exercise Duration: 20 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Create, edit, save, and process ABAP programs • Check ABAP programs for correct syntax • Test and activate ABAP programs
Business Example
You need to create an ABAP program that displays information on all existing flight departure times in a list. The data is to be read from the database table SFLIGHT.
System Data
System: Client: User ID: Password: Set up instructions: training system Will be assigned Will be assigned Will be assigned Will be assigned No special instructions required when using a standard
Task 1:
Create program 1. Create the executable program ZBC400_##_GS_LIST without a “TOP include”.
Task 2:
Edit program 1. Define a work area for the data retrieval and data display (name suggestion: wa_flight): DATA wa_flight TYPE sflight. 2. Program a loop access to all data records in database table SFLIGHT: Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
273
Unit 7: Introduction to ABAP Workbench
TAW10_1
SELECT * FROM sflight INTO wa_flight. ... ENDSELECT. 3. For each data record, display the contents of the fields carrid, connid, fldate, seatsocc, and seatsmax in the list: NEW-LINE. WRITE wa_flight-carrid. WRITE ... 4. Check your program for syntax errors. Test and activate it.
274
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
Solution 11: Developing ABAP Programs
Task 1:
Create program 1. Create the executable program ZBC400_##_GS_LIST without a “TOP include”. a) Carry out this step as described in the training material.
Task 2:
Edit program 1. Define a work area for the data retrieval and data display (name suggestion: wa_flight): DATA wa_flight TYPE sflight. a) 2. See source code excerpt in the model solution.
Program a loop access to all data records in database table SFLIGHT: SELECT * FROM sflight INTO wa_flight. ... ENDSELECT. a) See source code excerpt in the model solution.
3.
For each data record, display the contents of the fields carrid, connid, fldate, seatsocc, and seatsmax in the list: NEW-LINE. WRITE wa_flight-carrid. WRITE ... a) See source code excerpt in the model solution.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
275
Unit 7: Introduction to ABAP Workbench
TAW10_1
4.
Check your program for syntax errors. Test and activate it. a) Carry out this step as described in the training material.
Result
Source code excerpt: SAPBC400WBS_GS_LIST
REPORT
sapbc400wbs_gs_list.
DATA wa_flight TYPE sflight.
SELECT * FROM sflight INTO wa_flight.
NEW-LINE. WRITE: wa_flight-carrid, wa_flight-connid, wa_flight-fldate, wa_flight-seatsocc, wa_flight-seatsmax.
ENDSELECT.
276
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
229
Exercise 12: Creating Transactions
Exercise Duration: 10 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Create transactions • Define transaction codes as personal favorites
Business Example
The users of your company are to be able to start their ABAP programs as transactions or define them as personal favorites.
System Data
System: Client: User ID: Password: Set up instructions: system Will be assigned Will be assigned Will be assigned Will be assigned No special instructions when using a standard training
Task 1:
Create transaction 1. Create transaction code ZBC400_##_GS for the executable program ZBC400_##_GS_LIST. Hint: In the transaction definition, select Program and Selection Screen (Report Transaction) as the start object. 2. Execute your program by entering the new transaction code in the command field.
Task 2:
Define favorites 1. 2. Add transaction code ZBC400_##_GS to your personal favorites. Execute your program by double-clicking the new favorite entry.
2005/Q4
© 2005 SAP AG. All rights reserved.
277
Unit 7: Introduction to ABAP Workbench
TAW10_1
Solution 12: Creating Transactions
Task 1:
Create transaction 1. Create transaction code ZBC400_##_GS for the executable program ZBC400_##_GS_LIST. Hint: In the transaction definition, select Program and Selection Screen (Report Transaction) as the start object. a) 2. Carry out this step as described in the training material.
Execute your program by entering the new transaction code in the command field. a) Carry out this step as usual.
Task 2:
Define favorites 1. 2. Add transaction code ZBC400_##_GS to your personal favorites. a) a) Carry out this step as described in the training material. Carry out this step as usual. Execute your program by double-clicking the new favorite entry.
278
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Developing Programs and Organizing Developments
Lesson Summary
You should now be able to: • Name and use the utilities for orderly software development • Create packages • Create programs • Create transactions
2005/Q4
© 2005 SAP AG. All rights reserved.
279
Unit Summary
TAW10_1
Unit Summary
You should now be able to: • Describe the structure of the Repository • Name and use the search tools of the Repository • Use the Object Navigator for displaying Repository objects • Name and use the utilities for orderly software development • Create packages • Create programs • Create transactions
280
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 8
233
Basic ABAP Language Elements
For more information, see the introductory instructor notes in the lesson.
Unit Overview
The unit overview lists the individual lessons that make up this unit.
Unit Objectives
After completing this unit, you will be able to: • • • • • • • • • Define elementary data objects (simple variables) Use basic ABAP statements with elementary data objects Execute and analyze programs in debugging mode Define structured data objects (structure variables) Use basic ABAP statements for structured data objects Analyze structured data objects in debugging mode Define internal tables Use basic ABAP statements with internal tables Analyze internal tables in debugging mode
Unit Contents
Lesson: Working with Elementary Data Objects................................ 282 Exercise 13: Basic ABAP Statements ....................................... 301 Lesson: Working with Structures ................................................. 307 Exercise 14: Working with Structures........................................ 313 Lesson: Working with Internal Tables ............................................ 321 Exercise 15: Working with Internal Tables .................................. 339
2005/Q4
© 2005 SAP AG. All rights reserved.
281
Unit 8: Basic ABAP Language Elements
TAW10_1
Lesson:
234
Working with Elementary Data Objects
Lesson Duration: 75 Minutes
Lesson Overview
In this lesson you will become familiar with the difference between data types and data objects (first only the elementary ones) and you will learn how to define and use these in a program. You will also learn some basic ABAP statements. Furthermore, you will find out how to use the ABAP Debugger for analyzing a program flow.
Lesson Objectives
After completing this lesson, you will be able to: • • • Define elementary data objects (simple variables) Use basic ABAP statements with elementary data objects Execute and analyze programs in debugging mode
This lesson deals with basic terms and concepts that are the same in all modern programming languages. The main thing is to point out the SAP-specific aspects. However, it could be that your participants’ experience is less than required. In this case, you will have to proceed more slowly in this lesson. The basic handling of the ABAP Debugger will be introduced here and, in the following lessons, further aspects of it will be explained.
Business Example
You are supposed to use simple variables in your programs and edit these with simple statements. Furthermore, you want to find the semantic errors in your programs by using the ABAP Debugger.
Data Types and Data Objects
A formal variable description is called data type. In contrast, a variable concretely defined by means of a data type is called data object. The following graphic shows how data types can be used:
282
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Elementary Data Objects
Figure 106: Using Data Types
The type of a data object defines its technical (and possibly also semantic) attributes. The type of interface parameter defines the type of the value of the actual parameters that are passed when the modularization unit is called. The type of an input/output field can provide further information in addition to the technical characteristics, such as the field and value input help. In this lesson, you will mainly learn how to use types for defining program-internal variables. Let’s have a look at the ABAP standard types predefined by SAP (implemented types) first. They are divided into two groups: Complete and incomplete types. The following implemented ABAP standard types are complete. That means they already contain the type-related, fixed length information: Complete ABAP standard types D Type for date(D), format: YYYYMMDD, length 8 (fixed) T Type for time (T), format: HHMMSS, length 6 (fixed)
2005/Q4
© 2005 SAP AG. All rights reserved.
283
Unit 8: Basic ABAP Language Elements
TAW10_1
I Type for integer (I), length 4 (fixed) F Type for floating point number (F), length 8 (fixed) STRING Type for dynamic length character string XSTRING Type for dynamic length byte sequence (HeXadecimal string) The following standard types do not contain a fixed length (incomplete). With these, the length of the variable has to be specified for data object definitions. Incomplete ABAP standard types C Type for character string (Character) for which the fixed length is to be specified N Type for numerical character string (Numerical character) for which the fixed length is to be specified X Type for byte sequence (HeXadecimal string) for which the fixed length is to be specified P Type for packed number (Packed number) for which the fixed length is to be specified. (In the definition of a packed number, the number of decimal points may also be specified.) For more information on predefined ABAP types, refer to the keyword documentation on the TYPES or DATA statement. You can use the standard types to declare more complete or also more more complex local data types. These only exist in the program in question and hence can only be used there. This declaration happens by means of a TYPES statement.
284
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Elementary Data Objects
Figure 107: Declaring Local Types
A data type defined in the ABAP Dictionary is called global as it can be used throughout the entire system (meaning in the entire SAP system in question).
Figure 108: Global Data Types in the Dictionary
In this lesson, we will only describe the data elements and use them as field types. The other global data types are used later in this course.
2005/Q4
© 2005 SAP AG. All rights reserved.
285
Unit 8: Basic ABAP Language Elements
TAW10_1
There are three categories of types in total: standard, local and global. We now want to use these types to define variables (data objects).
Figure 109: Defining Data Objects
Data objects are always defined with the DATA key word. You can use an ABAP standard type, a local type, or a global type to type a data object. You can refer to an already defined data object when defining additional variables (LIKE addition).
286
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Elementary Data Objects
Figure 110: Examples of the Definition of Elementary Data Objects
You can use the VALUE addition to pre-assign the value of an elementary data object. If the type information is missing in a variable definition, then standard type C is assumed. In contrast, if the length is missing, then the appropriate default length for the (incomplete) standard type is used. The "DATA myvar." statement without type or length information thus defines a character variable with a length of 1 as the default length of type C is one. You can get the default lengths of the incomplete standard types as well as other information from the keyword documentation on the TYPES or DATA statement.
2005/Q4
© 2005 SAP AG. All rights reserved.
287
Unit 8: Basic ABAP Language Elements
TAW10_1
Figure 111: Literals and Constants (Fixed Data Objects)
Fixed data objects have a fixed value, which is already fixed when the source text is written and cannot be changed at runtime. Literals and constants belong to the fixed data objects. You can use literals to specify fixed values in your programs. There are numeric literals (specified without quotation marks) and text literals (specified with quotation marks). The figure above shows some examples of literals. You define constants using the CONSTANTS statement. Their type is defined similarly to the definition of elementary data objects. The VALUE addition is required for constants. This is how you define the value of the constants. If possible, avoid literals completely when using statements. Instead, use constants. This significantly increases the ease of maintenance of your program.
288
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Elementary Data Objects
Figure 112: Local vs. Global Data Types
Local data types can only be used in the program where they are defined. Global data types, in contrast, can be used throughout the entire system. Apart from that, the latter also have the following advantages: • • The system-wide usability of global types increases the system’s consistency and their reusability reduces the amount of maintenance required. In the ABAP Dictionary you have the option of generating a where-used list for a global data type. The where-used list lists the Repository objects that use the data type in question. In addition to the technical information, global data types can also contain semantic information that corresponds to the business descriptions of the objects to be defined. They can then also be used for designing screen displays (for example, the short description on the left of the input field).
•
Local data types should be used only if used exclusively in the program where they are defined and if semantic information does not matter for the definition of the corresponding data objects.
2005/Q4
© 2005 SAP AG. All rights reserved.
289
Unit 8: Basic ABAP Language Elements
TAW10_1
Basic ABAP Statements
Figure 113: Value Assignments
When the program is started, the program context is loaded into a memory area of the application server and memory is made available for the data objects defined in the program. Every elementary data object is pre-assigned the type-specific initial value, except if a different value was pre-assigned using the VALUE addition. You can use the MOVE statement to transfer the contents of a data object to another data object. The following two syntax variants have the same effect: • • MOVE var1 TO var2.. var2 = var1..
If both data objects var1 and var2 are of different types, then there is a type conflict. In this case, a type conversion is carried out automatically, if a conversion rule exists. For detailed information on copying and the conversion rules, refer to the keyword documentation for the MOVE statement. The CLEAR statement resets the contents of a data object to the type-specific initial value. For detailed information on the initial values for a particular type, refer to the keyword documentation on the CLEAR statement.
290
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Elementary Data Objects
Figure 114: Calculations
In ABAP you can program arithmetic expressions nested to any depth. Valid operations include: • • • • • • • + * / ** DIV MOD Addition Subtraction Multiplication Division Exponentiation Integral division without remainder Remainder after integral division
Caution: Parentheses and operators are ABAP keywords and must therefore be separated from other words by at least one space. Several functions for different data types are predefined in the ABAP runtime environment. For example, the following statement provides the current length of the content of a character variable. length = STRLEN( cityfrom ). In the case of functions, the opening parenthesis is part of the function name. The rest must again be separated by at least one space.
2005/Q4
© 2005 SAP AG. All rights reserved.
291
Unit 8: Basic ABAP Language Elements
TAW10_1
In general, the standard algebraic rules apply to the processing sequence: Expressions in parentheses come first, then powers, then multiplication/division, and finally addition/subtraction. For detailed information on the available operations and functions, refer to the keyword documentation on the COMPUTE statement.
Figure 115: Conditional Branches
292
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Elementary Data Objects
In ABAP you have two ways to execute different sequences of statements, depending on certain conditions: • In the IF construct you can define any logical expressions as check conditions. If the condition is met, the system executes the relevant statement block. Otherwise, the condition specified in the ELSEIF branch (several are possible) is checked and so on. If none of the specified conditions are met, then the system executes the ELSE branch, if it is available. ELSEIF and ELSE branches are optional. For detailed information on formulating a logical expression refer to the keyword documentation on the IF statement. You can use the CASE construct to clearly distinguish cases. The content of the field specified in the CASE part is checked against the data objects listed in the WHEN branches to see whether they match. If the field contents match, the respective statement block is processed. If no comparison is successful, the system executes the OTHERS branch if it is available. Except for the first WHEN branch, all further additions are optional.
•
In both constructs the condition or match check happens sequentially from the top down. As soon as the statement block of a branch has been executed, the system immediately jumps to ENDIF or ENDCASE. Hint: If you want to implement similarity checks between a field and different values, you should prefer the CASE construct to the IF statement as it is clearer and performs better.
2005/Q4
© 2005 SAP AG. All rights reserved.
293
Unit 8: Basic ABAP Language Elements
TAW10_1
Figure 116: Loops
There are four loop constructs in ABAP. In the DO and WHILE loop the system field SY-INDEX contains the number of the current loop pass. Hence, querying this system field only makes sense within a loop. In nested loops, SY-INDEX always contains the loop pass number of the loop in which it is located. Unconditional/Index-Controled Loops The statement block between DO and ENDDO is continuously executed until the loop is left using termination instructions such as EXIT. You also have the option of specifying the maximum number of loop passes; otherwise you may get an endless loop. Header-Controled Loops The statement block between WHILE and ENDWHILE is continuously executed until the specified condition is no longer met. The condition is always checked before executing the statement block. Read Loops You can use the SELECT loop to read several entries of a database table in succession. In an internal table (table variable in the program), the same read function is implemented with the LOOP loop.
294
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Elementary Data Objects
Figure 117: Dialog Messages
You use the MESSAGE statement to send dialog messages to the users of your program. When you do this, you must specify the three digit message number and the message class. Message number and message class clearly identify the message to be displayed. You use the message type to specify where the message is to be displayed. You can test the display behavior for using the different message types by means of the DEMO_MESSAGES demo program that is shipped in the SAP standard. If the specified message contains placeholders, you can supply them with values from your program by using the WITH addition. Instead of the placeholders, the transferred values then appear in the displayed message text. For further information on the syntactical alternatives to the MESSAGE statement, refer to the keyword documentation. If you have used a WRITE in your SELECT program in the sy-subrc query to output an error message, it would now be appropriate to replace this with the MESSAGE using message 041 from the message class BC400 and with the Carrier parameter of your selection screen. Use message type i and explain that this can be improved later on using event control. Now you could introduce the “pocket calculator exercise”.
2005/Q4
© 2005 SAP AG. All rights reserved.
295
Unit 8: Basic ABAP Language Elements
TAW10_1
Working with the ABAP Debugger
Figure 118: Executing a Program in Debugging Mode
Here it would be appropriate to introduce the programs SAPBC400TSD_COPY_CLEAR and SAPBC400WBT_GETTING_STARTED on debugging from the BC400 package. There are several ways to start a program in debugging mode from the Object Navigator: a) In the navigation area for the selected program, choose the context menu Execute → Debugging. b) In the editor area, select the requested program line from which you wish to debug. Choose the Set/Delete breakpoint button. Afterwards, start the program by choosing F8 or in the navigation area via the context menu Execute → Direct. (The above-described setting of a breakpoint in the editor is only possible for active source texts.)
296
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Elementary Data Objects
Figure 119: Switching to Debugging Mode at Runtime
If you want to “debug” a certain function of a program, first start the program without the debugger and then switch to debug mode immediately before executing the function (e.g. pushbutton). There are two ways of doing this: a) Choose System → Utilities → Debugging ABAP (or screen). b) Enter /h in the command field in the standard toolbar and press Enter.
2005/Q4
© 2005 SAP AG. All rights reserved.
297
Unit 8: Basic ABAP Language Elements
TAW10_1
Figure 120: Debugging Mode: Single Step and Field Contents
In debugging mode, you can choose Single step to execute the program statement by statement. You can display the contents of up to eight data objects. To do so, enter their names in the field name area or copy them by “double-clicking” on the corresponding data objects from the source code.
298
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Elementary Data Objects
Figure 121: Debugging Mode: Breakpoints
You can set a breakpoint by double-clicking in front of a line of source code. You can also set a breakpoint for specific ABAP statements: Breakpoints → Breakpoint at → Statement. If you choose Continue, the program is executed up to the next breakpoint. The set breakpoints are only valid for the current debugger session. However, if you Save, the breakpoints stay for you for the duration of your current SAP session.
2005/Q4
© 2005 SAP AG. All rights reserved.
299
Unit 8: Basic ABAP Language Elements
TAW10_1
Figure 122: Debugging Mode: Tracing Data Changes
Watchpoints are breakpoints that depend on the field content. If you set a watchpoint without specifying a relational operator/comparative value on a field and choose Continue, then the program is executed until the content of the field changes. However, if you specified relational operator and comparative value, then, once you choose Continue, the program is executed until the specified condition is met. You can set up to 10 watchpoints and link these using a logical operator (AND or OR).
300
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Elementary Data Objects
253
Exercise 13: Basic ABAP Statements
Exercise Duration: 30 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Define elementary data objects • Assign values • Implement conditional branching • Perform calculations
Business Example
You are to create a simple ABAP program for the four basic calculation types. You must be able to enter the values and the arithmetic operator on a selection screen. Display the result in a list.
System Data
System: Client: User ID: Password: Set up instructions: 1. Will be assigned Will be assigned Will be assigned Will be assigned
No special instructions required when using a standard training system
Task 1:
Create program 1. Create the executable program ZBC400_##_COMPUTE without a “TOP include”.
Task 2:
Define input parameters (implicit definition of the selection screen). 1. Define the input parameters for two integer values (name suggestion: pa_int1, pa_int2) and an arithmetic operator (name suggestion: pa_op).
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
301
Unit 8: Basic ABAP Language Elements
TAW10_1
Task 3:
Execute calculations and set up the list output. 1. 2. 3. Additionally, define an elementary data object for the result; type: Packed number with two decimal places (name suggestion: result). Execute the calculation dependent on the specified arithmetic operator. Use the CASE statement for a branch. Display the result in a list.
Task 4:
Catch errors. 1. Display an error message on the list if the user has specified an invalid arithmetic operator. Use the IF statement for checking. 2. Display an error message on the list if the user tries to divide by zero. Hint: In a later lesson you will learn how to implement the catching of these errors with a more “elegant” user dialog.
302
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Elementary Data Objects
Solution 13: Basic ABAP Statements
Task 1:
Create program 1. Create the executable program ZBC400_##_COMPUTE without a “TOP include”. a) Carry out this step as usual.
Task 2:
Define input parameters (implicit definition of the selection screen). 1. Define the input parameters for two integer values (name suggestion: pa_int1, pa_int2) and an arithmetic operator (name suggestion: pa_op). a) See source code excerpt in the model solution.
Task 3:
Execute calculations and set up the list output. 1. Additionally, define an elementary data object for the result; type: Packed number with two decimal places (name suggestion: result). a) 2. See source code excerpt in the model solution. Execute the calculation dependent on the specified arithmetic operator. Use the CASE statement for a branch. a) 3. a) See source code excerpt in the model solution. See source code excerpt in the model solution. Display the result in a list.
Task 4:
Catch errors. 1. Display an error message on the list if the user has specified an invalid arithmetic operator. Use the IF statement for checking. a) See source code excerpt in the model solution. Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
303
Unit 8: Basic ABAP Language Elements
TAW10_1
2.
Display an error message on the list if the user tries to divide by zero. Hint: In a later lesson you will learn how to implement the catching of these errors with a more “elegant” user dialog. a) See source code excerpt in the model solution.
Result
Source text section: SAPBC400TSS_COMPUTE
REPORT sapbc400tss_compute.
PARAMETERS: pa_int1 TYPE i,
pa_op(1) TYPE c, pa_int2 TYPE i.
DATA result TYPE p DECIMALS 2.
IF NOT ( pa_op = ’+’ OR pa_op = ’-’ OR pa_op = ’*’ OR pa_op = ’/’ ).
WRITE: ’Invalid operator!’(iop).
ELSEIF pa_op = ’/’ AND pa_int2 = 0.
WRITE: ’No division by zero!’(dbz).
ELSE.
CASE pa_op. WHEN ’+’. result = pa_int1 + pa_int2. WHEN ’-’. result = pa_int1 - pa_int2. WHEN ’*’. result = pa_int1 * pa_int2.
Continued on next page
304
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Elementary Data Objects
WHEN ’/’. result = pa_int1 / pa_int2. ENDCASE.
WRITE: ’Result:’(res), result.
ENDIF.
Note: You will learn about the additions in parentheses for the WRITE statement in a later lesson. You can omit them here.
2005/Q4
© 2005 SAP AG. All rights reserved.
305
Unit 8: Basic ABAP Language Elements
TAW10_1
Lesson Summary
You should now be able to: • Define elementary data objects (simple variables) • Use basic ABAP statements with elementary data objects • Execute and analyze programs in debugging mode
306
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Structures
Lesson:
259
Working with Structures
Lesson Duration: 75 Minutes
Lesson Overview
In this lesson, we will continue with the definition of structured data objects (structure variables) and their analysis using the ABAP Debugger. Also, this chapter will teach you how to use basic ABAP statements for structured data objects.
Lesson Objectives
After completing this lesson, you will be able to: • • • Define structured data objects (structure variables) Use basic ABAP statements for structured data objects Analyze structured data objects in debugging mode
Structure variables in the program are simply “records” in other programming languages. The advantage of ABAP is that you can use global structure types (dictionary structures) to define uniform structure variables in different programs. This should be emphasized as a strength of the ABAP language.
Business Example
You are to process your own first data structures and search your programs for semantic errors using the ABAP Debugger.
2005/Q4
© 2005 SAP AG. All rights reserved.
307
Unit 8: Basic ABAP Language Elements
TAW10_1
Working with Structures
Figure 123: Definition of Structures with Global Types
In ABAP, you can define structured data objects (called structure variables or simply structures). This allows you to combine values that belong together logically into one data object. Structures can be nested. This means that components can be made up of more structures or even internal tables. In the program, structure variables are defined with the DATA statement, in the same way as elementary data objects. When you set the types, you can refer to • • • . The following graphic shows the definition of a structure variable using a locally declared structure type. a Dictionary structure a transparent table (that is then used as a structure type) or a structure type that is locally declared in the program
308
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Structures
Figure 124: Defining Structures with Local Types
You can use the TYPES statement to define local structure types. Here the components are enclosed by BEGIN OF structure_type_name, ... , END OF structure_type_name. . You can assign any type you want to each component by using the TYPE addition. For more details, refer to the keyword documentation for the TYPES statement. You define the data object itself in the usual way. If necessary, you can also define a structured data object directly. To do so, all you have to do is replace the leading key word TYPES with DATA. DATA: BEGIN OF structure_name, ... , END OF structure_name.
2005/Q4
© 2005 SAP AG. All rights reserved.
309
Unit 8: Basic ABAP Language Elements
TAW10_1
Figure 125: Access to Structure Components
Components of a structure are always addressed using a hyphen: structure_name-component_name. For this reason, you should not use hyphens in names.
Figure 126: Copying Structure Components with the Same Name
310
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Structures
The MOVE-CORRESPONDING statement copies the contents of the source structure to the target structure one component at a time. Here, only those components are considered that are available under the same name in both the source and the target structure. All other components of the structures remain unchanged. The individual value assignments can each be executed using MOVE.
Figure 127: Structures in Debugging Mode
You can trace the field contents of a structure in the Debugger by first entering the structure name in the Field Names area or copying it from the source code by double-clicking it. You get the component display of the structure by double-clicking the structure name in the Field Names area. Using this exercise, make it clear that the Debugger can also be used for semantic operations in a program whose functions are not yet known.
2005/Q4
© 2005 SAP AG. All rights reserved.
311
Unit 8: Basic ABAP Language Elements
TAW10_1
312
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Structures
265
Exercise 14: Working with Structures
Exercise Duration: 30 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Use the ABAP Debugger to trace the data flow and understand the connections between processing blocks. • Use the ABAP statement MOVE-CORRESPONDING to assign values between structures.
Business Example
You have to examine a specified ABAP program to ascertain when and how specific data is transported between certain structured data objects.
System Data
System: Client: User ID: Password: Set up instructions: 1. Will be assigned Will be assigned Will be assigned Will be assigned
No special instructions required when using a standard training system
Task 1:
Execute a program in debugging mode 1. Start the program SAPBC400WBS_GETTING_STARTED. On the selection screen, enter LH in the Airline field. In the command field, enter /h and then choose Enter. Choose F8 to run the program. You are now in debugging mode.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
313
Unit 8: Basic ABAP Language Elements
TAW10_1
2.
Check that all of the data objects are initial. Transfer all of the data objects defined in the program into the field view. Display the type assignment and the contents of the structure components. Hint: Within the program, the TABLES sbc400_carrier statement defines a structure variable of the same name and structure for the specified Dictionary structure SBC400_CARRIER. This unusual, non-intuitive type of structure definition is only used for screen programming. The program-internally defined structure is used as the data exchange interface between the program and the screen. For more information, refer to these exercises in the chapter on screen programming.
3.
Step through the program using the single-step function.
Task 2:
Analyze the field contents 1. Which fields of the structure WA_SCARR does the SELECT statement fill? What is the value of system field SY-SUBRC after this statement?
2.
Now observe how fields are copied from the structure WA_SCARR to the structure SBC400_CARRIER. Which field values are copied?
Continued on next page
314
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Structures
3.
The ABAP statement CALL SCREEN 100 processes screen 100. What are the technical names of the fields on the screen?
4.
On the screen, enter the appropriate values for the user name, date, and time, and continue the program with Enter. Which program-internal data objects are now output in the list? What are their values?
Task 3:
Trace the list structure 1. Now, observe how the WRITE statement constructs the list. Hint: After executing the first WRITE statement, an additional button appears in the tool bar. You can use this new button to display the list buffer generated so far. However, a list buffer line is displayed only once it is closed, that is, when the next line is started.
Task 4:
Set breakpoints and change field contents 1. Restart the program in Debugging mode. Set a breakpoint for each WRITE statement. Also set a watchpoint for structure WA_SCARR. Continue the program by selecting Continue, and check why the processing of the program is stopped in each case.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
315
Unit 8: Basic ABAP Language Elements
TAW10_1
2.
Restart the program in Debugging mode. Set a breakpoint for the CALL SCREEN statement and execute the program until it reaches this statement. Now, before processing the screen, assign a random name to the program-internal field UNAME of the SBC400_CARRIER structure. Hint: Choose Change Field Content in the Field Names area to change the field value in the Debugger. Now, let the system process the CALL SCREEN statement. What do you see on the screen?
316
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Structures
Solution 14: Working with Structures
Task 1:
Execute a program in debugging mode 1. Start the program SAPBC400WBS_GETTING_STARTED. On the selection screen, enter LH in the Airline field. In the command field, enter /h and then choose Enter. Choose F8 to run the program. You are now in debugging mode. a) 2. Carry out this step as described. Check that all of the data objects are initial. Transfer all of the data objects defined in the program into the field view. Display the type assignment and the contents of the structure components. Hint: Within the program, the TABLES sbc400_carrier statement defines a structure variable of the same name and structure for the specified Dictionary structure SBC400_CARRIER. This unusual, non-intuitive type of structure definition is only used for screen programming. The program-internally defined structure is used as the data exchange interface between the program and the screen. For more information, refer to these exercises in the chapter on screen programming. a) 3. a) Carry out this step as described in the training material. Carry out this step as described in the training material.
Step through the program using the single-step function.
Task 2:
Analyze the field contents 1. Which fields of the structure WA_SCARR does the SELECT statement fill? What is the value of system field SY-SUBRC after this statement? Answer: All, zero 2. Now observe how fields are copied from the structure WA_SCARR to the structure SBC400_CARRIER. Which field values are copied? Answer: Fields with the same name - therefore, MANDT, CARRID, CARRNAME, and CURRCODE. Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
317
Unit 8: Basic ABAP Language Elements
TAW10_1
3.
The ABAP statement CALL SCREEN 100 processes screen 100. What are the technical names of the fields on the screen? Answer: SBC400_CARRIER-CARRID SBC400_CARRIER-CARRNAME SBC400_CARRIER-CURRCODE SBC400_CARRIER-UNAME SBC400_CARRIER-UZEIT SBC400_CARRIER-DATUM
4.
On the screen, enter the appropriate values for the user name, date, and time, and continue the program with Enter. Which program-internal data objects are now output in the list? What are their values? Answer: The fields of the program-internal structure SBC400_CARRIER are output. Their values are those that were displayed or entered on the screen.
Task 3:
Trace the list structure 1. Now, observe how the WRITE statement constructs the list. Hint: After executing the first WRITE statement, an additional button appears in the tool bar. You can use this new button to display the list buffer generated so far. However, a list buffer line is displayed only once it is closed, that is, when the next line is started. a) Carry out this step as described.
Task 4:
Set breakpoints and change field contents 1. Restart the program in Debugging mode. Set a breakpoint for each WRITE statement. Also set a watchpoint for structure WA_SCARR. Continued on next page
318
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Structures
Continue the program by selecting Continue, and check why the processing of the program is stopped in each case. a) b) c) 2. Choose Breakpoints → Breakpoint for → Statement ..., to set a breakpoint referring to a statement name. Enter WRITE in the dialog box. In the dialog box, enter structure name WA_SCARR to create a watchpoint. The processing of the program is stopped at each breakpoint and whenever a watchpoint is triggered.
Restart the program in Debugging mode. Set a breakpoint for the CALL SCREEN statement and execute the program until it reaches this statement. Now, before processing the screen, assign a random name to the program-internal field UNAME of the SBC400_CARRIER structure. Hint: Choose Change Field Content in the Field Names area to change the field value in the Debugger. Now, let the system process the CALL SCREEN statement. What do you see on the screen? a) b) Carry out this step as described. On the screen, in the User field, you can see the name that was previously specified in the Debugger. For more information on the field transport between the screen and the program, refer to the appropriate chapter.
2005/Q4
© 2005 SAP AG. All rights reserved.
319
Unit 8: Basic ABAP Language Elements
TAW10_1
Lesson Summary
You should now be able to: • Define structured data objects (structure variables) • Use basic ABAP statements for structured data objects • Analyze structured data objects in debugging mode
320
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Internal Tables
Lesson:
272
Working with Internal Tables
Lesson Duration: 90 Minutes
Lesson Overview
In this lesson, you will learn how to define internal tables and use them in ABAP programs. Following this, you will analyze the internal tables in the ABAP Debugger at runtime.
Lesson Objectives
After completing this lesson, you will be able to: • • • Define internal tables Use basic ABAP statements with internal tables Analyze internal tables in debugging mode
The participants’ understanding of this lesson will depend on their previous experience. The concept of internal tables does not exist in any of the other common programming languages in this form. You should certainly emphasize that this extremely useful concept is one of the many strengths of ABAP.
Business Example
You are to use table variables as data stores in your programs and then search for semantic errors in such programs by means of the ABAP Debugger.
2005/Q4
© 2005 SAP AG. All rights reserved.
321
Unit 8: Basic ABAP Language Elements
TAW10_1
Working with Internal Tables
Figure 128: Internal Tables: Usage Options
An internal table is a data object, in which you can keep several identically structured data records at runtime (table variable). The number of data records is restricted only by the capacity of specific system installations. The ABAP runtime system dynamically manages the size of the internal table. That means, you as the developer do not have to do any work concerning memory management. The individual data sets in an internal table are known as a table rows or table entries. For this reason, the individual components in a row are referred to as fields or columns of the internal table. The row type of an internal table can be specified through any data type and describes the row structure of the table entries.
322
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Internal Tables
Internal tables are therefore a simple way of processing large data sets in a structured manner. Typical uses include: • • • Retaining data from database tables or sequential files for future processing Formatting data for screen or printer output (e.g., sort) Format data for using other services (e.g., subroutine, function module or method call)
Figure 129: Attributes of Internal Tables
The following properties specify an internal table completely: Line type The line type describes the structure of the table rows. You usually specify a structure type for that. But any data types are possible. Key The key of an internal table consists of the key fields including their order. The order of the key fields is used, amongst other things, for sorting in accordance with the keys. Depending on the access type, the key can be defined as unique or non-unique. Unique means that a row with certain key values may not exist more than once within the table. Table kind You can choose from three different table types: Standard, Sorted, and Hashed. Depending on the access type used, you should use the appropriate table type for the definition in order to enable high performance access. The following graphic illustrates the selection of the appropriate table type.
2005/Q4
© 2005 SAP AG. All rights reserved.
323
Unit 8: Basic ABAP Language Elements
TAW10_1
Figure 130: Attributes and Use of the Table Types
When a table entry is accessed by specifying the corresponding row number, this is called index access. In contrast, when you access an entry by entering a key value, this is called key access. Depending on the access type you should always choose the most suitable of the following three table types in order to enable high performance accesses: • With standard tables the row numbering (index) is maintained internally. Both index and key accesses are possible. You should choose this table type when you mainly use the index to access the internal table. • With sorted tables the data records are automatically sorted in ascending order of the key fields. Here too, the index is maintained internally. Both index and key accesses are possible. You should choose this table type if you mainly access the internal table with the key or would like the table to be automatically sorted by key. • With hashed tables the data records are managed for fast key access using the hashing procedure. A unique key is required. With hashed tables only key accesses are possible. You should choose this table type if the internal table is very large and you want to access it by key only.
324
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Internal Tables
In this course, we only deal with standard tables, but - apart from a few special cases the syntax is identical for all three table types.
Figure 131: Defining Internal Tables with Global Types
The type of an internal table is called table type. Table types can be defined globally in the ABAP Dictionary or locally in a program. The figure above shows a table type declared in the ABAP Dictionary as well as the program-internal definition of a table variable with reference to the table type. For detailed information on the declaration of global table types in the ABAP Dictionary, please refer to the online documentation which you access using the i button in the display or the maintenance of the table type.
2005/Q4
© 2005 SAP AG. All rights reserved.
325
Unit 8: Basic ABAP Language Elements
TAW10_1
Figure 132: Defining Internal Tables with Local Types
The graphic above shows a table declared locally in the program as well as the program-internal definition of a table variable with reference to the declared table type. When you list the key fields in the table type note that their order matters for certain processing types such as “sort by key”. For detailed information on defining local table types, refer to the keyword documentation for the TYPES statement. You can also directly define an internal table: All you have to do for that is to use DATA instead of TYPES. In the previous definitions of internal tables, Dictionary objects were always used: Either a table type (SBC400_T_SBC400FOCC) or at least a structure type (SBC400FOCC). The following graphic shows an “independent” table definition:
326
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Internal Tables
Figure 133: Independent Definition of Internal Tables
With this you can implement tables of any structure without having to refer to existing Dictionary structures. The following graphic shows an overview of possible definitions of internal tables:
Figure 134: Possible Definitions of Internal Tables
The short form of a table definition illustrated above implicitly uses the following default values:
2005/Q4
© 2005 SAP AG. All rights reserved.
327
Unit 8: Basic ABAP Language Elements
TAW10_1
Table type: Standard (default) Uniqueness of key: Non-unique (only option for a standard table) Table key: Default key (All non-numeric table fields are key fields) Hint: As the default key usually cannot be used in a meaningful way, you should only use it to define an internal table, if you do not need the key for processing your table. Caution: A common beginner’s error consists of the following syntax: DATA itab TYPE TABLE OF . In doing so, an internal table would be defined, the rows of which would also be internal tables (of the specified table type)!
Figure 135: Overview: Definition of structured data objects
328
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Internal Tables
Figure 136: Accessing Single Records (Overview)
For single record processing of an internal table, you usually need a work area for which the structure variable has to be defined with the same type as the line type of the internal table. The graphic above illustrates the processing of an internal table via the corresponding work area. APPEND Appends the contents of a structure to an internal table. This operation can only be used with standard tables. INSERT Inserts the content of a structure into an internal table. In the case of a standard table, this content is appended, in a sorted table it is inserted in the right place according to the key, and in a hashed table it is inserted according to the hash algorithm. READ Copies the content of a table row to a structure. MODIFY Overwrites an internal table row with the contents of a structure. DELETE Deletes a row of an internal table.
2005/Q4
© 2005 SAP AG. All rights reserved.
329
Unit 8: Basic ABAP Language Elements
TAW10_1
COLLECT Accumulates the contents of a structure in row of an internal table that has the same key. In doing so, only non-key fields are added. Hence, this statement can only be used for tables whose non-key fields are all numeric. For detailed information about the ABAP statements described here, refer to the relevant keyword documentation.
Figure 137: Processing Sets of Records (Overview)
LOOP . . . ENDLOOP The LOOP places the rows of an internal table one by one into the structure specified in the INTO clause. Within the LOOP, the current content of the structure can be output or changed and written back to the table. DELETE Deletes the rows of the internal table that satisfy the condition . INSERT Copies the contents of several rows of an internal table to another internal table. APPEND Appends the contents of several rows of an internal table to another standard table.
330
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Internal Tables
For detailed information about the ABAP statements described here, refer to the relevant keyword documentation.
Figure 138: Syntax Example: Inserting a Row
You can insert a row into an internal table by writing the required record into the prepared work area and then inserting it into the internal table with an INSERT statement. With standard and hash tables, this has the effect that the row is appended. With a sorted table, the line is inserted according to the key.
2005/Q4
© 2005 SAP AG. All rights reserved.
331
Unit 8: Basic ABAP Language Elements
TAW10_1
Figure 139: Syntax Example: Output Internal Table row-by-row
You can read and edit the contents of an internal table row-by-row using a LOOP statement. Within a search run the sy-tabix system field contains the row number of the current table entry. The above example shows the output of the respective current record using the WRITE statement as processing. If you want to change the content of the current table row within the loop pass, first change the copy of the row in the work area and then write it back to the current table row using the MODIFY statement. The syntax for this is: MODIFY itab FROM wa.
332
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Internal Tables
Figure 140: Syntax Example: Reading Using the Index
In the loop, you can restrict the access to certain rows by using the FROM-TO addition. In the above example, the system only runs through the first five rows in the internal table in sequence. You can use the READ TABLE statement to read a single record. You use the INDEX addition to specify the row number of the required record. Please note that in both examples of the above figure an index is used, which is only possible with index tables (i.e., standard and sorted).
2005/Q4
© 2005 SAP AG. All rights reserved.
333
Unit 8: Basic ABAP Language Elements
TAW10_1
Figure 141: Syntax Example: Reading Using the Key
In the loop, you can restrict the access to certain rows by using the WHERE addition. In the above example, the system only processes those internal table rows in which the CARRID field has the value LH. Hint: From a runtime requirement perspective the table most suited to this type of processing is a sorted table that has the CARRID field as its first key field. You can use the READ TABLE syntax in the above graphic to read a certain row of the internal table. In this case, you must assign values to all key fields after the WITH TABLE KEY addition. The return code sy-subrc is set to zero if a corresponding row is in the internal table. Hint: From the perspective of the runtime requirement, a hash table is most suitable for this type of single access in case of a large amount of data. Please note that with the WITH TABLE KEY addition all key fields have to be supplied with data. If you want to limit the fields you must use the WITH KEY addition.
334
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Internal Tables
Figure 142: Syntax Example: Sort and Delete Content
Standard and hash tables can be sorted in ascending or descending order by table key or columns by using the SORT statement. If neither ASCENDING nor DESCENDING is specified as the sorting order, then the first is used by default. Culture-specific sorting rules can even be taken into account, if necessary. You can use the optional AS TEXT addition to implement lexicographical sorting. In the German speaking environment this means that “ä” comes before “b” and not far behind “z”, which would be the case in case of non-lexicographical sorting. If you use the STABLE addition, which is also optional, the relative order of data records which have identical sort keys will remain intact during sorting. For more details, refer to the keyword documentation for the SORT statement. You can use the following statements for deleting the table contents: REFRESH This deletes the entire contents of the internal table. A part of the previously used memory remains available for future insertions.
2005/Q4
© 2005 SAP AG. All rights reserved.
335
Unit 8: Basic ABAP Language Elements
TAW10_1
CLEAR With internal tables without a header line (all that have been previously defined in the course), the CLEAR statement has the same effect as REFRESH. For internal tables with a header line (see below) in contrast, it only initializes the header line. FREE This deletes the entire contents of the internal table and releases the previously used memory. You use the FREE statement for internal tables that have already been evaluated and are no longer required in the further course of the program. This has the effect that previously assigned but no longer required memory becomes available again. Debug the program SAPBC400TSD_ITAB_SORT in the package BC400.
Figure 143: Internal Tables in Debugging Mode
In the debugger, you can monitor the content of an internal table by entering the table name in the field name area and then branching off to the table display by double-clicking.
336
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Internal Tables
Alternatively, you can also use the table button and specify the table name in the internal table field. Following that, you can get to the display of the table contents by pressing the Enter key.
Figure 144: Comparison: Internal Tables with and Without Header Lines
The WITH HEADER LINE addition in the definition of the internal table gives you the option of creating a table with header line. When this is done a work area (header line) that suits the table is created automatically so that the additional definition of the same is not necessary. This also simplifies the syntax of the table commands, as the system always refers to the automatically generated work area, which therefore no longer has to be specified explicitly. In spite of the mentioned advantages we no longer want to use table with header lines because: • • The automatically generated work area has the same name as the internal table, which does not contribute to making the program readable. Tables with header lines are not allowed in: – – . complex data objects (structures and internal tables that have internal tables as components) ABAP objects (object oriented extension of ABAP)
2005/Q4
© 2005 SAP AG. All rights reserved.
337
Unit 8: Basic ABAP Language Elements
TAW10_1
We only mention internal tables with header lines here because some older programs still use them and you have to work with such programs from time to time. It is for this purpose that further particularities of the header line are listed below: If an internal table with header line is called itab, then itab- tablefield is used to address the corresponding field in the work area. You can address the body of the table with itab[]. The following example illustrates the above-mentioned situation: DATA itab1 TYPE TABLE OF scarr WITH HEADER LINE. DATA itab2 LIKE itab1. itab1 = itab2 . itab1[] = itab2[] . Only operations with header lines ! Operations with table bodies
The following very old syntax also defines an internal table with header line, even though that is not stated specifically. DATA: BEGIN OF itab OCCURS n, field1 TYPE ... , field2 TYPE ... , ... , END OF itab. If there is enough time, you can write a program that demonstrates internal table handling. When you type the internal table, refer to an ABAP Dictionary type and show how you can search for table types using the where-used list function for the line types. When you discuss the header line, make it very clear why it is not supposed to be used any more but why it is useful to know about it nonetheless. Then go on to the exercise.
338
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Internal Tables
291
Exercise 15: Working with Internal Tables
Exercise Duration: 30 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Search for suitable table types in the ABAP Dictionary • Define internal tables based on a global table type • Fill internal tables using array fetch • Process the content of internal tables using a loop
Business Example
You are to output flight dates stored in database table SPFLI in a list by using an internal table (as temporary storage).
System Data
System: Client: User ID: Password: Set up instructions: system Will be assigned Will be assigned Will be assigned Will be assigned No special instructions when using a standard training
Task 1:
Define internal table 1. 2. Create the executable program ZBC400_##_ITAB_LOOP without a “TOP include”. Buffer the data from the database table SPFLI in an internal table. You should define an internal table with a line type that is compatible with the line structure of SPFLI.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
339
Unit 8: Basic ABAP Language Elements
TAW10_1
In the ABAP Dictionary, search for all table types that match this condition. Hint: Have the transparent table SPFLI displayed in the ABAP Dictionary. There, use the appropriate pushbutton to list the where-used list of SPFLI. (Pay attention to the correct selection when triggering the where-used list) 3. 4. Define an internal table (name suggestion: it_spfli) based on one of the found global table types. Define a suitable work area for the internal table (name suggestion: wa_spfli).
Task 2:
Fill and output the internal table 1. Program an array fetch access to all data records in the database table SPFLI as follows: SELECT * FROM spfli INTO TABLE it_spfli. 2. Use the LOOP statement to output the buffered data in the internal table in a list.
340
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Internal Tables
Solution 15: Working with Internal Tables
Task 1:
Define internal table 1. Create the executable program ZBC400_##_ITAB_LOOP without a “TOP include”. a) 2. Carry out this step as usual. Buffer the data from the database table SPFLI in an internal table. You should define an internal table with a line type that is compatible with the line structure of SPFLI. In the ABAP Dictionary, search for all table types that match this condition. Hint: Have the transparent table SPFLI displayed in the ABAP Dictionary. There, use the appropriate pushbutton to list the where-used list of SPFLI. (Pay attention to the correct selection when triggering the where-used list) a) 3. Carry out this step as described.
Define an internal table (name suggestion: it_spfli) based on one of the found global table types. a) See source code excerpt in the model solution. See source code excerpt in the model solution. Define a suitable work area for the internal table (name suggestion: wa_spfli). a)
4.
Task 2:
Fill and output the internal table 1. Program an array fetch access to all data records in the database table SPFLI as follows: SELECT * FROM spfli INTO TABLE it_spfli. a) See source code excerpt in the model solution.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
341
Unit 8: Basic ABAP Language Elements
TAW10_1
2.
Use the LOOP statement to output the buffered data in the internal table in a list. a) See source code excerpt in the model solution.
Result
Source code excerpt: SAPBC400TSS_ITAB_LOOP
REPORT sapbc400tss_itab_loop. DATA DATA it_spfli TYPE sbc400_t_spfli. wa_spfli LIKE LINE OF it_spfli.
SELECT * FROM spfli INTO TABLE it_spfli. * at least one dataset selected IF sy-subrc = 0. LOOP AT it_spfli INTO wa_spfli. WRITE: / wa_spfli-carrid, wa_spfli-connid, wa_spfli-cityfrom, wa_spfli-cityto, wa_spfli-deptime, wa_spfli-arrtime. ENDLOOP. ENDIF.
342
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Working with Internal Tables
Lesson Summary
You should now be able to: • Define internal tables • Use basic ABAP statements with internal tables • Analyze internal tables in debugging mode
2005/Q4
© 2005 SAP AG. All rights reserved.
343
Unit Summary
TAW10_1
Unit Summary
You should now be able to: • Define elementary data objects (simple variables) • Use basic ABAP statements with elementary data objects • Execute and analyze programs in debugging mode • Define structured data objects (structure variables) • Use basic ABAP statements for structured data objects • Analyze structured data objects in debugging mode • Define internal tables • Use basic ABAP statements with internal tables • Analyze internal tables in debugging mode
344
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 9
297
Data Retrieval
For more information, see the introductory instructor notes in the lesson.
Unit Overview
The unit overview lists the individual lessons that make up this unit.
Unit Objectives
After completing this unit, you will be able to: • • • • • List different methods for searching relevant database tables Program read access to specific columns and rows within a particular database table List different methods for read accesses to several database tables Explain the SAP authorization concept Implement authorization checks
Unit Contents
Lesson: Reading Database Tables ............................................... 346 Exercise 16: Data Retrieval Using a SELECT Loop ....................... 363 Exercise 17: Data Retrieval and Buffering in an Internal Table .......... 369 Lesson: Authorization Check...................................................... 375 Exercise 18: Authorization Check ............................................ 383
2005/Q4
© 2005 SAP AG. All rights reserved.
345
Unit 9: Data Retrieval
TAW10_1
Lesson:
298
Reading Database Tables
Lesson Duration: 110 Minutes
Lesson Overview
In this lesson you will learn how to retrieve information on database tables and how to read data from them. An overview of techniques that allow you to access multiple database tables will also be covered. This lesson concludes with a note about database table accesses that initiate changes.
Lesson Objectives
After completing this lesson, you will be able to: • • • List different methods for searching relevant database tables Program read access to specific columns and rows within a particular database table List different methods for read accesses to several database tables
Those participants that already have experience with platform-specific SQL statements (especially with porting problems) will be particularly enthused about ABAP Open SQL.
Business Example
You need to evaluate data from database tables.
346
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
Data Retrieval
Figure 145: Database Access (Architecture)
SQL is the abbreviation of Structured Query Language, a language that enables define, change, and read access to database tables. Every relational database system has a native SQL, which is unfortunately database-specific. Hence, an ABAP program with native SQL statements cannot be used without restrictions in all SAP systems (due to the different database systems of different SAP systems). In contrast Open SQL is an SAP-defined, database-independent SQL standard for the ABAP language. The Open SQL statements are dynamically converted to the corresponding native SQL statements of the currently used database system and are thus independent of the database. They allow the ABAP programmer uniform access to data, regardless of the database system installed.
2005/Q4
© 2005 SAP AG. All rights reserved.
347
Unit 9: Data Retrieval
TAW10_1
Figure 146: Searching for Database Tables
The above graphic illustrates the options for searching for the required database tables. Of course, you can also execute a free search via the Repository Information System.
Figure 147: Database Read Access (Overview)
348
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
You use the Open SQL statement SELECT to program database read access. The SELECT statement contains a series of clauses, each of which has a different task: • • • • Amongst other things, the SELECT clause describes which fields of the table are to be read. The FROM clause names the source (database table or view) from which the data is to be selected. The INTO clause determines the target variable into which the selected data is to be placed. The WHERE clause specifies the columns of the table that are to be selected.
For information about other clauses, please refer to the keyword documentation for the SELECT statement.
Figure 148: Reading Single Records
The SELECT SINGLE statement allows you to read a single record from the database table. To ensure a unique access, all key fields must be filled in the WHERE clause. The client field is an exception: If it is not specified the current client is assumed. (Please note that a client can only be specified in the SELECT select statement in combination with the CLIENT SPECIFIED addition. More details on this are provided in the course of this lesson.) You use the asterisk * to specify that all fields of the table row to be selected are to be read. If you only want a specific selection of columns, you can list the required fields instead of the *. The next graphic illustrates this.
2005/Q4
© 2005 SAP AG. All rights reserved.
349
Unit 9: Data Retrieval
TAW10_1
You use the INTO clause to specify the target variable to which the data record is to be copied. Left-justified, the target area must be structured like the table row or the specified required fields of the row. If the system finds a suitable record, the return value SY-SUBRC equals 0.
Figure 149: Suitable Target Structure for the Field List
If you want only a certain selection of fields from the table row to be read, these can be specified as a field list within the SELECT statement (as described in the above graphic). In the INTO clause, you must then name a target structure variable that has the same structure as the field list (at least in the beginning), that is, it contains the fields of the field list in the same order. Only the corresponding field types have to match. The names of the target structure fields are not taken into account. An alternative to specifying the target structure is to list the corresponding target fields in the INTO clause. INTO (field_1, ... , field_n)
350
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
Figure 150: Fields in the Target Structure that have the Same Names as those in the Field List
If you want to use a structure variable for receiving the read record, which has fields with the same names as the fields in the target list but has a different structure (additional fields, different order of fields), it makes sense to use the CORRESPONDING FIELDS OF addition. This has the effect that only fields of the same name are filled in the target area. Please make sure that the corresponding field types are also the same, because otherwise (like in the MOVE statement), a (complicated) conversion happens and it is possible that incomplete data (caused by cut-offs) can be transported to the target fields. The advantages of this variant are: • • The target structure does not have to be left-justified in the same way as the field list. This construction is easy to maintain, since extending the field list or target structure does not require other changes to be made to the program, as long as there is a field in the structure that has the same name (and if possible, the same type as well).
2005/Q4
© 2005 SAP AG. All rights reserved.
351
Unit 9: Data Retrieval
TAW10_1
Figure 151: Reading several rows using a loop
You can use the above-illustrated SELECT loop to read several rows of a database table into the program in succession. The WHERE clause determines which lines are read into the target structure and processed using the statement block specified in the loop body. Multiple logical conditions within the WHERE clause can be logically connected using AND or OR. The database delivers the data to the database interface of the application server in packages. The specified processing block then copies the records to the target area row-by-row for processing. The loop is left automatically once all required rows have been read and evaluated. The return value should be queried after the SELECT loop (i.e., after the ENDSELECT statement). SY-SUBRC has the value 0 if the system read at least one row. In this case, SY-DBCNT contains the number of records read.
352
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
Figure 152: Reading Several Rows Using an Array Fetch
You can use the INTO TABLE addition to copy the selected part of the database into an internal table directly instead of doing so row-by-row. This technique is called an array fetch. It is a high performance technology for filling an internal table with entries from a database table, as the data transport is realized in blocks and not in rows. Because an array fetch is not a type of loop processing, no ENDSELECT statement is required or allowed. In the same way as the SELECT variants discussed before, the internal table that is specified as the target in the array fetch must be structured left-justified in the same way as the field list. If an internal table does not meet this prerequisite, then you have to use the INTO CORRESPONDING FIELDS OF TABLE addition instead of INTO TABLE . There, the database columns specified in the field list are copied to the columns of the internal table that have the same names. Here, you also have to make sure that the field types of the corresponding columns match in order to avoid complex conversions and possibly incomplete data in the target table. With the array fetch, the content that might be in the internal table is overwritten. If you want to appends rows instead, you can use the APPENDING TABLE addition. The value of SY-SUBRC is zero if at least one record was copied to the internal table. SY-DBCNT then contains the number of rows read.
2005/Q4
© 2005 SAP AG. All rights reserved.
353
Unit 9: Data Retrieval
TAW10_1
Figure 153: Reading Data From Client-Specific Tables
A database table is called client-specific, if it has a client field (data type CLNT) as the first key column and contains client-specific entries. If you select data from client-specific tables without specifying the client, then only data records from the current client are read. The current client is transferred to the database system, where the data retrieval takes place. If you want to read data from an explicitly-specified client, you have to specify this client in the WHERE clause. Note however, that this is only possible when you use the CLIENT SPECIFIED addition after the FROM clause. As cross-client reading is rarely requested in practice and not relevant in the context of this course, the client field is usually omitted in the presentations.
354
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
Figure 154: Performance Aspect: Secondary Index
If a database table is frequently accessed using a certain selection, you should define a secondary index for the fields contained in the selection in order to speed up corresponding accesses. This happens in the display mode of the relevant transparent table in the ABAP Dictionary using the Indexes pushbutton. When you activate the index, a secondary index is created in the database. With selections from client-specific tables the client is always transmitted to the database (i.e., it is always part of the selection). Hence, it makes sense to include the client field when you define an index for such tables. At runtime, this can be used to restrict the database search to the relevant client block by means of the secondary index. After an index has been created and activated, the Database Optimizer automatically uses this index when the program is executed if the index can contribute to speeding up the respective selection. You do not have to specify the index manually in the SELECT statement.
2005/Q4
© 2005 SAP AG. All rights reserved.
355
Unit 9: Data Retrieval
TAW10_1
The primary index consists of all key fields of the database table and is created automatically. It speeds up accesses that have a selection across all key fields or at least a left justified part of the key fields. Hint: Please note that unnecessary indexes tend to have a negative effect on your system’s performance.
This would be a good time to carry out the two SELECT exercises. Show the high-performing alternative solution to the second exercise to illustrate the use of the array fetch in practice (program SAPBC400DDS_SELECT_ARRAY_FETCH).
Reading Multiple Database Tables, Accesses that Initiate Changes (Outlook)
There is often a requirement to read data from different tables and display it. First of all, you should look for Reuse Components that take care of the read process. The following graphic provides an overview of such read routines supplied by SAP, which you can use in your program.
356
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
Figure 155: Reuse Components for Data Retrieval
There are four types of data selecting reuse components: • Logical databases (= data retrieval programs that read data from tables that belong together hierarchically) • Function modules (= subroutines stored in the function library of the SAP system with encapsulated functionality, such as reading from hierarchically related tables) • • BAPIs (= Methods of Business Objects with read function, for example) Methods of global classes For detailed information on searching for and using logical databases, please refer to the online documentation for “ABAP programming and runtime environment”, section on “ABAP database access” or course BC405. Information about the other three techniques is available in the relevant units.
2005/Q4
© 2005 SAP AG. All rights reserved.
357
Unit 9: Data Retrieval
TAW10_1
If there are no useable reuse components available for your data selection, you have to implement the read access yourself. In general, the technique with the best performance is the implementation using a table join. Let’s read and output SPFLI records as an example. However, for each record the long name of the respective airline, which is stored in SCARR, is to be output as well. The following graphic shows the logical creation of the corresponding table join, from which you can select all the required data using the SELECT statement.
Figure 156: Example of a Table Join
Stress that it is possible to achieve the desired result using a loop on SPFLI with a SELECT SINGLE on SCARR for each loop pass but that the performance of this technique is very poor when there are large quantities of data.
358
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
Figure 157: Entries for Defining a Table Join
You have to answer three questions when you define a table join: • • Join tables Which database tables should be accessed? Join condition What is the condition under which the corresponding records from the join tables are summarized to a join record? • Join columns Which columns from the join tables should be available in the table join?
2005/Q4
© 2005 SAP AG. All rights reserved.
359
Unit 9: Data Retrieval
TAW10_1
Figure 158: Implementation Options for Table Joins
There are two options for implementing a table join: • In the ABAP Dictionary you create a database view that corresponds to a table join and select from it in your program. For detailed information, please refer to the online documentation for the ABAP Workbench, in the ABAP Dictionary section. • In your program, you select from a join that is defined there (ABAP join). At runtime, the system dynamically generates an appropriate database query in the database interface. For more information, see the keyword documentation for the FROM clause of the SELECT statement. Hint: A table join is a view of the relevant database tables and does not contain the corresponding data redundantly. With a selection from a table join the data is read from the corresponding database tables. You can join more than two tables in a join.
360
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
Show the online documentation for the SELECT-> FROM clause, in which the ABAP join is explained. If there is enough time, you can create a database view in the Dictionary with a view of SCARR and SPFLI. To do so, enter both tables and choose the Relationships function. Select the relationship between SCARR and SPFLI. The join condition is suggested automatically. Select some view fields under VIEW Fields. To do so, choose the “table fields” button. However, be sure to select the complete SPFLI key with the client field and the field SCARR-CARRNAME. To avoid warnings during activation, you should overwrite the default maintenance status with “restricted display/maintenance”. Activate the database view and write a small program with a SELECT on your view. Make it clear that the data is retrieved from the database tables SPFLI and SCARR according to the view definition and is not, for example, held redundantly in the view.
Figure 159: Database Change Accesses
In addition to the SELECT statement, Open SQL also contains the UPDATE, INSERT, DELETE and MODIFY statements. However, the thus possible database change accesses should not be used without knowing the SAP transaction concept as you might cause data inconsistencies otherwise. The SAP transaction concept is taught in course BC414.
2005/Q4
© 2005 SAP AG. All rights reserved.
361
Unit 9: Data Retrieval
TAW10_1
Hint: The key points of the above slide are to point out that data inconsistencies can be caused when the above statements are used inappropriately and to mention course BC414 in which the SAP transaction concept is taught.
362
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
315
Exercise 16: Data Retrieval Using a SELECT Loop
Exercise Duration: 30 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Program loop database accesses • Limit the data selection according to the input parameters
Business Example
Enhance your ABAP program to issue flight schedules so that only the schedules of the airlines selected by the user are displayed. The list should also include the occupancy, in percent, of each flight.
System Data
System: Client: User ID: Password: Set up instructions: system Will be assigned Will be assigned Will be assigned Will be assigned No special instructions when using a standard training
Task 1:
Read several rows using a loop according to the user selection 1. Copy your executable program ZBC400_##_GS_LIST (solution to exercise in lesson “Developing Programs and Organizing Developments”) or the template SAPBC400WBS_GS_LIST to the new name ZBC400_##_SELECT_SFLIGHT. 2. Change the work area definition (name suggestion: wa_flight). Now use the global structure SBC400FOCC for typing. Find out information about the fields of this structure. Define an input parameter for the airline abbreviation.
3.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
363
Unit 9: Data Retrieval
TAW10_1
4.
From database table SFLIGHT, select all flight schedules for the airline selected by the user. Restrict your selection to the table fields for which the work area contains a target field. What is the first key field in the transparent table SFLIGHT? Does your SELECT statement contain a WHERE clause? Does the database interface (still) use the primary index?
5.
Task 2:
Calculate the percentage occupancy per scheduled flight 1. 2. Within the loop statement, calculate the percentage occupancy for each flight. Assign the result to the PERCENTAGE field in your work area. Extend your list output to include the percentage occupancy.
364
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
Solution 16: Data Retrieval Using a SELECT Loop
Task 1:
Read several rows using a loop according to the user selection 1. Copy your executable program ZBC400_##_GS_LIST (solution to exercise in lesson “Developing Programs and Organizing Developments”) or the template SAPBC400WBS_GS_LIST to the new name ZBC400_##_SELECT_SFLIGHT. a) 2. Carry out this step as usual. Change the work area definition (name suggestion: wa_flight). Now use the global structure SBC400FOCC for typing. Find out information about the fields of this structure. a) See source code excerpt in the model solution. The global structure SBC400FOCC has the following components: - CARRID with type S_CARR_ID, - CONNID with type S_CONN_ID, - FLDATE with type S_DATE, - SEATSMAX with type S_SEATSMAX, - SEATSOCC with type S_SEATSOCC and - PERCENTAGE with type S_FLGHTOCC. With the exception of the last component, all the others have the same type as the fields of the same name in the transparent table SFLIGHT. There is no corresponding field in SFLIGHT for the PERCENTAGE field, which is to receive the percentage occupancy of the current flight. 3. 4. Define an input parameter for the airline abbreviation. a) See source code excerpt in the model solution. From database table SFLIGHT, select all flight schedules for the airline selected by the user. Restrict your selection to the table fields for which the work area contains a target field. a) See source code excerpt in the model solution. Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
365
Unit 9: Data Retrieval
TAW10_1
5.
What is the first key field in the transparent table SFLIGHT? Does your SELECT statement contain a WHERE clause? Does the database interface (still) use the primary index? a) The MANDT field is the first key field in the transparent table SFLIGHT. Even though you have not specified it in your WHERE clause, a value for this field (the current execution client) is transferred to the database due to the “automatic client”. That means, your selection is restricted by MANDT and not CARRID. Hence, the database interface can use the primary index for the selection of data records in this case (partial, but left justified specification of key fields in the selection restriction). Hint: Note on the automatic client: When the ABAP runtime system accesses client-specific tables for which no client is defined, it assumes that data should only be taken into account if it belongs to the client under which the user is logged on. Hence, the database interface automatically supplements the WHERE clause with the mandt = sy-mandt condition. (sy-mandt contains the current execution client.)
Task 2:
Calculate the percentage occupancy per scheduled flight 1. Within the loop statement, calculate the percentage occupancy for each flight. Assign the result to the PERCENTAGE field in your work area. a) See source code excerpt in the model solution.
Continued on next page
366
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
2.
Extend your list output to include the percentage occupancy. a) See source code excerpt in the model solution.
Result
Source code excerpt: SAPBC400DDS_SELECT_SFLIGHT
REPORT sapbc400dds_select_sflight. DATA wa_flight TYPE sbc400focc.
PARAMETERS pa_car TYPE s_carr_id.
* Select all flights belonging to carrier PA_CAR : SELECT carrid connid fldate seatsmax seatsocc FROM sflight INTO CORRESPONDING FIELDS OF wa_flight WHERE carrid = pa_car.
* Calculate occupation of each flight: wa_flight-percentage = 100 * wa_flight-seatsocc / wa_flight-seatsmax.
* Create list: WRITE: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate, wa_flight-seatsmax, wa_flight-seatsocc, wa_flight-percentage, ’%’. ENDSELECT. IF sy-subrc NE 0. WRITE: ’No ’, pa_car, ’flights found !’. ENDIF.
2005/Q4
© 2005 SAP AG. All rights reserved.
367
Unit 9: Data Retrieval
TAW10_1
368
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
321
Exercise 17: Data Retrieval and Buffering in an Internal Table
Exercise Duration: 35 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Fill an internal table with data from a database table • Sort the content of an internal table
Business Example
Enhance your ABAP program for outputting required flight schedules in such a way that the percentage occupancy can be output in ascending order.
System Data
System: Client: User ID: Password: Set up instructions: system Will be assigned Will be assigned Will be assigned Will be assigned No special instructions when using a standard training
Task 1:
Retrieve data and fill an internal table 1. Copy your program ZBC400_##_SELECT_SFLIGHT (solution to first exercise in this lesson) or the template SAPBC400DDS_SELECT_SFLIGHT to the new name ZBC400_##_SELECT_SFLIGHT_ITAB. Define an internal table (name proposal: it_flight) using a global table type that has the global structure SBC400FOCC as the row type. Hint: From SBC400FOCC use the where-used list to find a suitable table type, which might exist already. 3. Each SFLIGHT row that is read should not be output directly but inserted into an internal table (INSERT statement). Continued on next page
2.
2005/Q4
© 2005 SAP AG. All rights reserved.
369
Unit 9: Data Retrieval
TAW10_1
Task 2:
Sort and output the internal table 1. 2. Sort the internal table according to occupancy (ascending). Use a LOOP to display the contents of the internal table.
370
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
Solution 17: Data Retrieval and Buffering in an Internal Table
Task 1:
Retrieve data and fill an internal table 1. Copy your program ZBC400_##_SELECT_SFLIGHT (solution to first exercise in this lesson) or the template SAPBC400DDS_SELECT_SFLIGHT to the new name ZBC400_##_SELECT_SFLIGHT_ITAB. a) 2. Carry out this step as usual. Define an internal table (name proposal: it_flight) using a global table type that has the global structure SBC400FOCC as the row type. Hint: From SBC400FOCC use the where-used list to find a suitable table type, which might exist already. a) 3. Carry out this step as usual.
Each SFLIGHT row that is read should not be output directly but inserted into an internal table (INSERT statement). a) See source code excerpt in the model solution.
Task 2:
Sort and output the internal table 1. 2. Sort the internal table according to occupancy (ascending). a) a) See source code excerpt in the model solution. See source code excerpt in the model solution. Use a LOOP to display the contents of the internal table.
Result
Source code excerpt: SAPBC400DDS_SELECT_SFLIGHT_TAB
REPORT sapbc400dds_select_sflight_tab. DATA: it_flight TYPE sbc400_t_sbc400focc,
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
371
Unit 9: Data Retrieval
TAW10_1
wa_flight LIKE LINE OF it_flight. PARAMETERS pa_car TYPE s_carr_id.
* Select all flights belonging to PA_CAR : SELECT carrid connid fldate seatsmax seatsocc FROM sflight INTO CORRESPONDING FIELDS OF wa_flight WHERE carrid = pa_car. * Calculate occupation of flight wa_flight-percentage = 100 * wa_flight-seatsocc / wa_flight-seatsmax. * Insert flight into internal table INSERT wa_flight INTO TABLE it_flight.
* If you are using standard tables, "APPEND wa_flight TO it_flight." * would be the same as the above INSERT-statement. ENDSELECT.
IF sy-subrc = 0. * Sort internal table SORT it_flight BY percentage.
* Create list LOOP AT it_flight INTO wa_flight. WRITE: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate, wa_flight-seatsocc, wa_flight-seatsmax, wa_flight-percentage, ’%’. ENDLOOP.
ELSE. WRITE: ’No ’, pa_car, ’flights found !’.
Continued on next page
372
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Reading Database Tables
ENDIF.
2005/Q4
© 2005 SAP AG. All rights reserved.
373
Unit 9: Data Retrieval
TAW10_1
Lesson Summary
You should now be able to: • List different methods for searching relevant database tables • Program read access to specific columns and rows within a particular database table • List different methods for read accesses to several database tables
374
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Authorization Check
Lesson:
326
Authorization Check
Lesson Duration: 60 Minutes
Lesson Overview
In this lesson, you will learn why an authorization check is useful and how to include it in your programs.
Lesson Objectives
After completing this lesson, you will be able to: • • Explain the SAP authorization concept Implement authorization checks
For purposes of teaching the course, this topic has been placed in the context of data retrieval. It is very important that the participants understand the authorization concept and authorization check and can use them in their programs. You should also point out that implementing an authorization check using the corresponding program attribute is too inflexible and should only be used in simple cases. As a demo, create an authorization object from which you check the authorization in your program. Use thePATTERN button in the ABAP Editor. Double-click on the authorization object in the AUTHORITY CHECK statement to show how to find out the permissible activities for an object. Finally, show how to search for authorization objects in the Repository Information System.
Business Example
Authorization checks are necessary in your programs to protect the data from unauthorized access.
Authorization Checks
Critical data and parts of the functional scope of the SAP System must be protected from unauthorized access. You have to implement authorization checks in your program so that the user may only access areas for which he or she is authorized. The following graphic illustrates the SAP authorization concept.
2005/Q4
© 2005 SAP AG. All rights reserved.
375
Unit 9: Data Retrieval
TAW10_1
Figure 160: The SAP Authorization Concept
Figure 161: Authorization Objects and Authorizations (Example)
376
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Authorization Check
Authorization objects can be defined within object classes. When you define an authorization object, you have to specify appropriate fields (without values). You create an actual authorization by subsequently assigning values to these fields. This authorization can be integrated into the required user master records by means of an authorization profile. Several different authorizations (for the integration into different user master records) can be created for an authorization object.
Figure 162: Authorization Check (Principle)
At runtime, you can use the AUTHORITY-CHECK statement to check whether the actual user has the authorization required for executing the function in his or her user master record. Depending on the check result (sy-subrc), you can continue your program accordingly: sy-subrc = 0: User has required authorization -> Execute functionality (e.g. SELECT). Else: Authorization not available -> Appropriate note to user. Hint: In addition to the previously described option, programs and transactions can also be protected by means of authorization checks. However, such checks should only be considered as additions to, and not substitutions for, the above-described.
2005/Q4
© 2005 SAP AG. All rights reserved.
377
Unit 9: Data Retrieval
TAW10_1
Usually, the definition of an authorization object and the implementation of the authorization check are the responsibility of the developer, whereas subsequent steps such as the authorization and profile definition as well as the design of the user master records are the responsibility of the administrator. You will learn about the two steps required by the developer in the following section.
Figure 163: Creating Authorization Objects
Before you can implement the required authorization check in your program, you must first define the structure (the fields) of the respective authorization concept. An object usually consists of the ACTVT (activity) field and one other field, which specifies the data type to be protected (i.e., material number, airline and so on.) The values of these authorization fields specify what the user is authorized to do. You can now use transaction SU20 to create the fields. ACTVT is already in the system. You then use transaction SU21 to first create an object class and then create the authorization object specifying the appropriate fields. If your object contains the ACTVT field, then you must also maintain permitted activities with reference to the object. In doing so, you choose the activities that make sense for your object from all possible activities.
378
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Authorization Check
Finally, all that remains to be done is to implement the authorization check in your program. The following graphic illustrates the authorization check.
Figure 164: Authorization Check (Syntax Example)
For the authorization check in the program, you specify the authorization that is to be checked in the master record of the current user. The authorization is specified by specifying the authorization object, its fields, as well as the appropriate field values. Refer to the syntax in the above graphic. In our example, it is checked whether the user has an authorization for the S_CARRID object, in which the field CARRID (airline) contains the airline entered by the user, and the field ACTVT (activity) contains the value ’03’ (display). Table TACT contains all possible activity codes including their descriptions. Table TACTZ in contrast contains the activity codes that are permitted for specific objects.
2005/Q4
© 2005 SAP AG. All rights reserved.
379
Unit 9: Data Retrieval
TAW10_1
After the AUTHORITY-CHECK statement you should check the return code sy-subrc and control the further processing of your program accordingly. Hint: If you do not want to carry out a check for a field, either do not enter it in the AUTHORITY-CHECK statement or enter DUMMY as the field value. DUMMY is a predefined description entered without quotation marks. An example of a suppressed field check: When a change transaction is called, the system is to always check immediately whether the user has any change authorization for any airline. If the check fails, an appropriate message is to be output to the user immediately. Such a check can be implemented with the following syntax: AUTHORITY-CHECK OBJECT ’S_CARRID’ ID ’CARRID’ DUMMY ID ’ACTVT’ FIELD ’02’.
Figure 165: Implementing Authorization Checks in Programs
380
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Authorization Check
In order to avoid spelling errors in object and field names, you should have the AUTHORITY-CHECK statement generated into your source code by means of the Pattern button. Following that, maintain the field values and implement the sy-subrc check. Now ask the participants to carry out the exercise.
2005/Q4
© 2005 SAP AG. All rights reserved.
381
Unit 9: Data Retrieval
TAW10_1
382
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Authorization Check
333
Exercise 18: Authorization Check
Exercise Duration: 20 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Implement authorization checks • Set up the program flow in a variable manner depending on the outcome of the authorization check
Business Example
Your ABAP programs have to be enhanced in such a way that the flight times of the airline specified by the user can be read and output only if the user has display authorization for the selected airline.
System Data
System: Client: User ID: Password: Set up instructions: system Will be assigned Will be assigned Will be assigned Will be assigned No special instructions when using a standard training
Task 1:
Check for display authorization for airlines 1. Copy your executable program ZBC400_##_SELECT_SFLIGHT (solution of first exercise in lesson “Reading Database Tables”) or the template SAPBC400DDS_SELECT_SFLIGHT to the new name ZBC400_##_AUTHORITY_CHECK. Check whether the current user has display authorization for the chosen airline before selecting the requested data from the database. To do so, use authorization object S_CARRID. Hint: Use the relevant statement pattern in the ABAP Editor. Determine the appropriate activity code for the value assignment for the ACTVT field. Continued on next page
2.
2005/Q4
© 2005 SAP AG. All rights reserved.
383
Unit 9: Data Retrieval
TAW10_1
3.
Define a constant for the activity code to be used (suggested name: actvt_display; type assignment with data element ACTIV_AUTH). Use this constant in the authorization check. Execute the database access if the user has display authorization for the selected airline. If that is not the case, output an appropriate message as a list. Execute your program with airline codes AA and UA.
4. 5.
Task 2:
Additional task for the authorization check 1. Copy your executable program ZBC400_##_SELECT_SFLIGHT_ITAB (solution of second exercise in lesson “Reading Database Tables”) or the template SAPBC400DDS_SELECT_SFLIGHT_ITAB to the new name ZBC400_##_AUTHORITY_CHECK_2. Proceed as you did in the previous exercise.
2.
384
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Authorization Check
Solution 18: Authorization Check
Task 1:
Check for display authorization for airlines 1. Copy your executable program ZBC400_##_SELECT_SFLIGHT (solution of first exercise in lesson “Reading Database Tables”) or the template SAPBC400DDS_SELECT_SFLIGHT to the new name ZBC400_##_AUTHORITY_CHECK. a) 2. Carry out this step as usual. Check whether the current user has display authorization for the chosen airline before selecting the requested data from the database. To do so, use authorization object S_CARRID. Hint: Use the relevant statement pattern in the ABAP Editor. Determine the appropriate activity code for the value assignment for the ACTVT field. a) 3. See source code excerpt in the model solution.
Define a constant for the activity code to be used (suggested name: actvt_display; type assignment with data element ACTIV_AUTH). Use this constant in the authorization check. a) See source code excerpt in the model solution. Execute the database access if the user has display authorization for the selected airline. If that is not the case, output an appropriate message as a list. a) See source code excerpt in the model solution. Carry out this step as usual. Execute your program with airline codes AA and UA. a)
4.
5.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
385
Unit 9: Data Retrieval
TAW10_1
Task 2:
Additional task for the authorization check 1. Copy your executable program ZBC400_##_SELECT_SFLIGHT_ITAB (solution of second exercise in lesson “Reading Database Tables”) or the template SAPBC400DDS_SELECT_SFLIGHT_ITAB to the new name ZBC400_##_AUTHORITY_CHECK_2. a) 2. a) Carry out this step as usual. See source code excerpt in the model solution. Proceed as you did in the previous exercise.
Result
Source code excerpt: SAPBC400DDS_AUTHORITY_CHECK
REPORT sapbc400dds_authority_check. CONSTANTS actvt_display TYPE activ_auth VALUE ’03’.
DATA wa_flight TYPE sbc400focc. PARAMETERS pa_car TYPE s_carr_id. * Authority Check: User authorized to read data of the specified carrier? AUTHORITY-CHECK OBJECT ’S_CARRID’ ID ’CARRID’ FIELD pa_car ID ’ACTVT’ FIELD actvt_display.
CASE sy-subrc.
WHEN 0.
" user is authorized FROM sflight INTO CORRESPONDING FIELDS OF wa_flight WHERE carrid = pa_car.
SELECT carrid connid fldate seatsmax seatsocc
wa_flight-percentage = 100 * wa_flight-seatsocc / wa_flight-seatsmax. WRITE: / wa_flight-carrid COLOR COL_KEY, wa_flight-connid COLOR COL_KEY,
Continued on next page
386
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Authorization Check
wa_flight-fldate COLOR COL_KEY, wa_flight-seatsocc, wa_flight-seatsmax, wa_flight-percentage, ’%’. ENDSELECT. WHEN OTHERS. " user is not authorized
WRITE: / ’Authority-Check Error’(001). ENDCASE.
For the solution to task 2, refer to the source code of the program: SAPBC400DDS_AUTHORITY_CHECK_2
2005/Q4
© 2005 SAP AG. All rights reserved.
387
Unit 9: Data Retrieval
TAW10_1
Lesson Summary
You should now be able to: • Explain the SAP authorization concept • Implement authorization checks
388
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Unit Summary
Unit Summary
You should now be able to: • List different methods for searching relevant database tables • Program read access to specific columns and rows within a particular database table • List different methods for read accesses to several database tables • Explain the SAP authorization concept • Implement authorization checks
2005/Q4
© 2005 SAP AG. All rights reserved.
389
Unit Summary
TAW10_1
390
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 10
341
Subprograms in ABAP
For more information, see the introductory instructor notes in the lesson.
Unit Overview
The unit overview lists the individual lessons that make up this unit.
Unit Objectives
After completing this unit, you will be able to: • • • Define subroutines Call subroutines Analyze the execution of subroutines in debugging mode
Unit Contents
Lesson: Subroutines................................................................ 392 Exercise 19: Subroutines...................................................... 405
2005/Q4
© 2005 SAP AG. All rights reserved.
391
Unit 10: Subprograms in ABAP
TAW10_1
Lesson:
342
Subroutines
Lesson Duration: 70 Minutes
Lesson Overview
In this lesson you will learn why subroutines make sense and how you can use them in your ABAP programs. Furthermore, you will learn how the interface of a subroutine is used to pass parameters and how the different transfer types are used.
Lesson Objectives
After completing this lesson, you will be able to: • • • Define subroutines Call subroutines Analyze the execution of subroutines in debugging mode
Participants with programming experience should have no problems with this lesson. But in most cases there is a large number of participants that are not familiar with the concept and advantages of subroutines. Hence, you should clarify at the beginning of this lesson whether a basic introduction makes sense or is required.
Business Example
You need to structure a comprehensive program and encapsulate source code that is executed several times in a subroutine.
392
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Subroutines
Internal Program Modularization with Subroutines
Figure 166: Using Subroutines (Motivation)
A subroutine is a modularization unit within the program where a function is encapsulated in the form of source code. You page out a part of a program to a subroutine to get a better overview of the main program and to use the corresponding sequence of statements several times (see above graphic). The better overview is a result of your program becoming function-oriented: It structures the overall task in subfunctions, which are the responsibility of corresponding subroutines. Using subroutines also means that your program becomes easier to maintain as changes to functions often only have to be implemented in the subroutine (and not at various points in the main program). Furthermore, you can process a subroutine call “as a unit” in the debugger while executing your program and then look at the result. This usually makes it easier to find the source of the error.
2005/Q4
© 2005 SAP AG. All rights reserved.
393
Unit 10: Subprograms in ABAP
TAW10_1
Figure 167: Parameter Passing (Motivation 1)
394
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Subroutines
Figure 168: Parameter Passing (Motivation 2)
You can address all (global) variables defined in the main program from a subroutine. But, in order to call up a subroutine for a specific situation with different data objects for each situation, you do not use global variables in the subroutine but placeholders, which are replaced with the required global variables at the time the subroutine is called. These placeholders are called formal parameters and together they form the interface of the subroutine, which has to be declared when the subroutine is defined. When the subroutine is called, formal parameters must be specialized by means of corresponding global variables (actual parameters), in order to implement the reference of the subroutine processing to real variables. This assignment of actual parameters to formal parameters when calling a subroutine is called parameter passing.
2005/Q4
© 2005 SAP AG. All rights reserved.
395
Unit 10: Subprograms in ABAP
TAW10_1
Figure 169: Ways of Passing Interface Parameters
They way these variables of the main program are passed to the formal parameters of the subroutine is called passing type and is specified for each parameter in the interface of the subroutine. There are three passing types: Call by Value A copy is made of the actual parameter. This copy is assigned to the formal parameter. If in the subroutine a value is assigned to the corresponding formal parameter, this value will actually be assigned to a copy of the formal parameter and not its original. You use this pass type, to make the value of a global variable available to the subroutine (in the form of a variable copy) without making it possible to change the respective global variable (protecting the original). Please note, however, that creating copies, especially for large internal tables, can be time-consuming.
396
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Subroutines
Call by value and result With this transfer type, the same applies as for “call by value”. However, at the regular end of the subroutine, the value that was changed to this point is written back to the original. If the program is prematurely terminated through a STOP statement or a user message of type E, the writing back of the values is suppressed. You use this pass type to transfer the value of a global variable to the subroutine and to have the fully processed final value of the copy written back to the original. But note that the creation of copies and the writing back of values can be time-consuming, especially for large internal tables. Call by reference The actual parameter is assigned directly to the formal parameter. This means that value assignments to the formal parameter are executed directly on the actual parameter. You use this pass type if you want to run the subroutine processing directly on the specified actual parameter. It is popular for avoiding the time-consuming creation of copies for large internal tables.
2005/Q4
© 2005 SAP AG. All rights reserved.
397
Unit 10: Subprograms in ABAP
TAW10_1
Figure 170: Defining and Calling Subroutines
• • • •
A subroutine is introduced with FORM. The name and the interface of the subroutine are to be specified behind FORM. The statements of the subroutine follow. The ENDFORM statement concludes the subroutine.
In the interface definition you list the formal parameters of the subroutine (here: f1, f2, f3) and type them if necessary. The required pass type has to be specified for each parameter: Call by value You list each of the formal parameters that is supposed to have the pass type “call by value” (here: f1) with the VALUE prefix in the USING section. (Refer to the above graphic for the syntax.) Call by value and result You list each of the formal parameters that is supposed to have the pass type “call by value and result” (here: f1) with the VALUE prefix in the CHANGING section. (Refer to the above graphic for the syntax.)
398
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Subroutines
Call by reference You list each of the formal parameters that is supposed to have the pass type “call by reference” (here: f3) without the VALUE prefix in the CHANGING section. (Refer to the above graphic for the syntax) Note: A parameter without VALUE prefix, but placed in the USING section also has the pass type “call by reference”. However, this declaration syntax only makes sense for formal parameters that are passed to larger internal tables, which are not to be changed in the subroutine (documentation via USING) but are to be passed using “call by reference” in order to avoid making time-consuming copies. When the subroutine is called, the actual parameters to be transferred without VALUE prefix are specified under USING or CHANGING. The order of specification determines their assignment to the formal parameters. In the example in the above graphic, a is passed to f1, b to f2, and c to f3.
Figure 171: Typing the Interface Parameters
A formal parameter is typed generically, if it is typed using TYPE ANY or not typed at all. Actual parameters of any type can be transferred to such a parameter. At runtime, the type of the actual parameter is determined and assigned to the
2005/Q4
© 2005 SAP AG. All rights reserved.
399
Unit 10: Subprograms in ABAP
TAW10_1
formal parameter (type inheritance) when the subroutine is called. However, if the statements in the subroutine are not suited to the inherited type, a runtime error may occur (type conflict). Hence, generic typing should only be used if the type of the actual parameter is yet to be determined when the program is created or if it can vary at runtime (dynamic programming). You implement the concrete typing of a formal parameter by specifying a global or built-in type in the TYPE addition. In doing so, you specify that only actual parameters of the specified type are to be passed to the subroutine. A violation of the type consistency between formal and actual parameters is already picked up in the syntax check. This increases the stability of your program as type conflicts in statements within the subroutine are prevented. If you type with the standard types P, N, C or X, the missing characteristic “field length” is not inherited from the actual parameter until runtime. You achieve a complete type assignment with this type (i.e., including the field length) by defining and specifying locally defined types.
Figure 172: Typing the Interface Parameter for Structures and Internal Tables
400
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Subroutines
You must type formal parameters for structures and internal tables so that you can access the corresponding components. The components of structure parameters are known in the subroutine, as a result of the assigned type, so that you can address these components with the usual syntax. The typing of table parameters enables you to address these as internal tables using the usual syntax in the subroutine. Hint: Larger internal tables should be transferred by call by reference in order to avoid time consuming copies.
Figure 173: Visibility of Global and Local Data Objects
Variables defined in the main program are global data objects. They are visible (can be addressed) in the entire main program in every subroutine called. Variables defined within a subroutine are called local, as they only exist in the relevant subroutine - just like the formal parameters. The memory for formal parameters and local data objects is only allocated during the subroutine run and released again after execution. The formal parameters and local data objects of a subroutine can not have the same names. If there is a global data object with the same name as a formal parameter or a local data object, then the formal parameter or local data object is addressed within
2005/Q4
© 2005 SAP AG. All rights reserved.
401
Unit 10: Subprograms in ABAP
TAW10_1
the subroutine and the global data object is addressed outside the subroutine. This is called hiding rule. Within a subroutine the local data objects “hides” the global one with the same name. To clearly label your program-internal objects you could, for example, use the following prefixes: f_... for “formal parameters” and l_... for a “local data object”.
Figure 174: Syntax Example: Passing an Internal Table
In the above syntax example, the internal table it_flightinfo and the global variable carrid are passed by means of call by reference, even though they are not changed in the subroutine. The advantage of this is that no copies have to be made. To loop through the internal table, you need a work area with a compatible line type. This is locally defined in the subroutine with reference to the table parameter f_itab. The reference is possible because f_itab is typed in the interface of the subroutine.
402
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Subroutines
Figure 175: Implementing a Subroutine Call
You can have the PERFORM statement for calling a subroutine generated into your source code. First, define the subroutine and then save your main program. The newly-defined subroutine appears in the navigation area. Move it to the required call point in your program by means of drag & drop. All you have to do is replace the formal parameters in the generated source code with corresponding actual parameters. (Alternatively, the call generation can also be implemented using the “Pattern” pushbutton in the ABAP editor.) The advantage of the call generation is that it is impossible to forget or mix parameters.
2005/Q4
© 2005 SAP AG. All rights reserved.
403
Unit 10: Subprograms in ABAP
TAW10_1
Figure 176: Subroutines in Debugging Mode
If the current statement is a subroutine call, then you can execute the entire subroutine without stopping by choosing Execute. Processing only stops once the subroutine has been completed. In contrast, you can use Single Step to stop at the first statement of the subroutine and trace its operations in more detail. If the current statement is located in a subroutine, you can execute the rest of the subroutine without it stopping by choosing Return. Processing only stops once the subroutine has been completed. Use one of your previous programs to perform a demo using PERFORM. The subroutine that you create should have an interface with a structure or table parameter, in order to illustrate the type assignment of interface parameters. The participants can then try this themselves in the exercise.
404
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Subroutines
355
Exercise 19: Subroutines
Exercise Duration: 30 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Create subroutines • Use the subroutine interface to pass data
Business Example
Change your program so that the source code for the data output is encapsulated in a subroutine
System Data
System: Client: User ID: Password: Set up instructions: system Will be assigned Will be assigned Will be assigned Will be assigned No special instructions when using a standard training
Task 1:
Create a subroutine with table parameters 1. Copy your program ZBC400_##_SELECT_SFLIGHT_ITAB or the corresponding model solution SAPBC400DDS_AUTHORITY_CHECK_2 to the new program ZBC400_##_SUBROUTINE. Encapsulate the data output in a subroutine. To do so, define the subroutine (suggested name: WRITE_LIST) and type the interface parameter so that it can be transferred to the internal table designed for the output. 3. Display the data from the subroutine using a LOOP. To do this, create the required table work area as a local data object in the subroutine (name proposal: wa).
2.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
405
Unit 10: Subprograms in ABAP
TAW10_1
Task 2:
Call subroutine 1. 2. After the sorting of the internal table, call the subroutine to output the table. Execute your program to test the result.
406
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Subroutines
Solution 19: Subroutines
Task 1:
Create a subroutine with table parameters 1. Copy your program ZBC400_##_SELECT_SFLIGHT_ITAB or the corresponding model solution SAPBC400DDS_AUTHORITY_CHECK_2 to the new program ZBC400_##_SUBROUTINE. a) 2. Carry out this step as usual. Encapsulate the data output in a subroutine. To do so, define the subroutine (suggested name: WRITE_LIST) and type the interface parameter so that it can be transferred to the internal table designed for the output. a) 3. See source code excerpt in the model solution. Display the data from the subroutine using a LOOP. To do this, create the required table work area as a local data object in the subroutine (name proposal: wa). a) See source code excerpt in the model solution.
Task 2:
Call subroutine 1. 2. After the sorting of the internal table, call the subroutine to output the table. a) a) See source code excerpt in the model solution. Carry out this step as usual. Execute your program to test the result.
Result
Source code excerpt: SAPBC400PBS_SUBROUTINE
REPORT sapbc400pbs_subroutine.
CONTSTANTS actvt_display TYPE activ_auth VALUE ’03’.
DATA: it_flight TYPE sbc400_t_sbc400focc, wa_flight LIKE LINE OF it_flight.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
407
Unit 10: Subprograms in ABAP
TAW10_1
PARAMETERS pa_car TYPE s_carr_id.
* Authority Check: AUTHORITY-CHECK OBJECT ’S_CARRID’ ID ’CARRID’ FIELD pa_car ID ’ACTVT’ CASE sy-subrc. FIELD actvt_display.
WHEN 0.
" User is authorized
SELECT carrid connid fldate seatsmax seatsocc FROM sflight INTO CORRESPONDING FIELDS OF wa_flight WHERE carrid = pa_car.
wa_flight-percentage = 100 * wa_flight-seatsocc / wa_flight-seatsmax.
APPEND wa_flight TO it_flight. ENDSELECT. IF sy-subrc = 0. SORT it_flight BY percentage. PERFORM write_list USING it_flight. ELSE. WRITE: ’No ’, pa_car, ’flights found !’. ENDIF. WHEN OTHERS. " User is not authorized
WRITE: / ’Authority-Check Error’(001). ENDCASE.
*&--------------------------------------------------------------* *& * Form WRITE_LIST --> P_IT_FLIGHT *&--------------------------------------------------------------*
*---------------------------------------------------------------* FORM write_list USING p_it_flight TYPE sbc400_t_sbc400focc.
Continued on next page
408
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Subroutines
DATA wa LIKE LINE OF p_it_flight. LOOP AT p_it_flight INTO wa. WRITE: / wa-carrid COLOR COL_KEY, wa-connid COLOR COL_KEY, wa-fldate COLOR COL_KEY, wa-seatsocc, wa-seatsmax, wa-percentage, ’%’. ENDLOOP. ENDFORM. " WRITE_LIST
2005/Q4
© 2005 SAP AG. All rights reserved.
409
Unit 10: Subprograms in ABAP
TAW10_1
Lesson Summary
You should now be able to: • Define subroutines • Call subroutines • Analyze the execution of subroutines in debugging mode
410
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Unit Summary
Unit Summary
You should now be able to: • Define subroutines • Call subroutines • Analyze the execution of subroutines in debugging mode
2005/Q4
© 2005 SAP AG. All rights reserved.
411
Unit Summary
TAW10_1
412
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 11
361
Introduction to ABAP Events
For more information, see the introductory instructor notes in the lesson.
Unit Overview
The unit overview lists the individual lessons that make up this unit.
Unit Objectives
After completing this unit, you will be able to: • • • Describe the event-controlled processing of an executable ABAP program List the most important basic events and explain their purpose Use the most important basic events expediently
Unit Contents
Lesson: ABAP Events.............................................................. 414
2005/Q4
© 2005 SAP AG. All rights reserved.
413
Unit 11: Introduction to ABAP Events
TAW10_1
Lesson:
362
ABAP Events
Lesson Duration: 20 Minutes
Lesson Overview
In this lesson, you will find out how an executable ABAP program is processed in an event-controlled manner. You will learn about the most important basic events as well as their purposes and you will be able to use them in your programs.
Lesson Objectives
After completing this lesson, you will be able to: • • • Describe the event-controlled processing of an executable ABAP program List the most important basic events and explain their purpose Use the most important basic events expediently
Event control is an SAP-specific concept. The purpose of this lesson is to explain the way the ABAP runtime system works with regards to an executable (type 1) program. The participants are to learn about the most important basic events, understand their purpose, and be able to use them in their programs.
414
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: ABAP Events
We will also illustrate how a more complex, executable program is structured and why earlier programs could be executed. Hint: The LOAD-OF-PROGRAM event, which has existed in parallel to INITIALIZATION since Release 4.6 and was previously taught unnecessarily in this course in connection with executable programs, has now been replaced with INITIALIZATION for the following reasons: • LOAD-OF-PROGRAM has been mainly designed for use in function groups and module pools that did not have a “start action” prior to 4.6. INITIALIZATION is still used for executable programs in order to implement the dynamic default settings for the selection screen. (See also the documentation for the corresponding events) Using LOAD-OF-PROGRAM in an executable program can have undesirable side effects, which the following mini program illustrates: PARAMETERS myvar TYPE i DEFAULT 10. LOAD-OF-PROGRAM. (IF ...) " optional, not important here myvar = myvar + 1. (ENDIF.) Why does a 1 appear instead of 11 as the default value on the selection screen? The reason for that is: – in contrast to INITIALIZATION, the LOAD-OF-PROGRAM event is triggered before(!) executing the DEFAULT additions of PARAMETERS or SELECT-OPTIONS statements and DEFAULT additions are evaluated only if the value of the corresponding data object is still initial.
•
–
If INITIALIZATION was used in the mini program, 11 would appear as the default value on the selection screen as INITIALIZATION is only triggered after the DEFAULT additions have been evaluated.
2005/Q4
© 2005 SAP AG. All rights reserved.
415
Unit 11: Introduction to ABAP Events
TAW10_1
Business Example
You are to prepopulate your selection screen with default values dynamically (i.e. with reference to the situation).
Purpose and Usage of ABAP events
Figure 177: Structures and Procedures of an Executable ABAP Program
When you start an ABAP program, all global data objects of the programs are first created in the working memory (memory allocation). After that, the runtime system triggers various events in succession. If a processing block exists for a triggered event in the program, then the statements of this block are executed in sequence. The graphic above shows which basic events are triggered in which sequence and how the corresponding processing blocks are implemented in the program. An executable ABAP program is a collection of processing blocks that are processed for the respective events. Outputs created by means of WRITE statements are first stored in list buffers and only displayed as a list once the START-OF-SELECTION block has been processed.
416
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: ABAP Events
Figure 178: Purpose of ABAP Events
If values are assigned to the PARAMETERS variables in the INITIALIZATION block, then these are displayed as (changeable) default values in the input fields when the selection screen is displayed subsequently. You do have the option of specifying a default value for the respective input field in the PARAMETERS definition by means of the DEFAULT addition. However, you can use the described value assignment in the INITIALIZATION block to assign another default value (dynamic prepopulation of the selection screen) in a runtime-dynamic manner (meaning with reference to the situation). The example program on the next graphic illustrates this. If the user confirms with the F8 pushbutton on the selection screen, then his inputs are transported into the corresponding program-internal PARAMETERS variables and the AT SELECTION-SCREEN event is triggered. Hence the corresponding processing block is suitable for an input or authorization check. The sending of a type ’E’ message in this event block (for example, in case of a missing user authorization) would cause the selection screen to be displayed again with the error message (so that a new entry can be made). The “selection screen” lesson explains this in more detail. If no error message is sent in the AT SELECTION-SCREEN block, then START-OF-SELECTION is triggered as the subsequent event. The main processing of the program should then happen in the corresponding processing block.
2005/Q4
© 2005 SAP AG. All rights reserved.
417
Unit 11: Introduction to ABAP Events
TAW10_1
The general input or authorization checks are implemented in the AT SELECTION-SCREEN block and, if necessary, an error message is sent in order to process the selection screen for a new entry. For the time being the latter should be mentioned without an example as more details are provided in the “selection screen” lesson. It should be emphasized that the option of displaying the selection screen again is no longer given in the START-OF-SELECTION block to further emphasize the difference between these two events.
Figure 179: Example Program
The example given here contains a selection screen with an input field for a date. Under normal circumstances, the current date is to appear as the default value (DEFAULT sy-datum). However, under certain conditions (IF) the date of the same weekday of the following week (pa_date = pa_date + 7.) is to be displayed as the default value. The graphic above also shows how the runtime system reacts when the processing block is missing. There are simply no statements executed for the corresponding event and the next event is triggered.
418
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: ABAP Events
To demonstrate this, the above example program should be shown without the AT SELECTION-SCREEN block (maybe using the debugger). It is not available as a standard demonstration in the system, as it is up to the instructor to decide which dynamic check condition is used. For example, the following options are available: IF sy-datum = ’20051231’. IF sy-langu = ’D’. IF sy-uname = .
Figure 180: Event Block Characteristics
Processing blocks cannot be nested as nesting would contradict the concept of ABAP events. As mentioned, if the processing block is missing no statements are executed and the next event is triggered. The ABAP runtime system controls the triggering of the events and thus the execution of the processing blocks. Therefore, the sequence in which the event blocks are placed in the program is not important. If no blocks are implemented in the program, then all statements are implicitly assigned to the standard processing block START-OF-SELECTION. That is also the reason why earlier programs of this course could be executed. Apart from the already explained basic events for executable programs, there are further events for various other tasks. For example, there is the AT LINE-SELECTION event that is triggered by the user double-clicking on the list. This event can be used, for example, to display the detailed information for the row in the list that was clicked on. The “list” lesson provides more information on this. You can find further documents in the ABAP documentation for the term “event”.
2005/Q4
© 2005 SAP AG. All rights reserved.
419
Unit 11: Introduction to ABAP Events
TAW10_1
The following graphic shows the general overall structure of an executable ABAP program.
Figure 181: Program Structure (Overview)
In addition to the already explained event blocks other processing blocks can be implemented in the program. For example, a subroutine (FORM ... ENDFORM.) is a block executed for the “event” triggered by PERFORM. If you want to send the user a screen, then you must have defined this for the program in advance. Apart from the layout, the so-called flow logic of the screen also has to be implemented. This specifies, which program-internal processing units (modules) are to be executed in preparation for the screen display (for example, reading the data to be displayed) or as a reaction to the user actions on the screen. This is called the Process Before Output (PBO) or Process After Input (PAI) of the screen. Together, they form the flow logic of the screen. The flow logic does not contain any direct ABAP statements but references to modules that are implemented in the program in the form of processing blocks (MODULE ... ENDMODULE.). The appropriate lesson provides more information on screen programming.
420
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: ABAP Events
Facilitated Discussion
You now have the opportunity to discuss any questions.
Discussion Questions
Use the following questions to engage the participants in the discussion. Feel free to use your own additional questions. See list of lesson objectives.
2005/Q4
© 2005 SAP AG. All rights reserved.
421
Unit 11: Introduction to ABAP Events
TAW10_1
Lesson Summary
You should now be able to: • Describe the event-controlled processing of an executable ABAP program • List the most important basic events and explain their purpose • Use the most important basic events expediently
422
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Unit Summary
Unit Summary
You should now be able to: • Describe the event-controlled processing of an executable ABAP program • List the most important basic events and explain their purpose • Use the most important basic events expediently
2005/Q4
© 2005 SAP AG. All rights reserved.
423
Unit Summary
TAW10_1
424
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 12
371
Classic List Processing
Note:For technical reasons, the lessons “Selection Screen” and “Generating and Designing a Selection Screen” contain redundant slides. You should these slides in unit “Generating and Designing a Selection Screen”. If you are short of time, you can omit the exercises for unit “Generating and Designing a Selection Screen”. For more information, see the introductory instructor notes in the lesson.
Unit Overview
The unit overview lists the individual lessons that make up this unit.
Unit Objectives
After completing this unit, you will be able to: • • • • • • • • • • • • Describe the attributes and benefits of ABAP lists Implement list and column headers Implement multi-level lists Implement interactive lists List the properties and benefits of selection screens Implement the options for restricting selections on the selection screen Implement the input and authorization check with an error dialog using the selection screen Explain the uses of selection screens Declare fields with PARAMETERS Declare fields with SELECTION-OPTIONS Design the selection screen Identify the characteristics of the logical database
2005/Q4
© 2005 SAP AG. All rights reserved.
425
Unit 12: Classic List Processing
TAW10_1
• • • • •
List the advantages of the logical database Explain the structure of logical database subobjects Use various selections in logical database subobjects Explain the concept of database programs in logical database subobjects Explain how to retrieve data from the database
Unit Contents
Lesson: List .......................................................................... 427 Exercise 20: List ................................................................ 441 Lesson: Selection Screen.......................................................... 449 Exercise 21: Selection Screen................................................ 463 Lesson: Generating and Designing the Selection Screen..................... 469 Exercise 22: Designing, Initializing, and Checking a Selection Screen 479 Lesson: Introduction to Logical Databases ...................................... 489 Lesson: Logical Database Subobjects and Data Retrieval.................... 497 Exercise 23: GET Events ..................................................... 509 Exercise 24: GET LATE Events and Checks from Internal Program Selections ....................................................................... 515
426
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: List
Lesson:
373
List
Lesson Duration: 110 Minutes
Lesson Overview
In this lesson, you will learn about the benefits and different functions of the ABAP list. You will also be able to react to the user double-clicking the basic list by showing a details list that contains detailed information on the basic list rows that have been clicked (interactive list).
Lesson Objectives
After completing this lesson, you will be able to: • • • • Describe the attributes and benefits of ABAP lists Implement list and column headers Implement multi-level lists Implement interactive lists
Details lists are a very good example of how event-controlled programming saves the application developer a lot of work. You should emphasize this.
Business Example
You need to write a program that displays row-specific information in a details list when the user chooses a row in a basic list.
2005/Q4
© 2005 SAP AG. All rights reserved.
427
Unit 12: Classic List Processing
TAW10_1
The List
Figure 182: Features of Lists
The main purpose of a list is to display data with a minimum of programming efforts. Lists also take the special requirements of business data into account: • • Lists can be designed in multiple languages: Texts and headers appear in the logon language whenever a corresponding translation is available. Lists can display monetary values in the appropriate currency.
The following options are available when programming a list: • • • • Screen: You can add colors and icons Printers Internet/Intranet: The system is able to automatically convert to HTML. Save: You can save lists within the SAP system as well as outside (for further processing, for example, using spreadsheet programs).
428
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: List
In the following section, show the standard list functions, primarily the menu System → List. Furthermore, you should demonstrate list headers, text symbols and the multilingual capability.
Figure 183: Standard List Functions
The standard list GUI offers the user several functions: You can use the Menu Painter to adapt the default list interface to your own needs. The “User Interface” lesson provides more information on this.
2005/Q4
© 2005 SAP AG. All rights reserved.
429
Unit 12: Classic List Processing
TAW10_1
Figure 184: List and Column Headers
Each list can have a single line list header and up to four lines of column headers. If no list header is defined, the program title (short description) is used as the header. For the initial maintenance of the headlines, you must first activate your program. Afterwards, create the list by running the program. You can then maintain the headers directly above your list using the menu System → List → List Header. The next time you start the program, they will appear in the list automatically. If you want to change the maintained header (follow-up maintenance), then you do not have to start the program again and generate the list. Instead, starting from the editor into which the program is loaded you can get to the maintenance environment for changing the headers by choosing Goto → Text Elements → List Headers .
430
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: List
Figure 185: Multilingual Capabilities of Lists
The text elements of a program - this also includes the header - can be translated into different languages. When a user executes a program, relevant text elements are always automatically displayed in the logon language of the user (automatic language). To translate the text elements of your program choose the Menu Goto → Translation from the ABAP-Editor. In order to design texts in the list body in multiple languages and use the automatic language, text symbols are used. A text symbol consists of a three-digit alphanumeric ID xxx as well as a translatable text and, like the headers, belongs to the text elements of a program. There are two options for defining text symbols for your program: • • From the ABAP Editor, choose the menu Goto → Text Elements → Text Symbols or you address the text symbol in your source code using the syntax described below and double-click its ID (Forward navigation).
From your program, you address a text symbol with TEXT-xxx. At runtime the text is inserted in the logon language of the user if the appropriate translation exists (see “translating the text elements” above).
2005/Q4
© 2005 SAP AG. All rights reserved.
431
Unit 12: Classic List Processing
TAW10_1
In order to make specifying a text symbol more intuitive you can also use the following syntax instead of TEXT-xxx: ’...’(xxx). Here, ’...’ should be the text of the text symbol in the original language of the program. Hint: Please note that text elements also have to be activated.
Figure 186: Generating a Basic List
The above graphic shows the generation of the basic list as an introduction to the details list. In addition to the WRITE statement, you can also use SKIP and ULINE to structure the list. Refer to the ABAP keyword documentation for these two statements.
432
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: List
Figure 187: Generating a Details List
When the user selects a basic list by means of double-click or function key F2, the ABAP event AT LINE-SELECTION is triggered. If you want to have the system display a list with the required detailed information (interactive list) as the response to this user action, then you must implement this in your program in the form of a corresponding processing block. There, you can read the data requested by the user and output them with the WRITE statement. The details list with the output data, which “overwrites” the basic list, is generated automatically. By pressing the pushbutton with the “green arrow” or the F3 function key, the user can return to the basic list and choose another row. Hint: If an AT LINE-SELECTION block is implemented in the program, then a pushbutton with the magnifying glass symbol also appears above the list. Marking the list row and then choosing this button has the same effect as double-clicking the list row.
2005/Q4
© 2005 SAP AG. All rights reserved.
433
Unit 12: Classic List Processing
TAW10_1
Figure 188: Generating Several Details Lists
The row selection on the detail list also triggers the AT LINE-SELECTION event. This means that the corresponding processing block in the program is executed in this case as well. Hence you must be able to determine within this block on which list the current row selection was made so that you can react adequately. You can use the sy-lsind system field for this. This field shows the current list level: “0” for the basic list, “1” for the first details list, and so on. The above graphic shows the value of sy-lsind and how it is set in each case: Each row selection automatically increases sy-lsind by 1; each return to the previous list level reduces sy-lsind by 1. Up to 20 list levels are possible. The value of sy-lsind should be used to control processing in the AT LINE-SELECTION block (for example, by means of a CASE statement). A WRITE statement is always executed on the current list level. If no details list is generated for a row selection in the AT LINE-SELECTION block, then sy-lsind is automatically reduced by one. Afterwards, the system displays the same level where the row selection took place.
434
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: List
Figure 189: Simple Syntax Example
The above example program has the following function: • • • On the basic list, the text “Basic list” is output followed by the current sy-lsind value of 0. When a basic list row is selected, the text “1st details list” is displayed on the details list followed by the current sy-lsind value of 1. When the user selects a row from the details list, he or she gets a second details list on which the text “2nd details list” appears followed by the current sy-lsind value of 2. If a line of the seconds details list is selected, sy-lsind is increased to 3 but no further details list is generated. Hence sy-lsind is automatically reduced by 1 and the second details list is displayed again.
•
2005/Q4
© 2005 SAP AG. All rights reserved.
435
Unit 12: Classic List Processing
TAW10_1
Figure 190: Application Example of a Details List
Program SAPBC400UDD_DETAIL_LIST of package BC400 is suitable for the demonstration. If necessary, you can also demonstrate the selection of an invalid line. Such an action should not have any effects. This can be implemented using the CLEAR commands and the CHECK NOT wa_spfli-carrid IS INITIAL. statement. All three statements are still commented out in the program so that you can give a meaningful demonstration. If necessary, the comments should be removed in a copy of the program. The exercise follows this section. The above graphic shows an application example for a program with a basic list and a details list: • • The flight connections with detailed data should be displayed on the basic list. These are read from database table SPFLI. On the details list, the flight schedules for the selected flight connection should appear with the respective detailed data. These are read from database table SFLIGHT.
In order to be able to select relevant information for the details list when a basic list row is selected, the selected row or at least the key values of the row must be available for the AT LINE-SELECTION event. The following graphics show you how this can be implemented.
436
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: List
Figure 191: Buffering Row-Specific Data in the Hide Area
In order to be able to access the key values of the selected row when a basic list row is selected, you have to implement the following concept: • • For each basic list row, the relevant key values are stored in the HIDE area within the program. When a row is selected the data that has been hidden for that particular row will be made available again.
The row-specific holding of key values in the HIDE area happens by means of the HIDE statement (here: HIDE: wa_spfli-carrid, wa_spfli-connid.), which must be executed directly after generating each basic list row. When the row is selected, the relevant key values are transported back to the source fields (here: wa_spfli-carrid and wa_spfli-connid) and the AT LINE-SELECTION event is triggered. The following graphic illustrates this. Hint: You do not have to output the HIDE fields with the WRITE statement first. That means: For each basic list row, you can also store information that does not appear on the basic list in the HIDE area by means of the HIDE statement. The HIDE field can also be a “flat” structure.
2005/Q4
© 2005 SAP AG. All rights reserved.
437
Unit 12: Classic List Processing
TAW10_1
Figure 192: Data Flow for the Row Selection
Hint: Details lists do not have fixed standard headers like basic lists as they can be varied dynamically. Hence, you might have to implement your own headers using WRITE statements. The following graphic shows the entire AT LINE-SELECTION block of the example program. In this block, basically data (here: flight schedules) is read and output by means of the HIDE values that have been transported back to the source fields.
438
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: List
Figure 193: Source Code Excerpt (Application Example)
Hint: The sample program presented is SAPBC400UDD_DETAIL_LIST, part of package BC400.
2005/Q4
© 2005 SAP AG. All rights reserved.
439
Unit 12: Classic List Processing
TAW10_1
440
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: List
387
Exercise 20: List
Exercise Duration: 50 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Implement details lists in the program
Business Example
When a basic list row is selected by the user, your program should display the corresponding information on a details list. When you discuss the exercise you should explain to the participants that the two CLEAR statements in the sample solution are useful. They serve to catch an invalid row selection (e.g. double-click list header). Without CLEAR statements “old wa_flight data” would be used to generate a details list for an invalid row selection. With CLEAR statements, a blank details list would be generated. If you do not wish to generate a details list at all, then a wa_flight check is also required in the AT LINE-SELECTION block (see program SAPBC400UDS_DETAIL_LIST2).
System Data
System: Client: User ID: Password: Set up instructions: system Will be assigned Will be assigned Will be assigned Will be assigned No special instructions when using a standard training
Task 1:
Prepare the generation of the details list 1. Copy your program ZBC400_##_SELECT_SFLIGHT or the corresponding template SAPBC400DDS_AUTHORITY_CHECK to the new program ZBC400_##_DETAIL_LIST. Ensure that the relevant key values for the creation of the details list are available to your program when a basic list row (specific flight date) is selected. Continued on next page
2.
2005/Q4
© 2005 SAP AG. All rights reserved.
441
Unit 12: Classic List Processing
TAW10_1
3.
In your program, implement a function block for generating the basic list and one for the details list.
Task 2:
Create the details list 1. 2. In the first line of the details list, display key information from the selected flight schedule. Underneath, display a horizontal line and a blank line. Retrieve all bookings for the selected flight schedule from database table SBOOK and output them on the details list. Read only the following fields for output for each booking: BOOKID, CUSTOMID, CUSTTYPE, CLASS, ORDER_DATE, SMOKER, CANCELLED. 3. Optional : Display the fields LOCCURAM and LOCCURKEY on the details list: Use the CURRENCY addition of the WRITE statement to make sure that the currency amount LOCCURAM is formatted according to the currency LOCCURKEY. Hint: WRITE: wa_sbook-loccuram CURRENCY wa_sbook-loccurkey, wa_sbook-loccurkey. 4. Optional : Display the BOOKID field in the color COL_KEY.
442
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: List
Solution 20: List
Task 1:
Prepare the generation of the details list 1. Copy your program ZBC400_##_SELECT_SFLIGHT or the corresponding template SAPBC400DDS_AUTHORITY_CHECK to the new program ZBC400_##_DETAIL_LIST. a) 2. Carry out this step as usual. Ensure that the relevant key values for the creation of the details list are available to your program when a basic list row (specific flight date) is selected. a) 3. See source code excerpt in the model solution. In your program, implement a function block for generating the basic list and one for the details list. a) See source code excerpt in the model solution.
Task 2:
Create the details list 1. In the first line of the details list, display key information from the selected flight schedule. Underneath, display a horizontal line and a blank line. a) 2. See source code excerpt in the model solution. Retrieve all bookings for the selected flight schedule from database table SBOOK and output them on the details list. Read only the following fields for output for each booking: BOOKID, CUSTOMID, CUSTTYPE, CLASS, ORDER_DATE, SMOKER, CANCELLED. a) See source code excerpt in the model solution.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
443
Unit 12: Classic List Processing
TAW10_1
3.
Optional : Display the fields LOCCURAM and LOCCURKEY on the details list: Use the CURRENCY addition of the WRITE statement to make sure that the currency amount LOCCURAM is formatted according to the currency LOCCURKEY. Hint: WRITE: wa_sbook-loccuram CURRENCY wa_sbook-loccurkey, wa_sbook-loccurkey. a) See source code excerpt in the model solution. See source code excerpt in the model solution.
4.
Optional : Display the BOOKID field in the color COL_KEY. a)
Result
Source code excerpt (without optional parts) : SAPBC400UDS_DETAIL_LIST
REPORT
sapbc400uds_detail_list.
CONSTANTS actvt_display TYPE activ_auth VALUE ’03’. DATA: wa_flight TYPE sbc400focc, wa_sbook TYPE sbook.
PARAMETERS pa_car TYPE s_carr_id.
START-OF-SELECTION. AUTHORITY-CHECK OBJECT ’S_CARRID’ ID ’CARRID’ FIELD pa_car ID ’ACTVT’ FIELD actvt_display.
CASE sy-subrc. WHEN 0. SELECT carrid connid fldate seatsmax seatsocc FROM sflight INTO CORRESPONDING FIELDS OF wa_flight
Continued on next page
444
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: List
WHERE carrid = pa_car. wa_flight-percentage = 100 * wa_flight-seatsocc / wa_flight-seatsmax. WRITE: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate, wa_flight-seatsocc, wa_flight-seatsmax, wa_flight-percentage,’%’. * Hide key values of the current line HIDE: wa_flight-carrid, wa_flight-connid, wa_flight-fldate. ENDSELECT. IF sy-subrc NE 0. WRITE: ’No ’, pa_car, ’flights found !’. ENDIF. WHEN OTHERS. WRITE: / ’Authority-Check Error’(001). ENDCASE. CLEAR wa_flight.
AT LINE-SELECTION. IF sy-lsind = 1. WRITE: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate. ULINE. SKIP. * Reading bookings of the selected flight SELECT bookid customid custtype class order_date smoker cancelled FROM sbook INTO CORRESPONDING FIELDS OF wa_sbook WHERE carrid = wa_flight-carrid AND AND * connid = wa_flight-connid fldate = wa_flight-fldate.
Creating detail list WRITE: / wa_sbook-bookid, wa_sbook-customid, wa_sbook-custtype, wa_sbook-class, wa_sbook-order_date, wa_sbook-smoker,
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
445
Unit 12: Classic List Processing
TAW10_1
wa_sbook-cancelled. ENDSELECT. ENDIF. CLEAR wa_flight.
Source code excerpt (with optional parts) : SAPBC400UDS_DETAIL_LIST1
REPORT sapbc400uds_detail_list1.
CONSTANTS actvt_display TYPE activ_auth VALUE ’03’. DATA: wa_flight TYPE sbc400focc, wa_sbook TYPE sbook.
PARAMETERS pa_car TYPE s_carr_id.
START-OF-SELECTION. AUTHORITY-CHECK OBJECT ’S_CARRID’ ID ’CARRID’ FIELD pa_car ID ’ACTVT’ CASE sy-subrc. WHEN 0. SELECT carrid connid fldate seatsmax seatsocc FROM sflight INTO CORRESPONDING FIELDS OF wa_flight WHERE carrid = pa_car. wa_flight-percentage = 100 * wa_flight-seatsocc / wa_flight-seatsmax. WRITE: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate, wa_flight-seatsocc, wa_flight-seatsmax, wa_flight-percentage,’%’. * Hide key values of the current line HIDE: wa_flight-carrid, wa_flight-connid, wa_flight-fldate. ENDSELECT. IF sy-subrc NE 0. WRITE: ’No ’, pa_car, ’flights found !’. FIELD actvt_display.
Continued on next page
446
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: List
ENDIF. WHEN OTHERS. WRITE: / ’Authority-Check Error’(001). ENDCASE. CLEAR wa_flight.
AT LINE-SELECTION. IF sy-lsind = 1. WRITE: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate. ULINE. SKIP. * Reading bookings of the selected flight SELECT bookid customid custtype class order_date smoker cancelled loccuram loccurkey FROM sbook INTO CORRESPONDING FIELDS OF wa_sbook WHERE carrid = wa_flight-carrid AND AND * connid = wa_flight-connid fldate = wa_flight-fldate.
Creating detail list WRITE: / wa_sbook-bookid COLOR col_key, wa_sbook-customid, wa_sbook-custtype, wa_sbook-class, wa_sbook-order_date, wa_sbook-smoker, wa_sbook-cancelled, wa_sbook-loccuram CURRENCY wa_sbook-loccurkey, wa_sbook-loccurkey. ENDSELECT. ENDIF. CLEAR wa_flight.
2005/Q4
© 2005 SAP AG. All rights reserved.
447
Unit 12: Classic List Processing
TAW10_1
Lesson Summary
You should now be able to: • Describe the attributes and benefits of ABAP lists • Implement list and column headers • Implement multi-level lists • Implement interactive lists
448
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Selection Screen
Lesson:
395
Selection Screen
Lesson Duration: 80 Minutes
Lesson Overview
In this lesson you will learn about the advantages of using the selection screen. In addition to the previous PARAMETERS definitions, you will also learn about the SELECT-OPTIONS restriction option with which the user can specify significantly more complex restrictions for the data selection. Following that you will learn how to use the ABAP events AT SELECTION-SCREEN for implementing an input or authorization check with a possible error dialog using the selection screen.
Lesson Objectives
After completing this lesson, you will be able to: • • • List the properties and benefits of selection screens Implement the options for restricting selections on the selection screen Implement the input and authorization check with an error dialog using the selection screen
Just like the list, the selection screen is a good example of how much time developers save with the ABAP functions already implemented by SAP. Participants should already be familiar with some of the elements dealt with in the following lesson (such as PARAMETERS). Such topics are meant as recaps and should be dealt with quickly. The focus of this lesson is on the SELECT-OPTIONS and error dialog on the selections screen by using the AT SELECTIO-SCREEN. The exercise should be carried out at the end of this lesson.
Business Example
The selection screen of your program should allow users to specify much more complex restrictions for the data selection than is possible for simple PARAMETERS definitions. If the result of the input or authorization check is negative, the selection screen should be displayed with a corresponding error message so the user can make another entry.
2005/Q4
© 2005 SAP AG. All rights reserved.
449
Unit 12: Classic List Processing
TAW10_1
Advantages of Selection Screens
Figure 194: Architecture and Purpose of Selection Screen
In general, selection screens are used for entering selection criteria for data selection. For example, if the program creates a list of data from a very large database table, it often makes sense for the user to select the data records he actually requires and only reading those from the database. Apart from reducing the memory requirement, this also reduces the network load.
450
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Selection Screen
Figure 195: Selection Screen Attributes
The selection screen has the following standard functions: • Texts on the selection screen (selection texts) can be maintained in several languages. At runtime the texts are automatically displayed in the user’s logon language. (Automatic language) The system checks types automatically: If the user enters something that does not correspond to the type of the input field, the SAP GUI will ignore it, so it won’t even appear on the selection screen. In addition to single value entries (PARAMETERS), you can also implement complex selections (SELECT-OPTIONS) on the selection screen. The user can then enter intervals, comparative conditions or even patterns as restrictions. If the input field is defined using a Dictionary element (e.g. data element), then the field documentation (documentation of the data element) can be displayed on the input field, using the F1 (input help) function key. The data element’s search help for displaying possible inputs can be called up using the F4 (input help) function key. • You can easily save completed selection screens as variants for reuse or use in background operation.
•
•
•
2005/Q4
© 2005 SAP AG. All rights reserved.
451
Unit 12: Classic List Processing
TAW10_1
Figure 196: Using Selection Options
The above graphic illustrates the use of selection options, which enable complex entries. Every selection screen contains an information icon (also known as a “Help on Screen” icon). Choose this icon to display additional information. You will learn more about defining selection options using the SELECT-OPTIONS statement later in this lesson.
452
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Selection Screen
Figure 197: Semantic Information on Global Types on the Selection Screen
If an input field is typed with a data element, the following additional semantic information is available on the selection screen: • • • The long field label of the data element can be copied to describe the input field on the selection screen (selection text). (See next graphic) The documentation of the data element is automatically available as an input help (F1 help). If a search help is linked to the data element , it is available as an input help (F4 help). (A search help is an independent dictionary object that displays a list of possible input values to the user (possibly with additional information), from which he can then select one for input.) If the input field is typed with a structure field which is in turn defined using a data element, then the above-described semantic information of the data element is available on the selection screen. If the structure field is also copied to a search help, then this “overwrites” the search help of the data element. For more information, refer to the online documentation for the ABAP Dictionary.
2005/Q4
© 2005 SAP AG. All rights reserved.
453
Unit 12: Classic List Processing
TAW10_1
Figure 198: Selection Texts
On the selection screen, the names of the input fields appear as their description by default. However, you can replace these with corresponding selection texts, which you can then translate into any further languages you require. At runtime, the selection texts are then displayed in the logon language of the user (automatic language). Just like the list headers and text symbols, selection texts belong to the text elements of the program. From the ABAP Editor, choose the menu GoTo → Text Elements → Selection Texts to maintain them. You can implement your translation using the menu GoTo → Translation. If the input field is typed directly or indirectly with a data element, you can copy the long field name from one of the texts stored in the Dictionary (“dictionary reference”). This provides you with an easy option for standardizing the texts.
454
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Selection Screen
Figure 199: Variants
The completed selection screens are the variants of the program. After the program has been started, the user can load variants to the respective selection screen to facilitate repeated identical or almost identical inputs. You have to include a variant when you schedule an ABAP program in the background run, if the program has a selection screen, as user inputs are not possible in the background. You define program-specific variants by starting the program, completing the selection screen and saving it (disc pushbutton). You can also define different attributes for the variant. If variants have already been defined for a program, then an additional pushbutton appears on the selection screen with the text flag “get variant...”. This push button lists the defined variants for selection. In order to be able to define his own variants, the user must have the corresponding authorization (in the production system). But you can also define variants in the development system and then have them transported to the production system. Variants with the name prefix ’CUS&’ are system variants. They are transported like ordinary repository objects and are not client-specific. All other variants are client-specific and must be transported separately. From the ABAP Editor, choose the menu GoTo → Variants to go to the variant management of your program, where you can perform follow-up maintenance for your variants with regards to values and attributes. There, choose the menu Tools → Transport Request to specify the variants to be transported as well as a request. The transport happens when the request is released. For more information on variants, choose the pushbutton Information on Variant Attributes on the screen in order to maintain your variant attributes.
2005/Q4
© 2005 SAP AG. All rights reserved.
455
Unit 12: Classic List Processing
TAW10_1
Input Options on the Selection Screen
Figure 200: Single-Value Input (PARAMETERS Statement)
The above graphic shows the usage and the runtime behavior of an input variable defined using a PARAMETERS statement. Once again, the definition of such an input variable creates a variable in the system and implicitly generates a selection screen with a corresponding input option. An input variable is defined in the same way as an ordinary variable. The only difference is that the PARAMETERS keyword is used instead of DATA. You have to consider three particularities: • • • The name of the input variable may be up to 8 characters long. It may not be typed with the standard types F, STRING and XSTRING. The assignment of a default value is not implemented with the VALUE addition but with the DEFAULT addition.
A default value assignment by means of the DEFAULT addition or value assignment before displaying the selection screen (INITIALIZATION) is displayed on the selection screen as a default value that can be overwritten. If the user enters a value and chooses Execute, the input values are transferred to the internal value and, for example, can be used to restrict the database selection.
456
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Selection Screen
Figure 201: Entering Complex Restrictions (the SELECT-OPTIONS Statement)
Selection options are defined when you use the SELECT-OPTIONS name FOR data_object. statement, where name is the name of the select option and data_object is an already defined variable. Such a definition creates an internal table of the specified name within the program (here so_car) and generates a selection screen with an input option for limiting the specified variable (here: wa_spfli-carrid). User entries are transported to the automatically generated internal table when Execute is chosen. This table always has four columns: sign, option, low, and high. The above graphic shows, which entries are created for which user input: • • • If ’LH’ is entered, a row is generated with the values ’I’ (inclusive), ’EQ’ (equal), ’LH’ and Space. If the interval ’AA’ to ’DL’ is entered, a row is generated with the values ’I’ (inclusive), ’BT’ (between), ’AA’ and ’DL’. If ’BA’ is entered as the single value to be excluded, a row is generated with the values ’E’ (exclusive), ’EQ’ (equal), ’BA’ and Space.
The internal table filled with the entered selection criteria can be used for the database selection, as illustrated in the graphic. The table content is interpreted as follows:
2005/Q4
© 2005 SAP AG. All rights reserved.
457
Unit 12: Classic List Processing
TAW10_1
If I_1, ... , I_n and E_1, ... , E_m are the inclusive/exclusive conditions of the internal table, then the following composite condition is used to limit the data selection: ( I_1 OR ... OR I_n ) AND ( NOT E_1 ) AND ... AND ( NOT E_m ) If the table is empty because there are no restrictions, the WHERE conditions always applies to the respective field. Hint: The IN operator can also be used in logical expressions: IF wa_spfli-carrid IN so_car. For defining a selection option, the same three particularities apply as for the PARAMETERS statement (see above). If the internal table of the selection option is filled using the DEFAULT addition or APPEND statement before the selection screen is displayed (INITIALIZATION, then its content is displayed on the selection screen as suggested conditions that can be overwritten. For further details, refer to the keyword documentation for SELECT-OPTIONS.
458
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Selection Screen
Event after the Selection Screen
Figure 202: AT SELECTION-SCREEN Event
On the selection screen the AT SELECTION-SCREEN event is triggered both by choosing Enter as well as Execute (F8). After the corresponding processing block has been processed, the following START-OF-SELECTION event is triggered and the relevant processing started, if Execute was used. However, if Enter was chosen, the selection screen is displayed again.
2005/Q4
© 2005 SAP AG. All rights reserved.
459
Unit 12: Classic List Processing
TAW10_1
Figure 203: Error Dialogs in AT SELECTION-SCREEN
Immediately before processing the AT SELECTION-SCREEN block, the user entries are automatically transferred to the corresponding variables in the program. Hence, it makes sense to implement required input and authorization checks in this processing block. If the check result is negative, you can simply send out an error message to the user and have the selection screen displayed again. The user then has then option of making new entries. In contrast, an error message in the START-OF-SELECTION block would be displayed under program termination. The following graphic illustrates a simple example program with authorization check and error dialog on the selection screen.
460
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Selection Screen
Figure 204: Syntax Example: Authorization Check with Error Dialog
Additional information can be found in the keyword documentation for “AT SELECTION-SCREEN”.
2005/Q4
© 2005 SAP AG. All rights reserved.
461
Unit 12: Classic List Processing
TAW10_1
462
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Selection Screen
409
Exercise 21: Selection Screen
Exercise Duration: 30 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Use the ABAP statement SELECT-OPTIONS to implement a complex selection criterion on the selection screen • Use complex restrictions for database selections • Program error dialogs using the standard selection screen
Business Example
On the selection screen, users should be able to enter complex restrictions for the database selection instead of a single value. Furthermore, the selection screen should be displayed again with a corresponding error message when the user does not have the authorization for the requested data.
System Data
System: Client: User ID: Password: Set up instructions: system Will be assigned Will be assigned Will be assigned Will be assigned No special instructions when using a standard training
Task 1:
Define and use selection options. 1. Copy your program ZBC400_##_DETAIL_LISTor the corresponding template SAPBC400UDS_DETAIL_LIST to the new program ZBC400_##_SEL_SCREEN.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
463
Unit 12: Classic List Processing
TAW10_1
2.
On your selection screen, make it possible to enter complex restrictions for the connection number (CONNID). Hint: When you assign a type to the airline and the connection number, refer to fields of the same structure, so that the user gets context-sensitive search helps.
3.
Use the restrictions entered by the user for the selection from the database table SFLIGHT.
Task 2:
Implement an authorization check with an error dialog on the selection screen 1. Change your program in such a way that, in case of a missing authorization for the airline entered, an appropriate error message is sent and the selection screen is displayed again for re-entry. Hint: Message class BC400 already contains a suitable message, which you can use.
464
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Selection Screen
Solution 21: Selection Screen
Task 1:
Define and use selection options. 1. Copy your program ZBC400_##_DETAIL_LISTor the corresponding template SAPBC400UDS_DETAIL_LIST to the new program ZBC400_##_SEL_SCREEN. a) 2. Carry out this step as usual. On your selection screen, make it possible to enter complex restrictions for the connection number (CONNID). Hint: When you assign a type to the airline and the connection number, refer to fields of the same structure, so that the user gets context-sensitive search helps. a) 3. See source code excerpt in the model solution.
Use the restrictions entered by the user for the selection from the database table SFLIGHT. a) See source code excerpt in the model solution.
Task 2:
Implement an authorization check with an error dialog on the selection screen 1. Change your program in such a way that, in case of a missing authorization for the airline entered, an appropriate error message is sent and the selection screen is displayed again for re-entry. Hint: Message class BC400 already contains a suitable message, which you can use. a) See source code excerpt in the model solution.
Result
Source code excerpt: SAPBC400UDS_SEL_SCREEN
REPORT sapbc400uds_sel_screen.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
465
Unit 12: Classic List Processing
TAW10_1
CONSTANTS actvt_display TYPE activ_auth VALUE ’03’. DATA: wa_flight TYPE sbc400focc, wa_sbook TYPE sbook.
PARAMETERS pa_car LIKE wa_flight-carrid. SELECT-OPTIONS so_con FOR wa_flight-connid.
* First event processed after leaving the selection screen AT SELECTION-SCREEN. AUTHORITY-CHECK OBJECT ’S_CARRID’ ID ’CARRID’ FIELD pa_car ID ’ACTVT’ FIELD actvt_display.
IF sy-subrc NE 0. * Return to selection screen and display message in status bar MESSAGE e045(bc400) WITH pa_car. ENDIF.
START-OF-SELECTION. SELECT carrid connid fldate seatsmax seatsocc FROM sflight INTO CORRESPONDING FIELDS OF wa_flight WHERE carrid = pa_car AND connid IN so_con. wa_flight-percentage = 100 * wa_flight-seatsocc / wa_flight-seatsmax. WRITE: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate, wa_flight-seatsocc, wa_flight-seatsmax, wa_flight-percentage, ’%’. HIDE: wa_flight-carrid, wa_flight-connid, wa_flight-fldate. ENDSELECT. IF sy-subrc NE 0. WRITE ’Requested data not found !’. ENDIF. CLEAR wa_flight.
Continued on next page
466
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Selection Screen
AT LINE-SELECTION. IF sy-lsind = 1. WRITE: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate. ULINE. SKIP. SELECT bookid customid custtype class order_date smoker cancelled loccuram loccurkey FROM sbook INTO CORRESPONDING FIELDS OF wa_sbook WHERE carrid = wa_flight-carrid AND AND connid = wa_flight-connid fldate = wa_flight-fldate.
WRITE: / wa_sbook-bookid color col_key, wa_sbook-customid, wa_sbook-custtype, wa_sbook-class, wa_sbook-order_date, wa_sbook-smoker, wa_sbook-cancelled, wa_sbook-loccuram CURRENCY wa_sbook-loccurkey, wa_sbook-loccurkey. ENDSELECT. ENDIF. CLEAR wa_flight.
2005/Q4
© 2005 SAP AG. All rights reserved.
467
Unit 12: Classic List Processing
TAW10_1
Lesson Summary
You should now be able to: • List the properties and benefits of selection screens • Implement the options for restricting selections on the selection screen • Implement the input and authorization check with an error dialog using the selection screen
468
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Generating and Designing the Selection Screen
Lesson:
415
Generating and Designing the Selection Screen
Lesson Duration: 40 Minutes
Lesson Overview
This lesson explains how to generate and design selection screens. First, the lesson lists the uses of selection screens. It explains how to declare fields with PARAMETERS or SELECTION-OPTIONS. The lesson also explains how to design the selection screen.
Lesson Objectives
After completing this lesson, you will be able to: • • • • Explain the uses of selection screens Declare fields with PARAMETERS Declare fields with SELECTION-OPTIONS Design the selection screen
Ensure that learners are introduced to new keywords. Explain the content and use all the demonstrations.
Business Example
You work as a programmer for ABC Tours and Travels. The manager of the company wants to view flight data for their client, ABC Airways, in the form of a list. You need to write a program to generate a user-friendly screen, which will generate a list displaying the required data.
Selection Screen Overview
The upper half of the graphic provides an overview of the selection screen for the logical database. Briefly mention that Release 4.0 includes a new ABAP keyword (NODES). Make a reference to the following unit. The lower half of the graphic shows the standard selection screen (screen 1000) that is created using PARAMETERS and SELECT-OPTIONS statements. The third section shows how to create multiple selection screens in a program using a function introduced in Release 4.0. Call additional selection screens using CALL SELECTION-SCREEN.
2005/Q4
© 2005 SAP AG. All rights reserved.
469
Unit 12: Classic List Processing
TAW10_1
Figure 205: Selection Screen: Overview
Selection screens serve as an interface between the program and the user. They are used to limit the amount of data read from the database. Logical databases provide selection screens whose concrete appearance depends on the specified node name (NODES). Selection screen versions, if supplied by the logical database, offer a subset of default selection screens. You can use the declarative language elements PARAMETERS and SELECT-OPTIONS to generate a default selection screen (screen 1000) with input-ready fields. Besides default selection screens, you can create selection screens using SELECTION-SCREEN BEGIN OF .... and call the screens using CALL SELECTION-SCREEN. Create variants to save selection screen values that are used repeatedly. These variants can be recalled for use when required. A variant is required if a report is to run in a background work process.
Declaring Fields with Parameters
Use the ABAP keyword PARAMETERS to create a selection screen. Describe the syntax (DEFAULT, OBLIGATORY, MEMORY ID). Explain the parameter as a check box and radio button group. Specify the features of this setup. The value of a check box can only be X or a space. Only one parameter can be marked in a radio button group.
470
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Generating and Designing the Selection Screen
Present the following demonstration on check boxes and radio button groups: SAPBC405_SSCD__CHECKBOX_RADIOB
Figure 206: Declaring Fields with PARAMETERS
The PARAMETERS keyword is a declarative language element. As in the DATA statement, you can declare parameters with TYPE or LIKE. The system generates input-ready fields in the selection screen. The names of PARAMETERS fields can be up to eight characters long. You can maintain selection texts using the menu path Goto→ Text Elements→ Selection Texts. You can set a default value for a PARAMETERS keyword with the DEFAULT addition. If you assign a MEMORY ID , the system retrieves the current value from the SAP memory and displays automatically. If you declare mandatory fields with the OBLIGATORY addition, users cannot leave the selection screen until values have been specified in these fields. Automatic checking by the ABAP Dictionary is turned off for report selection screens, by default. However, if you make a reference to a dictionary object that has a foreign key defined, using VALUE CHECK will make the dictionary verify that the input is valid. You can also define parameters as check boxes (AS CHECKBOX). This creates a one-character field that can contain a " " (space) or an X. You can evaluate the contents of check boxes using IF/ENDIF control structures.
2005/Q4
© 2005 SAP AG. All rights reserved.
471
Unit 12: Classic List Processing
TAW10_1
You can also define a series of radio buttons for a selection screen with the addition RADIOBUTTON GROUP . The maximum length of the name for a RADIOBUTTON GROUP is four characters. Only one radio button in a group can be active and evaluated during program processing. You can evaluate the contents of radio buttons using CASE/ENDCASE control structures.
Declaring Fields with Select Options
Selections with SELECT-OPTIONS Explain SELECT-OPTIONS (internal table with fixed structure). Selection Options and Multiple Selections In Release 4.6C, the selection options and delete function are not available on the application toolbar, but in the context menu. Show the following demonstration: SAPBC405_SSCD_SELECT_OPTIONS Syntax of the SELECT-OPTIONS statement Explain syntax in detail.
Figure 207: Selections with SELECT-OPTIONS
472
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Generating and Designing the Selection Screen
The SELECT-OPTIONS keyword is a declarative language element with the same eight-character naming restriction as PARAMETERS. Unlike the PARAMETERS keyword, SELECT-OPTIONS permits a range of values and complex selections instead of just a single input-ready field. The SELECT-OPTIONS keyword generates an internal table with a standard structure and a header line. This table has four columns: sign, option, low, and high. Just as with PARAMETERS, you can maintain the selection text using the menu path Goto → Text elements → Selection texts. Use the addition FOR to specify the field against which the system should check selection entries. This field must be declared in a DATA or TABLES statement. Both high and low fields inherit the attributes of the referenced field. Each line of the selection table formulates a condition using one of the following relational operators: • • SIGN: I (Include), E (Exclude) OPTION: EQ, NE, LE, LT, GE, GT, BT (Between), NB (Not Between), CP (Contains Pattern), NP (Contains Pattern not)
The selection set is the union of all includes (I1,..., In) minus the union of all excludes (E1, ..., Em). If no values are entered in the SELECT-OPTIONS object, all rows are returned from the database.
Figure 208: SELECT-OPTIONS with Multiple Selection Criteria
2005/Q4
© 2005 SAP AG. All rights reserved.
473
Unit 12: Classic List Processing
TAW10_1
When the user makes entries in a SELECT-OPTIONS object, the system automatically populates the internal table. To change the default entries for table fields SIGN and OPTION, choose menu Edit → Selection options., the system offers alternatives appropriate for the selection. If the traffic signal icon is green during Select, there is an (I)nclusive in the sign column. A red light indicates (E)xclude. To delete a table entry, use the menu Edit → Delete selection criterion. Each selection criterion can be used to make multiple selections unless otherwise defined. If multiple selections are present, the color of the arrow changes from white to green.
Figure 209: Syntax of the SELECT-OPTIONS Statement
Additions to the SELECT-OPTIONS statements are: • DEFAULT enables you to set default values for low or low and high parameters. You can use OPTION and SIGN to set default values for option and sign , which differ from the normal default addition. You can set a default value for a SELECT-OPTIONS keyword with the DEFAULT addition. If you assign a MEMORY ID , the system retrieves the current value from the SAP system memory and displays it automatically. LOWER CASE suppresses conversion of the entry to upper case. This addition is not permitted for Dictionary fields, because the attribute set in the Dictionary takes precedence. OBLIGATORY generates a mandatory field. A question mark is displayed in the entry field in the selection screen and the user should enter a value. NO-EXTENSION suppresses multiple single or multiple range selections. NO INTERVALS suppresses the seltab-high (upper interval limit) entry on the selection screen. You can use the additional screen, Multiple selection, to specify ranges.
• • •
474
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Generating and Designing the Selection Screen
Designing the Selection Screen
Designing the Selection Screen I The design of the selection screen should provide ease of use and clarity. Related fields should be grouped together and enclosed in a frame. Explain the syntax. Show the following demonstration: SAPBC405_SSCD_SEL_SCREEN_I Frames on the selection screen Designing the Selection Screen II Explain the syntax of multiple output parameters in a single line. Show the following demonstration: SAPBC405_SSCD_SEL_SCREEN_II Mention pos_low and pos_high position markers.
Figure 210: Designing the Selection Screen I
You can use the SELECTION-SCREEN keyword to design the layout of the selection screen.
2005/Q4
© 2005 SAP AG. All rights reserved.
475
Unit 12: Classic List Processing
TAW10_1
You can group screen elements that logically belong together using the extension BEGIN OF BLOCK . You can place a frame around the screen elements using WITH FRAME. You can nest frames to a maximum depth of five. You can assign a title to the block only if you use a frame. You can declare the title as either text-xxx or a field name with maximum length of eight characters. In the second case, you set the text at runtime in the INITIALIZATION event. Before designing a selection screen, you should become familiar with the screen design guidelines listed in transaction BIBS.
Figure 211: Designing the Selection Screen II
You can display multiple parameters and comments on the same line on the screen. To do so, you need to enclose the parameters between the SELECTION-SCREEN BEGIN OF LINE and SELECTION-SCREEN END OF LINE statements. The COMMENT parameter enables you to include text in the line. Comment text must always have a format (position and output length). The position can be set using a data field or pos_low or pos_high. The latter are low and high positions for the SELECT-OPTIONS field on the selection screen. Adding COMMENT ... FOR FIELD ensures that F1 Help for the field is displayed for the comment text and the parameter. If you hide the parameter (selection variant: attribute invisible), the comment text is also hidden. You can use POSITION to set the cursor for the next output position (only within ... BEGIN OF LINE ... END OF LINE).
476
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 12: Classic List Processing
TAW10_1
477
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 12: Classic List Processing
TAW10_1
478
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Generating and Designing the Selection Screen
423
Exercise 22: Designing, Initializing, and Checking a Selection Screen
Exercise Duration: 25 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Use the SELECT-OPTIONS statement • Use the PARAMETERS statement • Design a selection screen • Initialize and check (optional)
Business Example
Extend your program using the SELECT-OPTIONS statement for the connection number and the flight date and parameters for output control.
Task:
1. Copy or enhance your program Z##FOL1_..., or copy the sample solution, SAPBC405_FOLS_1, to program Z##SSC1_... . Sample solution for exercise: SAPBC405_SSCS_1. Extend the selection screen using SELECT-OPTIONS for the connection number and the flight date and parameters for output control. Extend the selection screen using select options for the connection number and the flight date. Suppress the multiple selection option for the flight date. Enclose the selections for the airline carrier ID and the connection number within a frame that has a title. Enclose the Group the flight date in a block. Create a frame with a title around the block. Maintain the selection texts for all selection screen fields. Implement a group of parameters for output control. Create a group of three radio buttons with the following functions: Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
479
Unit 12: Classic List Processing
TAW10_1
- All flights are read - Only domestic flights are read - Only international flights are read The default setting should be for international flights. Create an additional parameter for country code referencing wa_flights_countryfr and prompt the user to specify a value if a domestic flight is selected. Create a frame without a title around the radio button set. Create a frame around the complete display parameters and assign a title and selection texts. Arrange the frames and texts as shown in the template. Ensure that only the requested data records are read from the database. To do this, supplement the WHERE clause of the SELECT statement with the conditions that result from the selections. Implement the logic for the radio button group. Note: You need to use three SELECT statements with different WHERE conditions. You can map the national/international condition directly on the database:countryto = dv_flights~countryfr or countryto dv_flights~countryfr. Use the tilde (~) to address the database field. OPTIONAL Initialize the selection table for the airline name to display the flights of airlines AA through QF, but not AZ. Display error message 003 in message class BC405 if the user has selected domestic flights and the input parameter for the country is initial. If there is an error, only the radio button group and the country parameter should be ready for input.
480
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Generating and Designing the Selection Screen
Solution 22: Designing, Initializing, and Checking a Selection Screen
Task:
1. Copy or enhance your program Z##FOL1_..., or copy the sample solution, SAPBC405_FOLS_1, to program Z##SSC1_... . Sample solution for exercise: SAPBC405_SSCS_1. Extend the selection screen using SELECT-OPTIONS for the connection number and the flight date and parameters for output control. Extend the selection screen using select options for the connection number and the flight date. Suppress the multiple selection option for the flight date. Enclose the selections for the airline carrier ID and the connection number within a frame that has a title. Enclose the Group the flight date in a block. Create a frame with a title around the block. Maintain the selection texts for all selection screen fields. Implement a group of parameters for output control. Create a group of three radio buttons with the following functions: - All flights are read - Only domestic flights are read - Only international flights are read The default setting should be for international flights. Create an additional parameter for country code referencing wa_flights_countryfr and prompt the user to specify a value if a domestic flight is selected. Create a frame without a title around the radio button set. Create a frame around the complete display parameters and assign a title and selection texts. Arrange the frames and texts as shown in the template. Ensure that only the requested data records are read from the database. Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
481
Unit 12: Classic List Processing
TAW10_1
To do this, supplement the WHERE clause of the SELECT statement with the conditions that result from the selections. Implement the logic for the radio button group. Note: You need to use three SELECT statements with different WHERE conditions. You can map the national/international condition directly on the database:countryto = dv_flights~countryfr or countryto dv_flights~countryfr. Use the tilde (~) to address the database field. OPTIONAL Initialize the selection table for the airline name to display the flights of airlines AA through QF, but not AZ. Display error message 003 in message class BC405 if the user has selected domestic flights and the input parameter for the country is initial. If there is an error, only the radio button group and the country parameter should be ready for input. a)
*&-------------------------------------------------------------*& Report SAPBC405_SSCS_1 *& *&-------------------------------------------------------------*& Solution: Exercise 1; Selection Screen *& *&-------------------------------------------------------------INCLUDE bc405_sscs_1top.
*&-------------------------------------------------------------*& Event TOP-OF-PAGE *&-------------------------------------------------------------TOP-OF-PAGE. * Title FORMAT COLOR COL_HEADING INTENSIFIED ON. ULINE. WRITE: / sy-vline, ’Flight data’(001), AT line_size sy-vline. ULINE. * Column header Continued on next page
482
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Generating and Designing the Selection Screen
FORMAT COLOR COL_HEADING INTENSIFIED OFF. WRITE: sy-vline, AT pos_c1 ’Flight’(002). * Fix left scroll boundary SET LEFT SCROLL-BOUNDARY. WRITE: ’Date’(003) , ’Departure location’(004), ’Arrival location’(005), ’Price’(006), AT line_size sy-vline. ULINE.
************************************************************* Optional parts: Initializing and checking a selection screen *************************************************************
*&----------------------------------------------------------*& Event INITIALIZATION *&----------------------------------------------------------INITIALIZATION. " OPTIONAL * Initialize select-options for CARRID MOVE: ’AA’ TO so_car-low, ’QF’ TO so_car-high, ’BT’ TO so_car-option, ’I’ TO so_car-sign. APPEND so_car. CLEAR so_car. MOVE: ’AZ’ TO so_car-low ’EQ’ TO so_car-option, ’E’ TO so_car-sign. APPEND so_car. CLEAR so_car.
*&----------------------------------------------------------*& Event AT SELECTION-SCREEN ON BLOCK PARAM *&----------------------------------------------------------AT SELECTION-SCREEN ON BLOCK param. " OPTIONAL * check country for national flights is not empty CHECK national = ’X’ AND country = space. MESSAGE e003(bc405). Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
483
Unit 12: Classic List Processing
TAW10_1
*&-------------------------------------------------------------*& Event START-OF-SELECTION *&-------------------------------------------------------------START-OF-SELECTION. * Checking the output parameters CASE mark. WHEN all. * Radiobutton ALL is marked SELECT * FROM dv_flights INTO TABLE it_flights WHERE carrid IN so_car AND connid IN so_con AND fldate IN so_fdt. WHEN national. * Radiobutton NATIONAL is marked SELECT * FROM dv_flights INTO TABLE it_flights WHERE carrid IN so_car AND connid IN so_con AND fldate IN so_fdt AND countryto = dv_flights~countryfr AND countryto = country. WHEN internat. * Radiobutton INTERNAT is marked SELECT * FROM dv_flights INTO TABLE it_flights WHERE carrid IN so_car AND connid IN so_con AND fldate IN so_fdt AND countryto dv_flights~countryfr. ENDCASE.
*&-------------------------------------------------------------*& Event END-OF-SELECTION *&-------------------------------------------------------------END-OF-SELECTION. SORT it_flights BY carrid connid fldate. * Data output Continued on next page
484
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Generating and Designing the Selection Screen
PERFORM data_output.
*&----------------------------------------------------------*& Form DATA_OUTPUT *&----------------------------------------------------------* List output of flight data *-----------------------------------------------------------FORM data_output. * Loop at the internal table for writing data LOOP AT it_flights INTO wa_flights. * Get a new page if CONNID has changed. ON CHANGE OF wa_flights-connid. NEW-PAGE. ENDON. * Mark international flights FORMAT COLOR COL_KEY INTENSIFIED ON. IF wa_flights-countryfr EQ wa_flights-countryto. WRITE: / sy-vline, icon_space AS ICON CENTERED. ELSE. WRITE: / sy-vline, icon_bw_gis AS ICON CENTERED. ENDIF. * Data output WRITE: wa_flights-carrid, wa_flights-connid. FORMAT COLOR COL_NORMAL INTENSIFIED OFF. WRITE: wa_flights-fldate, wa_flights-cityfrom, wa_flights-cityto, wa_flights-price CURRENCY wa_flights-currency, wa_flights-currency, AT line_size sy-vline. ENDLOOP. ENDFORM. " DATA_OUTPUT
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
485
Unit 12: Classic List Processing
TAW10_1
*&-------------------------------------------------------------*& Include BC405_SSCS_1TOP *& *&-------------------------------------------------------------REPORT bc405_sscs_1top LINE-SIZE 100 NO STANDARD PAGE HEADING. * Include for using icons INCLUDE . * Constants for writing position CONSTANTS : pos_c1 TYPE i VALUE 6, line_size TYPE i VALUE 100. * Constant for CASE statement CONSTANTS mark VALUE ’X’. * Internal table like DDIC view DV_FLIGHTS DATA: it_flights LIKE TABLE OF dv_flights, wa_flights LIKE dv_flights. * Selections for SELECTION-SCREEN WITH FRAME TITLE SELECT-OPTIONS: connections BEGIN OF BLOCK conn text-tl1. so_car FOR wa_flights-carrid, so_con FOR wa_flights-connid. SELECTION-SCREEN END OF BLOCK conn. * Selections for flights SELECTION-SCREEN BEGIN OF BLOCK flight WITH FRAME TITLE text-tl2. SELECT-OPTIONS so_fdt FOR wa_flights-fldate NO-EXTENSION. SELECTION-SCREEN END OF BLOCK flight. * Output parameter SELECTION-SCREEN BEGIN OF BLOCK param WITH FRAME TITLE text-tl3. SELECTION-SCREEN BEGIN OF BLOCK radio WITH FRAME. PARAMETERS: all RADIOBUTTON GROUP rbg1, national RADIOBUTTON GROUP rbg1, internat RADIOBUTTON GROUP rbg1 DEFAULT ’X’. SELECTION-SCREEN END OF BLOCK radio. Continued on next page
486
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Generating and Designing the Selection Screen
PARAMETERS country LIKE wa_flights-countryfr. SELECTION-SCREEN END OF BLOCK param.
2005/Q4
© 2005 SAP AG. All rights reserved.
487
Unit 12: Classic List Processing
TAW10_1
Lesson Summary
You should now be able to: • Explain the uses of selection screens • Declare fields with PARAMETERS • Declare fields with SELECTION-OPTIONS • Design the selection screen
488
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Introduction to Logical Databases
Lesson:
433
Introduction to Logical Databases
Lesson Duration: 30 Minutes
Lesson Overview
A Logical Database (LDB) is an ABAP program that reads data from the database and makes the data available to report programs. This lesson provides an overview of the features and structure of a logical database. It also lists the advantages of using a logical database.
Lesson Objectives
After completing this lesson, you will be able to: • • Identify the characteristics of the logical database List the advantages of the logical database
Explain the importance of the logical database and that it offers a single specific logical view on data. There is a hierarchy to these views. Tables and structures from the ABAP Dictionary can be used as nodes.
Business Example
You work as a programmer for ABC Tours and Travels. You need to inform the Executive Board of the company about the importance of the logical database to read data in the hierarchical structure of tables, which helps in better data organization.
Logical Database Overview
Generating Lists Present the following alternatives: reading data using Open SQL, Native SQL, and a logical database. Highlight the advantages of Open SQL (independent of database, syntax check, SAP buffer) over Native SQL. Introduce the logical database as a tool (reader). Logical Database: Overview A logical database offers one specific logical view on data. There is a hierarchy to these views. Tables and structures from the ABAP Dictionary can be used as nodes. Logical Database: F1S Nodes
2005/Q4
© 2005 SAP AG. All rights reserved.
489
Unit 12: Classic List Processing
TAW10_1
F1S contains 3 nodes, specifically 3 tables from flight data model BC_TRAVEL. The tables are linked through foreign key dependencies. Sample Program for a logical database Explain the program in the system. Point out on the selection screen that only event blocks and data record processing has been programmed (no SELECT statements). Show demonstration: SAPBC405_LDBD_SIMPLE_EXAMPLE
Figure 212: Generating Lists
In general, the system reads data that appears in a list from the database. You can use either Open SQL or Native SQL statements to read data from the database. Avoid using Native SQL to maintain portability from one RDBMS to another. Also, Native SQL requires to be recoded to take advantage of upgrades in the RDBMS. Open SQL has no such limitations or requirements. The use of a logical database program provides an excellent alternative to programming data retrieval. Logical databases retrieve data records in primary key sequence and make the data available to ABAP programs. They also offer the advantage of security because authority checks are made in the logical database program rather than in the report program.
490
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Introduction to Logical Databases
Figure 213: Logical Database: Overview
A logical database is an ABAP program that reads data from the database and makes the data available to other report programs. A hierarchical structure determines the order in which the data is supplied to programs. A logical database also provides a selection screen that checks user entries and conducts error dialogs. You can add your own parameters and select options. The SAP system provides approximately 190 logical databases in Release 4.6. The names of logical databases have been extended from three characters to 20 characters in Release 4.0 (namespace prefix maximum of 10 characters). If the name of the logical database is three characters in length, the first two characters name the logical database and the third character identifies the application area. A list of the values for the third character can be displayed by looking at a program’s attributes and then pressing F4 on the Application field. For example, DDF is named for Debtor Data and the letter F represents financial data.
2005/Q4
© 2005 SAP AG. All rights reserved.
491
Unit 12: Classic List Processing
TAW10_1
Figure 214: Logical Database: F1S Nodes
Demo programs and exercises for ABAP courses and ABAP documentation refer to the SAP system’s BC_TRAVEL flight data model, which is found in development class BC_DATAMODEL. The following tables form the nodes of the logical database F1S: • • • SPFLI: Flight connections SFLIGHT: Flights SBOOK: Bookings
492
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Introduction to Logical Databases
Figure 215: Sample Program for a Logical Database
You need to specify the name of the logical database in the program’s attributes for an executable (type 1) program. Use the keyword NODES to specify the nodes of the logical database that you want to use in the program. NODES allocates appropriate storage space for the node (a work area or a table area depending on the node type). Note: The keyword TABLES can still be used in Release 4.6.data records, it issues the statement PUT which triggers the GET event in the report program.
Advantages of a Logical Database
Advantages of a Logical Database Emphasize the advantages of a logical database. Many programs, Quick Views, and queries can work together in a single database. This means that maintenance is concentrated in a single location. A logical database provides a selection screen, performs input checks, and reads the requested data. You only have to program data processing in ABAP.
2005/Q4
© 2005 SAP AG. All rights reserved.
493
Unit 12: Classic List Processing
TAW10_1
Figure 216: Advantages of a Logical Database
A logical database can be the data source for several QuickViews, queries, and reports. In QuickView, the logical database program (LDB) can be specified directly as a data source. A query works with the logical database when the InfoSet that generated the query is defined with a logical database. In the case of executable programs, the LDB is entered in the attributes or called using the function module LDB_PROCESS. See appendix for information on how to use the function module. Logical databases offer several advantages over other methods of data retrieval, such as: • • The system generates a selection screen. The use of selection screen versions or variants provides the required flexibility. The programmer does not need to know the exact structure or relationship of the tables involved. The data is made available to the application program in primary key sequence. Performance improvements within logical databases directly affect all programs linked to the logical database without having to change the programs themselves. Maintenance and enhancements can be performed at a central location. Authorization checks are made in the logical database program rather than in the application program.
• •
494
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Introduction to Logical Databases
Facilitated Discussion Discussion Questions
Use the following questions to engage the participants in the discussion. Feel free to use your own additional questions. Discuss the advantages of a logical database.
2005/Q4
© 2005 SAP AG. All rights reserved.
495
Unit 12: Classic List Processing
TAW10_1
Lesson Summary
You should now be able to: • Identify the characteristics of the logical database • List the advantages of the logical database
496
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Logical Database Subobjects and Data Retrieval
Lesson:
440
Logical Database Subobjects and Data Retrieval
Lesson Duration: 50 Minutes
Lesson Overview
This lesson focuses on logical database (LDB) subobjects. The lesson begins with an explanation of the structure of logical database subobjects. It explains how to use selections in logical database subobjects. It also explains the importance of database programs and the use of database program in logical database subobjects. Finally, it explains how data is read from the database.
Lesson Objectives
After completing this lesson, you will be able to: • • • • Explain the structure of logical database subobjects Use various selections in logical database subobjects Explain the concept of database programs in logical database subobjects Explain how to retrieve data from the database
Ensure that the various logical database subobjects are presented and explained. Explain the interaction between the report, LDB database program, and structure. Also, explain in detail the problem that occurs when you enhance the selection screen of the logical database. CHECK is required in the program. When doing the exercises, remember that a new exercise track begins here; participants work with a new program. Experience has shown that participants lose a lot of time trying to format the lists. Tell the participants that formatting is a secondary priority and they should concentrate on programming the required functions.
Business Example
You work as a programmer for ABC Tours and Travels. The manager of the company requires a list of current flight data. You need to write a program that displays current flight data using the logical database.
2005/Q4
© 2005 SAP AG. All rights reserved.
497
Unit 12: Classic List Processing
TAW10_1
Structure of LDB Subobjects
LDB Subobjects: Structure Present the logical database subobjects using transaction SE36 (logical database Builder). The structure determines the read sequence. There are various node types since Release 4.0. Release 4.6 contains a new type, dynamic, where the actual characteristics assigned to the node are determined at run time. The permissible characteristics are programmed in the logical database. Logical database BC405_DIFF_NODES contains various node types. Demonstration: SAPBC405_LDBD_DIFF_NODES.hr includes logical database PNP, which contains dynamic nodes. Show how to access the logical database in the system. Show the structure of F1S. It is recommended that you show the structure of other logical databases because the structure in F1S is very simple. Explain the sequence in which events are triggered. Show demonstration: SAPBC405_LDBD_EVENTS Program Flow and Termination Alternatives Explain the differences between the various Cancel alternatives.
498
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Logical Database Subobjects and Data Retrieval
Figure 217: LDB Sub-Objects: Structure
Logical databases comprise of several subobjects. The structure determines the hierarchy and the read sequence of data records. Node names can contain up to 14 characters. There are four node types such as: • Table (type T): The node name is the name of a transparent table. This node type corresponds to the concept prior to Release 4.0A. The table name must be identical to the node name. Deep types (complex) are not allowed. DDIC type (type S): Any node name is possible. The node is assigned a structure or a table type from the Dictionary. The node name can differ from the type name. Deep structures are possible. Type groups (type C): The node type is defined in a type group. The name of the type group must be maintained in the Type group field. DDIC types are generally preferred because other applications that use the logical database, such as SAP Query, can access them (short texts, and so on). Dynamic nodes (type A): Do not have a fixed type and are not classified until program run time. The types that are permitted are determined when the structure is created.
•
•
•
2005/Q4
© 2005 SAP AG. All rights reserved.
499
Unit 12: Classic List Processing
TAW10_1
Figure 218: Events in Logical Databases
The START-OF-SELECTION event triggers before control is given to the read routine of the logical database. The END-OF-SELECTION event triggers after all GET events have been processed (all data records have been read and processed). The GET event triggers when the logical database supplies data for this node. This means that GET events are processed several times and that data has already been read from the database for these events. The sequence in which GET events are processed is determined by the structure of the logical database. The GET LATE event triggers when all subordinate nodes of node have been processed before the data is read for the next (when a hierarchy level has been completed). At the start of the event, the system automatically adds a line feed and sets the font and intensity to the system defaults. If colors were set in other events, they are reset.
500
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Logical Database Subobjects and Data Retrieval
Figure 219: Program Flow and Termination Alternatives
The CHECK keyword ends the current processing block if the condition is false. The STOP keyword ends program processing. Unlike the EXIT statement, the processing block END-OF-SELECTION processes first (if it exists). If there is a STOP statement within the END-OF-SELECTION processing block, program processing ends and the list buffer is displayed. The EXIT statement exits the program but does not trigger the END-OF-SELECTION event. Any list buffer that was created before the EXIT keyword is encountered will be displayed. You can also use the REJECT statement. The data record does not process further. Processing continues on the same hierarchy level when the next data record is read. REJECT can also be used within a subroutine.
Selections in LDB Subobjects
LDB Subobjects: Selections You define logical database selection screens using the selection include: which nodes on the selection screen provide which PARAMETERS and SELECT-OPTIONS. You also define which nodes are available for field selection and dynamic selection.
2005/Q4
© 2005 SAP AG. All rights reserved.
501
Unit 12: Classic List Processing
TAW10_1
Show the selection include of F1S in the system. Explain in detail parameters and selections and show the assignment to nodes (... FOR NODE). Show the Extras menu in the logical database Builder (transaction SE36), that is used to query field selections externally. Selection Screen for the Logical Database Explain how the selection screen depends on the NODES Statement. The logical database reads data using a prescribed sequence defined in the database’s structure. Create a program with NODES: SFLIGHT and explain why the selections for SPFLI are provided. Restart program SAPBC405_LDBD_SIMPLE_EXAMPLE and run the dynamic selections for F1S. Explain what a selection view is.
Figure 220: LDB Sub-Objects: Selections
Logical database programs have an include named db sel in which the logical database selection screen(s) are defined. The addition FOR NODE assigns selections to individual logical nodes. The appearance of a selection screen directly depends on the NODES statement contained within your program. A field selection can be defined in the logical database program for individual nodes. This is done using the keyword FIELD SELECTION FOR NODE in the SELECTION-SCREEN statement. The code in the logical database program enables the application program to use the GET FIELD to restrict the amount of data retrieved.
502
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Logical Database Subobjects and Data Retrieval
A few logical databases also designate dynamic selections for individual nodes. This is done by dynamic selection using the addition DYNAMIC SELECTIONS FOR NODE. The Dynamic selection button appears on the report’s selection screen. You can determine which selection fields can be set by choosing a particular selection view (type: CUS) or using the selection view delivered by the SAP system (type: SAP). A few large logical databases have several selection screen versions. Each selection screen version contains a subset of the selection criteria (language element: EXCLUDE). You can specify which selection screen to display by entering the selection screen version number in the program attributes.
Figure 221: Selection Screen for the Logical Database
When you enter a logical database in the attributes of the type 1 program, the system processes the selection screen of the logical database. The concrete characteristics of the selection screen depend on the node specified in the NODES statement. If you specify a node of type T (table), you can also declare the table work area using the TABLES statement. If you address only subordinate nodes (in the hierarchy) of the logical database in the program (for example, SFLIGHT), the selection screen criteria for the superior node in the hierarchy (SPFLI) also appears. You can thus restrict the dataset to be read so that it meets specific requirements. Note: A logical database always reads in accordance with its structure. This means that if you need data only from a node deep in the hierarchy, you should either find another logical database where the desired node is higher in the structure or program data retrieval .
2005/Q4
© 2005 SAP AG. All rights reserved.
503
Unit 12: Classic List Processing
TAW10_1
Figure 222: Logical Database: Dynamic Selections
If the logical database supports dynamic selections, Dynamic selections appears on the selection screen. When the user selects Dynamic selections, a second selection screen is displayed, which enables the user to select additional database fields. The system transfers the selections directly to the logical database program and to the database (dynamic selections). The selection view determines which fields are displayed on the selection screen. Create your own view with type CUST and use it to override the view with type SAP.
LDB Subobjects Database Programs
LDB Subobjects: Database Programs Database access and authorization checks in individual form routines are programmed in the database program. Explain the structure (collection of form routines). Show the database program of the F1S on the system. Mention the naming convention SAPDB.
504
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Logical Database Subobjects and Data Retrieval
Figure 223: LDB Subobjects: Database Programs
Logical database programs are named SAPDB for logical database . The programs are a collection of subroutines, each of which is performed for specific events. For example, subroutine is processed once at the start of the database program. This program can define default values for the selection screen of the LDB. Other subroutines are processed during the event PBO (Process Before Output) and PAI (Process After Input) of the selection screen. Checks such as authorization checks (AUTHORITY-CHECK), are usually performed during the event PAI. Database access (SELECT statements) is programmed in put_ subroutines. These subroutines may be processed several times depending on the selection criteria specified by the user. The sequence in which these subroutines are processed is determined by the structure of the logical database.
Data Retrieval
Explain the interaction between the report, LDB database program, and structure. In addition, go into detail about the problem that, when you enhance the selection screen of the logical database, CHECK is required in the program. Interaction: LDB and Program
2005/Q4
© 2005 SAP AG. All rights reserved.
505
Unit 12: Classic List Processing
TAW10_1
Highlight the interaction between: structure – database program – program. Explain how control is passed between the database program and the program. Checking Internal Program Selections Explain the CHECK function. Show demonstration SAPBC405_LDBD_CHECK_SEL using the debugger.
Figure 224: Interaction: LDB and Program
When a report program that uses a logical database is started, control is initially passed to the database program of the logical database. Each event has a corresponding subroutine in the database program (for example, subroutine init for event INITIALIZATION). During the interaction between the LDB and the associated report, the subroutine is always processed first, followed by the event (if there is one in the report). Logical database programs read data from a database according to the structure declared for the logical database. They begin with the root node and then process the individual branches consecutively from top to bottom. The logical database reads the data in PUT_ subroutines. During event PUT, control passes from the database program to the GET event of the associated report. The data is made available in the corresponding work areas in the report. The processing block defined for the GET event is performed and control then returns to the logical database. PUT activates the next form subroutine found in the structure. This flow continues until the report collects all the available data.
506
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Logical Database Subobjects and Data Retrieval
The depth of data read in the structure depends upon a program’s GET events. A logical database reads to the lowest GET event contained within structure attributes. Only those GET events for which processing is supposed to take place are written in the report program. Logical databases read all data records found on the direct access path.
Figure 225: Checking Internal Program Selections
If you specify a logical database and declare additional selections in the program attributes that refer to the fields of a node not designated for dynamic selection, you need to use the CHECK statement to see if the current data record fulfills the selection criteria. If the data record does not fulfill these selection criteria, processing of the current event block ends.
2005/Q4
© 2005 SAP AG. All rights reserved.
507
Unit 12: Classic List Processing
TAW10_1
508
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Logical Database Subobjects and Data Retrieval
451
Exercise 23: GET Events
Exercise Duration: 30 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Create a list with data read from a logical database
Business Example
In this exercise, you need to write a program to create a list that reads data from the SPFLI, SFLIGHT, and SBOOK logical databases. Use the SAPBC405_LDBS_1 template to create the program.
Task:
1. Create program Z##LDB1_... using TOP include (Z##LDB1_...TOP) and enter the logical database F1S in the program attributes. Ensure that you specify Executable program as the program type. To do this, you need to change the program type. Sample solution for exercise: SAPBC405_LDBS_1. The logical database should supply the program with data for nodes SPFLI, SFLIGHT, and SBOOK. Create a list that displays the following data: Table SPFLI: CARRID, CONNID, CITYFROM, AIRPFROM, CITYTO, AIRPTO. Table SFLIGHT: FLDATE, PRICE, CURRENCY, PLANETYPE, SEATSMAX, SEATSOCC,FREE_SEATS. Table SBOOK: BOOKID, CUSTOMID, SMOKER, LUGGWEIGHT, WUNIT. Field FREE_SEATS is not a table field – it has to be calculated by the program. The price and luggage weight should be output with the appropriate units. Create a list in which each line outputs the information for one node (see above). The list should have 83 columns. Maintain the column headers (standard list header). Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
509
Unit 12: Classic List Processing
TAW10_1
Format the list (optional). Output the first line in color COL_HEADING not intensified, the second line in COL_NORMAL intensified, and the third line in COL_NORMAL not intensified. Buffer the list. Note: To output the fields, you need to use pattern functions available in the ABAP Editor.
510
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Logical Database Subobjects and Data Retrieval
Solution 23: GET Events
Task:
1. Create program Z##LDB1_... using TOP include (Z##LDB1_...TOP) and enter the logical database F1S in the program attributes. Ensure that you specify Executable program as the program type. To do this, you need to change the program type. Sample solution for exercise: SAPBC405_LDBS_1. The logical database should supply the program with data for nodes SPFLI, SFLIGHT, and SBOOK. Create a list that displays the following data: Table SPFLI: CARRID, CONNID, CITYFROM, AIRPFROM, CITYTO, AIRPTO. Table SFLIGHT: FLDATE, PRICE, CURRENCY, PLANETYPE, SEATSMAX, SEATSOCC,FREE_SEATS. Table SBOOK: BOOKID, CUSTOMID, SMOKER, LUGGWEIGHT, WUNIT. Field FREE_SEATS is not a table field – it has to be calculated by the program. The price and luggage weight should be output with the appropriate units. Create a list in which each line outputs the information for one node (see above). The list should have 83 columns. Maintain the column headers (standard list header). Format the list (optional). Output the first line in color COL_HEADING not intensified, the second line in COL_NORMAL intensified, and the third line in COL_NORMAL not intensified. Buffer the list. Note: To output the fields, you need to use pattern functions available in the ABAP Editor. a)
*&----------------------------------------------------------*& Report SAPBC405_LDBS_1 *& *&----------------------------------------------------------*& Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
511
Unit 12: Classic List Processing
TAW10_1
*& *&-------------------------------------------------------------INCLUDE bc405_ldbs_1top.
*&-------------------------------------------------------------*& Event GET SPFLI *&-------------------------------------------------------------GET spfli. * Data output SPFLI FORMAT COLOR COL_HEADING INTENSIFIED OFF. WRITE: / sy-vline, spfli-carrid, spfli-connid, spfli-cityfrom, spfli-airpfrom, spfli-cityto, spfli-airpto, AT line_size sy-vline.
*&-------------------------------------------------------------*& Event GET SFLIGHT *&-------------------------------------------------------------GET sflight. * Calculate free seats free_seats = sflight-seatsmax - sflight-seatsocc. * Data output SFLIGHT FORMAT COLOR COL_NORMAL INTENSIFIED ON. WRITE: / sy-vline, sflight-fldate, sflight-price CURRENCY sflight-currency, sflight-currency, sflight-planetype, sflight-seatsmax, sflight-seatsocc, free_seats, AT line_size sy-vline.
*&-------------------------------------------------------------*& Event GET SBOOK *&-------------------------------------------------------------GET sbook. FORMAT COLOR COL_NORMAL INTENSIFIED OFF. Continued on next page
512
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Logical Database Subobjects and Data Retrieval
WRITE: / sy-vline, sbook-bookid, sbook-customid, sbook-smoker, sbook-luggweight UNIT sbook-wunit, sbook-wunit, AT line_size sy-vline.
*&----------------------------------------------------------*& Include BC405_LDBS_1TOP *& *&----------------------------------------------------------REPORT sapbc405_ldbs_1 LINE-SIZE 83.
* Used nodes of the structure of the logical database F1S NODES: spfli, sflight, sbook. * Variables DATA: free_seats LIKE sflight-seatsocc. * Constants CONSTANTS: line_size LIKE sy-linsz VALUE 83.
2005/Q4
© 2005 SAP AG. All rights reserved.
513
Unit 12: Classic List Processing
TAW10_1
514
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Logical Database Subobjects and Data Retrieval
457
Exercise 24: GET LATE Events and Checks from Internal Program Selections
Exercise Duration: 20 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Create a list that reads data from a logical database • Check internal selections for their validity
Business Example
Extend your program with validity of selections.
Task:
1. Extend program Z##LDB1_... or copy the sample program SAPBC405_LDBS_1 to program Z##LDB2_... . Sample solution for exercise: SAPBC405_LDBS_2. Add a SELECT-OPTIONS statement for the posting date (SBOOK-CUSTOMID) to the selection screen. Frame the selection and maintain the selection text. Ensure that only bookings that meet the specified selection criteria are output in the list. Include the booking date in the list output. Maintain the column header (standard list header). In the list, output a solid line when all the bookings for a date have been output and when data of a flight has been completely output. Display each flight on a new page.
2005/Q4
© 2005 SAP AG. All rights reserved.
515
Unit 12: Classic List Processing
TAW10_1
Solution 24: GET LATE Events and Checks from Internal Program Selections
Task:
1. Extend program Z##LDB1_... or copy the sample program SAPBC405_LDBS_1 to program Z##LDB2_... . Sample solution for exercise: SAPBC405_LDBS_2. Add a SELECT-OPTIONS statement for the posting date (SBOOK-CUSTOMID) to the selection screen. Frame the selection and maintain the selection text. Ensure that only bookings that meet the specified selection criteria are output in the list. Include the booking date in the list output. Maintain the column header (standard list header). In the list, output a solid line when all the bookings for a date have been output and when data of a flight has been completely output. Display each flight on a new page. a)
*&-------------------------------------------------------------*& Report SAPBC405_LDBS_2 *& *&-------------------------------------------------------------*& *& *&-------------------------------------------------------------INCLUDE bc405_ldbs_2top.
*&-------------------------------------------------------------*& Event GET SPFLI *&-------------------------------------------------------------GET spfli. * Data output SPFLI FORMAT COLOR COL_HEADING INTENSIFIED OFF. WRITE: / sy-vline, spfli-carrid, spfli-connid, spfli-cityfrom, spfli-airpfrom, spfli-cityto, spfli-airpto, Continued on next page
516
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Logical Database Subobjects and Data Retrieval
AT line_size sy-vline.
*&----------------------------------------------------------*& Event GET SFLIGHT *&----------------------------------------------------------GET sflight. * Calculate free seats free_seats = sflight-seatsmax - sflight-seatsocc. * Data output SFLIGHT FORMAT COLOR COL_NORMAL INTENSIFIED ON. WRITE: / sy-vline, sflight-fldate, sflight-price CURRENCY sflight-currency, sflight-currency, sflight-planetype, sflight-seatsmax, sflight-seatsocc, free_seats, AT line_size sy-vline.
*&----------------------------------------------------------*& Event GET SBOOK *&----------------------------------------------------------GET sbook. * Check select-option CHECK so_cust. FORMAT COLOR COL_NORMAL INTENSIFIED OFF. WRITE: / sy-vline, sbook-bookid, sbook-customid, sbook-smoker, sbook-luggweight UNIT sbook-wunit, sbook-wunit, sbook-order_date, AT line_size sy-vline.
*&----------------------------------------------------------*& Event GET SPFLI LATE *&----------------------------------------------------------GET spfli LATE. ULINE. Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
517
Unit 12: Classic List Processing
TAW10_1
NEW-PAGE.
*&-------------------------------------------------------------*& Event GET SFLIGHT LATE *&-------------------------------------------------------------GET sflight LATE. ULINE.
*&-------------------------------------------------------------*& Include BC405_LDBS_2TOP *& *&-------------------------------------------------------------REPORT sapbc405_ldbs_2 LINE-SIZE 83.
* Used nodes of the structure of the logical database F1S NODES: spfli, sflight, sbook. * Additional selections SELECTION-SCREEN BEGIN OF BLOCK order WITH FRAME. SELECT-OPTIONS: so_cust FOR sbook-customid. SELECTION-SCREEN END OF BLOCK order. * Variables DATA: free_seats LIKE sflight-seatsocc. * Constants CONSTANTS: line_size LIKE sy-linsz VALUE 83.
518
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Logical Database Subobjects and Data Retrieval
Lesson Summary
You should now be able to: • Explain the structure of logical database subobjects • Use various selections in logical database subobjects • Explain the concept of database programs in logical database subobjects • Explain how to retrieve data from the database
2005/Q4
© 2005 SAP AG. All rights reserved.
519
Unit Summary
TAW10_1
Unit Summary
You should now be able to: • Describe the attributes and benefits of ABAP lists • Implement list and column headers • Implement multi-level lists • Implement interactive lists • List the properties and benefits of selection screens • Implement the options for restricting selections on the selection screen • Implement the input and authorization check with an error dialog using the selection screen • Explain the uses of selection screens • Declare fields with PARAMETERS • Declare fields with SELECTION-OPTIONS • Design the selection screen • Identify the characteristics of the logical database • List the advantages of the logical database • Explain the structure of logical database subobjects • Use various selections in logical database subobjects • Explain the concept of database programs in logical database subobjects • Explain how to retrieve data from the database
520
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Test Your Knowledge
463
Test Your Knowledge
1. The maximum length of the name for a RADIOBUTTON GROUP is eight characters.
Determine whether this statement is true or false.
□ □ 2.
True False
to SELECT-OPTION The addition statement suppresses multiple-single or multiple-range selections.
Fill in the blanks to complete the sentence.
3.
and are declarative language elements that are used to generate default selection screens with input-ready fields.
Fill in the blanks to complete the sentence.
4.
What is the use of adding COMMENT For FIELD while designing the selection screen ?
5.
It is recommended that you use Native SQL to read data from a logical database to maintain portability from one RDBMS to another.
Determine whether this statement is true or false.
□ □ 6.
True False
For a logical database whose name has three characters, the first two characters of the logical database. The third character identifies refer to the the .
Fill in the blanks to complete the sentence.
2005/Q4
© 2005 SAP AG. All rights reserved.
521
Test Your Knowledge
TAW10_1
7.
If there is a ___________ statement within the END-OF-SELECTION processing block, program processing ends and the list buffer is displayed.
Choose the correct answer(s).
□ □ □ □ 8.
A B C D
REJECT CHECK STOP EXIT
The Logical database reads the data in subroutines.
Fill in the blanks to complete the sentence.
9.
If you address subordinate nodes in the hierarchy, the selection screen criteria for only that subordinate node appears.
Determine whether this statement is true or false.
□ □
True False
10. Checks such as Authorization checks are usually performed during the event Process Before Output (PBO).
Determine whether this statement is true or false.
□ □
True False
522
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Test Your Knowledge
465
Answers
1. The maximum length of the name for a RADIOBUTTON GROUP is eight characters. Answer: False The maximum length of the name for a RADIOBUTTON GROUP is four characters. 2. The addition NO-EXTENSION to SELECT-OPTION statement suppresses multiple-single or multiple-range selections. Answer: NO-EXTENSION 3. PARAMETERS and SELECT-OPTIONS are declarative language elements that are used to generate default selection screens with input-ready fields. Answer: PARAMETERS, SELECT-OPTIONS 4. What is the use of adding COMMENT For FIELD while designing the selection screen ? Answer: Adding COMMENT For FIELD ensures that F1 Help for the field is displayed for the comment text and the parameter. 5. It is recommended that you use Native SQL to read data from a logical database to maintain portability from one RDBMS to another. Answer: False Avoid using Native SQL to read from the database, because it needs to be recoded to take advantage of RDBMS upgrades. 6. For a logical database whose name has three characters, the first two characters refer to the name of the logical database. The third character identifies the application area. Answer: name, application area
2005/Q4
© 2005 SAP AG. All rights reserved.
523
Test Your Knowledge
TAW10_1
7.
If there is a ___________ statement within the END-OF-SELECTION processing block, program processing ends and the list buffer is displayed. Answer: C If there is a STOP statement within the END-OF-SELECTION processing block, program processing ends and the list buffer is displayed.
8.
The Logical database reads the data in PUT_ subroutines. Answer: PUT_
9.
If you address subordinate nodes in the hierarchy, the selection screen criteria for only that subordinate node appears. Answer: False If you address only subordinate nodes in the hierarchy, the selection screen criteria for the superior node in the hierarchy also appears.
10. Checks such as Authorization checks are usually performed during the event Process Before Output (PBO). Answer: False Checks such as Authorization checks are usually performed during the event Process After Input (PAI).
524
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 13
467
Creating and Calling Function Groups and Function Modules
For more information, see the introductory instructor notes in the lesson.
Unit Overview
Function modules enable you to store parts of programs globally in the system so that they can be used by all programs.. Function modules are embedded in function groups. In this way, function groups and function modules enable modularization. This unit provides you with the essentials required for working with function groups and modules.
Unit Objectives
After completing this unit, you will be able to: • • • • • • • • Define function groups Explain the structure of a function group Define function modules Define interfaces of function modules Define and raise exceptions for function modules Test function modules Implement function module calls in ABAP Implement exception handling in ABAP
Unit Contents
Lesson: Function Groups .......................................................... 527
2005/Q4
© 2005 SAP AG. All rights reserved.
525
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Exercise 25: Creating a Function Group .................................... 533 Lesson: Function Modules......................................................... 536 Exercise 26: Creating Function Modules.................................... 549 Lesson: Calling Function Modules................................................ 557 Exercise 27: Implementing and Calling Function Modules ............... 563 Exercise 28: Using Global Data of a Function Group ..................... 569
526
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Groups
Lesson:
468
Function Groups
Lesson Duration: 20 Minutes
Lesson Overview
This lesson introduces function groups. You will learn the components that comprise a function group and how it is structured. You will also learn how to create a new function group.
Lesson Objectives
After completing this lesson, you will be able to: • • Define function groups Explain the structure of a function group
The participants should at least be vaguely familiar with the structure of function groups. This lesson is intended primarily to motivate (why use function modules?) and as preparation for the complex example application used in the exercises in the subsequent lessons. It is particularly important for you to emphasize that global data is static.
Business Example
Mr. Jones is an ABAP software developer at a major corporation that develops proprietary business applications in ABAP. He is asked to develop a flexible new application for flight bookings. One of the requirements is to develop as many reusable components as possible. Mr. Jones knows that function modules are reusable components, so he begins his development project with an emphasis on function modules. In a first step, he creates the necessary function groups.
Function Modules and Function Groups
Function modules are special procedures that are globally visible and that can be called from within other ABAP programs. They can only be defined and implemented in special ABAP programs, which are called function groups. Function groups are not executable programs – that is, they cannot be started using transaction codes or by entering their names. They serve exclusively as main programs for the function modules. In most cases, a function group contains several function modules that perform related functions or operate on the same data.
2005/Q4
© 2005 SAP AG. All rights reserved.
527
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
When an ABAP program calls a function module, the corresponding function group is loaded into the internal session, where it remains until the calling program ends. If the program calls several function modules from the same function group (or the same function module several times) consecutively, the function group is only loaded during the first call.
Figure 226: Logical View of a Function Group
Aside from function modules, function groups can also contain the following elements: • • • Data declarations (global data objects) Subroutines Screens
These elements can be used by all the function modules in the function group. Global data objects are... ... encapsulated They cannot be accessed directly from outside the function group. Access is only possible by calling a suitable function module. .... static They retain their values when an executable program calls several function modules in the same function group consecutively.
528
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Groups
Structure of a Function Group
Figure 227: Physical View of a Function Group
Technically, a function group consists of a main program and a number of include programs. When you create a function group, the main program and the include programs are created automatically. The names of the individual components are generated from the name of the function group (), which can be up to 26 characters long.
2005/Q4
© 2005 SAP AG. All rights reserved.
529
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
The main program, SAPL, merely contains INCLUDE statements for the following include programs: • TOP include Include program LTOP contains the FUNCTION-POOL statement and the global data declarations. • U includes Include program LUXX contains additional INCLUDE statements for the include programs LU01, LU02, ... . These contain the actual function modules. • F includes The include programs LF01, LF02, ... can be used to define subroutines that all the function modules can access through an internal call. • O includes The include programs LO01, LO02, ... can be used to define PBO modules (OUTPUT) for the screens in the function group. • I includes The include programs LI01, LI02, ... can be used to define PAI modules (INPUT) for the screens in the function group. The creation of these include programs is largely automated through the forward navigation in the ABAP Workbench.
Function Groups and Global Classes
Until object-oriented programming was introduced in ABAP, cross-program modularization was implemented largely through function module calls. Today, the methods of global classes are also available for this purpose. Global classes feature a number of advantages over function groups. In addition to important object-oriented concepts like inheritance, polymorphism, and interfaces, the greatest benefit stems from the fact that classes can be instantiated more than once.
530
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Groups
Figure 228: Function Groups and Global Classes
Still, function groups continue to play a significant role in ABAP programming. Global classes cannot be used as alternatives to function modules in the following important application cases: Screens In contrast to classes, function groups can contain screens, which makes it possible to encapsulate user dialogs in function modules. Remote capability Function modules can be called by external systems (Remote Function Call). Update Certain function modules (update modules) can be used for updates. They are not run directly when called, but instead at the end of the logical unit of work (LUW). Asynchronous execution Function modules are executed in parallel in a separate work process. The calling program does not wait until processing of the function module is complete.
2005/Q4
© 2005 SAP AG. All rights reserved.
531
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Creating a Function Group
Figure 229: Creating a Function Group
To create a function group, proceed as follows: 1. 2. Choose the object list for a function group in the Object Navigator. Enter the name of a new function group and press ENTER or the sure to observe the customer namespace). button (be
A dialog window appears, asking whether you want to create the new function group. 3. Click Yes to confirm. A dialog box with the attributes of the function group appears. 4. 5. Enter a short text and press the Save button. Assign the function group to a package and a correction request in the next screens.
The result: the main program, TOP include, and Uxx includes are created for the new function group.
532
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Groups
475
Exercise 25: Creating a Function Group
Exercise Duration: 10 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Create function groups
Business Example
Your company wants to develop an application that calculates and displays possible flight connections between two cities. In addition to direct flights, connections with stopovers should also be included. After the user enters the departure and destination cities, a list of possible flights should be displayed. If necessary, the user can also display the individual stopovers for a specific connection. You plan to use different programming techniques to display the data. As a result, the data retrieval function should be developed separately from the display function. It should also be possible to develop the display function in an external system. You are in charge of implementing the data retrieval function. You decide to program it as a function group with function modules, which can be remote-enabled if necessary. You will implement this project successively in this exercise and the subsequent exercises in this unit.
System Data
System: Client: User ID: Password: Set up instructions: Will be assigned Will be assigned Will be assigned Will be assigned No special settings required in the standard training system
Task:
Create function group 1. Create function group ZBC402_##_CONN.
2005/Q4
© 2005 SAP AG. All rights reserved.
533
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Solution 25: Creating a Function Group
Task:
Create function group 1. Create function group ZBC402_##_CONN. a) Perform this step as described in the course materials.
534
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Groups
Lesson Summary
You should now be able to: • Define function groups • Explain the structure of a function group
2005/Q4
© 2005 SAP AG. All rights reserved.
535
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Lesson:
478
Function Modules
Lesson Duration: 60 Minutes
Lesson Overview
In this lesson, you will learn how to create a function module. You will also learn how you can define the interface, enter documentation, and test the function module.
Lesson Objectives
After completing this lesson, you will be able to: • • • • Define function modules Define interfaces of function modules Define and raise exceptions for function modules Test function modules
This lesson summarizes everything the participants need to know about function modules. In particular, you should emphasize the techniques and options that have been added in recent releases and which therefore might not be familiar to all participants: the logical IS SUPPLIED condition, class-based exceptions, and test sequences.
Business Example
Mr. Jones is an ABAP software developer at a major corporation that develops proprietary business applications in ABAP. He is asked to develop a flexible new application for flight bookings. One of the requirements is to develop as many reusable components as possible. Mr. Jones knows that function modules are reusable components, so he begins his development project by creating function modules.
Creating Function Modules
Before you create a new function module, you should search for a suitable function group or create a new one.
536
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Modules
Figure 230: Creating a Function Module
To create the function module, proceed as follows: 1. 2. 3. Decide in which function group you want to use to create the new function module. Display the object list for the function group in the navigation area of the Object Navigator. Open the context menu for the function group in the tree structure and choose Create –> Function Module. A dialog box with the attributes of the function module appears. 4. Enter a name and a short text for the function module. Be sure to use the customer namespace for function modules (customer function modules start with “Z_” or “Y_”). Click the (Save) button. If necessary, assign the function module to a package and a correction request in the next screens.
5. 6.
A new function module is created. In the process, a new U include is generated automatically, and the Uxx include in the function group is supplemented with an appropriate INCLUDE statement.
2005/Q4
© 2005 SAP AG. All rights reserved.
537
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Maintaining Attributes
Figure 231: Attributes of a Function Module
In the attributes of a function module, you specify its general administrative data and its process type: • • Remote-enabled modules can also be called from other systems. Update modules are used for consolidated database changes, and have additional functions for doing so.
538
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Modules
Editing the Source Code
Figure 232: Source Code of a Function Module
When you create a function module, a corresponding U include is generated automatically. You use this include to program the functions of the function module. Note that you cannot load U includes directly in the ABAP Editor. They can only be edited within the Function Builder. The FUNCTION and ENDFUNCTION statements denote the beginning and end of the function module. The interface of the function module is displayed as generated comment lines. These lines are updated automatically when the interface is changed. You define the interface itself in the appropriate tab pages.
2005/Q4
© 2005 SAP AG. All rights reserved.
539
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Defining Interface Parameters
Figure 233: Interface Parameters for Function Modules
Interface parameters are used to exchange data between the calling program and the function module.
Parameter Types
We differentiate between the following types of parameters: Import parameters are passed by the calling program to the function module. Export parameters are passed by the function module to the calling program. Changing parameters are used for both import and export. They are passed by the calling program to the function module. The function module can change their contents and pass them back to the calling program. Tables parameters represent a special option for passing internal tables. These tables are imported and exported. In general, you should no longer use tables parameters for regular function modules. Use other parameter types to pass the internal tables instead (typed with a table type from the Dictionary or a generic table type).
540
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Modules
Typing Interface Parameters
You can only use data types that are declared system-wide to type interface parameters. These global types are: • • • Elementary ABAP data types Generic types that are declared system-wide (such as ANY TABLE) Data types from the ABAP Dictionary
In contrast to its use in subroutines, LIKE references to internal program data objects are not allowed here.
Passing by Reference or by Value
By default, all parameters are passed by reference. If you want to pass parameters by value, you must select the relevant option when you define the interface. This is rarely necessary in regular function modules. Note that passing values has a negative effect on performance – particularly when internal tables are passed. Therefore, in local calls table parameters are always passed by reference. Hint: Passing by reference is not allowed in remote-enabled function modules.
Optional Parameters
You can flag import, changing, and tables parameters as optional. The calling program does not have to supply these parameters with values. Export parameters are always optional. You can define default values for optional import and changing parameters, which are used if the calling program does not pass any values.
2005/Q4
© 2005 SAP AG. All rights reserved.
541
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Using Optional Parameters
Figure 234: Logical Condition IS SUPPLIED
When you program function modules, you can design the program flow to be dependent on whether the calling program has supplied an optional parameter or not. To do so, you use logical expressions in the format IS SUPPLIED or IS NOT SUPPLIED, where stands for the name of the optional parameter. Note that EXPORT parameters are always optional. Hint: You can use this technique, for example, when data whose retrieval and formatting is extremely performance-intensive is only needed for some calls of a function module. An obsolete logical condition, IS REQUESTED, still exists for EXPORT and CHANGING parameters.
542
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Modules
Exceptions
Figure 235: Declaring and Raising Exceptions
Function modules can raise exceptions in order to inform the calling program of error situations. To do so, you have to declare the exceptions in the function module interface. Choose a name for each exception that the function module might raise. You have two options for raising an exception when an error occurs within a function module: RAISE . If the is listed in the call of the function module, control returns to the calling program. If it is not listed, the program terminates with a runtime error. MESSAGE () RAISING . If the exception is listed in the call, control returns to the calling program. If the exception is not listed in the calling program, message from message class is sent. The program is either terminated or continues, depending on the message type, . Therefore, no runtime error is raised.
2005/Q4
© 2005 SAP AG. All rights reserved.
543
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Class-Based Exceptions
Figure 236: Declaring and Raising Class-Based Exceptions
As an alternative to defining names, you can also list exception classes in the function module interface. To do so, set the Exception Classes checkbox. These exception classes must be defined beforehand as global classes with type “Exception Class” (naming convention: exception classes start with “CX_” or “ZCX_”). The use of class-based exceptions is described in detail in course BC401, ABAP Objects. To raise a class-based exception, you could use the following statement: RAISE EXCEPTION TYPE . If the constructor of the exception class has parameters, use the EXPORTING addition to supply them with data. Hint: Remote-enabled function modules cannot raise class-based exceptions.
544
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Modules
Documentation
Function modules can and should be reused in other programs. Accordingly, it is particularly important that you document the functions and interface of a function module carefully. We differentiate between function module documentation and parameter documentation.
Figure 237: Documenting Function Modules
Function Module Documentation
In the function module documentation, you describe the functions that the function module provides. The information in this documentation should be detailed enough that another programmer does not have to analyze the source code in order to use the function module correctly. In addition to describing the functions, you can also specify example calls, hints for using the function module, and other source of information in the documentation. To edit the function module documentation, press the FModule Documentation button or choose menu path Goto → Documentation while in change mode of the Function Builder.
Parameter Documentation
In the parameter documentation, you enter information about the individual parameters and exceptions of the function module.
2005/Q4
© 2005 SAP AG. All rights reserved.
545
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
You should describe the meaning of each parameter and, if necessary, its value range and default value. For exceptions, you should describe exactly which error situations will raise this exception, as well as its effects. You can reach the documentation of parameters and exceptions from the Long Text column in the parameter/exception list of the Function Builder.
Testing Function Modules
You can use the test environment in the Function Builder to check whether your function runs properly and returns the correct results. Use the single test or a test sequence, depending on whether you want to test a single function module or a sequence of several function modules.
Single Test
Figure 238: Testing a Function Module
To test a single function module within the Function Builder, press the (Test/Execute).
button
546
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Modules
This generates a test framework from the active interface definition. You can now enter input values for all import, changing, and tables parameters. To enter table or structure parameters, double-click on the respective parameter name. You can then execute the function module either directly ( button) or in debugging mode ( Debugging button). To avoid having to enter the same values repeatedly for complex interfaces, you can use the test data directory as described below: Saving the test data To save test data, press the save button ( ) after you enter the parameter values, and enter a short text to describe the test dataset. Retrieving test data To retrieve saved test data, press the Test Data Dir. button in the parameter entry screen and then double-click an entry in the list to select it.
Test Sequence
Function groups often make use of the fact that the contents of global data are retained between individual function module calls. During a single test, however, the corresponding function group is loaded anew each time. Accordingly, the single test is often unsuitable for testing function modules in such function groups. The test sequence enables you to test several function modules consecutively, without a reset of the function group after each function call.
2005/Q4
© 2005 SAP AG. All rights reserved.
547
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Figure 239: Calling a Test Sequence
To execute a test sequence, proceed as follows: 1. 2. 3. Display the object list for the function group in the navigation area of the Object Navigator. Open the context menu for the function group in the tree structure and choose Test Sequence.... In the next dialog box, enter the names of the function modules you want to test, in the order you want to test them. The list can contain the same function module several times. (Click the Get Test Sequence button to repeat an existing test sequence). Choose Execute ( button). Enter the parameter values for the first function module call and start the test ( button). The result of the first function module in the sequence is displayed. To test the next function module in the sequence, choose Back ( button). When you are finished, you have the opportunity to save the test sequence. At the same time, the parameter values from the single tests are saved in the test data directory.
4. 5.
548
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Modules
491
Exercise 26: Creating Function Modules
Exercise Duration: 15 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Create function modules • Define function module interfaces • Document function modules
Business Example
Now that you have created the function group, you want to create the necessary function modules. During your search of reusable components, you found function module BC402_FMDD_CONNECTION_LIST, which determines the data you need, but only returns it in a single internal table. This does not satisfy your requirements specifically, because stopovers should not be displayed before the user requests them. Moreover, the function module is not flagged as remote-enabled. You decide to create two new function modules: • • One function module to retrieve the data and provide the overview list without the list of stopovers A second function module to return a table with the stopovers for a specific flight from the list
When you type the interface parameters, you use function module BC402_FMDD_CONNECTION_LIST as a guide, because you plan to call this function module within your new function modules. Hint: In this exercise, you will create the two function modules and define the interfaces. You will program the source text itself in the next exercise.
System Data
System: Client: User ID: Password: Will be assigned Will be assigned Will be assigned Will be assigned
2005/Q4
© 2005 SAP AG. All rights reserved.
549
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Set up instructions:
No special settings required in the standard training system
Task 1:
Preparation 1. 2. Display function module BC402_FMDD_CONNECTION_LIST in the Function Builder and familiarize yourself with the typing of the interface parameters. If you have not created a function group called ZBC402_##_CONN yet, make a copy of function group BC402_FMDT_CONN_A and call it ZBC402_##_CONN.
Task 2:
Create the function module for the list of flights 1. 2. Create a new function module named Z_BC402_##_GET_CONN_LIST in your function group. Define one import parameter each for the departure and destination cities. Choose the same types as the corresponding parameters in function module BC402_FMDD_CONNECTION_LIST. Does it make sense to make the parameters optional? Should you set the parameters to transfer by value or transfer by reference? 3. Define an export parameter for the list of flights without the corresponding stopovers. Use an appropriate table type for the parameter. Hint: The corresponding parameter in function module BC402_FMDD_CONNECTION_LIST contains both the flight data (structure type BC402_S_CONN) and the data for the corresponding stopovers (table type BC402_T_CONNSTEP). Search for a table type that only has structure type BC402_S_CONN as line type. When should you transfer the parameter by value? 4. Define a (non-class-based) exception for the situation in which no flight is found between the specified cities. When can a class-based exception cause problems here? 5. Enter brief documentation for the function module, the parameters, and the exception. Continued on next page
550
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Modules
Task 3:
Create the function module for the list of stopovers 1. 2. Create a new function module named Z_BC402_##_GET_STEP_LIST in your function group. Define an import parameter that uniquely identifies a flight. Hint: Note the table key in table type BC402_T_CONNECTION. 3. 4. 5. Create an export parameter for the list of stopovers and type it with table type BC402_T_CONNSTEP. Create an exception for the situation that the table with stopovers could not be determined for the specified flight. Enter brief documentation for this second function module.
2005/Q4
© 2005 SAP AG. All rights reserved.
551
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Solution 26: Creating Function Modules
Task 1:
Preparation 1. Display function module BC402_FMDD_CONNECTION_LIST in the Function Builder and familiarize yourself with the typing of the interface parameters. a) 2. In the Object Navigator, for example, press the Other Object ... button and choose the Function Group tab page in the next screen.
If you have not created a function group called ZBC402_##_CONN yet, make a copy of function group BC402_FMDT_CONN_A and call it ZBC402_##_CONN. a) Display the object list for function group BC402_FMDT_CONN_A in the navigation area and then choose Copy... in the context menu.
Task 2:
Create the function module for the list of flights 1. Create a new function module named Z_BC402_##_GET_CONN_LIST in your function group. a) 2. Perform this step as described in the course materials. Define one import parameter each for the departure and destination cities. Choose the same types as the corresponding parameters in function module BC402_FMDD_CONNECTION_LIST. Does it make sense to make the parameters optional? Should you set the parameters to transfer by value or transfer by reference? a) Define the parameters as required parameters, because you have to have both the departure city and destination city to determine a flight connection. If you want to classify the function module as remote-enabled later, you have to configure transfer by value for all the parameters. If not, you can leave them set to transfer by reference.
Continued on next page
552
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Modules
3.
Define an export parameter for the list of flights without the corresponding stopovers. Use an appropriate table type for the parameter. Hint: The corresponding parameter in function module BC402_FMDD_CONNECTION_LIST contains both the flight data (structure type BC402_S_CONN) and the data for the corresponding stopovers (table type BC402_T_CONNSTEP). Search for a table type that only has structure type BC402_S_CONN as line type. When should you transfer the parameter by value? a) Type the export parameter with table type BC402_T_CONN. You should only transfer the parameter by value if the function module is supposed to be remote-enabled.
4.
Define a (non-class-based) exception for the situation in which no flight is found between the specified cities. When can a class-based exception cause problems here? a) A class-based exception is not possible if you plan to flag the remote module later as remote-enabled.
5.
Enter brief documentation for the function module, the parameters, and the exception. a) Perform this step as described in the course materials.
Task 3:
Create the function module for the list of stopovers 1. Create a new function module named Z_BC402_##_GET_STEP_LIST in your function group. a) 2. Perform this step as described in the course materials. Define an import parameter that uniquely identifies a flight. Hint: Note the table key in table type BC402_T_CONNECTION. a) Create the import parameter with type INT4.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
553
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
3.
Create an export parameter for the list of stopovers and type it with table type BC402_T_CONNSTEP. a) Perform this step as you did in the previous exercise. Create an exception for the situation that the table with stopovers could not be determined for the specified flight. a) Perform this step as you did in the previous exercise.
4.
Continued on next page
554
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Function Modules
5.
Enter brief documentation for this second function module. a) Perform this step as you did in the previous exercise.
Result
The (generated) source text of your first function module should now look something like this:
FUNCTION bc402_get_conn_list_a. *"---------------------------------------------------------------------*"*"Lokale Schnittstelle: *" *" *" *" *" *" *" IMPORTING VALUE(IP_START) TYPE VALUE(IP_DEST) TYPE EXPORTING REFERENCE(EP_CONN_LIST) TYPE EXCEPTIONS NO_CONN BC402_T_CONN S_FROM_CIT S_TO_CITY
*"---------------------------------------------------------------------ENDFUNCTION.
The (generated) source text of your second function module should now look something like this:
FUNCTION bc402_get_step_list_a. *"---------------------------------------------------------------------*"*"Lokale Schnittstelle: *" *" *" *" *" *" IMPORTING VALUE(I_NUMBER) TYPE EXPORTING REFERENCE(E_STEPLIST) TYPE EXCEPTIONS NOT_FOUND BC402_T_CONNSTEP INT4
*"---------------------------------------------------------------------ENDFUNCTION.
2005/Q4
© 2005 SAP AG. All rights reserved.
555
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Lesson Summary
You should now be able to: • Define function modules • Define interfaces of function modules • Define and raise exceptions for function modules • Test function modules
556
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Calling Function Modules
Lesson:
499
Calling Function Modules
Lesson Duration: 50 Minutes
Lesson Overview
In this lesson, you will learn how to implement function module calls in ABAP and handle exceptions.
Lesson Objectives
After completing this lesson, you will be able to: • • Implement function module calls in ABAP Implement exception handling in ABAP
The participants should generally be familiar with function module calls and exception handling. Accordingly, these sections are provided primarily for the sake of completeness. Worth mentioning, however, is the predefined exception ERROR_MESSAGE, which is not very well-known. The highlight of this lesson are the exercises, in which specific examples are used to illustrate how static, global data can be used for data encapsulation. They also demonstrate the use of nested tables and field symbols.
Business Example
Mr. Jones is a software developer at a major corporation that develops proprietary business applications in ABAP. He is asked to develop a flexible new application for flight bookings. One of the requirements is to develop as many reusable components as possible. Mr. Jones knows that function modules are reusable components, Now that he has written all the necessary function modules, he has to write the core application where these reusable modules are called.
Programming Function Module Calls
Function modules are called using the CALL FUNCTION ABAP statement. The name of the function module, , is specified as a literal (in upper case and enclosed in single quotes) or as a variable (dynamic call). This is followed by the declarations, in which each interface parameter is explicitly assigned an actual parameter.
2005/Q4
© 2005 SAP AG. All rights reserved.
557
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Figure 240: Programming Function Module Calls
The easiest way to program function module calls is to use the Pattern function. Alternatively, you can also display the function group in the navigation area and move the function module to the edit area with Drag&Drop. Both methods display a function module call with a complete list of all interface parameters. The optional parameters are inactive. Any existing default values are also displayed. If the function module uses non-class-based exceptions, their handling is also prepared. Hint: Starting in Release 6.40, you can also prepare the handling of class-based exceptions, but you may have to activate this function first in your Workbench settings. To display the settings, choose menu path Utilities → Settings → ABAP Editor → Pattern Assign correctly typed actual parameters to the interface parameters. To do so, you can display the types of the interface parameters in the Function Builder. The following applies to the list of interface parameters: Following the EXPORTING statement, values must be passed to all the non-optional import parameters of the function module. The optional parameters can also be supplied with data here.
558
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Calling Function Modules
Following the IMPORTING statement, appropriately typed actual parameters can accept the export parameters from the function module. Following the CHANGING and TABLES statements, all non-optional changing and tables parameters have to be assigned appropriately typed actual parameters.
Handling Exceptions
If a function module can raise exceptions, you should provide for appropriate handling. If an exception is raised but not handled, the program will terminate. The syntax of the exception handling depends on whether or not the function module uses class-based exceptions.
Non-Class-Based Exceptions
Figure 241: Handling Non-Class-Based Exceptions
To handle non-class-based exceptions, you have to list the exceptions in the function module call, following keyword EXCEPTIONS, and assign a positive integer value to each of them. You can assign the same value to several exceptions. If the function module raises an exception, system field sy-subrc is set to the assigned numeric value, and program execution continues immediately after the function module call. In addition to the exceptions that are defined explicitly in the function module interface, other predefined exceptions can also be listed:
2005/Q4
© 2005 SAP AG. All rights reserved.
559
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
OTHERS If you specify OTHERS after EXCEPTIONS, all the exceptions that are not listed explicitly are assigned a shared return code. ERROR_MESSAGE If you specify ERROR_MESSAGE after EXCEPTIONS, you can influence the handling of messages that are sent within the function module without the ... RAISING ... addition. They are handled as described below, depending on their type: • • • Messages with type S, I, and W are ignored (but recorded in the log in the case of background processing). Messages with type E and A terminate the function module, equivalent to raising exception ERROR_MESSAGE. There is no effect on messages with type X – that is, messages of this type always terminate the program.
Class-Based Exceptions
Figure 242: Handling Class-Based Exceptions
To handle class-based exceptions, the function module call has to be located between the TRY. and ENDTRY. statements. You can handle an exception after the CATCH statement, which must appear after the function module call, but still within the TRY block.
560
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Calling Function Modules
If the function module raises the exception, the program flow is continued immediately after the corresponding CATCH statement. If you want to access the instance of the exception class – for example, to read the message texts contained within it – you have to declare a suitable variable and add the optional ... INTO addition to the CATCH statement.
2005/Q4
© 2005 SAP AG. All rights reserved.
561
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
562
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Calling Function Modules
505
Exercise 27: Implementing and Calling Function Modules
Exercise Duration: 25 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Implement function modules • Call function modules • Test function modules
Business Example
Now that you have created the function modules and defined the interfaces, you implement the module that determines the list of flights.
System Data
System: Client: User ID: Password: Set up instructions: Will be assigned Will be assigned Will be assigned Will be assigned No special settings required in the standard training system
Task 1:
Preparation 1. 2. If you do not have a function group called ZBC402_##_CONN yet, make a copy of function group BC402_FMDS_CONN_A and call it ZBC402_##_CONN. If you do not have a function module called Z_BC402_##_GET_CONN_LIST yet, make a copy of function module BC402_GET_CONN_LIST_A in your function group and call it Z_BC402_##_GET_CONN_LIST.
Task 2:
Implement function module Z_BC402_##_GET_CONN_LIST. 1. Program a call of function module BC402_FMDD_CONNECTION_LIST. To do so, declare an internal table with an appropriate type to receive export parameter EP_CONNECTION_LIST. Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
563
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
2. 3.
If the function module does not find any flights, raise an exception. Now process the result of the function module call in a loop. Use this loop to fill the export parameter of your own function module. Note that we highly recommend using field symbols in nested internal tables. Test your function module.
4.
564
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Calling Function Modules
Solution 27: Implementing and Calling Function Modules
Task 1:
Preparation 1. If you do not have a function group called ZBC402_##_CONN yet, make a copy of function group BC402_FMDS_CONN_A and call it ZBC402_##_CONN. a) 2. Display the object list for function group BC402_FMDS_CONN_A in the navigation area and then choose Copy... in the context menu.
If you do not have a function module called Z_BC402_##_GET_CONN_LIST yet, make a copy of function module BC402_GET_CONN_LIST_A in your function group and call it Z_BC402_##_GET_CONN_LIST. a) Carry out this step as usual.
Task 2:
Implement function module Z_BC402_##_GET_CONN_LIST. 1. Program a call of function module BC402_FMDD_CONNECTION_LIST. To do so, declare an internal table with an appropriate type to receive export parameter EP_CONNECTION_LIST. a) Declare an internal table with table type BC402_T_CONNECTION. At the present time, it will be sufficient to create the internal table locally in your function module. In the next exercise, however, we will create the internal table globally in the function group. b) 2. 3. See source text excerpt from model solution. Implement the call with the Pattern function or with Drag&Drop. See source text excerpt from model solution.
If the function module does not find any flights, raise an exception. a) Now process the result of the function module call in a loop. Use this loop to fill the export parameter of your own function module. Note that we highly recommend using field symbols in nested internal tables. a) See source text excerpt from model solution.
4.
Test your function module. Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
565
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
a)
Perform this step as described in the course materials.
Result
Source text excerpt: Function module BC402_GET_CONN_LIST_B
FUNCTION bc402_get_conn_list_b. *"---------------------------------------------------------------------*"*"Lokale Schnittstelle: *" *" *" *" *" *" *" DATA DATA IMPORTING VALUE(IP_START) TYPE VALUE(IP_DEST) TYPE EXPORTING REFERENCE(EP_CONN_LIST) TYPE EXCEPTIONS NO_CONN wa_conn lt_connection_list LIKE LINE OF ep_conn_list. TYPE bc402_t_connection. TYPE bc402_s_connection. BC402_T_CONN S_FROM_CIT S_TO_CITY
*"----------------------------------------------------------------------
FIELD-SYMBOLS
* call function module and store result in global data TRY. CALL FUNCTION ’BC402_FMDD_CONNECTION_LIST’ EXPORTING ip_start ip_dest IMPORTING ep_connection_list = lt_connection_list. = ip_start = ip_dest
* anything found by function module? CATCH cx_bc402_no_connection. * raise exception MESSAGE e171(bc402) RAISING no_conn. ENDTRY.
* copy result to output LOOP AT lt_connection_list ASSIGNING . MOVE-CORRESPONDING TO wa_conn. APPEND wa_conn TO ep_conn_list. ENDLOOP.
Continued on next page
566
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Calling Function Modules
ENDFUNCTION.
2005/Q4
© 2005 SAP AG. All rights reserved.
567
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
568
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Calling Function Modules
509
Exercise 28: Using Global Data of a Function Group
Exercise Duration: 20 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Use global data objects of a function group to buffer data • Understand the runtime behavior of a function group • Test sequences of function modules
Business Example
When function module Z_BC402_##_GET_STEP_LIST is called, you want to return a table of stopovers for a specific flight. To avoid having to call function module BC402_FMDD_CONNECTION_LIST again, you save the result of a function module Z_BC402_##_GET_CONN_LIST in a global data object. You then access this buffered data in function module Z_BC402_##_GET_STEP_LIST.
System Data
System: Client: User ID: Password: Set up instructions: Will be assigned Will be assigned Will be assigned Will be assigned No special settings required in the standard training system
Task 1:
Preparation 1. 2. If you do not have a function group called ZBC402_##_CONN yet, make a copy of function group BC402_FMDS_CONN_B and call it ZBC402_##_CONN. If you do not have a function module called Z_BC402_##_GET_STEP_LIST yet, make a copy of function module BC402_GET_STEP_LIST_B in your function group and call it Z_BC402_##_GET_STEP_LIST. If you do not have a function module called Z_BC402_##_GET_CONN_LIST yet, make a copy of function module BC402_GET_CONN_LIST_B in your function group and call it Z_BC402_##_GET_CONN_LIST. Continued on next page
3.
2005/Q4
© 2005 SAP AG. All rights reserved.
569
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Task 2:
Save the results in the global data of the function group. 1. 2. In the global data of the function group, create an internal table with table type BC402_T_CONNECTION. Make sure the global internal table is filled in function module Z_BC402_##_GET_CONN_LIST. Ensure that the table contents are deleted if the module raises an exception.
Task 3:
Implement function module Z_BC402_##_GET_STEP_LIST. 1. 2. Read the requested flight from the global table. If the requested line is not found, raise an exception. Fill the export parameter of the function module.
Task 4: (Optional)
Enhance the function module with an additional exception that is raised if the global data is not filled. 1. Add an additional exception to the interface. At the start of the function module, check whether the global table contains at least one line.
Task 5:
Use the “Test Sequence” function to test the function modules. 1. Use the “Test Sequence” function to test function module Z_BC402_##_GET_STEP_LIST. Test a sequence consisting of a call of function module Z_BC402_##_GET_CONN_LIST and one (or more) call of function module Z_BC402_##_GET_STEP_LIST.
570
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Calling Function Modules
Solution 28: Using Global Data of a Function Group
Task 1:
Preparation 1. If you do not have a function group called ZBC402_##_CONN yet, make a copy of function group BC402_FMDS_CONN_B and call it ZBC402_##_CONN. a) 2. Carry out this step as usual. If you do not have a function module called Z_BC402_##_GET_STEP_LIST yet, make a copy of function module BC402_GET_STEP_LIST_B in your function group and call it Z_BC402_##_GET_STEP_LIST. a) 3. Carry out this step as usual. If you do not have a function module called Z_BC402_##_GET_CONN_LIST yet, make a copy of function module BC402_GET_CONN_LIST_B in your function group and call it Z_BC402_##_GET_CONN_LIST. a) Carry out this step as usual.
Task 2:
Save the results in the global data of the function group. 1. In the global data of the function group, create an internal table with table type BC402_T_CONNECTION. a) See source text excerpt from model solution. To access the global data from the Function Builder, choose menu path Goto → Global Data. Alternatively, you can also edit the top include. 2. Make sure the global internal table is filled in function module Z_BC402_##_GET_CONN_LIST. Ensure that the table contents are deleted if the module raises an exception. a) See source text excerpt from model solution.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
571
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Task 3:
Implement function module Z_BC402_##_GET_STEP_LIST. 1. Read the requested flight from the global table. If the requested line is not found, raise an exception. a) 2. a) See source text excerpt from model solution. See source text excerpt from model solution. Fill the export parameter of the function module.
Task 4: (Optional)
Enhance the function module with an additional exception that is raised if the global data is not filled. 1. Add an additional exception to the interface. At the start of the function module, check whether the global table contains at least one line. a) See source text excerpt from model solution.
Task 5:
Use the “Test Sequence” function to test the function modules. 1. Use the “Test Sequence” function to test function module Z_BC402_##_GET_STEP_LIST. Test a sequence consisting of a call of function module Z_BC402_##_GET_CONN_LIST and one (or more) call of function module Z_BC402_##_GET_STEP_LIST. a) To start the “Test Sequence” function, proceed as described in the course materials. Enter the names of the function modules that you want to test in the sequence. Each function module will then be tested as usual.
Result
Source text excerpt: LBC402_FMDS_CONN_CTOP
FUNCTION-POOL bc402_fmds_conn_b MESSAGE-ID bc402. DATA: gt_connection_list TYPE bc402_t_connection.
Source text excerpt: Function module BC402_GET_CONN_LIST_C Continued on next page
572
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Calling Function Modules
FUNCTION bc402_get_conn_list_c. *"---------------------------------------------------------------------*"*"Lokale Schnittstelle: *" *" *" *" *" *" *" DATA DATA IMPORTING VALUE(IP_START) TYPE VALUE(IP_DEST) TYPE EXPORTING REFERENCE(EP_CONN_LIST) TYPE EXCEPTIONS NO_CONN wa_conn lt_connection_list LIKE LINE OF ep_conn_list. TYPE bc402_t_connection. TYPE bc402_s_connection. BC402_T_CONN S_FROM_CIT S_TO_CITY
*"----------------------------------------------------------------------
FIELD-SYMBOLS
TRY. CALL FUNCTION ’BC402_FMDD_CONNECTION_LIST’ EXPORTING ip_start ip_dest IMPORTING EP_CONNECTION_LIST . * anything found by function module? CATCH cx_bc402_no_connection. CLEAR gt_connection_list. * raise exception MESSAGE e171(bc402) RAISING no_conn. ENDTRY. = lt_connection_list = ip_start = ip_dest
* copy result to output LOOP AT lt_connection_list ASSIGNING . MOVE-CORRESPONDING TO wa_conn. APPEND wa_conn TO ep_conn_list. ENDLOOP.
* copy result to global data gt_connection_list = lt_connection_list.
ENDFUNCTION.
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
573
Unit 13: Creating and Calling Function Groups and Function Modules
TAW10_1
Source text excerpt: Function module BC402_GET_STEP_LIST_C
FUNCTION bc402_get_step_list_c. *"-------------------------------------------------------------------*"*"Lokale Schnittstelle: *" *" *" *" *" *" *" IMPORTING REFERENCE(I_NUMBER) TYPE EXPORTING REFERENCE(E_STEPLIST) TYPE EXCEPTIONS NOT_FOUND NO_DATA BC402_T_CONNSTEP INT4
*"--------------------------------------------------------------------
FIELD-SYMBOLS LIKE LINE OF gt_connection_list.
* anything stored global data? IF LINES( gt_connection_list ) = 0. MESSAGE e173(bc402) RAISING no_data. ENDIF.
READ TABLE gt_connection_list ASSIGNING INDEX i_number.
IF sy-subrc 0. MESSAGE e172(bc402) RAISING not_found. ELSE. e_steplist = -steplist. ENDIF.
ENDFUNCTION.
574
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Calling Function Modules
Lesson Summary
You should now be able to: • Implement function module calls in ABAP • Implement exception handling in ABAP
2005/Q4
© 2005 SAP AG. All rights reserved.
575
Unit Summary
TAW10_1
Unit Summary
You should now be able to: • Define function groups • Explain the structure of a function group • Define function modules • Define interfaces of function modules • Define and raise exceptions for function modules • Test function modules • Implement function module calls in ABAP • Implement exception handling in ABAP
576
© 2005 SAP AG. All rights reserved.
2005/Q4
Unit 14
517
Programs Calls and Data Storage Management
For more information, see the introductory instructor notes in the lesson.
Unit Overview
In only very rare cases do applications comprise a single program. What happens when program A calls an additional program? How is the additional program called and are there differences between various program types? These questions should have been answered previously.
Unit Objectives
After completing this unit, you will be able to: • • • Explain how programs are called from within other programs Describe the various options for exchanging data between programs Explain how memory is managed in the ABAP virtual machine
Unit Contents
Lesson: Program Calls and Memory Management ............................ 578 Exercise 29: ABAP Memory .................................................. 599
2005/Q4
© 2005 SAP AG. All rights reserved.
577
Unit 14: Programs Calls and Data Storage Management
TAW10_1
Lesson:
518
Program Calls and Memory Management
Lesson Duration: 40 Minutes
Lesson Overview
In this lesson, we will list the options for calling programs. We also want to examine the possibilities that ABAP features for exchanging data between programs.
Lesson Objectives
After completing this lesson, you will be able to: • • • Explain how programs are called from within other programs Describe the various options for exchanging data between programs Explain how memory is managed in the ABAP virtual machine
Complex ABAP applications only rarely consist of just one program. In most cases, several different programs are called, which exchange data with one another. It is important to understand how memory is managed in ABAP programs, in order to ensure a proper application flow: How are sessions opened? How and when are they closed? And so on... It is also important to know about the options for passing data between these program units. This lesson is dedicated to ABAP memory and SAP memory; cross-user storage methods are discussed in another lesson.
Business Example
Mr. Jones is a software developer at a major corporation that develops proprietary business applications in ABAP. He is asked to develop a flexible new application for flight bookings. To modularize his application as much as possible, Mr. Jones writes more than one ABAP program. As a result, some programs have to be called from within other programs. Once Mr. Jones has learned how programs can be called from within other ABAP programs, he can use these program calls efficiently and implement the data transfer between the programs correctly.
Synchronous Program Calls
ABAP features two options for executing a program from within another program: the SUBMIT and CALL TRANSACTION (or LEAVE TO TRANSACTION) statements. The statements can differ in their effects: In one case, the calling program ends as soon as the called program is started. In another case, the calling program waits until
578
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
the called program is finished, and execution of the calling program continues with the statement after the program call. We therefore differentiate between the following terms: Insert The process flow of the calling program pauses while the called program is being executed. After the called program is complete, the calling program is continued. New start The calling program is terminated and the called program is started.
Figure 243: Synchronous Program Calls
Within a single user session complete programs can run only sequentially. This technique is also referred to as sequential calls. If you want to run activities in parallel, you have to use function modules. Note: More information about this technique is available in other training courses and in the ABAP keyword documentation for the CALL FUNCTION ... STARTING NEW TASK ... statement.
2005/Q4
© 2005 SAP AG. All rights reserved.
579
Unit 14: Programs Calls and Data Storage Management
TAW10_1
Figure 244: Calling an Executable Program
To start an executable (type 1) program, use the SUBMIT statement. If you use the VIA SELECTION-SCREEN addition, the standard selection screen of the called program (if any) is displayed. If you use the AND RETURN addition, the system resumes processing with the first statement of the calling program after the SUBMIT statement once the called program has finished. Note: For further information, refer to the ABAP keyword documentation for the SUBMIT statement.
580
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
Figure 245: Calling a Transaction
If you use the LEAVE TO TRANSACTION ’T_CODE’ statement, the system terminates the current program and starts the transaction with transaction code T_CODE. The statement is the equivalent of entering /NT_CODE in the command field. The CALL TRANSACTION ’T_CODE’ statement allows you to insert a program with a transaction code into the call chain. You can use the LEAVE PROGRAM statement to force the termination a program. If the statement occurs in a program that you called using CALL TRANSACTION ’T_CODE’ or SUBMIT prog_name AND RETURN, the system resumes processing at the next statement after the call in the calling program. In all other cases, the user returns to the application menu from which he or she started the program. If you use the ... AND SKIP FIRST SCREEN addition, the system does not display the contents of the first screen in the transaction. Caution: However, it does process the flow logic.
2005/Q4
© 2005 SAP AG. All rights reserved.
581
Unit 14: Programs Calls and Data Storage Management
TAW10_1
If you started a transaction using CALL TRANSACTION ’T_CODE’ and that transaction uses update techniques, you can use the UPDATE ... addition to specify the update technique – asynchronous (default), synchronous, or local – that the program should use. Note: For more information, refer to training course BC414 (Programming Database Updates) and the SAP Library.
Memory Management
The way in which main memory is organized from the program’s point of view can be represented in the following simple model:
Figure 246: Logical Memory Model
There is a distinction between internal and external sessions: • Generally, an external session corresponds to an SAPGUI window. You can create a new session with System → New Session or by calling /OT_CODE. You can have up to six external sessions open simultaneously in one user session. External sessions are subdivided into internal sessions (placed in a stack). Each program that is started occupies its own internal session. Each external session can contain up to nine internal sessions.
•
Data for a program is visible only within an internal session. In general, data visibility is restricted to the relevant program.
582
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
How Internal Sessions Respond to Program Calls
This section illustrates how the stack inside an external session changes with various program calls. The starting point for the first case is the execution of a SUBMIT ... AND RETURN or CALL TRANSACTION statement within a program:
Inserting a Program
Figure 247: Before Inserting a Program
When you insert a program, the system creates a new internal session, which contains the new program context. The new session is placed in the stack. The program context of the calling program remains in the stack.
2005/Q4
© 2005 SAP AG. All rights reserved.
583
Unit 14: Programs Calls and Data Storage Management
TAW10_1
Figure 248: The Inserted Program Runs
When the called program finishes, its internal session (the top one in the stack) is deleted. Processing is resumed in the next-lowest internal session in the stack.
Figure 249: After the Inserted Program Ends
584
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
Starting a New Executable Program
When you end a program and start a new one, there is a difference between calling an executable program and calling a transaction. The starting point for the second case is the execution of a SUBMIT statement within a program:
Figure 250: Before Starting a New Executable Program
If you call an executable program using its program name (and end the calling program), the system destroys the internal session of the program that you are terminating (the top one from the stack). The system creates a new internal session, which contains the program context of the called program. The new session is placed in the stack. Any program contexts that that have been created before are retained. Therefore, the topmost internal session in the stack is ultimately replaced.
2005/Q4
© 2005 SAP AG. All rights reserved.
585
Unit 14: Programs Calls and Data Storage Management
TAW10_1
Figure 251: The New Executable Program Runs
Starting a New Transaction
The starting point for the third case is the execution of a LEAVE TO TRANSACTION statement within a program:
Figure 252: Before Starting a New Transaction
586
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
If you start a program using its transaction code, all of the internal sessions in the stack are destroyed. The system creates a new internal session, which contains the program context of the called program.
Figure 253: The New Transaction Runs
This means the complete stack of internal sessions is initialized, which also means the ABAP memory is initialized after the call.
Program Groups
In a previous lesson, we discussed the visibility of data definitions in an ABAP program. We saw that we can differentiate between global and local variables. In this section, we will investigate how the system acts when one program calls a subroutine of a second program. By the end of this section, the participants should be aware of the hazards of external subroutine calls. Use program SAPBC402_PGCAD_CALLER to demonstrate program groups. This program makes two subroutine calls and sends one screen in each subroutine. The first called program, SAPBC402_PGCAD_CALLED_TYPE_1 sends screen 100 of the calling program(!), and the data is represented correctly. Although the second called program (SAPBC402_PGCAD_CALLED_TYPE_F) is also a type 1 program, the introductory statement is “FUNCTION-POOL” – which actually causes a new
2005/Q4
© 2005 SAP AG. All rights reserved.
587
Unit 14: Programs Calls and Data Storage Management
TAW10_1
program group (“additional program group”) to be opened within the internal session. The called screen is actually the one from the called program; however, no data is displayed, because the TABLES structure is only visible within a program group. Debug the program call. In the conventional debugger, you can display all the programs that are loaded into the active internal session with menu path Goto –> Status Display –> Loaded Programs. The In Group with... column indicates the program group to which each program belongs. You can see that the first called program is loaded in a group with the calling program, but the second program opens a new program group (no entry in the In Group with... column). Therefore, function module calls provide a way to cleanly separate program groups (similar to classes).
Figure 254: Program Groups Within an Internal Session
When the system starts an internal session, it always creates the main program group. Any number of additional program groups can also be created in the same internal session. Each program group has exactly one main program. When an (external) subroutine is called, the main program of this subroutine is loaded into the program group of the calling program.
588
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
Developers have to watch out for two things: • • All the programs in a program group share the interface work areas that are declared with TABLES, NODES, and COMMON PART. Within a program group, CALL SCREEN can only be used to call screens of the main program.
Figure 255: Main/Additional Program Groups
When a function module (CALL FUNCTION) from a function group that has not been loaded yet or a method (CALL METHOD) from a class definition that has not been loaded yet is called, an additional program group is created. Caution: Strictly speaking, the program type (which you can define in the program attributes) is not the decisive factor in whether an external subroutine call opens a new program group. The statement that starts the program is the decisive factor. (If a type 1 program is started with the FUNCTION-POOL statement, an additional program group is opened anyway, as you can see in the Debugger.) In general, when you use external subroutine calls, you always run the risk that data definitions from one program will be shared with other programs. While this may be intended in some exceptional cases, you should avoid it wherever possible under the aspects of encapsulation and ease of maintenance.
2005/Q4
© 2005 SAP AG. All rights reserved.
589
Unit 14: Programs Calls and Data Storage Management
TAW10_1
Transferring Data
Following the discussion about how to start programs from within other programs in the previous section, we will now examine how data can be exchanged between programs. There are several different ways to pass data between programs that are running in separate program contexts (internal sessions). Of these methods, however, we will only introduce the ones that are platform-independent and only exchange data transiently.
Overview of Data Transfer Options
Figure 256: Passing Data Between Programs: Overview
You can use the following techniques (among others) for passing data: • • • • • The interface of the called program (usually a standard selection screen) ABAP memory SAP memory Database tables Local files on the presentation server
590
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
We will only discuss the first three techniques in this section, because they are the only ones that fulfill our transience requirement. For further information about passing data using database tables or the shared buffer, refer to the ABAP keyword documentation for the EXPORT and IMPORT statements. For further information about transferring data between an ABAP program and your presentation server, refer to the documentation of function modules GUI_UPLOAD and GUI_DOWNLOAD. You can also use the methods of class CL_GUI_FRONTEND_SERVICES for this purpose.
Passing Data Using the Program Interface
Figure 257: Passing Data Using the Program Interface
When you call ABAP programs that have a standard selection screen, you can pass data for the input fields in the call. There are two ways to do this: • • By specifying a variant for the selection screen when you call the program By specifying specific values for the input fields when you call the program
2005/Q4
© 2005 SAP AG. All rights reserved.
591
Unit 14: Programs Calls and Data Storage Management
TAW10_1
Figure 258: Preassignment of Input Fields
The WITH addition in the SUBMIT statement allows you to assign values to the fields on a standard selection screen. The relational operators EQ, NE, ... and the inclusion operators I and E have the same meanings as with select options. If you want to set several selections for a selection option, you can also use the RANGE type instead of individual WITH additions. This creates a selection table that you can fill as though it were a selection option. You then pass the whole table to the executable program. If you want to display the standard selection screen when you call the program, use the VIA SELECTION-SCREEN addition. When you use the SUBMIT statement, use the Pattern function in the ABAP Editor to insert an appropriate statement pattern for the program you want to call. The pattern automatically supplies the names of the parameters and selection options that are available on the standard selection screen. Hint: For further information about working with variants and about other syntax variants of the WITH addition, refer to the ABAP keyword documentation for the SUBMIT statement.
592
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
Passing Data with an Internal Table when Starting a Transaction
Figure 259: Passing Data Using an Internal Table
When you call a transaction using the CALL TRANSACTION ’T_CODE’ USING bi_itab statement, you can run the transaction T_CODE using the values from internal table bi_itab in the screen fields. This internal table has to have the structure BDCDATA and be filled accordingly. The MODE addition allows you to specify whether the screen contents should all be displayed (A – default setting), only when an error occurs (E), or not at all (N). You can use the MESSAGES INTO addition to specify an internal table into which any system messages should be written. The corresponding internal table has to have the line type of global structure BDCMSGCOLL. You can find out if the transaction was executed successfully from the return code(SY-SUBRC). This technique can be useful if: • • You are processing in dialog, but the input fields have not been filled using GET parameters You want to process the transaction in the background. In this case, you normally have to pass the function codes in the table as well.
2005/Q4
© 2005 SAP AG. All rights reserved.
593
Unit 14: Programs Calls and Data Storage Management
TAW10_1
Figure 260: Fields in the Global Type BDCDATA
Filling the internal table in batch input format: • Each screen that you want to fill and process automatically in the transaction must be identified by a line in which only the PROGRAM, DYNPRO, and DYNBEGIN fields are filled. After the record that identifies the screen, use a new BDCDATA record for each field you want to fill. These records use the FNAM and FVAL fields. You can fill the following fields: – – – Input/output fields (with data) The command field BDC_OKCODE (with a function code) The field for cursor positioning BDC_CURSOR (with a field name)
•
This technique is also one of the possible ways of transferring data from non-SAP systems. When you do this, the internal table with the structure BDCDATA must be filled completely. For more information, refer to training course BC420 (Data Transfer) and the SAP Library.
594
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
Figure 261: Passing Data Using an Internal Table: Applied Example
The above example shows the example transaction BC402_CALD_CTA_U from package BC402. When the user creates a new customer entry, the program calls transaction BC402_CALD_CRE_CUST. This transaction has not implemented import from ABAP memory and its input fields are not set as GET parameters. The customer data is, therefore, passed using an internal table and processed “invisibly”. If the operation is successful, the new customer record can be entered in the waiting list. The filled internal table in BDCDATA format is illustrated above. At runtime, CURRENT_NAME stands for the customer name from the input field and CURRENT_CITY stands for the city. You address the command field using BDC_OKCODE. You use the BDC_OKCODE field to address the command field, into which you enter the function code that would have been triggered by the user choosing a function key, pushbutton, or menu entry in dialog mode (or by entering a code directly in the command field).
ABAP Memory and SAP Memory
It is often necessary to transfer data between two different programs. However, it is not always possible to specify this data as an addition in the program call. In such cases, you can use the SAP memory and the ABAP memory to transfer data between programs:
2005/Q4
© 2005 SAP AG. All rights reserved.
595
Unit 14: Programs Calls and Data Storage Management
TAW10_1
Figure 262: Range of ABAP Memory and SAP Memory
•
SAP memory is a user-specific memory area for storing field values. It is therefore not that useful for passing data between internal sessions. Values in SAP memory are retained for the duration of the user session. SAP memory can be used between external sessions in the same user session. All external sessions of a user session can access SAP memory. You can use the contents of SAP memory as default values for screen fields.
•
ABAP memory is also user-specific. There is a local ABAP memory for each external session. You can use it to exchange any ABAP data objects (fields, structures, internal tables, complex objects) between the internal sessions in the same external session. When the user exits an external session (/i in the command field), the corresponding ABAP memory is automatically initialized or released.
ABAP Memory
The EXPORT ... TO MEMORY statement copies any number of ABAP data objects with their current values to a data cluster in the ABAP memory. The ID addition (maximum 60 characters long) enables you to identify different clusters.
596
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
Figure 263: Passing Data Using the ABAP Memory
If you use a new EXPORT TO MEMORY statement for an existing data cluster, the new one overwrites the old one. The IMPORT ... FROM MEMORY ID ... statement allows you to copy data from ABAP memory into the corresponding fields of your ABAP program. You can also restrict the selection to a part of the data cluster in the IMPORT statement. The variables into which you want to read data from the cluster in ABAP memory must have the same types in both the exporting and the importing programs. You use the FREE MEMORY ID ... statement to release a data cluster explicitly. Caution: When you call programs using transaction codes, you can only use the ABAP memory to pass data to the transaction in the insert case (CALL TRANSACTION) .
2005/Q4
© 2005 SAP AG. All rights reserved.
597
Unit 14: Programs Calls and Data Storage Management
TAW10_1
SAP Memory
Figure 264: Passing Parameters Using SAP Memory
You can define memory areas (parameters) in SAP memory in various ways: • By creating input/output fields with reference to the ABAP Dictionary. These take the parameter names from the data elements to which they refer. Alternatively, you can enter a name in the attributes of the input/output fields. Then, you can also choose whether the entries from the field should be transferred to the parameter (SET), or whether the input field should be filled with the value from the parameter (GET). To find out about the names of the parameters assigned to input fields, display the field help for the field with the (F1) key and choose Technical info. • You can also fill the memory areas directly with the SET PARAMETER ID ’PAR_ID’ FIELD var. statement and read from them with the GET PARAMETER ID ’PAR_ID’ FIELD var. statement. Finally, you can define parameters in the Object Navigator and the user can specify user specific default values.
•
598
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
539
Exercise 29: ABAP Memory
Exercise Duration: 30 Minutes
Exercise Objectives
After completing this exercise, you will be able to: • Use SUBMIT to call a program (report) • Use the ABAP memory to exchange data between programs
Business Example
An existing program selects data based on user entries and outputs it in a list. You want to call this program from within another program, and use the ABAP memory to pass the selected data back to the calling application.
System Data
System: Client: User ID: Password: Set up instructions: Will be assigned Will be assigned Will be assigned Will be assigned No special settings required in the standard training system
Task 1:
Preparation 1. Copy program ZBC402_##_BOOKINGS from the exercise in the “ABAP Runtime” lesson, or copy the model solution SAPBC402_RUNS_BOOKINGS. Name the copied program ZBC402_##_SUBMIT_CALLED.
Task 2:
Modify the program 1. 2. Deactivate the program lines that are used to output the data. Instead, store the selected data in an internal table. Enhance the program such that the internal table is exported to the ABAP memory after a successful data selection. To do so, assign a suitable ID for your data cluster (suggested name: BC402_##_SBOOK). Make sure the data cluster is released if no data is read. Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
599
Unit 14: Programs Calls and Data Storage Management
TAW10_1
Task 3:
Call the program 1. 2. Create a new executable program with name ZBC402_##_SUBMIT_CALLER. Implement a call of your program, ZBC402_##_SUBMIT_CALLED. Make sure the program is inserted – that is, after it ends, control should return to the calling program. Supply the selection screen of the calling program with the following values: Customer number "0033". Flight bookings within the last 180 days. Hint: Use suitable elementary data objects for the interval of booking data, which you fill beforehand dependent on the current date (system field SY-DATUM). 4. After the inserted program is executed, import the data from the ABAP memory and output it. If an error occurs, respond with error message 361 from message class BC402.
3.
600
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
Solution 29: ABAP Memory
Task 1:
Preparation 1. Copy program ZBC402_##_BOOKINGS from the exercise in the “ABAP Runtime” lesson, or copy the model solution SAPBC402_RUNS_BOOKINGS. Name the copied program ZBC402_##_SUBMIT_CALLED. a) Proceed as usual.
Task 2:
Modify the program 1. Deactivate the program lines that are used to output the data. Instead, store the selected data in an internal table. a) 2. See source text excerpt from the model solution. Enhance the program such that the internal table is exported to the ABAP memory after a successful data selection. To do so, assign a suitable ID for your data cluster (suggested name: BC402_##_SBOOK). Make sure the data cluster is released if no data is read. a) See source text excerpt from the model solution.
Task 3:
Call the program 1. 2. Create a new executable program with name ZBC402_##_SUBMIT_CALLER. a) Proceed as usual. Implement a call of your program, ZBC402_##_SUBMIT_CALLED. Make sure the program is inserted – that is, after it ends, control should return to the calling program. a) 3. Implement a SUBMIT statement. Use the AND RETURN addition. See source text excerpt from the model solution. Supply the selection screen of the calling program with the following values: Customer number "0033". Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
601
Unit 14: Programs Calls and Data Storage Management
TAW10_1
Flight bookings within the last 180 days. Hint: Use suitable elementary data objects for the interval of booking data, which you fill beforehand dependent on the current date (system field SY-DATUM). a) 4. See source text excerpt from the model solution.
After the inserted program is executed, import the data from the ABAP memory and output it. If an error occurs, respond with error message 361 from message class BC402. a) See source text excerpt from the model solution.
Result
Source Text Excerpt: MIT_CALLED
REPORT sapbc402_pgcs_submit_called.
SAPBC402_PGCS_SUB-
*----------------------------------------------------------------------* TYPES: ty_t_sbook TYPE STANDARD TABLE OF sbook WITH NON-UNIQUE DEFAULT KEY. *----------------------------------------------------------------------* DATA: gt_sbook wa_sbook PARAMETERS: pa_cust TYPE sbook-customid. SELECT-OPTIONS: so_odate FOR wa_sbook-order_date. *----------------------------------------------------------------------* START-OF-SELECTION. TYPE ty_t_sbook, LIKE LINE OF gt_sbook.
*----------------------------------------------------------------------*
SELECT * FROM sbook INTO TABLE gt_sbook
Continued on next page
602
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
WHERE customid AND
=
pa_cust
order_date IN so_odate.
IF sy-subrc 0. MESSAGE s038(bc402). * Zu dieser Selektion existieren keine Daten (Bitte Neueingabe)
FREE MEMORY ID ’BC402_SBOOK’. * ENDIF.
*----------------------------------------------------------------------* *END-OF-SELECTION.
* * * * * * * * * * * *
LOOP AT gt_sbook INTO wa_sbook.
WRITE: / wa_sbook-carrid, wa_sbook-connid, wa_sbook-fldate, wa_sbook-bookid, wa_sbook-customid, wa_sbook-luggweight, wa_sbook-wunit.
ENDLOOP.
ELSE. EXPORT it_sbook FROM gt_sbook TO ENDIF. MEMORY ID ’BC402_SBOOK’.
Source Text Excerpt: MIT_CALLER
REPORT sapbc402_pgcs_submit_caller.
SAPBC402_PGCS_SUB-
*----------------------------------------------------------------------* TYPES: ty_t_sbook TYPE STANDARD TABLE OF sbook WITH NON-UNIQUE DEFAULT KEY. *----------------------------------------------------------------------* DATA:
Continued on next page
2005/Q4
© 2005 SAP AG. All rights reserved.
603
Unit 14: Programs Calls and Data Storage Management
TAW10_1
it_sbook wa_sbook
TYPE ty_t_sbook, LIKE LINE OF it_sbook,
fromdate todate
TYPE sbook-order_date, TYPE sbook-order_date.
*----------------------------------------------------------------------* START-OF-SELECTION.
fromdate = sy-datum - 180. todate = sy-datum.
SUBMIT sapbc402_pgcs_submit_called AND RETURN WITH pa_cust EQ ’0033’ WITH so_odate BETWEEN fromdate AND todate.
IMPORT it_sbook TO it_sbook FROM MEMORY ID ’BC402_SBOOK’.
*----------------------------------------------------------------------* IF sy-subrc 0. MESSAGE e361(bc402). ELSE. *----------------------------------------------------------------------* LOOP AT it_sbook INTO wa_sbook.
WRITE: / wa_sbook-carrid, wa_sbook-connid, wa_sbook-fldate, wa_sbook-bookid, wa_sbook-customid, wa_sbook-luggweight, wa_sbook-wunit.
ENDLOOP.
ENDIF.
604
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Lesson: Program Calls and Memory Management
Facilitated Discussion
Reinforcement
Discussion Questions
Use the following questions to engage the participants in the discussion. Feel free to use your own additional questions. Which options are available for passing data between programs?
2005/Q4
© 2005 SAP AG. All rights reserved.
605
Unit 14: Programs Calls and Data Storage Management
TAW10_1
Lesson Summary
You should now be able to: • Explain how programs are called from within other programs • Describe the various options for exchanging data between programs • Explain how memory is managed in the ABAP virtual machine
606
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Unit Summary
Unit Summary
You should now be able to: • Explain how programs are called from within other programs • Describe the various options for exchanging data between programs • Explain how memory is managed in the ABAP virtual machine
2005/Q4
© 2005 SAP AG. All rights reserved.
607
Course Summary
TAW10_1
Course Summary
You should now be able to: • • • • • • • • Describe the data structure of SAP systems Use the ABAP Workbench tools Create lists using classic reports Create and call function groups and function modules Work with the ABAP Dictionary Program in a performance-sensitive manner Describe the concepts behind object-oriented programming Create lists using ALV Grid Control
608
© 2005 SAP AG. All rights reserved.
2005/Q4
Glossary
ABAP interpreter Work process component that executes the processing logic of an ABAP program and communicates with the database interface. ALE Application Link Enabling: a means of creating and operating distributed applications. BAPI A Business Application Programming Interface is a standardized programming interface that facilitates internal and external access to business processes and data in SAP systems. BOR The Business Object Repository gives you an overview of the business objects in an SAP system, and functions for managing them. Buffer Area in the main memory of an instance that can be used for temporary storage of data frequently used by the applications. Central system A central SAP system consists of a single instance, which provides all necessary SAP services, and the accompanying database. Both the instance and the database will normally be hosted on the same computer. Client A client usually represents a company in an SAP system. This means that if an SAP system has several clients, then several companies can be represented and simultaneously active in that system. The client has a corresponding key field in the tables of the database for that SAP system. If you are logged on to a specific client, then you can only access data for that client. Clients therefore correspond to independent business entities. Software component that uses the services provided by a server (software-oriented view) or work station for which the server provides resources (hardware-oriented view). Command field You can start applications directly by entering the transaction code in the command field.
2005/Q4
© 2005 SAP AG. All rights reserved.
609
Glossary
TAW10_1
CPI-C Common Program Interface Communication describes the exchange of data between different programs. Data “packed” in CPI-C can be transferred using various technical protocols, such as TCP/IP or LU6.2. database interface Component of a work process that connects it to the database. The database interface translates Open SQL into database-specific SQL, thereby enabling communication with the database. DIAG Dynamic Information and Action Gateway: Protocol for communication between SAP GUI and the application server (also known as the SAP GUI protocol). Dispatcher Central process on an instance. It is responsible, among other things, for starting work processes and distributing the transaction load across work processes. EDI Electronic Data Interchange. The electronic exchange of structured data, such as business documents, between domestic and international companies using a variety of hardware, software and communication services. For this purpose, the data involved is formatted according to predefined standards. You can configure EDI using ALE. F1 Help You can use the F1 key to display an explanation of fields, menus, functions and system messages. The F1 help also displays technical information on the relevant field. F4 Help The F4 help displays input help (possible values) for a field that is ready for input. favorite field group A field group comprises a set of related screen elements, for example, all checkboxes in one selection. gateway Interface that converts one communication protocol into another communication protocol. HTTP World Wide Web (WWW) application protocol. The HyperText Transfer Protocol (HTTP) controls communication between the Web browser (the HTTP client) and the Web server (the HTTP server). IDoc Intermediate document: SAP standard format for electronic data exchange between systems.
610
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Glossary
Instance Administrative unit that combines SAP system components providing one or more services. The services provided are started and stopped at the same time. Internet Communication Manager The Internet Communication Manager (ICM) is the component of the SAP architecture that enables an SAP system to communicate directly with the Internet. LU6.2 Logical Unit Type 6.2: SNA log for program-to-program communication. SNA (System Network Architecture) prescribes the logical structures, formats and logs for the transfer of data within a network. Message Server Independent program that maintains a list of all instances in an SAP system. The message server determines which instance a user logs on to and organizes communication between instances. mySAP Business Suite mySAP Business Suite is a complete package of open enterprise solutions that link all people involved, information, and processes, and therefore improve the effectiveness of your business relationships. Native SQL Database language that enables the use of database-specific SQL statements in an ABAP program. OLE Object Linking and Embedding is supported by SAP systems. The information required by the OLE interface is transferred using RFC to OLE-enabled applications outside the SAP system. Open SQL SAP-specific range of SQL statements. Open SQL allows you to avoid conflicts between database tables and makes ABAP programs independent of the database system used. PAI Process After Input. PAI is a processing block in the screen flow logic that is executed after the screen is displayed. This processing block calls modules in ABAP programs and determines the processing that is required after a user action on the screen. PBO Process Before Output. Block of code that is processed after a screen is called but before it is actually displayed.
2005/Q4
© 2005 SAP AG. All rights reserved.
611
Glossary
TAW10_1
Quick Link Navigation tool to facilitate rapid access to specific areas of the SAP Service Marketplace. To call up a Quick Link, simply add it to the Web address, preceded by a “/” (for example: http://service.sap.com/netweaver). request queue Queue into which incoming requests are placed. RFC The Remote Function Call (RFC) is an SAP interface protocol based on CPI-C. It simplifies the programming of communication processes between systems. Role A role is a collection of activities that a person performs to participate in one or more business scenarios in an organization. You access the transactions, reports, Web-based applications and other objects contained in roles through user menus. SAP Easy Access SAP Easy Access is the default initial screen in SAP systems. The left side of the screen contains a tree hierarchy of the menus available to you in the SAP system; you can use the right side of the screen to display a graphic, such as your company logo. SAP GUI SAP Graphical User Interface; medium, which the user can use to exchange information with the computer. You can use the user interface to choose commands, start programs, display files and execute other options by pressing function keys or selecting menu options. SAP GUI for HTML SAP GUI that runs in the Web browser and generates HTML pages dynamically on the basis of SAP screens. Requires an Internet Transaction Server (SAP ITS). SAP GUI for Java Platform-independent SAP GUI, requires a Java environment. SAP GUI for Windows SAP GUI implementation in a Windows environment SAP Logon When you call up the SAP Logon, it displays a list of SAP systems for which you can start the logon process. This list is taken from the information in a file on the front end: saplogon.ini. This file is usually centrally preconfigured and provided for end users. During logon, the SAP Logon program also enables logon load balancing using the resources available for the system selected.
612
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Glossary
SAP Note An SAP Note is text information on a specific topic, problem or system message that you may come across when working in the system. All SAP Notes are stored at SAP in an online database, and customers can call them up from there. An example question could be: “Which versions of Database XY are approved by SAP for use with my SAP system?” SAP Service Marketplace Central portal (URL http://service.sap.com) that provides services, information and other offers to SAP customers and partners. SAP system An SAP system can be, for example, an SAP R/3 Enterprise, an SAP BW- or an SAP CRM system. SAP systems are the central components of SAP solutions within the framework of the mySAP Business Suite. SAP Web Application Server Server (software-oriented view) that provides a range of services for operating an SAP system. The terms instance and SAP Web Application Server are usually used synonymously. SAP Web AS Java Since SAP Web AS 6.20, SAP ships a J2EE application server called SAP Web AS Java. On this application server you can execute programs written in Java (more precisely: according to the J2EE standard). screen Also called “dynpro”, from DYNamic PROgram. A screen consists of a screen image and its underlying flow logic. screen processor Component that executes the screen flow logic of application programs. Server Software component that provides a service (software-oriented view) or central computer within a network that provides resources for the individual work-station computers (hardware-oriented view). Shared memory Area of the main memory that all work processes for that instance can access. SMTP SMTP: Simple Mail Transfer Protocol. SMTP is the most commonly used protocol for transmitting e-mails on the Internet. The e-mail program passes the e-mail to an SMTP server, which then transfers it to the recipient's mail server. In SAP systems, the ICM has now taken on the role of the mail server. SOAP SOAP: Simple Object Access Protocol For an exact and current definition of the current SOAP standard, see http://www.w3.org
2005/Q4
© 2005 SAP AG. All rights reserved.
613
Glossary
TAW10_1
task handler The task handler coordinates processes and manages resources within a work process. TCP/IP The Transmission Control Protocol/Internet Protocol, developed in 1969, describes a procedure for transferring data between computers. It is the standard protocol for Internet data transfer. transaction code A transaction code (also known as a TCode) is a sequence of characters that identifies a transaction in the SAP system. A transaction code may contain up to 20 characters and must always begin with a letter. Permitted characters are letters from A to Z, numbers from 0 to 9, and the underscore. To call up a transaction, enter the transaction code into the command field and choose ENTER. User Master Record The user master record contains the definition of a particular user in the client. Some of the fields are name, first name, initial password and phone number. The user master record is used to create the user context (see: user context) when a user logs on to the system. Work process Process that handles requests in an SAP system. The following work process types exist: Dialog (for executing dialog programs), update (for changing database entries), background (for executing background jobs), spool (for print formatting) and enqueue (for executing lock operations). workflow event A workflow event creates a link between an activity in the SAP system and the people involved.
614
© 2005 SAP AG. All rights reserved.
2005/Q4
Index
A
ABAP, 108 ABAP Dictionary, 139 ABAP documentation, 259 ABAP interpreter, 139 ABAP syntax, 255 activate, 261 active, 261 actual parameter, 395 APPEND, 329 Application Component, 237 Application help, 74 application hierarchy, 239 Application server level, 219 AT LINE-SELECTION, 433 AT SELECTION-SCREEN, 459 AUTHORITY-CHECK, 377 authorization, 377 Authorization Check, 375 authorization object, 377 Authorization profile, 377 Call by reference, 396 Call by value, 396 Call by value and result, 396 CASE, 293 Central services, 125 Central system, 120 chained statement, 257 Change request, 248 CHECK keyword, 501 CLEAR, 290, 336 Client, 57 Client/Server Concept, 109 COLLECT, 330 Column Header, 430 command field, 73 comment, 257 COMPUTE, 291 Constant, 288 CONSTANTS, 288 VALUE addition, 288 context menu, 241 Conversion rule, 290 customizing, 75
B
Background work process, 116 BAPI, 159, 357 BAPI Definition, 166 Basic event, 416 Basic list, 432 Branches conditional, 293 Breakpoint, 296, 299 Business Object, 159
D
DATA, 286, 309, 326 BEGIN-OF-addition, 309 LIKE addition, 286 VALUE addition, 287 Data object, 282 fix, 288 global, 401 local, 401 structured, 308 Data type global, 285
C
Calculation, 291
2005/Q4
© 2005 SAP AG. All rights reserved.
615
Index
TAW10_1
local, 284 Data Type, 282 database interface, 138–139, 145 database level, 219 database management system relational, 219 DDIC type, 499 Debugging mode, 296, 311 Defaults and Own Data, 61 DELETE, 329–330 details list, 433 DIAG, 54 Dialog message, 295 dispatcher, 137 Dispatcher, 116, 128 DO, 294 Documentation ABAP, 259 keyword, 259 Dynamic nodes, 499 Dynamic selections, 504
Function builder, 164 Function module, 357
G
Gateway Server, 118 generate, 262 Global variable, 395
H
Hashed table, 324 header, 337 HIDE, 437 HIDE area, 437 Hiding rule, 401 HTTP, 159 HTTPS, 159
I
IF, 293 inactive, 261 Index access, 324 input history, 95 INSERT, 329, 331 Instance, 120 Interactive lists, 433 interface of a subroutine, 395 Interface technologies, 163 Intermediate document (IDoc), 159 Internal table delete content, 335–336 header line, 337 index access, 333 inserting rows, 331 key, 323 key access, 334 line by line output, 332 local data type, 326 properties, 323 row type, 323 row types, 322 sorting entries, 335 Interne table
E
Enqueue work process, 116 Enterprise Java Beans, 108 Event, 416 Expression arithmetic, 291
F
F1 Help, 74 F4 Help, 75 Flow Logic, 420 FORM, 398 CHANGING- addition, 398 USING addition, 398 formal parameter, 395 type assignment, 399 FREE, 336 Function predefined, 291 STRLEN, 291
616
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Index
table type, 323 Internet Communication Manager, 118 Internet Transaction Server, 112, 614
N
Native SQL, 145, 347, 490
O
Object class, 377 Object Navigator, 241 online documentation, 77 Open SQL, 145, 347
J
J2EE, 108 Java Server Pages, 114
K
keyword documentation, 259
P
package, 237, 249 PAI, 138 Parameter ID, 74, 97 PARAMETERS, 456 PBO, 138 Performance Assistant, 74 Presentation server level, 219 Pretty Printer, 256 Primary index, 356 Processing block, 416 Profile parameter rdisp/max_alt_modes, 57 program generate, 262 Program activate, 261 program group additional program group, 587 main program group, 587
L
Layout, Customizing, 95 list buffer, 416 List Header, 430 List level, 434 Literal, 288 logical database, 357 Logical databases, 490, 499 Loop, 294 LOOP, 330, 332 INDEX addition, 333 INTO clause, 330 WHERE addition, 334
M
memory, 595 ABAP memory, 596 SAP memory, 598 Memory allocation, 416 Message, 295 MESSAGE, 295 WITH addition, 295 Message Server, 118, 121 MODIFY, 329, 332 MOVE, 290 MOVE-CORRESPONDING, 311 multiple logons, 58 mySAP Business Suite, 4
Q
quick info, 96 Quick Link, 197 QuickViews, 494
R
RDBMS, 219 READ, 329 READ TABLE INDEX addition, 333 WITH addition, 334 Record, 308 REFRESH, 335
2005/Q4
© 2005 SAP AG. All rights reserved.
617
Index
TAW10_1
Repository, 236 Repository Information System, 237 Repository object create objects, 244 request queue, 136 Request queue, 128 required entry, 75 Reuse Components, 356 RFC, 159, 162 Role-based user menu, 70 roll in, 137 roll out, 137 runtime object, 262 Runtime system, 416
S
SAP Easy Access, 61 SAP GUI, 53, 55, 128 SAP GUI for HTML, 54 SAP GUI for the Java environment, 54 SAP GUI for Windows, 54 SAP Java Connector, 127 SAP Library, 76–77 SAP Logon, 56 SAP NetWeaver, 12 SAP Note, 57 SAP Service Marketplace URL, 196 SAP Web Application Server, 128 SAP Web Application Server ABAP, 126 SAP Web Application Server ABAP + Java System, 126 SAP Web Application Server Java System, 126 SAP Web AS Java, 108 scalability, 219 screen, 138 Screen, 420 Screen elements, 62
screen processor, 138 Secondary index, 355 SELECT, 349 SELECT-OPTIONS, 457 Selection screen variant, 455 Selection Screen, 450 session, 57 Software Deployment Manager, 124 SORT, 335 AS TEXT addition, 335 STABLE addition, 335 sorted table, 324 Spool work process, 116 SQL, 347 Standard table, 324 Status bar, 97 STOP keyword, 501 Structure data object, 308 Structure component, 310 subroutine, 393 sy-tabix, 332 System field SY-DBCNT, 352–353 SY-INDEX, 294 sy-lsind, 434 SY-SUBRC, 258
T
Table internal, 322 Table join, 358 Table type, 325 Task, 248 task handler, 138 TCP/IP, 162 Technical Information, 74 Text element, 431 text symbol, 431 The buffer, 145 transaction code
618
© 2005 SAP AG. All rights reserved.
2005/Q4
TAW10_1
Index
SM04, 122 SM50, 119 SM51, 122 SM59, 165 Transaction code BAPI, 167 SBWP, 180 SM66, 142 SNOTE, 199 SWO1, 166 Transport Layer, 252 Transport Organizer, 248 Type conflict, 290 Type conversion, 290 Type groups, 499 TYPES, 284, 309 BEGIN-OF addition, 309
SAP NetWeaver, 47 SAP Service Marketplace, 8, 196 user context, 137 User Master Record, 58
V
Variable, 282 Version active, 261 inactive, 261
W
watchpoint, 300 WHILE, 294 Work area, 329 work process, 138 Work process, 128 Work processes, 116 workflow event, 179 worklist, 261
U
Update work process, 116 URL global SAP homepage, 8 SAP Help Portal, 8, 76 SAP Info, 8 SAP Insider Online, 8 SAP Interface Repository, 171
X
XML, 159
2005/Q4
© 2005 SAP AG. All rights reserved.
619
Index
TAW10_1
620
© 2005 SAP AG. All rights reserved.
2005/Q4
Feedback
SAP AG has made every effort in the preparation of this course to ensure the accuracy and completeness of the materials. If you have any corrections or suggestions for improvement, please record them in the appropriate place in the course evaluation.
2005/Q4
© 2005 SAP AG. All rights reserved.
621