36 1 4MB
TAW10 Introduction to the ABAP Workbench (1/2)
TAW10 1/2 ABAP Workbench Fundamentals AG 2003 SAP SAP AG
n n n n
R/3 System Release 4.6D or above 2003/Q2 Material number 5006 0990
© SAP AG
TAW10
0-1
Copyright
Copyright 2003 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. All rights reserved.
SAP AG 2003
Comments on trademarks: n Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. n Microsoft®, WINDOWS®, NT®, EXCEL®, Word®, PowerPoint® and SQL Server® are registered trademarks of Microsoft Corporation. n IBM®, DB2®, DB2 Universal Database, OS/2®, Parallel Sysplex®, MVS/ESA, AIX®, S/390®, AS/400®, OS/390®, OS/400®, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere®, Netfinity®, Tivoli®, Informix and Informix® Dynamic ServerTM are trademarks of IBM Corporation in USA and/or other countries. n ORACLE® is a registered trademark of ORACLE Corporation. n UNIX®, X/Open®, OSF/1® and Motif® are registered trademarks of the Open Group. n Citrix®, the Citrix logo, ICA®, Program Neighborhood®, MetaFrame®, WinFrame®, VideoFrame®, MultiWin® and other Citrix product names referenced herein are trademarks of Citrix Systems, Inc. n HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology. n JAVA® is a registered trademark of Sun Microsystems, Inc. n JAVASCRIPT® is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. n MarketSet and Enterprise Buyer are jointly owned trademarks of SAP AG and Commerce One.
n
SAP, R/, mySAP, mySAP.com, xApps, xApp, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies.
© SAP AG
TAW10
0-2
Development Consultant mySAP Technology – ABAP Workbench
TAW10
10 days
mySAP Technology ABAP Workbench Fundamentals
TAW12
15 days
mySAP Technology - ABAP Workbench Concepts
Development consultant certification – mySAP Technology – ABAP Workbench
SAP AG 2003
© SAP AG
TAW10
0-3
Course Prerequisites
Required
l Solid EDP basic knowledge l Good programming experience in a different programming language
SAP AG 2003
© SAP AG
TAW10
0-4
Target group Target group
?
l Development consultants and developers who are responsible for adapting and developing ABAP/ABAP Objects programs
Duration l 10 days
?
SAP AG 2003
© SAP AG
TAW10
0-5
Course Goals
At the end of this course, you will be able to: l Work with the ABAP Workbench tools l Write your own simple ABAP programs l Program object-oriented ABAP Objects
SAP AG 2003
© SAP AG
TAW10
0-6
Course Content: mySAP Technology – ABAP Workbench Fundamentals
Preface Complex
mySAP.com Technologies
Complex
ABAP Workbench Fundamentals
Complex
ABAP Objects Case Study
SAP AG 2003
n n
This SAP Consultant Education training course contains different individual courses (sections), each of which deals with a separate topic Each individual course (section) is divided into different units.
© SAP AG
TAW10
0-7
Course Content: mySAP Technology – ABAP Workbench Concepts
Preface Complex
ABAP Dictionary
Complex
Programming Database Updates
Complex
Techniques of List Processing
Complex
Solution Manager
Programming User Dialogs
Complex
Enhancements and Modifications
Complex
Case Study
SAP AG 2003
n n
This SAP Consultant Education training course contains different individual courses (sections), each of which deals with a separate topic Each individual course (section) is divided into different units.
© SAP AG
TAW10
0-8
Complex: mySAP.com Technologies
SAP AG 2003
© SAP AG
TAW10
1-1
Course Content: mySAP.com Technologies
Unit
mySAP.com
Unit
Navigation
Unit
Technical Structure of an SAP System
Unit
Cross-System Concepts
SAP AG 2003
© SAP AG
TAW10
1-2
mySAP.com
Contents: l System Overview l Internet Technologies l Interfaces l SAP Service Marketplace
SAP AG 2003
© SAP AG
TAW10
2-1
mySAP.com (1)
System System Overview Overview Internet Internet Technologies Technologies Interfaces Interfaces SAP SAP Service Service Marketplace
SAP AG 2003
© SAP AG
TAW10
2-2
Possibilities Offered by mySAP.com Only a fraction of the integration possibilities is shown here...
R/3
The Internet, or 'the rest of the world' Other software
Marketplace
Laptop or PDA (handheld)
New business partner
Field staff R/3: FI/CO BW
Only browser required
R/3: HR CRM
Customer TM
R/3: SD
R/3 Legacy software
APO
Your company
Other software Business partner
SAP AG 2003
n
mySAP.com provides the option of mapping internal business processes with employees and external business processes for partners, customers or suppliers using the Internet.
© SAP AG
TAW10
2-3
SAP R/3 (Enterprise) SAP GUI for HTML
browser browser Classic users
SAP R/3 (Enterprise)
SAP SAP GUI GUI ESS
Middleware components
(such as SAP ITS)
browser browser
ESS = Employee Self-Service SAP AG 2003
n n
SAP R/3 Enterprise provides a wide range of core business functions (as did its precursor, SAP R/3), including Financial Accounting and Human Resources Management. SAP R/3 Enterprise, which excellently complements all SAP solutions, can be used as an ERP backend system.
© SAP AG
TAW10
2-4
mySAP CRM e.g. Internet selling
browser browser
Mobile Services
Middleware components
CRM System
ERP Backend
Laptop
Call Center
SAP SAP GUI GUI SAP AG 2003
n n
Many companies now attach growing importance to generating and maintaining customer loyalty. This is why it is necessary to manage customer information efficiently. mySAP Customer Relationship Management (mySAP CRM) not only enables you to do this, it also enables you to optimize your customer relationships as a whole and throughout the life cycle – from customer acquisition through sales processes and order fulfillment to customer service.
© SAP AG
TAW10
2-5
mySAP E-Procurement
Catalog
Employees within your company
... Middleware
ERP Backend
EBP System
SAP SAP GUI GUI
... Internet Marketplace
Not necessarily required
SAP AG 2003
n
mySAP E-Procurement supports business-to-business procurement of both production materials and indirect materials (pencils, paper, etc.). You can make purchases on e-marketplaces, use electronic bid invitations or search for the best offers on the World Wide Web.
© SAP AG
TAW10
2-6
mySAP BI BW System
ERP Backend
Manager
... GUI GUI
SEM System
ERP Backend
Not necessarily required SAP AG 2003
n
n
The mySAP Business Intelligence solution provides you with a variety of options for extracting, evaluating, storing and disseminating the data in your systems so you can make business or strategic decisions. mySAP BI components: - SAP Business Information Warehouse (SAP BW) - SAP Strategic Enterprise Management (SAP SEM)
© SAP AG
TAW10
2-7
mySAP SCM Manager (person responsible) BW System
ERP Backend
APO System
Other ERP Backend
GUI GUI (Excel-based (Excel-based for for example) example)
Manager (planner)
SAP SAP GUI GUI SAP AG 2003
n
n
n
n
mySAP Supply Chain Management (mySAP SCM) gives you the tools you need to manage your entire logistics chain, so you can control all intracompany and intercompany processes, from mapping the logistics chain to sourcing, and from requirements planning to sales. The Internet-enabled functions in mySAP Supply Chain Management allow you to control the logistics chain even beyond your company boundaries. This enables you to collaborate with your partners and customers, exchanging important information and reacting swiftly as the need arises. One of the central modules of mySAP SCM is the Advanced Planner & Optimizer (APO). APO includes the following components: Supply Chain Cockpit, Demand Planning, Supply Network Planning and Deployment, Production Planning and Detailed Scheduling and Global Available-toPromise. By combining APO with the Business Information Warehouse, SAP customers can optimize performance and costs along the entire logistics chain.
© SAP AG
TAW10
2-8
mySAP Enterprise Portal
ERP Backend
Employee
Portal
browser browser browser browser browser browser
Other ERP Backend
Browser Browser
Other sources of information or systems (such as the Internet) SAP AG 2003
n
n
Possibilities offered by mySAP Enterprise Portal: - Simple, uniform access to different sources of information (single point of entry) - Easy access to different software components from various providers (for example, Baan, PeopleSoft, Oracle, and Siebel, alongside SAP) - Users need to log onto the portal once only to access all systems (Single Sign On) - Role-based access to functions - The portal can be personalized by adjusting it to personal needs - Secure access from anywhere mySAP Enterprise Portal can be used as an employee, customer and/or supplier portal, amongst others.
© SAP AG
TAW10
2-9
mySAP.com (2)
System System Overview Overview Internet Technologies Internet Technologies Technologies Interfaces Interfaces SAP SAP Service Service Marketplace
SAP AG 2003
© SAP AG
TAW10
2-10
SAP ITS, SAP Web AS: HTTP Communication HTTP request HTTP
Web server HTTP
SAP ITS RFC/ DIAG SAP Application Server previously "SAP Basis")
SAP Web Application Server
optional RFC Various SAP systems
SAP AG 2003
n
There are basically two ways of accessing an SAP component in dialog mode from the Internet: - Using the SAP Internet Transaction Server (SAP ITS) - Using the Internet Communication Manager (ICM) of the SAP Web Application Server (SAP Web AS)
© SAP AG
TAW10
2-11
The SAP Internet Transaction Server SAP ITS
Service files
Common host Web browser HTTP
Web server
CGI*
WGate
TCP/IP AGate
DIAG RFC
SAP System
HTML page
•HTMLBusiness Templates •Flow files
CSS files
SAP AG 2003
n
* NSAPI and ISAPI are also supported
The SAP ITS provides the following options: - Automatic conversion of SAP screens into HTML format - Use of screen-based IACs (Internet Application Components) that have been delivered with the R/3 System for years (the online store, for example) - Use of the SAP GUI for HTML, a 1:1 conversion of SAP screens into HTML
© SAP AG
TAW10
2-12
The SAP Web Application Server SAP Application Server, up to (incl.) Rel. 4.6D
SAP Web Application Server as of Rel. 6.10
Dispatcher WP
WP
DB
Dispatcher Dispatcher WP
WP
WP
WP
Memory pipes
ICM
DB
SAP AG 2003
n n n n
The SAP Web AS is a further development of the classic SAP Basis technology. A new process has been added to the SAP kernel, the Internet Communication Manager (ICM). The ICM enables you to process directly queries that were placed from the Internet/Intranet via a browser. The Web browser and ICM communicate using Business Server Pages; these are HTML pages that also contain ABAP coding, for example, so that the HTML page can be filled with data at runtime. The SAP GUI for HTML cannot currently be used with the ICM (-> SAP ITS)
© SAP AG
TAW10
2-13
mySAP.com (3)
System System Overview Overview Internet Internet Technologies Technologies Interfaces Interfaces SAP SAP Service Service Marketplace
SAP AG 2003
© SAP AG
TAW10
2-14
Interfaces Technologies Used in SAP Systems
P H HTT
SMTP SMTP II EEDD
A ALLE BAPI BAPI OLE OLE RFC RFC CPI-C CPI-C
Open Interfaces Interfaces TCP/IP TCP/IP
LU6.2 LU6.2
Open Interfaces
SAP AG 2003
n n
n
n
mySAP.com is an open system. It supports a variety of network communication protocols. Information can be exchanged between component systems and non-SAP systems. SAP supports the TCP/IP (Transmission Control Protocol/Internet Protocol) and SNA LU6.2 (System Network Architecture; Logical Unit 6.2) protocols. Communication in mySAP.com takes place using the standard TCP/IP protocol. LU6.2 was developed by IBM and is used to communicate with mainframe-based R/2 Systems. R/3 application programming supports CPI-C (Common Programming Interface Communication), RFC (Remote Function Call) and OLE Automation (Object Linking and Embedding) as communication interfaces. Other interfaces are based on this technology, such as communication via BAPIs (Business Application Programming Interfaces), EDI (Electronic Data Interchange) or an ALE (Application Link Enabling) distribution model. It is also possible to send and receive mails using SMTP (Simple Mail Transfer Protocol).
© SAP AG
TAW10
2-15
Business Process Distribution Using ALE
Distributed business processes n
Accounting Central Controlling n Information systems: n Inventory n Purchasing n Sales n Central purchasing n Reference system for master data and tax data n
n n n n n
Plant maintenance Inventory management Internal sales, shipping and billing Local purchasing PP
n
Sales, shipping and billing n Purchasing of trading goods n Inventory management n Local Controlling
SAP AG 2003
n
ALE is the business-controlled message exchange - Through synchronous and asynchronous communication - Using BAPI interfaces and IDoc data containers - Using consistent data (the applications do not use a central database, but are filled independently by regional databases with their own database) - Across loosely linked SAP applications.
© SAP AG
TAW10
2-16
RFC Connection Options SAP system (SAP R/2 also possible)
External system
ABAP program
External program
RFC interface
RFC interface
SAP system
RFC interface ABAP program
SAP AG 2003
n
n
Remote Function Call (RFC) is a communications interface that is based on CPI-C, but which has more functions and is easer for application programmers to use. You can use R/3 and R/2 Systems as well as external applications as RFC communication partners. See also SAP Notes 13903 and 116051. RFC is the protocol for calling special subroutines over the network. These subroutines are labeled function modules. Function modules are comparable with C functions or PASCAL procedures. They have a defined interface via which data, tables and return codes can be exchanged. Function modules are managed in the R/3 System in their own function library, called the Function Builder.
© SAP AG
TAW10
2-17
Remote Function Call in Detail Calling system
System called
RFC DESTINATION R/2 R/3 DEST
...
... CALL FUNCTION XY DESTINATION DEST EXPORTING... IMPORTING... ...
FUNCTION XY. . . . ENDFUNCTION.
RFC interface
RFC interface interface RFC
SAP AG 2003
n n
Function modules remote calls across system borders are only different to local remote calls in that a special parameter (Destination) specifies the destination host on which the program is to be executed. There are three types of RFC call: - Synchronous RFC call: the calling program stops until the function module has been processed in the destination system and any results have been returned to the caller. Only then does the calling program continue processing. - Asynchronous RFC call: the calling program runs parallel to and independently of function module processing in the destination system. Programmers are responsible for handling result processing. In addition, the destination system must also be available at the time of the RFC call. - Transactional RFC call: several function modules can be grouped into one transaction. They are processed in the destination system within an LUW once only, and in the sequence in which they were called. In the case of an error, the calling system receives a confirmation that you can access using Transaction SM58. In the case of transactional RFC, the destination system does not have to be available at the time of the RFC call. In addition, you can configure the frequency and intervals of individual queries.
© SAP AG
TAW10
2-18
mySAP.com (4)
System System Overview Overview Internet Internet Technologies Technologies Interfaces Interfaces SAP SAP Service Service Marketplace Marketplace
SAP AG 2003
© SAP AG
TAW10
2-19
service.sap.com – the SAP Service Marketplace
?
?? ?
Problem messages
Current Output / messages? Notes database
Training course information
Corrections
SAP Software Change Registration
Service requirements SAP AG 2003
n
n n n
The SAP Service Marketplace under http://service.sap.com is aimed at SAP customers and partners (unlike http://www.sap.com, which provides information on all SAP solutions and on SAP as a company for everyone). At the SAP Service Marketplace you can access various services, special information and additional offers. You must be registered as a user to use the SAP Service Marketplace. 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 (apart from the necessary Internet access).
© SAP AG
TAW10
2-20
mySAP.com: Unit Summary
You are now able to l Name some of the advantages that your company gains by using mySAP.com e-business solutions. l Describe where SAP ITS and SAP Web AS can be used and how they work l Name various interface technologies used by SAP systems l Use the SAP Service Marketplace
SAP AG 2003
© SAP AG
TAW10
2-21
Navigation
Contents: l Logon and Screen Design l User Guide l Getting Help l User Settings
SAP AG 2003
© SAP AG
TAW10
3-1
Navigation (1)
Logon Logon and and Screen Screen Design Design User User Guide Guide Getting Getting Help Help User User Settings Settings
SAP AG 2003
© SAP AG
TAW10
3-2
The SAP Logon Program
SAP Logon 610 Language DEV [SPACE]
SID
Group/Server
Sys.No. Messageserver
DEV
SPACE
00
Logon
twdf0670
Properties Groups...
Server... New... Delete
SAP AG 2003
n
n
The SAP GUI program connects the front-end computer with a specific SAP System. Theoretically you can specify the SAP system required at command-line level when calling the SAP GUI program. In practice, you never need to do this. SAP provides another program for starting the SAP GUI: SAP Logon. When you call up the SAP Logon, it displays a list of SAP systems whose logon process can be started. This list is derived from a file on the front-end computer: saplogon.ini. This file is normally preconfigured centrally and made available to end users.
© SAP AG
TAW10
3-3
The Logon Screen for an SAP System
Users
System
Help
SAP R/3 New password
client
100
User
|
Password
Language
DE
Please call your user administrator on Tel. 1972 if you have problems logging on
DEV (1) (100)
TWDF0670 OVR
SAP AG 2003
n
n
n
n n
n
SAP systems are client systems . You can use the client concept to control several separate enterprises in one system at the same time. The BW and KW components are exceptions since each uses one client only. Each user session only accesses data on the client that you selected when you logged on. A client is a self-contained organizational unit in the system. Each client has its own data environment and, therefore, its own user master and transaction data, assigned user master records and chart of accounts and specific Customizing parameters. So that you can log onto the system, you must have a user master record created for you for the corresponding client. For reasons of access protection, you must enter a password when you log onto the system. The system does not display the password that you enter (stars are displayed in place of the password). SAP systems are multilingual. You can use the Language field to select the logon language for the current session. Multiple logons are recorded as of Release 4.6. This is for reasons of both security and licensing. If the same user logs on more than once, then the system displays a warning message for each subsequent logon. You can add your own texts to the logon screen in different ways. For more information, see SAP Note 205487.
© SAP AG
TAW10
3-4
SAP Easy Access
Menu
Edit
Favorites
Extras
System
Help
SAP Easy Access Other menu
Create role
Assign users
Documentation
Favorites SAP menu Office Information Systems tools
DEV (1) (100)
TWDF0670
OVR
SAP AG 2003
n n
The SAP Easy Access screen is the standard way to access the system. You navigate within the system using a clearly arranged tree structure. You can attach an image such as your company logo to the right side of the screen. This image can be assigned throughout the system and is valid for all clients. Given that you have authorization to do so, you can find a detailed description of the settings that are required to do this by choosing Extras -> Administration information. Please note that the graphic is stored in the system and transported to the front-end every time SAP Easy Access is called. Although it is transported in compressed form, the graphic should not exceed 20 KB. You can also prevent the graphic from being called by choosing the setting Low Speed Connection in the SAP Logon program (see SAP Note 161053), or by choosing Extras --> Settings in the SAP Easy Access screen. See also "User Settings".
© SAP AG
TAW10
3-5
Screen Elements Users
Edit
Goto
System
Menu bar Standard toolbar Title bar Application toolbar
Help
Maintaining your user profile
Command field ESCH
User Last changed by
Address
ESCH
Defaults
05.07.2001 15 : 46 : 37
Parameter s
StartMenu Logon language Output Controller OutputDevice
Status
Saved
Tab page
Decimal notation
Input fields Checkboxes Radio buttons
1.234.567,89 1,234,567.89 1 234 567,89
Output immediately Delete after output
Date format DD.MM.YYYY
Personal time zone CET
MM/DD/YYYY MM-DD-YYYY YYYY.MM.DD
CATT Test status
YYYY/MM/DD YYYY-MM-DD
Status bar DEV (1) (100)
TWDF0670
OVR
SAP AG 2003
n
n n
n n n n n
Command field: you can start applications directly by entering their transaction code in the command field (this is hidden by default). You can find the transaction code for an application either in the SAP Easy Access menu tree (see "User Settings") or in the application itself under System -> Status. Menu bar: the menus shown here depend on which application you are in. These menus may also contain cascading menus. Standard toolbar: the icons in the standard toolbar are shown on every R/3 screen. If they are not available in an application, the pushbuttons that you cannot use on that screen are deactivated. If you position the cursor over an icon for a short time, the system displays quick info text with the name or function of the icon. If appropriate, you also see the corresponding function key setting. The application toolbar shows the icons available in the application you are currently in. Title bar: the title bar names the function that is available in the application you are currently in. Checkboxes: checkboxes enable you to select several options from a group of fields at the same time. Radio buttons: radio buttons enable you to choose exactly one item from a selection. Tab: arranges several information screens to improve clarity. Status bar: the status bar displays information such as warnings and errors about the current system status.
© SAP AG
TAW10
3-6
Navigation (2)
Logon Logon and and Screen Screen Design Design User Guide User Guide Guide Getting Getting Help Help User User Settings Settings
SAP AG 2003
© SAP AG
TAW10
3-7
Favorites List and User Menu
Menu
Edit
Favorites
Extras
System
Help
SAP Easy Access Other menu
Create role
Assign users
Documentation
Favorites URL - SAP Service Marketplace SM50 - Process Overview SM04 - User List
Favorites list
Role SAP_BC_BASIS_ADMIN System: Running Operation System Configuration Performance Analysis Problem Analysis Overview RZ20 - CCMS Monitoring Details
Role-based menu
DEV (1) (100)
TWDF0670
OVR
SAP AG 2003
n n n n n
n
Role: a role describes a number of activities in the system that it makes sense to define. These represent the scope of functions that users typically require at their work station. Roles (formerly "activity groups") must be set up using the Profile Generator so that SAP system users can work with user-specific or work station-related menus . Roles are also used to assign users with authorization for the activitie s defined in menus. Predefined user roles from all application areas are included in the standard system as of Release 4.6. When users are assigned roles, they can choose between the standard SAP menu and their user menus. In addition to their roles, end users can also use Favorites to personalize their access to the system. You can create your own Favorites list of the transactions, reports, files and Web addresses that you frequently use. You can create edits using the Favorites menu or simply using the mouse to "drag & drop" URLs or links to files to your personal favorites list.
© SAP AG
TAW10
3-8
Navigation Options
Menu
Edit
Favorites
Extras
System Create session End session
SAP Easy Access Command field Other menu
User profile Services Utilities List
Favorites URL - SAP Service Marketplace SM50 - Process Overview SM04 - User List Role SAP_BC_BASIS_ADMIN System: Running Operation
Services for object Object history Own spool requests Own jobs Short message Status... Log off
System Configuration Performance Analysis Problem Analysis Overview RZ20 - CCMS Monitoring
Details
Menu
SAP Easy Access and Favorites list SAP AG 2003
n
You can call the following types of system functions: Ÿ Using the mouse by selecting a - menu entry - Favorites - an SAP Easy Access entry - using the keyboard (ALT + the underlined letter of the menu option required) - by entering a transaction code in the command field: In SAP systems, each function (not each screen!) is assigned a transaction code. You can call the allocated transaction code from any system screen. For example, you can display the customer master data, enter "/n" and then enter the corresponding transaction code: "/nfd03". You can determine the transaction code by choosing Status in the System menu. Additional input options: - "/n" ends the current transaction. - "/i" deletes the current session - "/osm04" opens a new session and branches to the specified transaction (SM04).
© SAP AG
TAW10
3-9
The System and Help Menus
Menu
Edit
Favorites
SAP Easy Access Other menu
Extras
System
Help
Create session
Application help
End session
SAP Library
User profile
Glossary Create roleRelease Notes Assign users
Services Utilities
Favorites SAP menu Office Information Systems tools
Documentation
SAP Service Marketplace
List
Feedback
Services for object
Settings...
Object history Own spool requests Own jobs Short message Status... Log off
DEV (1) (100)
TWDF0670
OVR
SAP AG 2003
n
n
You can find the following options amongst others in the System menu option: Ÿ Create/end session: creates and ends a session. System administrators can use parameter rdisp/max_alt_modes to set the maximum number of sessions to a number between 2 and 6. Ÿ User profile: contains user-specific settings. Choose Own data to use parameters IDs that fill specific fields in the system (such as the company code field) with default values. Ÿ List: important list functions, such as searching by character string, saving to PC files, printing and so on. - Status: displays the most important user and system data - Logoff: ends the SAP R/3 session (with a request for confirmation) The menu option Help contains the following options, amongst others: - A context-sensitive Application Help - SAP Library call (see next page) - A Glossary
© SAP AG
TAW10
3-10
Navigation (3)
Logon Logon and and Screen Screen Design Design User User Guide Guide Getting Getting Help Help User User Settings Settings
SAP AG 2003
© SAP AG
TAW10
3-11
F1 Help Output Controller OutputDevice
Output immediately Delete after output Personal time zone CET
Technical information
CATT Test status
F1 help
Performance Assistant
Print parameter 2 Indicates whether spool requests are printed immediately. Select this field to print your spool requests immediately. lassen. Leave the field blank to retain spool requests in the spool system until they are released. To release these spool requests for printing, you can use System -> Services -> Output controller. SAP AG 2003
n n
You can choose the F1 key to display an explanation of fields, menus, functions and messages. The F1 help also displays technical information on the relevant field. This information includes, for example, the parameter ID that you need to set user-specific default values for input fields that are also linked to the parameter ID.
© SAP AG
TAW10
3-12
F4 Help Address
Defaults
Language (2)38 Entries found
StartMenu
Restrictions Logon language Output Controller OutputDevice
F4 help
Langu... Language AF
Afrikaans
AR
Arabic
BG
Bulgarian
CS
Czech
DA
Danish
DE
German
EL
Greek
EN ES
English
ET
Estonian
FI
Finnish
FR
French
HE
Hebrew
HR
Croatian
HU
Hungarian
ID
Indonesian
Spanish
SAP AG 2003
n
You can use 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.
© SAP AG
TAW10
3-13
The SAP Library
SAP Library
Getting Started
Hide Tree
Open All Previous
Release Notes
IMG
Glossary
Search
Help on Help
Area
SAP Library
Close All Next
Synchronize
SAP Library Getting Started SAP Web Application Server SAP Knowledge Management Help on Help Help on the Web Copyright
SAP Web Application Server, Release 6.10, June 2001 © Copyright 2001 SAP AG. All rights reserved.
Local intranet
SAP AG 2003
n
n
n
SAP Systems provide extensive online help. You can call this help from every screen in the system. You can call up help by choosing the Help menu, or by choosing the appropriate icon (yellow question mark). You can also access the SAP Library easily and quickly from the SAP Service Marketplace. You can find the SAP Help Portal under Knowledge and Training. You can display the help in HTML format and also perform a very efficient full text search in the library. If the SAP Library has been installed, you can also call this option within your company. You can also access the Help Portal directly at http://help.sap.com.
© SAP AG
TAW10
3-14
Navigation (4)
Logon Logon and and Screen Screen Design Design User User Guide Guide Getting Getting Help Help User Settings User Settings Settings
SAP AG 2003
© SAP AG
TAW10
3-15
Two of the Many Personalization Options Menu Edit
Favorites Extras
System Help
Display documentation
SAP Easy Access Other menu
Technical details Settings Set start transaction
Shift+F6 Ctrl+Shift+F10 Shift+F9 Create role Shift+F7
Options ... New Visual Design ... Assign users Documentation Clipboard Generate graphic
Favorites SAP menu Office Information Systems tools
Create shortcut ... Activate GuiXT Default size Hardcopy Quick Cut and Paste Spelling Check Sapgui Help
Settings
About ...
This is used to specify settings Display favorites at end of list Do not display menu, only display favorites Do not display picture Display technical names
A range of settings simplifies working with the system DEV (1) (100)
TWDF0670 OVR
SAP AG 2003
n
n
n
Choose 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. When you choose Options, you have the option of activating Quick Cut and Paste. Under Options... you have the option of setting the reaction speed of the quick info text that is displayed when you position the cursor over an icon or pushbutton. You can set personal standard values by choosing System -> User Profile -> Own Data. You can do this on the tab pages Address, Defaults, and Parameters.
© SAP AG
TAW10
3-16
Navigation: Unit Summary
You are now able to l Log on to the system successfully l Name and use elements of a SAP GUI screen l Use F1 and F4 help l Display the information in the online documentation l Use the various options for personalizing the SAP system
SAP AG 2003
© SAP AG
TAW10
3-17
Navigation - Exercises Unit:
Navigation
Topic:
Basic Functions
At the conclusion of these exercises, you will be able to: •
Log on to an SAP system
•
Identify transaction codes
•
Access SAP Library information
•
Use the F1 help to find field information
•
Use the F4 help to search for possible field values
As a new SAP system user, start to navigate in the system using menu paths and transaction codes, and use the various types of online help.
All menu paths in the exercises refer to the SAP standard menu. 1-1
Logging on the system Select the corresponding system for this training course. Enter the client, user name, initial password, and the logon language specified by the instructor. When logging on for the first time, a window appears in which you must enter a new password twice. Note the Client: _ _ _ User: _ _ _ _ _ _ _ _ Password: __________ Language: _ _.
1-2
What is the maximum number of parallel sessions (windows of the SAP system) can you open by choosing System à Create session? Number: __
1-3
What are the functions called that you access using the following SAP standard menu paths and what are the corresponding transaction codes? 1-3-1 Tools → Administration → Monitor → System Monitoring → User Overview Function name: ___________________________________________ Transaction: _________________________________________________
© SAP AG
TAW10
3-18
1-3-2 Accounting → Financial Accounting → Accounts Receivable→ Master records→ Display
Select Customer 1000 in Company code 1000 to access the following screen.
Function name: ___________________________________________ Transaction: _________________________________________________ 1-4
Help 1-4-1 On the SAP Easy Access initial screen, if you choose Application Help ("Help" menu), you branch to which area of the SAP Library? _________________________________________________________
To answer the question below, you must call the transaction for displaying the customer master record. 1-4-2 Use the F1 help for the Customer field to answer the following question. What do you use the Customer field for? Summarize the business-relevant information here. ______________________________________________________
1-4-3 Use the F1 help for the Company code field. To which business area of the SAP Library does the system branch when you choose the Application Help icon at the top edge of the F1 help window? ______________________________________________________
1-4-4 Which icon at the upper edge of the F1 help window can you use to find the parameter ID for the Company code field? ______________________________________________________
© SAP AG
TAW10
3-19
1-4-5 Use the F4 help for the Customer field to find the number of customer "Becker ##". To do this, call the F4 help and use the search term "Becker*". Hint: ## is your group number. ___________________________________________________
© SAP AG
TAW10
3-20
Unit:
Navigation
Topic:
User-Specific Settings
At the conclusion of these exercises, you will be able to: •
Fill a field with default parameters
•
Make various user-specific settings
•
Maintain your favorites list
•
Define a user-specific start transaction
Start to define various user-specific settings.
Optional exercises are marked with an asterisk (*). 2-1
Define user parameters. 2-1-1 Assign a default value to the Company code field for your user. Hint: Your instructor will specify the Company code value (such as "1000"). You can find a hint on default values in the notes on the "User Settings" page. Parameter: ___ ___ ___ Parameter value: ___ ___ ___ ___
2-2
Define user-specific settings by choosing System --> User Profile --> Own Data. 2-2-1 Set your Logon Language to the language that you are using in the training course. 2-2-2 Define the Decimal Notation and the Date Format you require.
© SAP AG
TAW10
3-21
2-3
Maintain favorites 2-3-1 Create at least one new folder below the favorites folder. 2-3-2 Add two of your favorite transactions to this folder. 2-3-3 Add the Internet address “http://www.sap.com” below the title “SAP Homepage”.
2-4*
Define a start transaction in the "Extras" menu. 2-4-1 Set a transaction as the start transaction. You must now log off and on again so that the system can update the changes. Hint: You can also reset the start transaction to the standard value simply by deleting your entry.
© SAP AG
TAW10
3-22
Solutions Unit:
Navigation
Topic:
Basic Functions
1-1
Log on to the system indicated by the instructor and change your password.
1-2
To create and end sessions, choose System → Create session (or choose the corresponding icon) and System → End session. Depending on the system setting, up to six sessions can be opened simultaneously during one user terminal session.
1-3
You can find the transaction code under System → Status. These screens and transaction codes correspond to the menu paths: 1-3-1 SM04 for User List 1-3-2 FD03 for Customer Display: General Data
1-4
Help 1-4-1 The Getting Started unit is displayed with information about using SAP Easy Access. 1-4-2 Suggestion: The Customer field is used within an SAP system to identify a customer uniquely. 1-4-3 FI Accounts Receivable and Accounts Payable 1-4-4 Using the Technical Info icon you can find: Parameter ID: BUK 1-4-5 Customer##
(## is your group number)
If you use the F4 help for the Customer field, a dialog box appears in which you can enter various search criteria. The different tabs on the dialog box contain different search criteria. Use the Search term search criteria and enter the following data: Criterion Name
Value
Search term
Becker*
If you perform the search using the Enter key, a list of possible hits is displayed, from which you can select the corresponding value.
© SAP AG
TAW10
3-23
Unit: Navigation Topic: User-Specific Settings
2-1
Define user parameters 2-1-1 To define default values for a field, you need the parameter ID of the field concerned. To find this, you must first select a transaction that contains this field. Position the cursor on the corresponding field (just click on it with the mouse). Choose F1 → Technical Information → Parameter ID to display the information you require. For the Company code field, the parameter is BUK. Now enter this parameter into your user settings (System → User Profile → Own Data) in the Parameter tab and assign it the value that will be valid for the object in future. Then save your data.
2-2
Define user-specific settings 2-2-1 To set the logon language, go to the user profile (System → User Profile → Own Data) and then choose the Defaults tab. Enter the logon language you require in Logon Language. 2-2-2 See 2-2-1
2-3
Maintain favorites 2-3-1 To place favorites in a folder, you must first create a folder (functional areas): Favorites → Insert folder with a name of your choice. You can create as many folders as you like. You can move folders using the mouse to “drag & drop” them. 2-3-2 To create favorites, select specific applications (transactions) in the menu tree of the SAP standard menu that you require as favorites (those applications that you use daily). You can add entries to your favorites list by selecting the application and choosing Favorites → Add. You can subsequently move favorites into folders by choosing Favorites → Move favorites. You can also move favorites using the mouse to “drag & drop” them. 2-3-3 You create Internet addresses by choosing Favorites → Add Web address or file.
© SAP AG
TAW10
3-24
2-4
Define a start transaction 2-4-1 Extras → Set start transaction Enter a transaction and then choose Enter. The system message in the status bar displays that this transaction will be the start transaction the next time you log on. Hint: To reset this action, you must choose the menu path again and delete the transaction code you entered. The next time you log on to the system, the initial SAP Easy Access screen will be displayed again.
© SAP AG
TAW10
3-25
Technical Structure of an SAP System
Contents: l Data Structure l System Kernel
SAP AG 2003
© SAP AG
TAW10
4-1
Technical Structure of an SAP System (1)
Data Data Structure Structure System System Kernel Kernel
SAP AG 2003
© SAP AG
TAW10
4-2
Application Data
(Orders, Invoices,...)
Client-Specific Customizing (Company Codes, Plants, Stores, ...)
(Orders, Invoices,...)
Client-Specific Customizing
User
Application Data
(Authorizations, Master Record...)
Client 200
User
Client 100
(Authorizations, Master Records...)
mySAP.com System Data Structure
(Company Codes, Plants, Stores, ...)
...
Cross-Client Customizing
Repository Objects (For example: Table Definitions, Programs, Transactions, Function Modules) Customer Developments Basis
FI
CO
HR
PP
MM
SD
...
Development Classes SAP AG 2001
n n
n
n
n n
mySAP.com Systems contain different types of data. Some data can only be accessed from one client, such as business application data (documents, material masters, and so on), and most Customizing settings. Customizing is used to define a customer’s organizational structures, such as distribution channels, company codes, and so on, and to set customer-specific parameters for SAP transactions. The client-specific data is closely related. At input, application data is checked against the Customizing settings in the client. If inconsistencies are found, the input is rejected. This is why application data usually makes sense only in its own Customizing environment. In addition to the client-specific Customizing settings, there are other settings that are set once and are active for all clients. These cross-client Customizing settings include printer settings, for example. The Repository is also client-independent. It contains all ABAP Dictionary objects (tables, data elements, and domains) as well as all ABAP programs, menus, screens, and so on. Because they are cross-client, Repository objects developed in one client are the same in all other clients in the same system.
© SAP AG
TAW10
4-3
Customizing ASAP Roadmap View:: Change Company View Company Code New entries
CoCd.
Customizing
Company name
. . . . Customizing
Customizing
SAP AG 1999
n n
n
In addition to the various data types in the SAP R/3 System, there are also different types of changes and adaptations in the SAP R/3 System, and in other mySAP.com component systems. As the SAP R/3 System is standard software, it must be adapted to the individual needs of each company that uses it. This tailoring process is called Customizing, which includes the client-specific and cross-client data shown in the slide. A small amount of Customizing may also be required after an SAP R/3 System upgrade. Customizing is not developed and tested in the same client in which it will be in production. This means that several clients are required during an SAP R/3 implementation. Customizing is executed and tested in one client. In a large installation, it may make sense to combine and test Customizing subprojects in another client. Production occurs in its own client.
© SAP AG
TAW10
4-4
Changes to Repository Objects DEV . . .
SAP Namespace
Customer Namespace QAS
Repository
PRD
Modifications
Extension
Customer Development
SAP AG 1999
n
In contrast to Customizing, the Repository does not necessarily need to be changed or enhanced for a mySAP.com System implementation: Ÿ Customers can add their own developments to the Repository. Ÿ In addition, customers can add what are called customer enhancements, which are customer objects added to existing objects in the SAP standard system. Customers add their enhancements using Customer Exits. Ÿ Modifications change SAP objects, such as reports and table definitions. The Repository delivered from SAP is not only enhanced, but changed as well. This is why the modifications may need to be adjusted to a new Repository installed during the next SAP R/3 upgrade. This adjustment may take some time. n As Repository objects are cross-client, it is not possible to use a development system as a production environment. The danger of creating data inconsistencies would be too great. n Therefore, if changes are to be made to the Repository, we recommend two, even better, three systems. The third SAP R/3 System can be used for testing and quality assurance. n All customer developments take place in the customer namespace. This means that all objects created by customers have names within a certain namespace, for example beginning with Y or Z for ABAP programs.
© SAP AG
TAW10
4-5
Technical Structure of an SAP System (2)
Data Data Structure Structure System System Kernel Kernel
SAP AG 2003
© SAP AG
TAW10
4-6
The System Kernel
Applications
ABAP Interpreter
Screen Processor User Interface
ABAP Dictionary
Runtime Environment
Communication Interface
Programming Interfaces
Operating System and Hardware Platform SAP AG 1999
n
This unit introduces the central processes of mySAP.com Basis Technology. This includes an explanation of how a user request is sent to and processed by the application layer, and which process types are involved in processing the request. Data entered by the user is sent through the user interface (the SAP GUI) to the dispatcher, which coordinates further processing. The work processes use the same source code as the dispatcher and whose substructures such as the Screen Interpreter and the ABAP Interpreter are presented here. Another topic is data exchange with the database.
© SAP AG
TAW10
4-7
Processing User Requests
Presentation
SAP GUI
SAP GUI
SAP GUI
SAP GUI
Communication
Application Dispatcher Buffer Work Process
Database
Work Process
Work Process
Database Processes
DB
SAP AG 1999
n
n
n
n
n
The dispatcher is the central process of the application server. The dispatcher manages, in association with the operating system, the resources for the applications written in ABAP. The main tasks of the dispatcher include distributing transaction load to the work processes, connecting to the presentation level, and organizing communication. User input is received by the SAP presentation program SAPGUI, converted into its own format and then sent to the dispatcher. The processing requests are then saved by the dispatcher in request queues and processed according to a first in-first-out principle. The dispatcher distributes the requests one after the other to available work processes. Data is actually processed in the work process, although the user, who creates the request using the SAP GUI, is not always assigned the same work process. There is no fixed assignment of work processes to users. Once the data has been processed, 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. During initialization of the mySAP.com component system, the dispatcher executes the following actions among others: It reads the system profile parameters, starts work processes, and logs on to the message server (this service will be explained later).
© SAP AG
TAW10
4-8
SAP GUI Types
SAP GUI for Windows ®
Windows 32 Bit
SAP GUI for Java™
Java Application
SAP GUI for HTML
Browser-Based
SAP AG 1999
n
n n
The presentation interface SAPGUI (GUI = Graphical User Interface) implements the platformspecific input and output functions of an SAP business application. The SAP GUI is primarily based on the Windows Style Guide and is available for several platforms providing the same functions for each. If you have learned to use the SAP GUI on one platform, with the exception of a few small platform-specific GUI attributes, you can use the system on another platform exactly the same as before. The presentation software implements the graphical user interface using the functions provided by the relevant presentation environment. As of SAP R/3 Release 4.6B you have a choice between the “classic” SAP GUI and a number of alternative access possibilities: Ÿ SAP GUI for HTML Ÿ SAP GUI for Java™
© SAP AG
TAW10
4-9
Presentation Layer
Presentation
Workstation/PC Terminal Client
Windows PC
SAP GUI Process
Terminal Server
SAP GUI Process
Windows PC and Browser for SAP GUI for HTML
Java Environment SAP GUI
LAN / WAN Network
Application Dispatcher SAP AG 1999
n
n
n
n
The data flow between the presentation level and the application level when using the SAP GUI for Windows consists not of prepared images, but of compact, logical information about control elements and user entries (DIAG Protocol). The amount of data that must be transferred for each screen change when using the SAP GUI for Windows is typically several kB. You can also connect application servers over Wide Area Networks (WANs). For more information, see SAP Note 161053. An Internet Transaction Server is used for the SAP GUI for HTML to turn the SAP GUI data flow from the dispatcher into HTML, and conversely. In this case, an HTML data flow is exchanged between the WGate of the ITS (see the Communications and Integrations Technology unit) and the Frontend. The primary advantage of the SAP GUI for HTML is the low installation cost for the Frontend; all you need is a browser. SAP GUI for Java receives the Standard DIAG Protocol (from the dispatcher) and places this on the Frontend in HTML or, if in use by Java Plug-Ins, in a graphical format, which can, for example, be displayed in a browser. In this case the installation costs for the Frontend are equally minimal. For more information, see SAP Note 146505. For information about implementation of the SAP GUI on a Windows Terminal Client, see SAP Note 138869.
© SAP AG
TAW10
4-10
SAP Basis Database Layer Application Server
Database Server
ABAP Interpreter SELECT * FROM ...
DB Interface
Local Buffer
Data
OPEN SQL
Native SQL
Data
EXEC SQL. SELECT ... END EXEC.
Database
DB Data
Native Native SQL SQL DB Data
SAP AG 1999
n
n
n
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. The data, tables, and table relationships are defined in the database catalog (the data dictionary) of the database system. Within the ABAP programming language, you can use SAP OPEN SQL to access data in the database regardless of your database management system. The mySAP.com database interface converts Open SQL statements from ABAP statements into corresponding database statements. This means that the application programs that are written in ABAP do not depend on the database used. Furthermore, Native SQL commands can be used directly in ABAP. When interpreting Open SQL statements, the SAP database interface checks the syntax of these statements and ensures the optimal utilization of the local SAP buffers in the shared memory of the 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 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 a running system and are therefore ideally suited to buffering. The same is true of business application data, which is almost exclusively accessed as read-only and can therefore be buffered.
© SAP AG
TAW10
4-11
mySAP.com Processes
Message Server V2 Dialog D
Update
Disp.
V1 Disp.
Disp.
MS Disp.
Background 11
12
SAP Dispatcher
Lock Administration
1
10 9
2 3
8
4 7
6
5
B
Spool
E
S
Gateway Server
R/2
GW
R/3
SAP AG 1999
n
n
The operating system views the SAP runtime system as a group of parallel, cooperating processes. On each application server these processes include the dispatcher as well as work processes; the number of work processes depends on the available resources. Special work processes may be installed for dialog processing, update, background processing and spooling. In addition to these work process types (dialog processing (D), update (V: for the German "Verbuchung"), lock management (E), background processing (B), spool (S), the runtime system provides two additional services for internal and external communication (below are the restrictions on the number of work processes): Ÿ The message server (MS or M) communicates between the distributed dispatchers within a mySAP.com System and is therefore the prerequisite for scalability using several parallelprocessing application servers. Ÿ The gateway server (GW or G) allows communication between mySAP.com components such as SAP R/3 and SAP R/2 and external application systems. There is only one gateway process for each dispatcher process. Ÿ Dialog: Every dispatcher requires at least two dialog work processes Ÿ Spool: At least one for each mySAP.com System (more than one allowed for each dispatcher) Ÿ Update: At least one for each mySAP.com System (more than one allowed for each dispatcher) Ÿ Background processing: At least two for each mySAP.com System (more than one allowed for each dispatcher) Ÿ Enqueue: Only one enqueue work process is needed for each system
© SAP AG
TAW10
4-12
The Instance Concept
Instance (a)
Instance (b)
Dispatcher
...
Dispatcher
D-WP
B-WP
...
D-WP
D-WP
"Central" Instance (c)
Dispatcher
MS ...
D-WP
V-WP
E-WP
B-WP
S-WP
SAP AG 1999
n
n n n
n
n n
An instance is an administrative unit that combines mySAP.com system components providing one or more services. The services offered by an instance are started or stopped together. You use a common instance profile to set parameters for all of the components of an instance. A central mySAP.com System consists of a single instance that provides all of the necessary services. Each instance has its own SAP buffer areas. The example illustrates how a background processing server (a) and dialog server (b) are set up. These instances, which provide specific services, generally run on separate servers, but can also run on the same server, if needed. The message server provides the application servers with a central message service for internal communication (for example: trigger update, request and remove locks, or trigger background requests). The dispatchers for the individual application servers communicate through the message server that is installed once in each mySAP.com System (it is configured in the system profile files). Presentation servers can also log on to an application server through the message server. This means that you can use the message server performance database for automatic load distribution (logon load balancing).
© SAP AG
TAW10
4-13
The Dialog Work Process
Frontend: SAP GUI
Dispatcher
Work Process 1
Internal Memory
Request Queues
SAP AG 1999
n
n
n
Work Process n
Screen Processor ABAP Processor
Task Handler
...
Database Interface
Buffer Access Shared Memory
LAN / WAN Network
Rollout
Application Buffer Factory Calendar Screens ABAP Programs Tables Dictionary Objects...
Roll In Roll Area
User Context
Roll File
The following components on the application level are involved in processing a dialog request: Ÿ The dispatcher as central control process Ÿ Work process queues (administered by the dispatcher) for incoming requests. Ÿ One of the diaog work processes Ÿ Buffers in shared memory and also possibly the roll file The task handler coordinates activity within a dialog work process. It activates the screen processor or the the ABAP processor (which control the screen flow logic and process ABAP statements, respectively) and executes the roll-in and roll-out of the user context. The memory management system differentiates between main memory areas that are available exclusively to a 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 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 characterizes users (user context), such as their authorizations, administration information and additional data for the ABAP and dialog processor. It also contains data collected by the system in the preceding dialog steps in the running transaction (see slide Work Process Multiplexing and SAP Transactions). There are also additional memory areas for all processes in the shared memory for the factory calendar, screen, table, program, and other buffers.
© SAP AG
TAW10
4-14
Long-Running ABAP Programs Two Users Are Blocking Seven Dialog Work Processes with Long-Running Transactions
Dispatcher D-WP 1 1 12 1 10 2 9 3 8 4 76 5
D-WP 11 12 1 10 2 9 3 8 4 7 6 5
D-WP 11 12 1 10 2 9 3 8 4 7 6 5
D-WP
D-WP
11 1 2 1 10 2 9 3 8 4 7 6 5
11121 10 2 9 3 8 4 76 5
D-WP 1 1 12 1 10 2 9 3 8 4 76 5
D-WP
D-WP
11 12 1 10 2 9 3 8 4 7 6 5
Dialog Work Processes for Dialog Transactions SAP AG 1999
n
n
Dialog work processes should not be loaded down with long-running dialog steps, as these work processes would then not be available to other users. The remaining dialog work processes would have to handle many more users, thus considerably increasing response times. This is the reason for the parameter rdisp/max_wprun_time (default setting: 300 seconds), which sets the maximum time a dialog step is allowed to remain in a dialog work process. If this time is exceeded by more than double, the dialog step is terminated and the started transaction terminates with an error. This allows the administrator to ensure that users execute long-running actions only in the background work processes, which are designed for these types of long-running actions.
© SAP AG
TAW10
4-15
Background Processing
Dialog Server
Background Processing Server 3
Dispatcher
...
Dispatcher
D-WP
D-WP
1 11 10 9
12
B-WP
B-WP
B-WP
2
1 2 3
8
Background Scheduler (every 60 s)
4 7
...
6 5
Job
Job1
C
...
...
DB
4
XXX xxxx xxxx xxx XXX xxxx
UUU uuuu uuuu uuu
xxx uuu
xx uu
UU uuuu
uuu u
Scheduling Table SAP AG 1999
n
n
n
n
Background work processes are used for dialog-free execution of programs. They are used, for example, for periodic tasks such as reorganization or the automatic transfer of data from an external system to a mySAP.com component system. Background processing is scheduled in the form of jobs. Each job consists of one or more steps (ABAP reports, external programs or other operating system calls) that are processed sequentially. You can also set priorities (from "C" to "A") so that certain jobs are prioritized. Job processing is not generally triggered immediately (immediate start). Instead you specify a start date and time when you schedule the job. It may also be necessary to start jobs periodically, for example, system control jobs repeated on a fixed cycle. You can trigger a job start at the operating system level using the SAPEVT program. The background scheduler is responsible for automatically triggering the job at the specified time. The background scheduler is an ABAP program that regularly looks in the scheduling table for jobs to be executed and then ensures that they are executed (RDISP/BTCTIME, default 60 s).
© SAP AG
TAW10
4-16
Printing in mySAP.com Systems Triggering of print process, for example from SAP GUI: Printing a List
ABC XYZ
Spool Server
Operating System Spool
Dispatcher
...
D-WP
ABC
Spool Request
XYZ
1B ... 41 42 43 .... 0D 0A
S-W P
Output Request
LAN/WAN Printer server
Database/File System 1B ... 41 42 43 .... 0D 0A
TemSe
Operating System Spool
SAP AG 1999
n n
n
n n n
Spooling refers to the buffered transfer of data to output devices such as printers, fax devices and so on. In distributed systems, networked administration is necessary for this output. The spool mechanism in mySAP.com Systems can supply output requests to printers and external spoolers both within a local network as well as over WANs. The spool mechanism works with the local spool system on each server. Spool requests are generated in dialog mode or during background processing and are then set in the spool database with details about the output device and the print format. The data itself is stored in the TEMporary Sequential(TemSe) object database. When data is to be printed, an output request is generated for a spool request. This output request is processed by a spool work process. Once the spool work process has formatted the data for output, it returns the output request to the operating system spool system. The operating system spooler takes over the queue management and ensures that the required data is passed on to the output device.
© SAP AG
TAW10
4-17
Lock Administration in mySAP.com Systems
D-WP
E-WP
B-WP
Change Access
DB
D-WP
At Most Read Access
XXX xxxx xxxx xxx
xxx
xx
UUU uuuu uuuu uuu
uuu
uu
UU uuuu
uuu u
SAP AG 1999
n
n
n
n
The lock mechanisms present in the current rela tional database systems are not generally sufficient to handle business data objects (such as sales orders) that may affect several tables in the database. To coordinate several applications simultaneously accessing the same business object, the mySAP.com System provides its own lock management, controlled by the enqueue work process. In order for the system to execute lock requests, you must first define a lock object in the ABAP Dictionary. The lock object contains tables whose entries are to be locked. You can also have additional secondary tables using foreign key relationships (the name of a user-defined lock object must begin with "EY" or "EZ"). You can specify the lock mode ("S": shared lock or "E": exclusive lock) for a lock object. An exclusive lock (mode "E") can only be set if no other user has set a lock ("E" or "S") on the data record. The same user can request additional "E" or "S" locks within a transaction. If a lock object is activated, the system generates an ENQUEUE and a DEQUEUE function module. These function modules have the names ENQUEUE_ and DEQUEUE_, and are used in ABAP coding to lock and unlock data.
© SAP AG
TAW10
4-18
Requesting a Lock from the Enqueue WP
Enqueue Server
Dialog Server
Dispatcher
Dispatcher
...
...
D-WP
Call function 'ENQUEUE_E...'
E-WP
... Lock table in main memory
MS
SAP AG 1999
n
n
n
When a lock is requested, the system checks to determine whether the requested lock conflicts with any entries in the lock table. If there are conflicts, the lock request is rejected. The application program can then inform the user that the requested operation cannot currently be executed. The locks (enqueues) are administered by the enqueue work process using the lock table. The lock table is stored in the main memory of the server where the enqueue work process is running. In the example shown above, the dialog work process and the enqueue work processes are not located on the same application server, they communicate through the message server. Locks set by an application program are either reset by the application program itself, or using a special update program (second part of the SAP Logical Unit of Work). Locks, which are inherited in this way by an update work process, are also written to a file at operating system level. In transaction SM12, the locks held by the update program are colored blue, while the locks held in the dialog work process are colored black.
© SAP AG
TAW10
4-19
Work Process Multiplexing and SAP Transactions
Dialog WP 0
PBO 100
PAI
PBO
Screen 100
PAI
Screen
PAI PBO 100 105
Dialog WP 1
User Chooses:
Save / Cancel Screen 105
Dialog WP 2
PBO
PAI
Screen 110
PAI PBO 105 110
PBO
PAI 110
SAP AG 1999
n
n
n
n
Business transactions are processing units with related functions; these transactions execute consistent database changes meaningful for the business. Typical examples are credit and debit postings, which only make sense together, or creating an order and reserving the material concerned. Accordingly, an SAP transaction is implemented as a series of consistent, connected dialog steps. A user dialog step is represented by a screen (or a dynpro, which is a dynamic program = mask and flow logic). SAP transactions are not necessarily executed within one single dialog work process. In fact, the individual dialog steps of a transaction can be processed by various dialog work processes (work process multiplexing, which only exists for dialog work processes). Using asynchronous update, the dialog part of the transaction and the associated database update can also be run in different work process types or even on different servers. From the system’s point of view, a dialog step begins with the processing of a piece of data entered by the user (Process after Input (PAI) and the preparation and sending of the next screen template (Process before Output (PBO); after this, the screen that has been filled out by the user is once again accepted, and in turn the input data contained in the received screen is analyzed and processed. System and user dialog steps are processed alternately. The two parts of the dialog step from the system’s point of view are called PBO and PAI.
© SAP AG
TAW10
4-20
Technical Structure of an SAP System: Summary
You are now able to l Describe the data structure of SAP systems l Name various types of SAP GUI l Represent the basic structure of a mySAP.com system l Explain the relationships between the processes on the different client/server layers in SAP Systems (for example, R/3)
SAP AG 2003
© SAP AG
TAW10
4-21
Cross-System Concepts
Contents: l Organizational units and master data l Transactions and documents l Workflow
SAP AG 2003
© SAP AG
TAW10
5-1
Enterprise Structure: Terminology SAP SAP Enterprise
Company
Client Company Code
Subsidiary
Plant
Factory Sales Organization Department
Division
Business Area
Sales Organization Division Storage Locations
Warehouses SAP AG 2003
n n
The structure of an enterprise is mapped to SAP applications by organizational units. Organizational units summarize specific corporate functions. Organizational units can belong to a single application (a sales organization can belong to Sales and Distribution, for example) or they be assigned to several applications (a factory can be assigned to Materials Management and Production Planning, for example).
© SAP AG
TAW10
5-2
Enterprise Structures: Tiers SAP Client
Ides Holding
Germany
Company Code
U.S.A.
Plant Hamburg 1000
0001
Berlin 1100
Dresden 1200
0002
0003
Storage Location
SAP AG 2003
n
n
n
The client is the superior element of all organizational units. A client corresponds to a group with several subsidiaries. All company data in an R/3 installation are differentiated at least by client, but usually also by deeper organizational structures. Flexible organizational elements in the R/3 System mean you also have the option of mapping complex enterprise structures. Many organizational units are used to represent the legal and organizational structure of an enterprise from different points of view. The various enterprise areas are joined by linking the organizational units together and the structure of the total enterprise is represented in the R/3 System.
© SAP AG
TAW10
5-3
Master Data: Customer Master General Data Name Address Language...
Client
Financial Accounting Data Data Payment Parameters G/L Account Dunning.
Company Code
Sales Data Data Sales/Shipping Billing Parameter Partner
Customer Master Record
Sales Area
Storage Location SAP AG 2003
n n n
n
Master data are data records that remain in the database for a long period of time. Master data include customers, suppliers, materials, accounts and so on. Master data are created centrally (for all applications) . Master data have an organizational aspect. They are assigned to organizational units. A customer master record can be assigned to the following organizational units: company code, sales organization, distribution channel and division. Master data can be used for all modules. For example, customer master data have common data for accounting and sales.
© SAP AG
TAW10
5-4
Master Data: Material Master Material Number Short Text, Volume, Weight Basic Unit of Measure ... Delivering Plant Control Types Sales Unit ...
Material Master Record
Valuation Forecast Planning Parameters Purchasing Parameters ... Requirements Planning Parameters Inventory Management Physical Inventory ...
Client
Sales Organization Distribution Channel
Plant
Storage Location
SAP AG 2003
n n
The material master is the central source for a company to display material-specific data. It is used by all components of the SAP logistics system. The data in the material master can be used by all areas such as purchasing, inventory management, materials planning, invoice verification and so on.
© SAP AG
TAW10
5-5
Material Master: Database Conversion
MARA
MAKT
MARC
MARM
MVKE
MLAN
MEAN
MBEW
MLGN MLGT
MARD
MVER
MAPR
SAP AG 2003
n
The individual tables contain the following data: MARA General data MAKT Short texts MARM Conversion factors MVKE Sales data for each sales organization MLAN Sales data for each country MEAN EAN data MBEW Valuation data MARC Material data for each plant MLGN Material data for each LVS warehouse MLGT Material data for each LVS storage type MARD Material data for each storage location MVER Consumption data MAPR Forecast data (indicators)
© SAP AG
TAW10
5-6
Transaction: Using Master Data and Organizational Units
Company Code Sales Document Customer Master Record
Customer: 1000
Item
Material Master Record
Material Quantity
10
HD-1300
1
20
P-103
2
Sales Organization
Distribution Channel
Division
SAP AG 2003
n
n
n
n n
When a customer order is created, the transport agreements, terms of delivery and payment and so on agreed with the business partner must be considered. So that you don't have to enter this information for each activity connected with the business partner, the data that are relevant for the activity are copied from the business partner's material master. The information stored in the material master record (price per unit of measure, stock per storage location and so on) are processed in the order entry. This principle applies to processing the data from any master record involved in the activity. The relevant organization units must be assigned when a transaction is executed. This ensures that the assignments to the company structure are retained in the document that is created, in addition to the information stored for the customer and the material. A document is created for each transaction that is executed in the R/3 System. The document that is created from a transaction implicitly contains all of the default features for the master data and organizational units.
© SAP AG
TAW10
5-7
Message Type
Invoice
Immediately (creating orders)
Invoice
Invoice
On request (printing activity)
With next selection run or at a specified time (scheduling)
Messages Message type
Online (screen output)
Printer
Telefax
E-mail
EDI
SAP AG 2003
n
n
n
Whenever you save a query, an order, an outline agreement, a inquiry confirmation, a delivery note and so on, an output format is created from the document concerned. This output format is a message (message type). The message is then placed in the message queue, from where it can be released for printing, output via EDI and so on as required. The message is released either manually or automatically using a message control program. You can use the various send media to output individual messages during processing, provided that the corresponding message types and send media were assigned in Customizing. For each document type, you can define when and how the messages are sent. The message control can be stored as a default value in the business partner's master record.
© SAP AG
TAW10
5-8
SAP Business Workflow Leave form created
Decision
Employee Employee
Leave form processed
Dates not approved
Decision
Form changed
Form rejected
Decision
Supervisor Supervisor
Dates approved
Dates approved
Workflow completed SAP AG 2003
n n n
The SAP Business Workflow is a tool that you can use to optimize the flow of business transactions. It can execute consecutive work steps automatically, or coordinate the flow of information. Workflows control processes according to a predefined model and are particularly suitable for organizations that are structured and based on the principle of division of labor. Workflow brings the "right" work in the "right" sequence to the "right" persons at the "right" time. This can be done using an automated mail or a workflow item.
© SAP AG
TAW10
5-9
System-Wide Concepts: Unit Summary
You are now able to l Name the main elements in a business scenario l Describe the link between the main elements in a business scenario
SAP AG 2003
© SAP AG
TAW10
5-10
Complex: ABAP Workbench Fundamentals
SAP AG 2003
© SAP AG
TAW10
6-1
Course Content: ABAP Workbench Fundamentals (1)
Unit
ABAP Program Process
Unit
Data Retrieval
Unit
Introduction to the ABAP Workbench
Unit
Program-internal Modularization with Subroutines
Unit
Introduction to the ABAP Dictionary
Unit
The ABAP Runtime System
Basic ABAP Language Elements
Unit
User Dialog List
Unit
SAP AG 2003
© SAP AG
TAW10
6-2
Course Contents: ABAP Workbench Fundamentals (2)
Unit
User Dialog Selection Screen
Unit
User Dialog Screen
Unit
Global Modularization
Unit
Calling Programs and Transferring Data
Appendi x
SAP AG 2003
© SAP AG
TAW10
6-3
Main Business Scenario
Departure airport
Destination airport In this course, you will develop several programs designed to assist travel agencies. Some of their typical needs include: l
Departure city
Determining flight connections on specific dates Processing bookings for specific flights l Evaluating additional flight information, such as l Price l Capacity l
Destination city SAP AG 2001
© SAP AG
TAW10
6-4
Important Database Tables for the Flight Data Model SCARR
CARRID: CARRNAME: CURRCODE:
Airline ID Airline name Local currency of airline
SPFLI
CARRID: CONNID: COUNTRYFR: CITYFROM: AIRPFROM: COUNTRYTO: CITYTO: AIRPTO:
Airline ID Flight connection ID Country key for departure city Departure city Departure airport Country key for arrival city Destination city Destination airport
SFLIGHT
CARRID: CONNID: FLDATE: PRICE: CURRENCY: SEATSMAX: SEATSOCC:
Airline ID Flight connection ID Flight date Price Currency Maximum number of seats on flight Current number of occupied seats on flight
SAP AG 2001
You will refer to this information as you do the exercises throughout this course.
© SAP AG
TAW10
6-5
ABAP Program Process
Contents: l System Architecture and ABAP Program l Example Program with Selection Screen and List
SAP AG 2003
© SAP AG
TAW10
7-1
Program Flow of an ABAP Program: Unit Objectives
At the conclusion of this unit, you will be able to: l Describe the architecture of the R/3 System l Describe how to execute a simple dialog program using the ABAP runtime system
SAP AG 2001
© SAP AG
TAW10
7-2
System Architecture and ABAP Program
System System Architecture Architecture and and ABAP ABAP Program Program Example Example Program Program with with Selection Selection Screen Screen and and List List
SAP AG 2003
© SAP AG
TAW10
7-3
Client/Server Architecture
Presentation Server Layer
SAPGUI
SAPGUI
SAPGUI
Dispatcher
Application Server Layer
Database
SAPGUI
SAPGUI
SAPGUI
Dispatcher
Work Process
Work Process
Work Process
Work Process
Work Process
Work Process
Work Process
Work Process
SAP AG 2001
n
The R/3 System has a modular software architecture that follows software -oriented client/server principles.
n
The R/3 System allocates the presentation, application logic, and data storage to different computers. This serves as the basis for the scalability of the R/3 System.
n
The lowest level is the database level. Here data is managed with a relational database management system (RDBMS). In addition to application data, the database contains the programs and the metadata that the R/3 System requires for self-management.
n
ABAP programs (both the applications provided by SAP and the ones you develop yourself) run at the application server level. The ABAP programs read data from the database level, process the data, and possibly store data there.
n
The presentation server level contains the user interface through which each user can access the program, enter new data, and display the results of a work process.
n
The technical distribution of software is independent of its physical location on the hardware. All levels can be installed vertically (on top of each other on one computer) or each level can be installed on a separate computer. The presentation and application servers can be divided horizontally among any number of computers. The horizontal distribution of database components, however, depends on the type of database installed.
© SAP AG
TAW10
7-4
Excerpt for an ABAP Program
Presentation Server Layer
Work Process
Application Server Layer
ABAP Program
Database
SAP AG 2001
n
This graphic can be simplified for most topics discussed during this course. The interaction between a single user and a single ABAP program will be of primary interest to us during this course.
n
The exact processes involved in user dispatching on an application server are secondary to understanding how to write an ABAP program. Therefore, we will work with a simplified graphic that does not explicitly show the dispatcher and the work process. Certain slides will, however, include these details whenever they are relevant to ABAP programming.
n
ABAP programs are processed on the application server. The design of user dialogs and database dialogs is, therefore, of particular importance when writing application programs.
© SAP AG
TAW10
7-5
View for the User
Presentation Server Layer
Application Server Layer
Screen
Selection Screen
List
Black Box
Database
SAP AG 2001
n
Most users are only interested in how a business transaction flows and how to enter data into and display data from a transaction. The technical aspects of programming are less interesting. 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."
n
Technically speaking, there are three different types of screens: dynamic screens or dynpros, selection screens, and lists. Each type of screen provides different services. The developer’s task is to select for each user dialog exactly those types that are most suitable for the accomplishment of the tasks concerned. For this reason, developers should have precise knowledge of the technical aspects.
© SAP AG
TAW10
7-6
Interaction Between Server Layers
Program Start
ABAP Program ABAP Processing Block
Database Table ABAP Processing Block
ABAP Runtime System SAP AG 2001
Time
n
Once the user performs a user action (selecting Enter, a function key, a menu function or a pushbutton, for example), control is passed from the presentation server to the application server.
n
Only certain parts of the ABAP program are processed.
n
If a further user dialog is triggered from within the ABAP program, the system transmits the screen and passes control once again to the presentation server.
© SAP AG
TAW10
7-7
Example Program with Selection Screen and List
System System Architecture Architecture and and ABAP ABAP Program Program Example Example Program Program with with Selection Selection Screen Screen and and List List
SAP AG 2003
© SAP AG
TAW10
7-8
Program Start
Program Start
Repository
Database Table
SAP AG 2001
n
Time
Whenever a user logs on to the system, a screen is displayed. From this screen, the user can start an ABAP program via a menu path or by entering a transaction code.
© SAP AG
TAW10
7-9
System Loads Program Context
Program Start
ABAP Program
Repository
Selection Screen Data Objects
Database Table ABAP Processing Block
ABAP Runtime System SAP AG 2001
Time
n
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 the program information from the Repository, which is a special part of the database.
n
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 that is used to display the data is created dynamically at run time.
n
The ABAP runtime system controls the subsequent program flow.
© SAP AG
TAW10
7-10
Runtime System Sends Selection Screen
Program Start
ABAP Program
Repository
Data Objects
Database Table ABAP Processing Block
ABAP Runtime System SAP AG 2001
n
n
Time
Because 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 enters data in the input fields. Selection screens allow users to enter selection criteria required by the program.
© SAP AG
TAW10
7-11
Input Values Are Inserted into Data Objects
Program Start
ABAP Program
Repository
Data Objects
Database Table ABAP Processing Block
ABAP Runtime System SAP AG 2001
n n n n
Time
As soon as the user has finished entering data on the selection screen, he or she can trigger further processing of the program by selecting 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, an error message is triggered automatically. The user must correct the entries.
© SAP AG
TAW10
7-12
Program Requests Data Record from Database
Program Start
ABAP Program
Repository
Data Objects
Database Table ABAP Processing Block
ABAP Runtime System SAP AG 2001
n
Time
Within the ABAP processing block, a read access to the database is programmed. The program passes to the database information about which database table to access and which line in the table to read.
© SAP AG
TAW10
7-13
Database Returns Data Record to Program
Program Start
ABAP Program
Repository
Data Objects
Database Table ABAP Processing Block
ABAP Runtime System SAP AG 2001
n n
Time
The database returns the requested data record to the program and the runtime system ensures that this data is stored in the appropriate data objects. If a single record is accessed, this data object is usually a structure that contains components for all the required database fields.
© SAP AG
TAW10
7-14
Runtime System Sends List
Program Start
ABAP Program
Repository
Data Objects
Database Table ABAP Processing Block
ABAP Runtime System SAP AG 2001
n
Time
The layout of the subsequent list display was also programmed into the processing block. After completion, the runtime program sends this list as a screen to the presentation server.
© SAP AG
TAW10
7-15
Program Flow of an ABAP Program: Unit Summary
You are now able to: l Describe in basic terms the architecture of the R/3 System l Describe in basic terms the execution of a simple dialog program using the ABAP runtime system
SAP AG 2001
© SAP AG
TAW10
7-16
Introduction to the ABAP Workbench
Contents: l Introduction to the R/3 Repository l Working with the Object Navigator l Organizing Developments l Developing an ABAP Program
SAP AG 2001
© SAP AG
TAW10
8-1
Introduction to the ABAP Workbench: Unit Objectives
At the conclusion of this unit, you will be able to: l Describe the structure of the R/3 Repository and its search tools l Use the Object Navigator for your development work l Name and use the utilities for orderly software development l Create development classes, ABAP programs, and transaction codes
SAP AG 2001
© SAP AG
TAW10
8-2
Introduction to the R/3 Repository
Introduction Introduction to to the the R/3 R/3 Repository Repository Working Working with with the the Object Object Navigator Navigator Organizing Organizing Developments Developments Developing Developing ABAP ABAP Programs Programs
SAP AG 2001
© SAP AG
TAW10
8-3
The R/3 Repository
Presentation Server Layer
Application Server Layer
ABAP Program
Cross-client
Database
Client-specific
Repository
Customizing tables Application tables
SAP AG 2001
n n n
n
The database contains application and Customizing tables that are usually client-specific. The database also contains the R/3 Repository. The ABAP Dictionary is part of the R/3 Repository. The R/3 Repository contains all the development objects, for example, programs, definitions of database tables, or central data type definitions. Development objects are therefore also known as Repository objects. Repository objects are never client-specific; therefore, they can be viewed and used in all clients.
© SAP AG
TAW10
8-4
Structure of the R/3 Repository
Repository Objects FI
HR
MM
SD
WM MM
MM MM Cust.
Development Classes Function Modules Programs Tables ... SAP AG 2001
n n n n
The R/3 Repository is subdivided according to application components. Each application component is further divided into logical subdivisions called development classes. Repository objects are often made up of sub-objects that are themselves Repository objects. When you create a Repository object, you must assign it to a development class.
© SAP AG
TAW10
8-5
SAP Application Hierarchy SAP
0 + 0 + 0 +
+ 0 + 0 0 +
CA AC FI
Cross-Application Components Accounting - General Financial Accounting ... FBAS Financial Accounting Basis ... FI-GL General Ledger Acctg 0 + 0 + FI-LC Consolidation ... TR Treasury CO Controlling ...
Application component
Information System
Development class Selected subtree
SAP AG 2001
n
n n
The structure of the application components is shown in the application hierarchy. From the SAP Easy Access menu, you access the application hierarchy by choosing Tools → ABAP Workbench → Overview → Application Hierarchy. The application components are displayed in a tree structure in the application hierarchy. Expanding a component displays all the development classes that are assigned to that component. You can select a subtree or branch and navigate from the application hierarchy to the R/3 Repository Information System. The system then collects all development classes for the branch selected and passes them to the Repository Information System.
© SAP AG
TAW10
8-6
R/3 Repository Information System Repository Information System Business engineering ABAP Dictionary Basic objects Database tables Views Data elements Structures Table types ... Other objects Fields Programming Function Builder Program Library Prog. environment Program sub-objects ABAP objects Class library Components of classes Components of interfaces Environment SAP AG 2001
n n
You can use the Repository Information System to search for specific Repository objects. Suitable search criteria are available for the various Repository objects. Which objects are to be found using the Repository Information System depends on how you get there: Ÿ From within the application hierachy, select the Information system (double-click the selected application component or development class). This filters the the respective Repository objects. Ÿ From the SAP Easy Access menu, choose Tools→ ABAP Workbench → Overview → Information system. The system lists all the Repository Objects available for searching.
© SAP AG
TAW10
8-7
Working With the Object Navigator
Introduction Introduction to to the the R/3 R/3 Repository Repository Working Working with with the the Object Object Navigator Navigator Organizing Organizing Developments Developments Developing Developing ABAP ABAP Programs Programs
SAP AG 2001
© SAP AG
TAW10
8-8
ABAP Workbench Tools
Debugger
Screen Painter Menu Painter FI
HR
MM
SD
WM
Object Navigator
MM Cust.
ABAP Editor
ABAP Dictionary Function Builder Class Builder
SAP AG 2001
n
n n n n n n n
The ABAP Workbench contains different tools for editing Repository objects. These tools can be used throughout the entire software development cycle. The most important tools for creating and editing Repository objects are as follows: The ABAP Editor for editing source text The ABAP Dictionary for processing database table definitions, central data types, and more The Screen Painter for configuring screens (screens with functions for user dialogs) Menu Painter for designing the user interface (menu bar, standard toolbar, application toolbar) (see Interfaces) The Function Builder for processing function modules The Class Builder for processing central classes You can start these tools in three ways: Ÿ Directly from the Easy Access menu. Ÿ Using the Object Navigator. This has a tree diagram of all objects within a development class or program. Double -click on an object to start the respective tool. Ÿ By double-clicking from one tool to the next, and back again.
© SAP AG
TAW10
8-9
Screen Structure in the Object Navigator Full screen on/off
Tool area
Navigation area Right-click
Right-click
Context menu
Context menu
Size of display area can be changed
SAP AG 2001
n
n n
The Object Navigator screen is divided into two areas: Ÿ A navigation area for displaying an object list as a hierarchy tree Ÿ A tool area for displaying and editing a development object using the correct tool You can display or hide the hierarchy area. You can select functions from a context menu in both screen areas. You are given a choice of only those functions that are provided for displaying or editing the object to which you are pointing. Right-click on the object to open the context menu.
© SAP AG
TAW10
8-10
Working with the Navigation Area Application Hierarchy Development Class Program Function Group Class / Interface Internet Service Local Objects
Development Class BC400 Display higher-level object list
Use of navigation history
Refresh object list
BC400
Favorites
Dictionary objects Programs SAPBC400WBD_GETTING_STA SAPBC400WBT_GETTING_STA Function groups BC400 Classes CL_BC400
Double-click on a Repository object with subobjects: List of subobjects
SAP AG 2001
n
n n n n n
The Repository objects are organized in a hierarchy: Ÿ An application component can have different development classes. Ÿ A development class can contain different Repository objects: programs, function groups, ABAP Dictionary objects, and so on. Ÿ Each Repository object can have different subobjects assigned to it: - Subobjects belonging to a program: global data, types, events, subprograms, and so on - Subobjects belonging to a function group: global data, function modules, and so on You can enter the type of object list and the object name in the upper part of the navigation area. The object list is then displayed in the navigation area. To display the subobjects, double -click an object within the object list. If an object is not in an object list, you can display it by using the respective tool in the tool area. You can navigate between object lists either by either history or hierarchy. You can add object lists that you edit frequently to your favorites.
© SAP AG
TAW10
8-11
Navigation in the Tool Area
Functions of the current tool
Show navigation window
Use of navigation history
Navigation stack
Hide navigation window
SAP AG 2001
n n
In the tool area, you can display a window showing your navigation history, that is, a list of the objects you have displayed since you started the Object Navigator in the tool area. The object currently displayed in the tool area is highlighted in a different color.
© SAP AG
TAW10
8-12
Synchronization of Navigation and Tool Areas
Display object list
Double-click on a Repository object without subobjects or choose context menu: Display/change in tool area Display Change ...
SAP AG 2001
n n
n
Navigation in the navigation area is logically independent from navigation in the tool area. This allows for screens to be used in a flexible manner. If you wish, you can synchronize the two areas: Ÿ You can display an object in the tool area by double -clicking it, or by selecting the context menu from within the navigation area. The system automatically selects the appropriate tool for processing the object you selected. Ÿ To display the object list that belongs to an object you are currently processing in the tool area, choose Display object list. To create objects from an object list, you can use the context menu for that object type. If there is no entry in the object list for the required object type, you can create any number of objects using Edit object or Other object.
© SAP AG
TAW10
8-13
Organizing Developments
Introduction Introduction to to the the R/3 R/3 Repository Repository Working Working with with the the Object Object Navigator Navigator Organizing Organizing Developments Developments Developing Developing ABAP ABAP Programs Programs
SAP AG 2001
© SAP AG
TAW10
8-14
Transporting Repository Objects
Change Request
FI
HR
MM FI
SD
HR
MM
WM MM
SD Cust.
WM MM Cust.
Development System
Production System
SAP AG 2001
n n n n
Development projects are always implemented in a development system and then transported to the next system. Repository objects are automatically assigned to a transport route based on their belonging to a particular development class and on their actual function. A decisive criterion for combining the development projects is, therefore, which Repository objects need to be transported together because of their dependencies. You schedule the group transport of the Repository objects using a change request.
© SAP AG
TAW10
8-15
Scheduling a Development Project Schedule:
Monday
...
Friday Request is released
Locking Objects for for NonNon-Project Members Members Project Manager: FRY Team: FRY BC400-00 BC400-01 BC400-02 BC400-03 ...
SAP AG 2001
n n n n
n
Scheduling a development project using a change request covers the following aspects: All employees in the project start their work on a defined date. Employees have the chance to follow up and check their activities separately. The respective Repository objects can be processed by all employees involved in the project. For those developers who do not belong to the team, the Repository objects remain locked until the project is completed. The group triggers the transport of all the respective Repository objects.
© SAP AG
TAW10
8-16
Project Representation in the Workbench Organizer
Project Manager: FRY Team:
Workbench Organizer: Change Requests Change requests involving user BC400-00
FRY BC400-00 BC400-01 BC400-02 BC400-03
Project Manager
Changeable
Request number
Transportable
User
IT3K900051 CARSON
Task number
IT3K900052 CARSON IT3K900053 BC400-00
Repository objects created or corrected by employee
Report source ZBC400_00_FLIGHTLIST ABAP program IT3K900054 BC400-01
...
IT3K900055 BC400-02 IT3K900056 BC400-03 IT3K900057
...
SAP AG 2001
n
n
n
At the beginning of a development project, the project manager creates a change request in the Workbench Organizer. The project manager assigns all project team members to the change request. The Workbench Organizer then creates a task for each project developer. From now on, whenever an employee assigns a Repository object to this change request, the Repository object is automatically entered in the employee's task. Thus all Repository objects that an employee works on during a development project are collected within his or her task folder. The Repository objects are therefore locked for all developers who do not belong to this particular project. Unlike the logical functional divisions that separate Repository objects through the respective development class, change requests are project-related and, therefore, are limited to the time schedule involved. Thus, although a program always belongs to only one development class, it can belong to different change requests at different times.
© SAP AG
TAW10
8-17
Example: Creating Development Classes
Comply with customer namespace
Create Development Class ZBC400_00
Development Class Short Text
Exercises group 00 Where should the development objects be transported to?
Transport Layer Person Responsible
ZDEV
Software Component
HOME CA
Application Component
BC400-00
To which application component does the development class belong?
SAP AG 2001
n
You can create a development class in the Object Navigator. Ÿ As of Release 4.6C, you can choose the object type Development Class and enter the name of the development class in the input field. Make sure you comply with the customer namespace conventions. If the development class does not already exist, the system displays the Create Development Class dialog box. Ÿ For Release 4.6A and 4.6B, you must choose Edit object or Other object in the initial screen. Enter the name of the development class in the input field on Other tab page.
n
You should check the settings for the following attributes: Ÿ Transport layer - If you carry out your own developments, you must set up a transport layer for customer developments. Ÿ Person responsible - This person has full responsibility for the objects in this development class. The system automatically uses this user name as a default value. Ÿ Software component - For customer developments you should enter HOME as the software component. To get detailed information on the field, select F1 help. Ÿ Application component - Used to specify the location of the development class within the application hierarchy.
© SAP AG
TAW10
8-18
Assignment to a Change Request Prompt for transportable Workbench request Development class/p..
ZBC400_00
Request
IT3K90051
Workbench request
Exercises for participants of BC400
My requests
Prompt for transportable Workbench request Change requests involving user BC400-00
Double-click request number
Changeable Transportable IT3K900051 FRY IT3K900052 FRY IT3K900053 BC400-00 IT3K900054 BC400-01
SAP AG 2001
n
n n
All Repository objects that are created or changed must be assigned to the change request of the respective project. For this course, the trainer has created a change request for the project called "Exercises for Participants of BC400". Each group has a task within this change request. To display all change requests in which you have a task, select Own requests. When you assign all Repository objects (development classes, programs, and so on) to this change request, the system takes care of the exact assignment for your task.
© SAP AG
TAW10
8-19
Developing ABAP Programs
Introduction Introduction to to the the R/3 R/3 Repository Repository Working Working with with the the Object Object Navigator Navigator Organizing Organizing Developments Developments Developing Developing ABAP ABAP Programs Programs
SAP AG 2001
© SAP AG
TAW10
8-20
Features of the ABAP Programming Language
The ABAP programming language ... l Has defined types l Enables multi-language applications l Has SQL embedded within it l Has been enhanced as an object-oriented language l Is platform-independent l Is downwards compatible
Therefore, it is designed for dialog-based, business applications.
SAP AG 2001
n n n n n n
To support data processing by types, ABAP contains a systematic type hierarchy. 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 runtime system is one of the R/3 Basis components and is platform-independent. ABAP continues to evolve from release to release. If an old syntax statement is replaced by a better one, you can still run the old statement.
© SAP AG
TAW10
8-21
General ABAP Syntax I
ABAP keyword keyword
Additions and operands (dependent on keywords)
Period as symbol for closing the the ABAP statement
DATA DATA wa_scarr TYPE scarr.. START-OF-SELECTION. STARTSTART - OF OF-SELECTION. SELECT * FROM scarr INTO CORRESPONDING FIELDS OF wa_scarr.. NEW-LINE. NEWNEW -LINE. WRITE wa_scarr-carrid.. WRITE WRITE WRITE wa_scarr-carrname.. WRITE wa_scarr-url.. WRITE ENDSELECT. ENDSELECT.
SAP AG 2001
n n n n n n n n
n
ABAP programs consist up of individual statements. Each statement ends with a period. The first word in a statement is called a keyword. Words must always be separated by at least one space. Statements can be indented. Statements can take up more than one line. A single line can contain multiple statements. The ABAP runtime system is not case sensitive; that is, it does not distinguish between lowercase and uppercase letters for keywords, additions, and operands. To make it easier to separate them visually, in this course all keywords and their additions are in uppercase and all operands are in lowercase. For indentations and for converting uppercase and lowercase letters, use the Pretty Painter function. Choose Utilities → Settings → ABAP Editor → Pretty Printer
© SAP AG
TAW10
8-22
General ABAP Syntax II
** comments ... ** comments ... ** comments ...
Comments
DATA wa_scarr TYPE scarr. START-OF-SELECTION. " comments ... SELECT * FROM scarr INTO CORRESPONDING FIELDS OF wa_scarr. NEW-LINE. WRITE : wa_scarr-carrid, , wa_scarr-carrname, , wa_scarr-url..
Chained Statement
ENDSELECT.
SAP AG 2001
n n
Use an asterisk (*) to introduce comment lines. The ABAP runtime system ignores the comment line. If you want to enter a comment in the middle of a started line, enter double quotes.You can combine consecutive statements with an identical beginning into a single chained statement: Ÿ Close the identical beginning part with a colon. Ÿ Separate individual elements that come after the colon by commas. Ÿ Use blank spaces and line breaks before and after the separators (colons, commas, and periods). Ÿ The ABAP runtime system considers the individual parts of a chained statement to be single statements.
© SAP AG
TAW10
8-23
Return Value After ABAP Statements
PARAMETERS pa_carr TYPE scarr-carrid. DATA wa_scarr TYPE scarr. START-OF-SELECTION. SELECT SINGLE * FROM scarr INTO CORRESPONDING FIELDS OF wa_scarr WHERE carrid = pa_carr. IF sy sy-subrc - subrc EQ 0. NEW-LINE. WRITE: wa_scarr-carrid, wa_scarr-carrname, wa_scarr-url. ELSE. WRITE 'Sorry, no data found!'. ENDIF.
SAP AG 2001
n n n
With several ABAP statements, the ABAP runtime system writes a return code into the system field sy-subrc to indicate how successfully the statement was executed The return code zero (0) means that the statement was successful.. Read the documentation for the respective statements to find out whether and how this return code is set in individual cases.
© SAP AG
TAW10
8-24
Creating an ABAP Program Create Program Program
ZBC400_00_GS
With TOP Include
Comply with customer namespace! ABAP: Program Attributes ... Title
...
Attributes Type Status
Executable program Test program
Application Fixed point arithmetic
SAP AG 2001
n
n n n
From the Object Navigator, you can create a program using one of the following options: Ÿ In the navigation area, choose Program as the object type and enter a program name. Be sure to comply with the customer namespace conventions. If the program does not exist, the system displays the dialog sequence that lets you create a program. (This procedure is possible only as of Release 4.6C.) Ÿ Display the development class for which you want to create the program. Start the dialog sequence for creating a program using the development class context menu or the Program node. Ÿ Select Other object... or Edit object. Select the Program objects tab and enter the name. Select Create. In this course, deselect With Top Include (by removing the check mark from the checkbox). (If you don’t do this, your source text would be distributed to several programs.) Change the title to a meaningful short text. Choose Test program as the program status for all ABAP courses.
© SAP AG
TAW10
8-25
Keyword Documentation in the ABAP Editor
i Help START-OF-SELECTION. SELECT SINGLE * FROM scarr Editor Help INTO wa_scarr ABAP Overview WHERE carrid = pa_car. ABAP Term WRITE IF sy-subrc = 0. ABAP News MOVE-CORRESPONDING wa_scarr ABAP Docu and Examples TO sbc400_carrier. Keyword CALL SCREEN 100. Documentation MOVE-CORRESPONDING sbc400_carrier
WRITE WRITE:
F1 TO wa_scarr. wa_scarr-carrid, wa_scarr-carrname, wa_scarr-currcode.
ENDIF. SAP AG 2001
n
n
You can locate keyword documentation for an ABAP statement by: Ÿ Pointing to a statement and selecting F1 to go directly to the documentation for the statement Ÿ Selecting Information to go to a selection window for the various views of the keyword documentation. Choose Help → SAP Library → BC Basis Components to access extensive online documentation on all the tools and topics that relate to the ABAP Workbench.
© SAP AG
TAW10
8-26
Inactive and Active Development Objects Saved, for development and testing Activate Program 1, inactive version
Actively integrated, for system-wide usage Program 1, active version Program 2, active version
Program 3, inactive version
Program 3, active version
SAP AG 2001
n n
n n
Whenever you create a development object, or change and then save it, the system stores an inactive version only in the R/3 Repository. Before a Repository object is available on a system-wide basis, it must first be available as an active version. This active version of your program will be used whenever a user wants to execute your program. If your program is available in both versions, you can switch from one version to the other in display mode. Whenever you activate a program, the system first displays a list of all inactive objects that you have processed. This is called the worklist. If you continue to activate the program, the following happens: Ÿ The system saves the program, that is, it stores or overwrites the inactive version. Ÿ The system performs a syntax check. Ÿ The system stores the active version or overwrites it.
© SAP AG
TAW10
8-27
Generating Runtime Objects
saved,
actively integrated,
for development/testing
for system-wide usage Program 1, active version Program 2, active version
Program 3, inactive version
Program 3, active version Generate (automatically)
Generate (automatically)
For system-wide usage Program 3, temporary generated version
Program 3, generated version version
SAP AG 2001
n
When you generate a development object, the system creates (compiles) a separate runtime object (LOAD) and stores it in the R/3 Repository.
n n n
This generated version is then the version that is executed (interpreted). Generation takes place automatically, but it can be triggered explicitly. If, for example, a user wants to execute your program and there is still no generated version, the system will use the active version for generation. You can, however, determine which version you want to execute: Ÿ To execute the active version, start your program from the navigation area. Ÿ To execute the inactive version, test an executable program from the ABAP Editor. The system temporarily creates a generated version. In this way, development can continue without changing the current system status . All changes to the development object become visible system wide only when the program is activated again. With inactive versions, you have a local, separate view of the R/3 Repository, which provides the basis for a local runtime system.
n
n
© SAP AG
TAW10
8-28
Creating Transaction Codes System
Help
Create Report Transaction ZBC400_00_GS
Transaction code Development class
Z00GS ZBC400_00
Transaction text
...
Program
ZBC400_00_GS
... Classification Professional User Transaction Easy Web transaction ... ...
SAP AG 2001
n n n n n n
If you want to include a program in role menus or in the Favorites in your SAP Easy Access menu, you must assign a transaction code to it. In the Object Navigator, display the object list for your program. Right-click the program name and choose Create → Transaction. Comply with the customer namespace conventions. Choose Program and Selection Screen (Report Transaction) if the program is an executable program. On the next screen, enter the name of the program. Choose Professional User Transaction. Save the transaction code. Since each transaction code is a Repository object, you must assign it to a development class and to a change request on the following screens.
© SAP AG
TAW10
8-29
Adding a Transaction Code to the SAP Easy Access Menu System
Help
SAP Easy Access Favorites Object Navigator SAP Menu Add transaction
Enter Transaction Manually Transaction code
Z00GS
SAP AG 2001
n
n
To include a transaction code in the your role menu favorites: Ÿ Display the initial screen (SAP Easy Access menu). Ÿ Choose Favorites → Insert transaction. Ÿ Enter a transaction code in the dialog box . The transaction code short text appears under the Favorites node. You can start the appropriate program from the context menu for this new node.
© SAP AG
TAW10
8-30
Introduction to the ABAP Workbench: Unit Summary
You are now able to: l Describe the structure of the R/3 Repository and its search tools l Use the Object Navigator for your development work l Name and use the utilities for orderly software development l Create development classes, ABAP programs, and transaction codes
SAP AG 2001
© SAP AG
TAW10
8-31
ABAP Workbench Exercises Unit: Introduction to the ABAP Workbench Topic: Organizing Developments At the conclusion of these exercises, you will be able to: • Create a development class • Assign changes in Repository objects to a change request
As a developer for an airline group, you are given the task of developing evaluation programs for several airline companies. To group the Repository objects together logically and transport them, you must create a development class. User name:
Will be announced by the instructor.
Development class: Change request:
ZBC400_## Will be announced by the instructor.
## stands for the two-digit group number. 1-1
Log on to the operating system and then to the specified SAP R/3 training system using the user name the instructor has given you. Enter a new personal password.
1-2
Create the development class ZBC400_##. Assign it to the change request the instructor has given you.
1-3
From now on, assign all your Repository objects in the following exercises to this development class and this change request.
© SAP AG
TAW10
8-32
Exercises Unit: Introduction to the ABAP Workbench Topic: Developing ABAP Programs At the conclusion of these exercises, you will be able to: • Create, edit, save, and process ABAP programs • Check ABAP programs for correct syntax • Test and activate ABAP programs Create an ABAP program that lists additional information on all existing flight departure times. Get the data from the database table SFLIGHT. Program:
ZBC400_##_GS_LIST
Model solution:
SAPBC400WBS_GS_LIST
## stands for the two-digit group number. 2-1
Create the executable program ZBC400_##_GS_LIST without TOP Include.
2-2
Define a work area for the data retrieval and data display (name suggestion: wa_flight): DATA wa_flight TYPE sflight.
2-3
Program a loop access to all the data records in the database table SFLIGHT: SELECT * FROM sflight INTO wa_flight. ... ENDSELECT.
2-4
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 ...
2-5
Check your program for syntax errors, test it, and activate it
© SAP AG
TAW10
8-33
Exercises Unit: Introduction to the ABAP Workbench Topic: Transaction Codes At the conclusion of these exercises, you will be able to: • Assign transaction codes to ABAP programs • Add transaction codes to your Favorites list in the SAP Easy Access menu Give your first ABAP program a transaction code, in addition to its technical name, which you use to execute it.
Transaction code: ZBC400_##_GS Program: Model solution:
ZBC400_##_GS_LIST SAPBC400WBS_GS LIST
## stands for the two-digit group number. 3-1
Create transaction code ZBC400_##_GS for the executable program ZBC400_##_GS_LIST. Initial object: program and selection screen (report transaction) Execute your program by entering the new transaction code.
3-2
Include the transaction code ZBC400_##_GS in your favorites in the SAP-EasyAccess-menu. Execute your program by double-clicking the new favorite entry. From now on, it is best if you always work with the Object Navigator. It provides you with an overview of all Repository objects in your development class. From here, you can edit each object directly by selecting it from this list.
© SAP AG
TAW10
8-34
ABAP Workbench Solutions Unit: Introduction to the ABAP Workbench Topic: Organizing Developments
1
Follow the instructions as given in the notes and figures on page 3-18 and 3-19, Creating Development Classes and Assignment to a Change Request.
Unit: Introduction to the ABAP Workbench Topic: Developing ABAP Programs
2
Model solution: 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.
© SAP AG
TAW10
8-35
Unit: Introduction to the ABAP Workbench Topic: Transaction Codes
3-1
Follow the instructions as given in the notes and figure on page 3-29, Creating Transaction Codes.
3-2
Follow the instructions as given in the notes to the figure, Adding a Transaction Code to the SAP Easy Access Menu.
© SAP AG
TAW10
8-36
Introduction to the ABAP Dictionary
Contents: l SAP Flight Data Model l Transparent Tables l Structures l Using Transparent Tables and Structures in an ABAP Program
SAP AG 2001
© SAP AG
TAW10
9-1
Introduction to the ABAP Dictionary: Unit Objectives
At the conclusion of this unit, you will be able to: l Describe the SAP flight data model l Describe the structure of a transparent table l Describe the structure of a structure l List the possible uses of transparent tables and structures in ABAP programs
SAP AG 2001
© SAP AG
TAW10
9-2
Data Modeling
Real world
Data model
ABAP Dictionary
Relational database SAP AG 2001
n n n n
In the development of business application software, the real world must be partly mapped in the form of data. An entity represents a business unit. Entities all relate to each other. The entities and relationships are contained in the data model or entity relationship model (ERM). The conversion of the table definitions and their relationships in the ABAP Dictionary are based on this data model. The actual application data is physically stored in the database itself.
© SAP AG
TAW10
9-3
Flight Data Model for ABAP Training Courses
Departure city
Departure airport
Typical inquiries at the travel agency: l Suitable airports l Suitable flight connections l Suitable flight times l Additional flight information such as: price, availability
Destination airport
Destination city
SAP AG 2001
n
n
n
n
ABAP training courses, online documentation, and ABAP keyword documentation all use the same flight data model. All Repository objects in the flight data model are located in the development class BC_DATAMODEL. This training course demonstrates one simple excerpt from this data model, which the instructor can refine if necessary. If a person wants to travel from one place to another, she asks the travel agency the following questions: Ÿ What connection offers me the best and most direct flight? Ÿ At what times are flights offered on the date when I want to travel? Ÿ How can I optimize the travel conditions to find the best solution? What is the cheapest flight, the fastest connection, the connection that gets me there closest to the time when I want to arrive? The passenger’s view differs from that of a travel agency. In the data model, which is tailored to suit management of the necessary data, all data is stored, organized by technical criteria, in tables on a central database. The amount of data stored far exceeds the demands of the passenger. As a programmer, you must be able to compile the data in programs to suit the requirements of the travel agent.
© SAP AG
TAW10
9-4
Relational Data Model BC_CARRIER T
BC_AIRPORT
Airline
Airport
T
City
H BC_PLANFLI
BC_GEOCITY T
A T
R R
A
BC_CITAIRP
T
City-airport assignment
Timetable
H BC_SFLIGHT
T
Flight
BC_CUSTOM T
BC_COUNTER T
BC_TRAVLAG T
Customer
Sales office
Travel agency
H BC_BOOKING T
R
CR
CR
Flight booking
SAP AG 2001
n
n
n
The flight data model contains entities for all business information that is logically connected, such as: Ÿ Cities Ÿ Airports Ÿ Airlines Ÿ Flights These entities all relate to each other in certain ways: Ÿ Each flight schedule contains exactly one airline, one departure airport, and one destination airport. Ÿ Bookable flights always belong to exactly one existing flight schedule each. Ÿ You can assign cities to nearby airports. You can manage all necessary data without redundancies, using these relationships. At the same time, the travel agency is able to obtain all data requested by the customer.
© SAP AG
TAW10
9-5
Converting Using Transparent Tables BC_CARRIER T
Airline
SCARR SCARR MANDT
CARRID
CARRNAME
CURRCODE
URL
H BC_PLANFLI
T
Timetable
SPFLI MANDT
CARRID CONNID
AIRPFROM
AIRPTO
DEPTIME
...
H BC_SFLIGHT
T
Flight
SFLIGHT MANDT
CARRID CONNID FLDATE SEATSMAX
SEATSOCC
...
H BC_BOOKING T
Flight booking
SBOOK SBOOK MANDT
CARRID CONNID FLDATE BOOKID
CUSTOMID
COUNTER
...
SAP AG 2001
n n n n n
A transparent table contains different columns, to allow you to manage data records in a structured way. You define transparent tables in the ABAP Dictionary. In this context, the table key is especially significant. The table key of a table combines key fields, which are also called primary key fields . The values in the key fields allow the system to identify all data records uniquely. Fields that link to other tables are called foreign key fields . With these foreign key relationships you can manage the data hierarchically and consistently.
© SAP AG
TAW10
9-6
Technical Structure of a Transparent Table Transparent table Field uses Data element uses Domain
Table including data SAP AG 2001
n n n n n
You normally use a data element to assign a type to a table field. Semantic properties, such as field labels, are stored in the data element. You normally use a domain for the technical properties. The data type, among other things, is stored in the domain. The ABAP Dictionary contains the platform-independent description of the relevant database table. The database table has the same name as the transparent table in the ABAP Dictionary. The fields also have the same names in both the database and the ABAP Dictionary.
© SAP AG
TAW10
9-7
Transparent Tables in the ABAP Dictionary
Table
Edit
Goto
Utilities
Extras
Environment
System
Help
Dictionary: Display Table Indexes Transparent table
SPFLI
Short text
Flight schedule
Attributes Fields MANDT CARRID CONNID COUNTRYFR CITYFROM AIRPFROM COUNTRYTO CITYTO ...
Fields Key ! ! !
Field type S_MANDT S_CARR_ID S_CONN_ID LAND_1 S_FROM_CIT S_FROMAIRP LAND_1 S_TO_CITY ...
Active
Currency/Quantity Fields Data type CLNT CHAR NUMC CHAR CHAR CHAR CHAR CHAR ...
Length 3 3 4 3 20 3 3 20 ...
Dec. places 0 0 0 0 0 0 0 0 ...
Short text Client for training Airline Carrier Flight connection Country key City of departure Airport of departure Country key Arrival city ...
SAP AG 2001
n n
n
The fields make up the columns of the transparent table. A check mark in the Key column indicates that the corresponding field is a key field. You normally assign a type to a field using a data element (under Field type). The Short text stored with the data element is listed here. The technical attributes of the field are listed again under Data type, Length, and Dec. places. (A data element normally uses a domain.) This is a logical view of the table. It is a purely technical description. When it is physically converted, the table is in the database, where you also find the table content or the actual application data.
© SAP AG
TAW10
9-8
Structures in the ABAP Dictionary
Structure
Edit Goto Utilities Extras Environment System Help
Dictionary: Display Structure
Structure
SBC400FOCC
Short text
Percentage Occupancy of Flights
Attributes Component CARRID CONNID FLDATE SEATSMAX SEATSOCC PERCENTAGE
Components
Active
Entry help/check
Component type S_CARR_ID S_CONN_ID S_DATE S_SEATSMAX S_SEATSMAX S_FLGHTOCC
DTyp CHAR NUMC DATS INT4 INT4 DEC
Length 3 4 8 10 10 5
Currency/quantity fields Dec. places 0 0 0 0 0 2
Short text Airline Flight connection Flight date Maximum capacity Occupied seats Flight Occupancy
SAP AG 2001
n
n
A flat structure is defined in almost the same way as a transparent table, except that you cannot convert fie lds to key fields. This would be pointless for structures. Structures do not represent a database table in the ABAP Dictionary, but are a pure type definition instead. When defining a flat structure, however, we refer to component and component type as opposed to field and field type, because, in contrast to transparent tables, you can define complex structures. This means that, it is possible to store a structure or substructure under a component name.
© SAP AG
TAW10
9-9
Using Global Structures for Data Objects
DATA wa_focc TYPE sbc400focc sbc400focc. TABLES spfli spfli. PARAMETERS pa_carr TYPE spflispfli spfli-carrid. -carrid
carrid connid fldate wa_focc L H
400 20011231
seatsmax 450
mandt carrid connid countryfr cityfrom spfli 4 0 0 A A
64 US
seatsocc
New York
percentage
180
40
airpfrom countryto ... JFK
US
...
pa_carr L H
SAP AG 2001
n n n
n n n
A structure is used to centrally provide a data type in which fields from different tables are compiled. In the ABAP program, you can define data objects using the (Dictionary) structure. A transparent table merely represents a technical description in the ABAP Dictionary. Therefore you can use it as a central data type definition, as with a structure. This means that, similarly to the data object definitions listed above, the following variants are also possible: DATA wa_spfli TYPE spfli provides a data object, typed like the line in the transparent table SPFLI. TABLES sbc400focc provides a data object, typed like the structure SBC400FOCC. PARAMETERS pa_carr TYPE sbc400focc-carrid provides an input field, typed like the CARRID component of the structure SBC400FOCC.
© SAP AG
TAW10
9-10
Using Global Structures for Dialogs TABLES spfli. Screen Painter PARAMETERS pa_carr TYPE spfli-carrid.
Dict/Program fields
Airline Performance Assistant
F1 Short description ...
Short description of the airline
ID AA AB AC AF
The field contains the ID of the airline.
Documentation
Airline American Airlines Air Berlin Air Canada Air France
Input help
SAP AG 2001
n
n n n n n
If you use an elementary structure to define an input field on a selection screen, you can use semantic attributes or technical attributes. On request, the system automatically generates a documentation dialog and an input help dialog for the user. The necessary information for this is taken from the ABAP Dictionary. The same applies to fields of transparent tables. If you use an elementary structure component to assign a type to an input/output field on a screen, you can use the same attributes as with selection screens. If you have defined a foreign key relationship, the resulting value combinations appear in the input help on the screen. If an error occurs, the system processes an automatic error dialog. The same applies to fields of transparent tables. Use the TABLES statement to define the data object for the data transport between screen and program.
© SAP AG
TAW10
9-11
Introduction to the ABAP Dictionary: Unit Summary
You are now able to: l Describe the SAP flight data model l Describe the structure of a transparent table l Describe the structure of a structure l List the possible uses of transparent tables and structures in ABAP programs
SAP AG 2001
© SAP AG
TAW10
9-12
ABAP Dictionary Exercises Unit: Introduction to the ABAP Dictionary Topic: Using Global Structures for Data Objects and Dialogs At the conclusion of these exercises, you will be able to: • Establish the technical names of data types and data objects that are used in user dialogs. • Run where-used lists within an ABAP program. You have to examine a specified ABAP program to see whether global data types are used in it, and if so, which ones.
Program:
SAPBC400WBT_GETTING_STARTED
1-1
Open the object list for development class BC400. Find the program SAPBC400WBT_GETTING_STARTED, and open its object list. Throughout the exercise, make sure that you remain in display mode.
1-2
Run the program to find out how it works.
1-3
There is an input field on the selection screen. 1-3-1
What information must you pass to the program? (Use for field help.)
1-3-2
What values can you enter? (Use for input help.)
1-3-3
What information does the program provide?
1-3-4
What is the technical name of the input field? (Use the Technical information in field help.)
© SAP AG
TAW10
9-13
1-4
Two display fields appear on the screen. 1-4-1 Find out the screen number. (Choose System → Status.) 1-4-2 What information is displayed? (Use field help.) 1-4-3 What are the technical names of the display fields? Do the fields belong to a structure with a globally defined type? (Use the Technical information in field help.)
1-5
Use the object list to analyze the source code of the program. 1-5-1 What data objects are there? Where are they defined in the program? 1-5-2 Where in the program are they used? (Use the where-used list in the ABAP Editor.) 1-5-3 What data object corresponds to the input field on the selection screen? (Search the object list for a data object with the same name as the field that you found in step 1-3-4.)
© SAP AG
TAW10
9-14
ABAP Dictionary Solutions Unit: Introduction to the ABAP Dictionary Topic: Using Global Structures for Data Objects and Dialogs 1-3
Analyzing by executing a program: 1-3-1 You need to enter an airline code. 1-3-2 The values permitted here depend on the contents of database table SCARR. 1-3-3 The program displays detailed information on the airline selected. This information is first displayed on a screen and then as a list. 1-3-4 The technical name of the input field is pa_car.
1-4
Analyzing by executing a program: 1-4-1 The screen number is 100. 1-4-2 The system again displays the airline code and the currency code. 1-4-3 The output fields are sbc400_carrier-carrid and sbc400_carriercurrcode. Double-click in the Structure field to go to the ABAP Dictionary and analyze the global type more closely.
1-5
Analyzing using the program's object list: 1-5-1 The program has the structures sbc400_carrier and wa_scarr and the elementary data object pa_car. 1-5-2 The elementary data object pa_car belongs to the input field, with the same name, on the selection screen.
© SAP AG
TAW10
9-15
Basic ABAP Language Elements
Contents: l Data Types and Data Objects l Basic ABAP Statements l Using the ABAP Debugger l Working with Structures l Working with Internal Tables
SAP AG 2001
© SAP AG
TAW10
10-1
Basic ABAP Language Elements: Unit Objectives
At the conclusion of this unit, you will be able to: l Define elementary and structured data objects l Use basic ABAP statements l Execute and analyze programs in debugging mode
SAP AG 2001
© SAP AG
TAW10
10-2
Data Types and Data Objects
Data Data Types Types and and Data Data Objects Objects Basic Basic ABAP ABAP Statements Statements Using Using the the ABAP ABAP Debugger Debugger Working Working with with Structures Structures Working Working with with Internal Internal Tables Tables
SAP AG 2001
© SAP AG
TAW10
10-3
Using Data Types Data types describe the attributes of:
ABAP program
… Input / output fields
… Data objects ace ule erf d Int n mo o ti nc Fu
Object
Interface Subroutine
Interface Method
… ... Interface parameters SAP AG 2001
n n n
The type of a data object defines its technical attributes. The type of an interface parameter defines the type of the values (actual parameters) that are transferred when the modularization unit is called. In addition to the technical attributes, the type of an input or output field can provide further information; for example, you can use it to control the value or input help.
© SAP AG
TAW10
10-4
Local and Global Data Types Local data types: Technical attributes only
Central data types: Technical and semantic attributes ABAP Dictionary
ABAP program
ace ule erf d Int n mo o ti nc Fu
Object
Interface Subroutine
Interface Method
SAP AG 2001
n n n n n n
You can define data types in an ABAP program (local, keyword TYPES) or in the ABAP Dictionary (global). Using global data types has several advantages: Global types are managed centrally and you can use them in all repository objects. This increases the consistency of the system and significantly reduces the amount of maintenance. In the ABAP Dictionary, you can perform an environment analysis (where-used list). Global data types can be linked to business variables by content, and therefore contain semantic and technical information. You can use global datat types to design screens. When searching for global data types, make sure you take both the technical and semantic attributes into account. Only then will you be able to make full use of the maintenance and robustness advantages of your program.
© SAP AG
TAW10
10-5
Defining Data Objects
Local types TYPES type_name TYPE ...
Predefined ABAP types d t i
p
f n string c xstring x
DATA do_name TYPE type_name. Global types
DATA do_name_new LIKE do_name. SAP AG 2001
n n
n
n n
You can use a predefined ABAP type, a local, or a global type to type a data object. The following predefined ABAP types are complete: Ÿ d Date (format: YYYYMMDD) Ÿ t Time (format: HHMMSS) Ÿ i Integer Ÿ f Floating point number Ÿ string String (of variable length) Ÿ xstring Byte sequence (heXadecimal string, of variable length) You must define the length for these predefined types: Ÿ c Character Ÿ n Numeric character Ÿ x Byte (heXadecimal) Ÿ p Packed number (= binary coded decimals). You must enter the number of decimal places. For more information on predefined ABAP types, refer to the keyword documentation on TYPES or DATA. You can use LIKE to refer to the type of a predefined data object.
© SAP AG
TAW10
10-6
Defining Elementary Data Objects
TYPES t_percentage(3) TYPE p DECIMALS 2. DATA: number percentage carrid connid
TYPE TYPE TYPE TYPE
i VALUE 17, t_percentage, s_carr_id, sbc400focc-connid.
S_CARR_ID
Data element Structure
SBC400FOCC
17
number percentage
+
carrid connid
SAP AG 2001
n
n
n n n n
n
The predefined ABAP types (d, t, i, f, string, and xstring) are complete. This means they can define an elementary data object of these types as follows: DATA do_name TYPE predefined_ABAP_type. For the predefined ABAP types c, n, p, and x, you must define the length. This means you should first define an elementary type: TYPES type_name(length) TYPE predefined_ABAP_type. You use it to define the data object: DATA do_name TYPE type_name. For type p, you can also define the number of decimal places using the DECIMALS addition. You can use the VALUE addition to pre-assign the value of an elementary data object. For compatibility reasons, you can still construct data objects in the DATA statement without first having to define the type locally in the program with a TYPES statement. In the case of incompletely predefined ABAP types, the system adds standard values to make up the missing type information. If there is no type specification at all, the system defines a type c data object with a length of one.For the standard lengths and for more information, refer to the keyword documentation for TYPES and DATA. The same syntax applies to global types as to user-defined types: DATA do_name TYPE global_type_name
© SAP AG
TAW10
10-7
Fixed Data Objects Literal: Fixed data object without ID code
Numeric Numeric literal: Type ii or p literal: Type Positive integers: 123 Negative integers: -123
Constant:
Text literal literal: Type c Character string: 'aBcdE' Decimal numbers: '123.45' Floating point numbers: '123.45E01'
Fixed data object with ID code
CONSTANTS CONSTANTS const_name TYPE type_name VALUE [ literal | IS INITIAL ].
SAP AG 2001
n
You assign a value to each fixed data object in the source code. Therefore, it cannot be changed at run time. n You can use literals to transfer fixed values to ABAP statements. There are numeric literals and text literals. The latter are always enclosed in inverted commas: Ÿ You can display integers as numeric literals (in the case of negative numbers, with a preceding sign). The system then maps them onto the data type i, if they are within the value range of 4byte integers. Higher numeric literals are mapped onto data type p. Ÿ
n n
You must display all other literals (such as character sets, numbers with decimal pla ces, floating point numbers) as text literals. They are mapped onto data type c and converted later, if necessary. If you want to include an inverted comma in a text literal, you must enter it twice.
You define constants using the CONSTANTS statement. Their type is defined similarly to the type of an elementary data object with the DATA statement. The VALUE addition is required for constants Recommendation: Avoid literals when using statements. Create constants instead. This significantly improves program maintenance.
© SAP AG
TAW10
10-8
Basic ABAP Statements
Data Data Types Types and and Data Data Objects Objects Basic Basic ABAP ABAP Statements Statements Using Using the the ABAP ABAP Debugger Debugger Working Working with with Structures Structures Working Working with with Internal Internal Tables Tables
SAP AG 2001
© SAP AG
TAW10
10-9
Value Assignments Data declarations CONSTANTS c_qf TYPE s_carr_id VALUE 'QF'. DATA: carrid1 TYPE s_carr_id, carrid2 TYPE s_carr_id VALUE 'LH', counter TYPE i. Program start
c_qf
QF
carrid1
carrid2
counter
LH
0
MOVE c_qf TO carrid1.
QF
LH
0
carrid2 = carrid1.
QF
QF
0
ADD 1 TO counter.
QF
QF
1
CLEAR: carrid1, CLEAR carrid2, counter.
0
ABAP program ABAP runtime system Time SAP AG 2001
n
When a program is started, the program context is loaded into a storage area of the application server and made available for all the data objects. n Every elementary data object is preassigned the type-related initial value, except if you preassigned a different value using the VALUE addition. n You can use the MOVE statement to copy the contents of data objects. Two statements are available for this purpose: Ÿ MOVE source TO target. Ÿ target = source. n If the two data objects have different types, the type is automatically converted if there is a conversion rule. n For detailed information about copying and the conversion rules, refer to the keyword documentation for the MOVE statement. n The CLEAR statement resets the contents of a data object to the type-related initial value. For detailed information about the initial values for a particular type, refer to the keyword documentation for the CLEAR statement.
© SAP AG
TAW10
10-10
Calculations
Data declarations DATA: max TYPE sbc400focc-seatsmax, occ TYPE sbc400focc-seatsocc, percentage TYPE sbc400focc-percentage.
COMPUTE COMPUTE
percentage = occ * 100 / max.
The keyword is optional:
percentage = occ * 100 / max.
ABAP program SAP AG 2001
n
n
n n
In ABAP you can program arithmetic expressions nested to any depth. Note that parentheses and operators are keywords and must be separated by at least one blank character. The following are valid operators: + Addition Subtraction * Multiplication / Division ** Power DIV Integer division without remainder MOD Integer division with remainder There are several functions for different data types in the ABAP runtime environment. For example, the following statement returns the current length of the contents of a character set: length = STRLEN( cityfrom ). With functions the opening parenthesis is part of the ID. The rest must again be separated by at least one space. In general, the usual algebraic rules apply for the processing sequence: expressions in parentheses come first, then powers, then multiplication/division, and finally addition/subtraction. For detailed information about the available operations and functions, refer to the keyword documentation for COMPUTE..
© SAP AG
TAW10
10-11
Conditional Branching
CASE data_object_1. WHEN data_object_2. Statements
WHEN data_object_3 OR OR data_object_4. Statements
WHEN OTHERS. OTHERS
IF .
Statements
Statements
ENDCASE ENDCASE.
ELSEIF . Statements
ELSE ELSE. Statements
ENDIF ENDIF.
SAP AG 2001
n n
n
n n
n
In ABAP you have two ways to execute different sequences of statements, depending on certain conditions. With the CASE-ENDCASE construction the criterion for the execution of a statement block is the similarity of the data objects. If no comparison is successful, then the system executes the OTHERS branch, if it is available. Except for the first WHEN branch, all further additions are optional. With the IF-ENDIF construction, you can use any logical expressions. If the condition is met, the system executes the relevant statement sequence. If no comparison is successful, then the system executes the OTHERS branch, if it is available. Except for the first query, all further branches are optional. For both constructions, the system executes only one statement sequence and always for the first valid case. Recommendation: If, in every condition, you check that a variable is equal to a given value, use the CASE-ENDCASE construction. It is clearer and less runtime intensive. Outside of loops you can also use CHECK instead of IF. This query sets the execution of all statements up to the end of the current processing block under one condition. If this is unsuccessful, the system continues with the first statement in the next processing block.
© SAP AG
TAW10
10-12
Loops DO [ n TIMES ] [...]. Statements
ENDDO. Loop Loop counter: sy-index sy-index
WHILE . Statements
ENDWHILE.
LOOP AT ... Statements
ENDLOOP.
DO. Statements
SELECT ... Statements
ENDSELECT.
IF . EXIT. ENDIF. ENDDO.
SAP AG 2001
n
n
n
n
In ABAP there are four loop constructions, whereby LOOP-ENDLOOP and SELECT-ENDSELECT represent special cases. In the DO and WHILE loops, the system stores the number of the current loop pass in the sy-index field. If these loops are nested, sy-index contains the number of the current (that is, inner) loop. Unconditional/index controlled loops The statements between DO and ENDDO are executed until the loop is left over other statements. You also have the option of specifying the maximum number of loop passes; otherwise, you may get an endless loop. Header controlled loops The statements between WHILE and ENDWHILE are executed only if the condition has been met. You can use the statements CHECK and EXIT for different effects on the way the loop is processed. For example, you can construct a footer-controlled loop.
© SAP AG
TAW10
10-13
Dialog Messages
MESSAGE tnnn(message_class) [ WITH v1 [ v2 ] [ v3 ] [ v4 ] ].
Type
Meaning
Behavior
Message appears in
t s
Status message
Program continues without interruption
Status line in next screen
i
Information
Program continues after interruption
Modal dialog box
w
Warning
Context dependent
Status bar
e
Error
Context dependent
Status bar
a
Termination
Program aborted
Modal dialog box
x
Short dump
Runtime error MESSAGE_TYPE_X is triggered
Short dump
SAP AG 2001
n n n
n
You can use the MESSAGE statement to send dialog messages. You must specify the three-digit message number and the message class. Furthermore, you can use the WITH addition to include up to four values. The system, depending on the message text, inserts these values into the message text. You control the dialog behavior using the type abbreviation “t”. There are six different types of message: a Abort The program is ended after a dialog box. x Exit The program ends in a short dump. e Error Runtime behavior is context dependent. w Warning Runtime behavior is context dependent. i Information The program continues after a dialog box. s SuccessThe message appears in the status bar on the subsequent screen. For further information about the syntactic alternatives of the MESSAGE statement, refer to the keyword documentation.
© SAP AG
TAW10
10-14
Runtime Behavior of Dialog Messages Help
i
Editor Help ABAP Overview ABAP Term ABAP News ABAP Docu and Examples
ABAP Documentation and Examples ? BC - ABAP Programming ? ABAP Introduction ? ABAP Programming Language ? ABAP User Dialogs ? Screens ? Selection Screens ? Lists ? Messages Simple example for messages Demonstration for all message types ... ? SAP AG 2001
n n
Depending on the context in which they appear, some message types show different dialog behavior. You can find a program for testing the resulting options in the ABAP documentation. To access these example programs, choose Utilities → Help on→ABAP doc. and examples (in the following dialog box)
© SAP AG
TAW10
10-15
Using the ABAP Debugger
Data Data Types Types and and Data Data Objects Objects Basic Basic ABAP ABAP Statements Statements Using Using the the ABAP ABAP Debugger Debugger Working Working with with Structures Structures Working Working with with Internal Internal Tables Tables
SAP AG 2001
© SAP AG
TAW10
10-16
Executing a Program in Debugging Mode
Or: Set a breakpoint and execute the program Use the context menu Program ZBC400_00_GS ZBC400_00_GS
Execute
REPORT sapbc400wbt_getting_started. TABLES sbc400_carrier. DATA wa_scarr TYPE scarr. PARAMETERS pa_car TYPE scarr-carrid. START-OF-SELECTION. SELECT SINGLE * FROM scarr Debugging INTO CORRESPONDING WHERE carrid = pa_car. IF sy-subrc = 0. MOVE-CORRESPONDING wa_scarr TO sbc4 CALL SCREEN 100. MOVE-CORRESPONDING sbc400_carrier T WRITE:/
wa_scarr-carrid, wa_scarr-carrname,
SAP AG 2001
n
You can start a program in Debugging mode from the Object Navigator, without having to change the program in two ways: ŸIn the navigation area, choose Execute → Debugging for the selected program. ŸIn the editing area, select the desired program line and choose Set/delete breakpoint. Then start the program by choosing Execute→ Direct processing (F8)
© SAP AG
TAW10
10-17
Switching to Debugging Mode at Runtime
System
Or: Choose menu System
/h
Enter ‘/h’ into the command field and then select
Help
Utilities
Debug screen Debug ABAP
SAP AG 2001
n
If you want to debug only certain parts of a program, start the program first and then switch to debugging mode before a screen change. You can do this in two ways: Ÿ Choose System? Utilities? Debug ABAP or Debug screen. Ÿ Enter /h in the command field and select Enter.
© SAP AG
TAW10
10-18
Debugging Mode: Single Step and Field Contents X
SAP
ABAP Debugger
a
chws chws
Watchpoint r
6
SingleZJJ_FORMS step
Fixed point arithmetic 15 30 5
SELECT SINGLE * FROM scarr INTO CORRESPONDING FIELDS OF wa_scarr Current statement WHERE carrid = pa_carr. 4 IF sy-subrc = 0. MOVE-CORRESPONDING wa_scarr TO sbc400_carrier. Double-click the CALL SCREEN 100. data object MOVE-CORRESPONDING sbc400_carrier TO wa_scarr. 6 LH
1 - 4
Field Name
pa_carr
SY-SUBRC
0
SY-TABIX
Field Value
0
SY-DBCNT
1
SAP AG 2001
n n
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. Enter the names in the left input field or double-click the name in the displayed source code.
© SAP AG
TAW10
10-19
Debugging Mode: Breakpoints X
SAP
ABAP Debugger
a
chws chws
Watchpoint
6
Continue
Fixed point arithmetic 15 30 5
4SELECT SINGLE * FROM scarr INTO CORRESPONDING FIELDS OF wa_scarr WHERE carrid = pa_carr. IF sy-subrc = 0. MOVE-CORRESPONDING wa_scarr TO sbc400_carrier. CALL SCREEN 100. MOVE-CORRESPONDING sbc400_carrier TO wa_scarr. 1 - 4
Variant
SY-SUBRC
0
6
SY-TABIX
Variant
0
SY-DBCNT
1
SAP AG 2001
n n n n n
To set a breakpoint, double -click in front of a line of source code. To set a breakpoint for a specific ABAP statement, choose: ?Breakpoint? ?Breakpoint at? Statement. If you choose Continue, the program is executed up to the next breakpoint. If you Save the breakpoints, they remain intact while you are logged on to the system. With breakpoints, the ABAP Workbench switches to debugging mode only for the developer who set the breakpoints. All other users can execute the program directly or set their own breakpoints
© SAP AG
TAW10
10-20
Debugging Mode: Tracing Data Changes Watchpoint Create/Change Watchpoint Local watchpoint (only in specified program) Program pa_carr Field name Relational operator = Comparison field (Comparison value if not selected) Comp. field/value
LH
Watchpoints No. Local Program Field name pa_carr 1 2 3 ... 10 Logical operator between watchpoints
Operator Field Comp. field/value = LH
OR
AND
SAP AG 2001
n
n
Watchpoints are breakpoints that depend on the field content. You can create the following types of watchpoints: Ÿ Field name: The program is executed until the content of the field has changed. Ÿ Field name, relational operator, comparison value: The program is executed until the content of the field has changed so that the defined logical condition, relative to a value, is met. Ÿ Field name, relational operator, comparison value: The program is executed until the content of the field has changed so that the defined logical condition, relative to the content of a field, is met. You can set up to 10 watchpoints and link them using the logical operators AND or OR.
© SAP AG
TAW10
10-21
Working with Structures
Data Data Types Types and and Data Data Objects Objects Basic Basic ABAP ABAP Statements Statements Using Using the the ABAP ABAP Debugger Debugger Working Working with with Structures Structures Working Working with with Internal Internal Tables Tables
SAP AG 2001
© SAP AG
TAW10
10-22
Definition of Structures with Global Types
Structure SBC400FOCC
DATA wa_focc TYPE sbc400focc. DATA TABLES TABLES spfli.
SPFLI
carrid connid fldate
seatsmax
seatsocc
Transparent table
percentage
wa_focc mandt carrid connid countryfr cityfrom
airpfrom countryto ...
spfli
SAP AG 2001
n n n
In ABAP, you can define structured data objects (simply called structures). This allows you to combine values that belong together logically into one object. Structures can be nested. This means that components can consist of more structures or even tables. There are two ways to define structures: Ÿ For DATA struc_name TYPE struc_type, you can use local or global types struc_type. Ÿ TABLES global_struc_type defines a structure that is technically managed in a special memory area. It has the same name as the global structure, global_struc_type. For this variant, the global structure must be flat, that is, all components must have an elementary type. Since Release 4.0, TABLES structures serve only as interfaces for screen fields..
© SAP AG
TAW10
10-23
Definition of Structures with Local Types
TYPES: BEGIN BEGIN OF OF st_flightinfo, carrid TYPE s_carr_id, connid TYPE s_conn_id, fldate TYPE s_date, seatsmax TYPE sflight-seatsmax, seatsocc TYPE sflight-seatsocc, percentage(3) TYPE p DECIMALS 2, END END OF OF st_flightinfo . DATA wa_flightinfo TYPE st_flightinfo.
carrid connid fldate
seatsmax
seatsocc
percentage
wa_flightinfo
SAP AG 2001
n
n n n
You can also define structure types locally using the TYPES statement. The components are enclosed by the following statements as shown in the graphic: BEGIN OF structure_type_name. ... END OF structure_type_name. Each individual component can in turn be assigned any type you wish. For more information, refer to the keyword documentation for TYPES. You define the data object itself in the usual way. For compatibility reasons, you can also directly define a structured data object: DATA: BEGIN OF structure_name ... END OF structure_type_name
© SAP AG
TAW10
10-24
Addressing Structure Components
DATA: wa_scarr TYPE scarr. wa_scarr --carrid = 'LH'. SELECT SINGLE * FROM scarr INTO wa_scarr WHERE carrid = wa_scarr --carrid. WRITE:/ wa_scarr --carrid, wa_scarr --carrname, wa_scarr --url.
mandt carrid carrname currcode url wa_scarr
SAP AG 2001
n n
Components of a structure are always addressed using a hyphen: structure_name-component_name. For this reason, do not use hyphens in names.
© SAP AG
TAW10
10-25
Copying Structure Components with the Same Name
DATA: wa_sflight TYPE sflight, wa_focc TYPE sbc400focc. MOVE-CORRESPONDING MOVEMOVE -CORRESPONDING wa_sflight TO wa_focc.
mandt carrid connid fldate
...
seatsmax seatsocc ...
wa_sflight
wa_focc carrid connid fldate
seatsmax seatsocc percentage
SAP AG 2001
n
n
The statement MOVE-CORRESPONDING source_struc TO target_struc copies the contents of the structure source_struc into the structure target_struc component by component. The value assignment works only if the components have identical names. All other components remain unchanged.
© SAP AG
TAW10
10-26
Structures in Debugging Mode X
SAP
ABAP Debugger
a
chws chws
Watchpoint Fields Main program
6
Source code of
Fixed point arithmetic 5
wa_sbc400 Structured field SELECT SINGLE * FROM scarr INTO CORRESPONDING Length (in bytes) 58 FIELDS OF wa_scarr WHERE carrid = pa_carr. 4 IF sy-subrc =No. 0.Component name Type Length Contents MOVE-CORRESPONDING wa_scarr TO sbc400_carrier. 1100. MANDT C 3 100 Double-click the CALL SCREEN 2 CARRID AA C 3 data object MOVE-CORRESPONDING sbc400_carrier TO wa_scarr. 3 CARRNAME C 20 American Airlines Variant 4 CURRCODE USD C 5 wa_sbc400 5 MARK C 1 6 UNAME C 12 7 UZEIT 000000 T 6 8 DATE D 8 00000000 SY-SUBRC
0
SAP AG 2001
n
You can trace the field contents of a structure by entering the name of the structure in the left column. Double-click this entry to see the component display.
© SAP AG
TAW10
10-27
Working with Internal Tables
Data Data Types Types and and Data Data Objects Objects Basic Basic ABAP ABAP Statements Statements Using Using the the ABAP ABAP Debugger Debugger Working Working with with Structures Structures Working Working with with Internal Internal Tables Tables
SAP AG 2001
© SAP AG
TAW10
10-28
Internal Tables
Table can be extended dynamically
SAP AG 2001
n
Internal tables are data objects that allow you to retain several data records with the same structure in memory. In principle, the number of data records is unlimited. It is restricted only by the capacity limits of specific system installations. n The ABAP runtime system dynamically manages the length of internal tables. This eliminates any work concerning working memory management. n The individual data records in an internal table are known as table lines or table entries. For this reason, the individual components in a line are referred to as columns of the internal table. n The line type of an internal table can be any ABAP data type, elementary or structured, or it can be another internal table. n Internal tables are a simple way of processing large data records in a structured form within a program. Typical uses include: Ÿ Temporarily storing data from database tables for future processing Ÿ Structuring and formatting data for output Ÿ Formatting data for use by other services
© SAP AG
TAW10
10-29
Attributes of Internal Tables
Line Line type type
CARRID CONNID DISTANCE Line index 1
Key definition definition • Components Components • Sequence • Unique / nonnon- unique key key
3
AA LH LH
0017 0400 0400
2,572 6,162 7,273
4
QF
0005
10,000
5
SQ
0866
1,625
5
6
UA
0007
2,572
UA 0007
2
Index Index access access Data access type
Key access
SAP AG 2001
n n
The data type of an internal table is completely specified by the following attributes: Line type This is the source of the attributes of the individual columns. You normally specify a structure type but any data types are possible. n Key definition The key columns and their order define the criteria by which the tables are identified. Depending on the access type, the key can be defined as unique or non-unique . With unique keys there are no multiple entries with identical values in the key. n Data access type Ÿ With a key access – as with database tables – you access using the field contents. Example : A read access using the search term 'UA 0007' to an internal table with the unique key CARRID CONNID and the data pictured above returns exactly one data record. Ÿ Index access: Unlike database tables, with internal tables the system may number the lines and give the line an index. You can use this idex to access a specific table line. Example : A read access to a data record with index 5 returns the fifth data record of the internal table
© SAP AG
TAW10
10-30
Connection Between Table Kind and Access Type
Index tables Table type
STANDARD STANDARD TABLE TABLE
Hashed table
SORTED TABLE TABLE
HASHED TABLE TABLE
Index access n
Key access
Unique / NON- UNIQUE Non-Unique Key
UNIQUE | NON-UNIQUE
UNIQUE
Mainly keys
Keys only
n Access Using
Mainly index
SAP AG 2001
n
n
n
Another internal table attribute is the table type . Internal tables can be divided into three table types according to the respective access types: • With standard tables the line numbering is maintained internally. Both index and key accesses are possible. • With sorted tables the data records are always sorted according to key and saved. Here too, the index is maintained internally. Both index and key accesses are possible. • With hashed tables the data records are managed optimized at run time. A unique key is a requirement. With hashed tables only key accesses are possible. Which table type you use in each case, depends on how that table's entries are generally going to be accessed: • For index accesses you should normally use standard tables. • Sorted tables are best for unique keys and fixed sorting. • With hashed tables the runtime optimization is noticeable only if the accesses are of the read type with a unique key. This course deals with standard tables only. Apart from a few special cases, the syntax is identical for all three table types.
© SAP AG
TAW10
10-31
Definition of Internal Tables with Global Types Table type
SBC400_T_SBC400FOCC SBC400_T_SBC400FOCC
Line type and access Line type Data access type Key
Key definition Key category Key components
SBC400FOCC Standard table Key components Non-unique CARRID CONNID FLDATE
DATA DATA itab_flightinfo TYPE sbc400_t_sbc400focc.
carrid connid fldate
seatsmax
seatsocc
percentage
itab_flightinfo
SAP AG 2001
n n n
Table types can be defined locally in a program or globally in the ABAP Dictionary. For DATA itab_name TYPE itab_type you can use local or global types itab_type. For detailed information on the definition of global table types in the ABAP Dictionary, refer to the SAP Library under Basis → ABAP Workbench → BC-ABAP Dictionary → Types → Table types.
© SAP AG
TAW10
10-32
Definition of Internal Tables with Local Types
TYPES: tt_flightinfo TYPE STANDARD TABLE OF sbc400focc NON WITH WITH NON-UNIQUE NON-UNIQUE KEY KEY carrid connid fldate. DATA itab_flightinfo TYPE tt_flightinfo.
carrid connid fldate
seatsmax
seatsocc
percentage
itab_flightinfo
SAP AG 2001
n n n n n n n
You can also define internal table types locally using the TYPE statement. The table type is specified between TYPE and TABLE OF. The line type comes after TABLE OF. The key fields are listed after the WITH addition. Note that the order of the key fields plays a part here. For detailed information about defining local table types, refer to the keyword documentation on TYPES. You define the data object itself in the usual way. For compatibility reasons, you can also directly define an internal table as follows: DATA itab_name TYPE table_kind TABLE OF struc_type WITH key_def.
© SAP AG
TAW10
10-33
Overview: Typing Structured Data Objects ABAP program
ABAP Dictionary
DATA wa TYPE spfli. SELECT ... FROM spfli INTO wa ...
Transparent table
TABLES sbc400focc.
Structure Structure
SPFLI
(Description)
Database AA AA ... LH LH
17 64 ... 400 402
... ... ... ... ...
SPFLI
SBC400FOCC
DATA wa TYPE sbc400focc.
Structure Structure SBC400FOCC
DATA it TYPE sbc400_t_sbc400focc. AA AA ... LH LH
17 64 ... 400 402
... ... ... ... ...
Table type SBC400_T_SBC400FOCC
SAP AG 2001
© SAP AG
TAW10
10-34
Overview: Accessing Single Records Append
APPEND wa TO itab. APPEND
Insert
INSERT INSERT
Read
READ TABLE TABLE itab INTO wa . READ
Change
MODIFY TABLE itab FROM wa [ ]. MODIFY
Delete
DELETE itab . DELETE
wa INTO TABLE itab .
SAP AG 2001
n
n
The following single record operations are available for internal tables: In each case wa represents a structure that must have the same type as the line type of the internal table itab. Ÿ
APPEND Appends the contents of a structure to an internal table. This operation should be used with standard tables only.
Ÿ
INSERT Inserts the contents of a structure into an internal table. In a standard table it is appended, in a sorted table it is inserted in the right place, and in a hashed table it is inserted according to the hash algorithm.
Ÿ
READ Copies the contents of a line in an internal table to a structure.
Ÿ
MODIFY
Overwrites a line in an internal table with the content of a structure.
Ÿ
DELETE
Deletes a line of an internal table.
Ÿ
COLLECT Accumulates the contents of a structure into an internal table. This statement may be used only for tables whose non-key fields are all numeric. The numeric values are summarized for identical keys
For detailed information about the ABAP statements described here, refer to the relevant keyword documentation.
© SAP AG
TAW10
10-35
Overview: Processing Sets of Records LOOP LOOP AT itab INTO wa .
Loop: For all single record operations
ENDLOOP.. ENDLOOP
Delete
DELETE itab .
Inserting several lines from another internal table
INSERT LINES OF itab2
INTO itab1 .
APPEND INSERT LINES OF itab2 TO itab1.
Appending several lines from another internal table
SAP AG 2001
n
n
The following set operations are available for internal tables: In each case wa represents a structure that must have the same type as the line type of the internal table itab. Ÿ
LOOP ... ENDLOOP The LOOP places the lines of an internal table one by one into the structure specified in the INTO clause. All single record operations can be executed within the loop. In this case, for the single record operations, the system identifies the line to be processed.
Ÿ
DELETE Deletes the lines of the internal table that satisfy the condition .
Ÿ
INSERT Copies the contents of several lines of an internal table to another internal table.
Ÿ
APPEND Appends the contents of several lines of an internal table to another standard table.
For detailed information about the ABAP statements described here, refer to the relevant keyword documentation.
© SAP AG
TAW10
10-36
Syntax Example: Filling Line by Line
* define internal table and workarea: DATA: itab_flightinfo TYPE sbc400_t_sbc400focc, wa_flightinfo LIKE LINE OF itab_flightinfo.
itab_flightinfo
wa_flightinfo * fill structure with values: wa_flightinfo-carrid = ... wa_flightinfo-connid = ... wa_flightinfo-fldate = ... wa_flightinfo-seatsmax = ... wa_flightinfo-seatsocc = ... wa_flightinfo-percentage = ...
. . . . . .
* insert structure into internal table: INSERT wa_flightinfo INTO TABLE itab_flightinfo. SAP AG 2001
n n
You can insert lines into an internal table by first filling a structure with the required values and then inserting it into the internal table using the INSERT statement. For standard tables, this means that the line is appended to the table. For sorted tables and hash tables, the system inserts the line after referring to the key.
© SAP AG
TAW10
10-37
Syntax Example: Reading Contents Using a Loop
* define internal table and workarea: DATA: itab_flightinfo TYPE sbc400_t_sbc400focc, wa_flightinfo LIKE LINE OF itab_flightinfo.
itab_flightinfo
wa_flightinfo LOOP AT itab_flightinfo INTO wa_flightinfo. WRITE: / wa_flightinfo-carrid, wa_flightinfo-connid, wa_flightinfo-fldate, wa_flightinfo-seatsmax, wa_flightinfo-seatsocc, wa_flightinfo-percentage, '%'. ENDLOOP. SAP AG 2001
n n n
You can read and process the contents of an internal table using a LOOP by accessing the structure component within the loop. In this example, the WRITE statement is used to create a list from the field contents. If you want to change the contents of the internal table, first change the value of the components within the loop and then overwrite the line of the internal table using the MODIFY statement.
© SAP AG
TAW10
10-38
Operations on the Whole Internal Table
Sort
SORT SORT
Delete the entire content of the internal table
REFRESH REFRESH
itab .
itab.
SAP AG 2001
n n
n
n
n
The following operations affect the whole internal table. SORT You can use this to sort any number of columns in a standard or hashed table in ascending or descending order. You may want to take culture-specific sort rules into account. REFRESH This deletes the entire contents of an internal table. A part of the previously used working memory remains available for future insertions. FREE This deletes the entire contents of the internal table and releases the previously used working memory. CLEAR Unlike all other data objects, this statement has the same effect as the REFRESH statement on internal tables with no header line.
© SAP AG
TAW10
10-39
Syntax Example: Sorting a Standard Table
* define internal table and workarea: DATA: itab_flightinfo TYPE sbc400_t_sbc400focc, wa_flightinfo LIKE LINE OF itab_flightinfo.
itab_flightinfo
wa_flightinfo
SORT itab_flightinfo BY percentage DESCENDING DESCENDING.
Ascending or descending?
Name of column(s) by which to sort
SAP AG 2001
n n
n n
You can sort standard tables by any column, simply by entering the column name after the BY addition to the SORT statement. SORT itab [ ASCENDING | DESCENDING ] [ BY f1 [ ASCENDING | DESCENDING ] ... fn [ ASCENDING | DESCENDING ] ] [ AS TEXT ] [ STABLE ]. Sorting the internal table by the table key or specified field order: Without an addition the system sorts in ascending order. If you use the AS TEXT addition, the system will, while sorting by character-type fields, take the culture-specific sort rule into account. Only if you use the STABLE addition will the relative order of data records, which are identical in the sort key, remain intact during sorting. In this example, the data records of the internal table are sorted in descending order by the percentage occupancy of flights. For more details, refer to the keyword documentation for SORT.
© SAP AG
TAW10
10-40
Internal Tables in Debugging Mode X
SAP
ABAP Debugger
a
chws chws
Watchpoint Table
6
Table
Fixed point arithmetic 15 30 5
LOOP AT it_flightinfo INTO wa_flightinfo. 4 WRITE: / wa_flightinfo-carrid, wa_flightinfo-connid, it_flightinfo Internal table Double-click the data object Variant
it_flightinfo
SY-SUBRC
0
1 2 3 4 5 6 7 8
Type STANDARD
CARRID
CONNID
FLDATE
...
PERCENTAGE
AA AA AA AA LH LH LH LH
0017 0017 0017 0017 0400 0400 0400 0400
20000512 20000724 20000828 20001224 20000626 20000715 20001113 20001212
... ... ... ... ... ... ... ...
66 120 560 470 240 123 273 280
SAP AG 2001
n
You can trace the line contents of an internal table by entering the name in the left column. To see the table display, double -click this entry.
© SAP AG
TAW10
10-41
Basic ABAP Language Elements: Unit Summary
You are now able to: l Define elementary and structured data objects l Use basic ABAP statements l Execute and analyze programs in debugging mode
SAP AG 2001
© SAP AG
TAW10
10-42
ABAP Language Elements Exercises Unit: Basic ABAP Language Elements Topic: Basic ABAP Statements At the conclusion of these exercises, you will be able to: • Define elementary data objects • Assign values • Implement conditional branching • Perform calculations Create an ABAP program for the four basic calculation types. You must be able to enter the values and arithmetic operator on a selection screen. Display the result in a list.
Program:
ZBC400_##_COMPUTE
Model solution:
SAPBC400TSS_COMPUTE
## stands for the two-digit group number. 1-1
Create the executable program ZBC400_##_COMPUTE without "TOP Include".
1-2
Define the input parameters for two integers (name suggestion: pa_int1, pa_int2) and an arithmetic operator (name suggestion: pa_op). Additionally, define an elementary data object for the result type: packed number with two decimal places (name suggestion: result).
1-3
Execute the calculation in connection with the specified arithmetic operator. Use the CASE statement to do this.
1-4
Display the result in a list.
1-5
If the user has specified an invalid arithmetic operator on the selection screen, write an appropriate statement on the list screen.. Use the IF statement to do this.
© SAP AG
TAW10
10-43
1-6
If the user tries to divide by zero, display an appropriate statement on the list screen. In a later unit you will learn how you can implement the error handling with a more elegant user dialog.
© SAP AG
TAW10
10-44
Exercises Unit: Basic ABAP Language Elements Topic: Working with Structures At the conclusion of these exercises, you will be able to: • Use the Debugger to trace the data flow and understand the connections between processing blocks. • Use the MOVE-CORRESPONDING statement to assign values between structures. You have to examine a specified ABAP program to ascertain when and how certain data is transported between certain structured data objects.
Program:
SAPBC400WBS_GETTING_STARTED
2-1
Start the program SAPBC400WBS_GETTING_STARTED. On the selection screen, enter the airline code ‘LH’. In the command field, enter '/h' and then execute the program. You are now in debugging mode.
2-2
Make sure that all of the data objects are initial. Transfer all of the data objects defined in the program to the field view. Find out about the structure and type of the individual components.
2-3
Step through the program, one statement at a time, by choosing Single step (F5). Which fields of the structure wa_scarr does the SELECT statement fill? What is the value of system field sy-subrc after the statement?
2-4
Now observe how fields are copied from the structure wa_scarr to the structure sbc400_carrier. Which field values are copied?
2-5
The statement CALL SCREEN 100 processes screen 100. On the screen, enter appropriate values for the user name, date, and time, and continue with the program. Now observe how fields are copied from the structure sbc400_carrier to the structure wa_scarr.
2-6
Finally, observe how the WRITE statement constructs the list.
© SAP AG
TAW10
10-45
After the first WRITE statement, an extra button appears in the application toolbar, which allows you to display the current contents of the list buffer at any time.
2-7
Restart the program in Debugging mode. Set a breakpoint at the MOVECORRESPONDING statement. Before the screen is processed, assign a name to the structure component sbc400_carrier-uname in the Debugger. The button used to change the field values at runtime is next to the input/output field.
2-8
© SAP AG
Repeat step 2-1. Now set a breakpoint at the CALL SCREEN statement. Additionally, set a field content-dependent watchpoint for the condition that a field value of the structure wa_scarr changes. Choose Continue (F8) to continue the program and check why the debugging of the program is stopped in each case.
TAW10
10-46
Exercises Unit: Basic ABAP Language Elements Topic: Working with Internal Tables At the conclusion of these exercises, you will be able to: • Search for suitable table kinds in the ABAP Dictionary • Define internal tables based on a global table kind • Fill internal tables using array fetch • Process the content of internal tables using a loop. Create an ABAP program that lists additional information on all existing flight departure times. Get the data from the database table SPFLI. Program:
ZBC400_##_ITAB_LOOP
Model solution:
SAPBC400TSS_ITAB_LOOP
## stands for the two-digit group number. 3-1
Create the executable program ZBC400_##_ITAB_LOOP without "TOP-Include".
3-2
Buffer the data from the database table SPFLI in an internal table. Define an internal table with a line type that is compatible with the line structure of SPFLI. In the ABAP Dictionary, search for all internal table kinds that match this condition. (Use the Where-used list in the ABAP Editor.)
3-3
Define an internal table (name suggestion: it_spfli) based on one of the global table types you have found.
3-4
Define a work area that corresponds to the internal table (name suggestion: wa_spfli).
3-5
Program an array fetch access to all the data records in the database table SPFLI: SELECT * FROM spfli INTO TABLE it_spfli.
© SAP AG
TAW10
10-47
3-6
Display the buffered data in a list. Use the LOOP statement to do this.
© SAP AG
TAW10
10-48
ABAP Language Elements Solutions Unit: Basic ABAP Language Elements Topic: Basic ABAP Statements
1
Model solution:
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: 'Division by zero!'(dbz). ELSE. CASE pa_op. WHEN '+'. result = pa_int1 + WHEN '-'. result = pa_int1 WHEN '*'. result = pa_int1 * WHEN '/'. result = pa_int1 / ENDCASE. WRITE: 'Result:'(res),
pa_int2. pa_int2. pa_int2. pa_int2. result.
ENDIF.
© SAP AG
TAW10
10-49
Solutions Unit: Basic ABAP Language Elements Topic: Working with Structures
2-3
Which components are filled by the SELECT statement C? mandt, carrid, carrname, currcode, url. What is the value of the system field sy-subrc after the SELECT statement? Because there is a data record for the airline LH (Lufthansa) in the database table SCARR, sy-subrc is set to zero.
2-4
© SAP AG
Which field values are copied? mandt, carrid, carrname, currcode.
TAW10
10-50
Solutions Unit: Basic ABAP Language Elements Topic: Working with Internal Tables
3
Model solution:
REPORT sapbc400tss_itab_loop. DATA: it_spfli TYPE sbc400_t_spfli. DATA: wa_spfli TYPE spfli.
SELECT * FROM spfli INTO TABLE it_spfli. * at least one dataset selected IF sy-subrc = 0. * move each single dataset from internal table to * structure WA_SPFLI in order to write data on list 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.
© SAP AG
TAW10
10-51
Data Retrieval
Contents: l Data Retrieval for Database Tables l Querying the Database l Reading Database Tables l Authorization Checks l Preview
SAP AG 2001
© SAP AG
TAW10
11-1
Data Retrieval: Unit Objectives
At the conclusion of this unit, you will be able to: l List various ways of finding database tables l Program read access to specific columns and lines within a particular database table l Implement authorization checks l List the read access options for multiple database tables
SAP AG 2001
© SAP AG
TAW10
11-2
Querying the Database
ABAP program pa_car
Data objects
Database table SCARR
wa_scarr ABAP Processing block SELECT SELECT ... FROM scarr
DatabaseDatabasespecific conversion conversion
Open SQL
Database SQL
Database interface ABAP runtime system
SAP AG 2001
n
Open SQL statements are a subset of Standard SQL that is fully integrated in the ABAP language. (SQL stands for standard query language.)
n
Open SQL statements allow you to access the database in a uniform way from your programs, regardless of the database system installed. The database interface converts Open SQL statements to database-specific SQL statements.
© SAP AG
TAW10
11-3
Searching for Database Tables
Searching within a particular application component: Application hierarchy. Searching using a program : l Search in the ABAP Editor for the SELECT statement l Change to debugging mode during program execution and set breakpoint in the SELECT statement l If the program transmits a screen, display the structure field using F1 and technical information or navigate directly to the data element (double-click), or go directly to the data element (by double-clicking it) and open the where-used list in the tables
SAP AG 2001
n
You can search for database tables via the Application Hierarchy or the Repository Information System.
n
If you have the name of a program that accesses the database table you are searching for: Ÿ Debugger: Start this program in debugging mode and set a breakpoint at the SELECT statement. Ÿ ABAP Editor: Search for the SELECT statement in the source text. Ÿ If you know a program that contains a screen with input fields connected to the table you are looking for, choose F1 → Technical info. Double-click the technical name of the screen field to go to the ABAP Dictionary. This is often a structure field. Double -click the data element and then use the where-used list to search for transparent tables with the field type
© SAP AG
TAW10
11-4
Reading Database Tables
Reading Reading Database Database Tables Tables Authorization Authorization Checks Checks Preview Preview
SAP AG 2001
© SAP AG
TAW10
11-5
Programming Database Read Access
Which columns? SELECT
Which table(s)?
FROM