You are on page 1of 878

SAP ABAP

BOOK-01

SAP ABAP

I N D E X

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.

SAP in IBM/SAP-ERP Overview


ABAP Data Dictionary
Introduction to ABAP
ALV Reporting
OOPS ABAP
Module Pool Programming (Online)
Data Interface
ALE
LSMW
SAP Scripts
Smart Forms
ADOBE PDF Form
ABAP WDA
Enhancement
Production Quality ABAP Workshop
Upgrade Overview
Functional Overview

Service Line
Track Name
Category
Target Audience
Delivery Mode
Duration
JRSS

Table of Content for Technical Tracks_SAP ABAP (SAP)


SAP
SAP ABAP
Graduate Hire
Graduate Hire
Classroom
40 days
Application Developer-SAP.ABAP

Agenda:
Day 1: SAP in IBM/SAP-ERP Overview

ABAP Guhire overview


SAP NW overview
SAP in IBM

Day 2 and 3: ABAP Data Dictionary

ABAP DDIC basics,Overview of ABAP Dictionary


ABAP Dictionary Objects,Foreign Key Relationships
ABAP Dictionary Tables in Relational Databases
Adding Structures,ABAP Repository Information System
ABAP Dictionary Changes,Overview of Search Helps
ABAP Dictionary Objects-Views
Type Groups,Online Help & Documentation
Table Maintenance Generator

Day 4 to 6: Introduction to ABAP

Intro to ABAP, Adv Into to ABAP,


Interactive reporting

Day 7 to 9: Case study1: Data Dictionary and classical report

Day 10: Classical ALV reporting: Overview of ALV

Day 11 to 12: Introduction of OOPS ABAP - Day 1

Fundamentals of ABAP Objects

ABAP Objects Inheritance


ABAP Objects Interfaces
ABAP Objects - Events Handling
ABAP Objects - Global Classes and Interfaces
ABAP Objects - Class Based Exceptions

Day 13: Advanced ALV Report with OOPS

ABAP Objects - Advanced ALV with


ABAP Objects and RTTS

Day 14 and 15: Case study2: Detailed ALV Report with OOPS + Internal Assessment 1 (DDIC + OOPs)

Day 16: Online Programming


Introduction to Online Programming:

Online Programming Example


Screen Painter
ABAP Dictionary
Automatic Screen Field Checks
Issuing Messages
UserDefinedChecks
Default Values and Cursor Position
Graphical User Interface
Dynamic Screen Sequence
Conditional Execution of PAI Modules
Sub-screens
Database Operations
Logical Locking
Tabstrip Control
Table Control andScreen Modifications and Screen Flow Events

Day 17 to 18: Data Interface/Conversion/BAPI - Day 1

Background Processing
Application Server Files
Presentation Server Files
Batch Input Methods
Batch Input Session
Processing Batch Input Sessions

Call Transaction Method


Batch Input Recorder
Use of BAPIs for Data Interfacing

Day 19 to 20: Case Study3: End to End Interface Concepts uploading file from PS/AS and then BDC

Application Developer-SAP.ABAP

Day 22: LSMW: LSMW

Day 23: SAP Scripts

SAPScript Overview
SAPScript Forms
Coding in the SAPScript editor
SAPScript - Output Program
SAPScript Configuration
Printing SAPScript Forms
Debugging SAPScripts

Day 24: Smart Forms

Introduction to SmartForms
Global Settings
Pages and Windows
Basic Nodes
Auxiliary Nodes
Debugging SmartForm
User Defined Exceptions

Day 25: Case Study 4 : Smart Forms + Internal Assessment 2 -[ Online programming + BDC+ Scripts]
Day 26 to 27: ADOBE PDF For

Adobe - PDF based Print Form Architechture


Adobe - PDF based Print Form Interface
Adobe - PDF based Print Form Context
Adobe - PDF based Print Form Designer
Adobe - PDF based Print Form - Form Layout
Adobe - PDF based Print Form - Scripting in the Form
Adobe - PDF based Print Form - Integration into ABAP Programs
Adobe - PDF based Print Form - Tips and Tricks

Day 28: Case Study5: ADOBE PDF Form

Day 29: Introduction to ABAP WDA

Web Dynpro For ABAP-Introduction


Web Dynpro Controllers
Web Dynpro for ABAP-Navigation
Web Dynpro for ABAP-Context at Design Time
Web Dynpro for ABAP-Controller and Context Mapping
Web Dynpro for ABAP-Designing User Interface
Web Dynpro for ABAP-Messages
Web Dynpro for ABAP-Component Usage
Web Dynpro for ABAP-ALV

Day 30: User Exit/Badi/Enhancement Spot

Day 31: Case Study6: Enhancement

Day 32: Production Quality ABAP Workshop (Performance tuning)

Day 33: Production Quality ABAP Workshop (Testing/Adv Debugging/Troubleshooting Concepts)

Day 34: Upgrade Overview: ABAP Upgrade Training

Day 35: Funcational Overview Concepts + Internal Assessment 3 -[ WDA+User exit+enhancement ]

SAPFunctionalOverview
SAP MM overview for technical
SD Overview for SAP Technicals
SAP FICO Overview - Asset master & Transactions
SAP FICO _AP_user manual Overview;SD Overview for SAP Technicals

Day 36: IBM Methods & Tools [FS/TS/UTP Templates and Checklists and Programming Standards +
Overview - Delivery Management Tool - RTC + DE Case Study (Config. Mgmnt + SDLC)

Day 37: IBM Methods and Tools, Accelerators - RIC Generator, Code Snippet Generator, Auto TS
Generator + Code Optimizer and RIC Generator + DE Case Study (Metrics and Reviews/Inspection )

Day 38: Case Study7: Project Simulation CS with Documentation


Day 39: Practical exam - (On L&K SAP Server) + Assessment
Day 40: Assessment

Day 1
SAP in IBM_SAP-ERP Overview

SAP NetWeaver is an ambitious undertaking with so many dimensions that it is


hard even for experienced IT professionals to quickly understand its structure and
potential. Think of SAP NetWeaver as essentially an orchestra of technologies
with many programs and toolkits, each adding its own voice to the composition to
allow you to do things that could never be done before.
SAP Netweaver is Designed to
Enable change through increased business flexibility and adaptability.
Increase usability by making it easier for end users to work with all their
systems. This increases user adoption, cost savings, and productivity.
Enhance integration by making it possible for a collection of enterprise
applications to work together.
Enable innovation by allowing new applications to be constructed on top of
existing applications.
Save money by reducing the expense of owning and maintaining your existing
systems.

Net weaver can help users and groups improve their productivity through enhanced collaboration, optimized knowledge management and intuitive search in business

objects as well as
unstructured content.
Personalized access to mission-critical applications and data is accomplished using portals, desktop clients and mobile
interfaces.
Flexible UI technology enables IT organizations and partners to build their own state-of-the-art applications.
Key Terminologies Explained:
Custom UI Development
Web Dynpro ABAP , Java.
Motivation Behind Webdynpro is :
-UI definition independent of client technology.
-Abstract declaration.
-Different rendering engines for different (future) UI technologies
without adapting application coding
SAP EP
At its most basic level, the purpose of a portal is simple: to organize complex assortments of information and tools in an
accessible way. As the name indicates, a portal is a kind of doorway. SAP EP is both a doorway to SAPs underlying
applications and a doorway to all the business information in all its many forms and from all types of sources contained
within your company. SAP EP is the layer that interacts with the user, coordinates that interaction, and channels it to SAP
NetWeaver components, mySAP Business Suite solutions, and other applications. Then it displays the results. Example
ESS , MSS Applications.
Search Service in SAP
The search services in the SAP Net Weaver Application Server (AS) ABAP provide a framework for indexing and searching
SAP business objects in SAP applications. They comprise the following components:
Embedded Search
Embedded Search serves SAP Business Suite applications as a basic search technology platform for searching business
objects using the TREX engine (starting with SAP Business Suite 2008). Embedded Search is the Enterprise Search
component in the AS ABAP. It may be referred to as Enterprise Search (ABAP) in the documentation of SAP Business Suite
applications.
Search Engine Service
Search Engine Service serves SAP applications to use the TREX search engine to search for business objects (starting with
ERP 6.0).
TREX
The SAP NetWeaver standalone engine Search and Classification TREX provides SAP applications with numerous services
for searching, classification, and text-mining in large collections of documents (unstructured data) as well as for searching in
and aggregating across business objects (structured data). As a back-end engine, TREX provides search application such
as SAP NetWeaver Enterprise Search and search services such as Search Engine Service and Embedded Search with
indexing and search technologies. TREX as an SAP NetWeaver standalone engine is a significant part of most search
features in SAP applications. TREX cannot be licensed as a separate product.
Mobile:
SAP Solutions for Mobile Business has one purpose: To bring business processes to mobile devices in a seamless
computing environment, a kind of universal mobile adapter. To provide a complete solution, SAP created mobile applications
that work across multiple platforms and systems and developed an infrastructure for these applications using (surprise!) SAP
NetWeaver as the foundation.
An important aspect of SAP MI is that its based on open standards such as Java, XML, and SOAP. This means that the
platform can run on all kinds of devices and networks, from laptops to smart phones, and from wireless LANs to Bluetooth.

SAP BI as a whole is like the cockpit of a super airplane. The enterprise is the plane and SAP BI
is the onboard computer, collecting data like speed, gas airflow, fuel level, and weather
conditions. That data is promptly sorted, analyzed, and displayed so that both the pilot and
navigator have the information they need in the form they need whether a diagnostic readout or
a speedometer to make the right decision in real time. Knowing your speed is useful. Realizing
youre about to hit a major storm pattern is critical.
The role that SAP BI plays in SAP NetWeaver is that of a central, integrated repository for
information from distributed and heterogeneous sources. In more lucid language,just as in your
home, data is stored all over the place, from the box of tax papers in the basement to the recipe
file in the kitchen. In your enterprise, the good old Enterprise Resource Planning (ERP) system
has its data, the friendly Customer Relationship Management (CRM) system has its data, and a
grandfatherly legacy system that has been running for 20 years on a mainframe has even more
data. Add to that your Web site data, your co-workers spreadsheets of data, and even that
department down the hall that nobodys quite sure what it does might have some data. To find out
about the big picture, say customer or sales activity, the data from all these applications must be
brought together.
SAP BI is analogous to an airplane cockpit in a box, Business Content is a sample set of
blueprints to get your flight analysis and reporting started.
If Business Content can be likened to the airplane cockpit blueprint, the SAP BI preloaded
Analytical Applications can be likened to an automatic computer that can build that cockpit for you
based on the blueprint. It cant fly the plane for you but it has already calculated every successful
take off and landing and has a few strategies that it wants to recommend.
The Analytical Applications are similar: Theyre preloaded applications containing best practice
analytical models. One application might contain all the common calculations that are needed for
a company in the retail industry. Another application might contain best analytical techniques
common to any business calculating the lifetime value of a customer, for example.

Enterprise Information Management (EIM) is the business activity of creating, cleansing,


integrating, managing, governing, and archiving structured and unstructured data used by an
organization. EIM can help organizations integrate data and reconcile business information in
heterogeneous IT landscapes and cross-company business networks to create a trusted data
foundation for operational, analytical, and governance initiatives. SAP delivers solutions from
different product families (SAP NetWeaver, SAP Business Objects IM, and SAP solution
extensions) that support EIM activities such as enterprise data warehouse (EDW)
management, master data management, data integration and data quality management,
metadata management, information lifecycle management, and enterprise content
management. By managing information assets effectively, organizations can minimize data
integration efforts, streamline end-to-end business process execution, and gain well-founded
business insight.
MDM:
The role of SAP MDM in SAP NetWeaver is way more than just that of a special purpose
repository. You see, this product not only helps collect master data from all over the place, but
with the soul of a data janitor it also helps clean up that data. It finds duplicate data and stores
relationships between master data in records across systems. It also distributes master data
back to source systems.
Best way to Understand MDM is by below example:
When company A buys company B, one of the first tasks facing company A is to figure out where
the overlap is. For example, three groups of customers exist: customers who do business with
company A only; customers who do business with company B only; and customers who do
business with both companies. After a merger has been announced, the faster you sort out
which part of which company goes with which customer, the better. Otherwise, you may have
sales staff from company A and company B calling on the same customer or even competing
for the same business without anyone catching on. Also, be sure that you quickly introduce
company As products to company Bs customers, and vice versa.
One way to handle this is to wait until both companies are running on the same systems.
However, in most mergers of any size, that usually takes years. SAP MDM provides a much
better solution that goes like this:
-SAP MDM performs a consolidation so that all customers are identified in all the systems at
company A and company B.
-SAP MDM harmonizes the data in all the systems.

Service-oriented architecture (SOA) middleware facilitates communication


between disparate applications and systems based on the exchange of XML
messages.
Most Commonly used Middleware tool is SAP PI.
SAP PI, like other software, is simply a set of tools. But SAP PI acts like a
superhighway: Whenever an application needs to send or receive a message,
SAP PI is the road that carries it. SAP PI has on-ramps and off-ramps, and rules
that make sure every message is received and read correctly when it reaches its
destination.
Now on to brass tacks. The purpose of SAP PI is to connect applications with
each other. The problem is that frequently each application has its own format for
data. So SAP PI is also like a translator in that it specializes in converting formats
between applications from SAP or any other vendors so that they can
successfully exchange messages.

10

11

Organizations face a difficult challenge in todays security-conscious world having


to support transparent enterprise boundaries, location-independent users, and
the growing demands for regulatory compliance. With SAP NetWeaver, IT
organizations can enable safeguards that protect their business, while helping
users -- and the business processes they rely on proceed unhindered by
security operations.

12

Application Life-cycle Management provides processes, tools, services, and an


organizational model to manage SAP and non-SAP solutions throughout the
complete application life cycle. Instead of just focusing on the individual phases,
SAP provides a holistic approach. Results of the different phases can be
leveraged by other phases due to the integration provided by SAP Solution
Manager This helps you to implement your IT solutions faster and operate them
at lower cost.

13

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

SAP Overview
ECC 6.0

The evolution of ERP solutions


Materials Requirement Planning (MRP-I) began as a technique for developing enterprise-wide
business solutions by providing automated tools for forecasting demands and planning according
to the forecast

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

SAP Overview
ECC 6.0

An integrated suite of business applications, which..

Closely links, monitors, and controls primary enterprise resources like manpower, machine,
material, methods, market and money

Enables corporate firms to readily change their processes to adapt to the ever changing
business scenario

Provides expertise in industry specific business processes

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

SAP Overview
ECC 6.0

ERP - What Its Not

ERP facilitates the decision making but does not decide.

ERP provides comprehensive information to optimize but does not optimize dynamically.

It automates and integrates transactions but does not target the cycle time.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

ECC 6.0

ERP will impact

Communication and information domain

Leadership and authority

Company policies

Jobs and rewards

Company structure and culture

Skills and knowledge of employees

Information is available online generally to a much broader audience

ERP can alter how work gets done and thus how people work together

ERP alters the level of decision-making authority

ERP can alter organizational structure

IBM Global Services

SAP Overview

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

ECC 6.0

Recipe for a successful ERP application

Comprehensive functionality

Integration among modules and functions

Best Business Practices

Global support

IBM Global Services

SAP Overview

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

SAP Overview
ECC 6.0

In 1972, five former IBM employees -- Dietmar Hopp, Hans-Werner Hector, Hasso Plattner, Klaus
Tschira, and Claus Wellenreuther -- launch a company called Systems, Applications, and Products in
Data Processing in Mannheim, Germany. Their vision: to develop standard application software for
real-time business processing.
SAP is now the recognized leader in providing collaborative business solutions for all types of
industries and for every major market.
Serving more than 36,200 customers worldwide, SAP is the world's largest business software
company and the world's third-largest independent software provider overall.
Today, SAP employs more than 38,400 people in more than 50 countries.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

SAP Overview
ECC 6.0

In 1990s SAP R/3 was released.


With SAP R/3, SAP ushers in a new generation of enterprise software -- from mainframe computing
(client-server architecture) to the three-tier architecture of database, application, and user interface.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

ECC 6.0

Heterogeneous Platforms

IBM Global Services

SAP Overview

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

SAP Overview
ECC 6.0

With the Internet, the user becomes the focus of software applications. SAP develops mySAP
Workplace and paves the way for the idea of an enterprise portal and role-specific access to
information.
As mentioned earlier, with the introduction of mySAP Business Suite, SAP is now organized
into a service-based architecture, which has the following:
mySAP Customer Relationship Management (CRM)
mySAP ERP
mySAP Product Lifecycle Management (PLM)
mySAP Supply Chain Management (SCM)
mySAP Supplier Relationship Management (SRM)
mySAP ERP addresses the core business software requirements of the most demanding midsize
and large organizations -- in all industries and sectors.
mySAP ERP includes four individual solutions that support key areas of Enterprise Resource
Planning:
mySAP ERP Human Capital Management (HCM) -- Maximize workforce potential.
mySAP ERP Financials -- Turn finance into a strategic business partner.
mySAP ERP Operations -- Free up resources; budget for innovation.
mySAP ERP Corporate Services -- Streamline business processes and costs.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

SAP Overview
ECC 6.0

SAP has since broadened the integration vision of mySAP Technology into a blueprint they call
the Enterprise Services Architecture (ESA).
SAP NetWeaver is a comprehensive integration and application platform, mySAP Technology is
now renamed SAP NetWeaver; NetWeaver delivers the ESA blueprint.
SAP NetWeaver is a vision, or paradigm, of total integration of :
People
Information
Business Processes
Applications
SAP has a team of over 2000 developers in a single organization, working on NetWeaver.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

ECC 6.0

Quick Facts about SAP ERP6.0:


Launched in June 2006
Built on SAP NetWeaver 7.0
Approximately 7000 systems (12/2007)
Platform upon which SAP will deliver future software innovations
Software innovation delivered via
SAP enhancement packages

IBM Global Services

SAP Overview

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

SAP Overview
ECC 6.0

Because configuration is captured in data, as opposed to code, it survives software upgrades and
other changes.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

SAP Overview
ECC 6.0

R/3 applications are written in the ABAP programming language, and run within the application
layer of the R/3 System.

ABAP programs communicate with the database management system of the central relational
database (RDBMS), and with the graphical user interface (SAPGUI) at presentation level.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

SAP Overview
ECC 6.0

ABAP programs are objects of the R/3 Repository. Like all other Repository objects, you maintain
them using an ABAP Workbench Tool.

To open ABAP programs directly from the tool ABAP Editor, select the menu path Tools -> ABAP
Workbench ->Development -> User Interface -> ABAP Editor from the SAP menu of SAP Easy
Access (or start Transaction SE38). If you want to change a program using this method, you must
already know its name and environment.

This procedure is only suited for maintaining or creating relatively simple or short programs,
which have few or no additional components. It is better to access ABAP programs through Tools
-> ABAP Workbench -> Overview -> Object Navigator from the SAP menu of SAP Easy Access
(or start Transaction SE80).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ERP / SAP Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Client Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Client Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Client Overview

SAP Overview
ECC 6.0

A client is a logical portion of an SAP R/3 physical database. From a business standpoint, a client can
be interpreted as a logical group of companies.
All customizing (configuration) and development (ABAP) work in SAP R/3 is performed in a
client. However, the data from both customizing and development work may be stored within an
individual client (client dependent data) or among all clients (client independent data) in the system.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

SAP Overview

SAP Client Overview

ECC 6.0

The data in each client may be separate from that of the other clients. There are basically
two types of data in an SAP R/3 System. Client-dependent and client-independent data.
Client-dependent data is defined as data specific to an individual client. Client-independent
data can be defined as data contained across all clients in the system.
Some examples of client-dependent data include number ranges, ABAP variants, and user
masters as well as the data that is created or updated through SAP R/3 transactions
transaction data).
Examples of client-independent data include data dictionary objects (tables, views), ABAP
source code, screens, and menus.
All data resides in tables. To determine if a particular table is client-dependent or client-independent,
the table structure needs to be reviewed. The table structure can be viewed by the data dictionary
(SE11). If MANDT (client in German) is the first key field of the table, then the table is clientdependent; otherwise, the table is client-independent.
For example, the TSTC table is client-independent; however, the USR01 table is client-dependent.
As shown in the above diagram, every SAP R/3 system contains the three clients 000, 001, and 066.
Lets review these clients and examine what they contain.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Client Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Client Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

SAP Overview

SAP Client Overview

ECC 6.0

During a standard install of the SAP R/3 system, clients 000, 001, and 066 are set-up and
provided.
These clients provide different features and must not be deleted.
Client 000 performs special functions. In particular, it is given extended functionality during
upgrades.
Client 001 is basically a copy of 000 and can be used as a basis for a new customizing client.
Client 066 is a special client which is provided for operational system monitoring. It is used by
SAP R/3s Early Watch Service to provide performance recommendations.
In releases prior to 3.0, client 000 contained a model company. As of Release 4.0 clients, 000 and 001
are identical. Client 000 no longer contains a model company. Either client can be used as the basis
for configuration through a client copy. Typically, most projects start with a copy of client 000 to begin
building configuration.
Customer work should never take place in the three delivered clients.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Client Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Client Overview

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

SAP Overview
ECC 6.0

Saplogon is used to create icons to logon to SAP R/3. However, the icons created with Saplogon are
not placed in the SAP R/3 Windows group, they are instead shown via the Saplogon Menu (shown in
the slide). The SAP logon pad is available once the SAP GUI is installed at the workstation.
The Saplogon Menu can be thought of as a one-stop shopping store, where end-users can
choose from logon icons, logon groups, or create new logon icons.
Logon icons will log a user onto one specific application server. A logon group will log the user
onto one of several applications servers depending on which one has the best performance
statistics.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

SAP Overview
ECC 6.0

To create a shortcut for connecting to a new SAP application server, follow the procedure below:
1. Click the New Item button and enter the following details :

Description: Give a meaningful short text for identifying the Server. The Server will be
available in the SAP Logon pad with this name. Nor

Application Server: Give the IP/Address of the Application Server, provided by the basis
administrator.

System number: Give the system number provided by the basis administrator. It should be
kept as 00, if nothing is specified.

System ID given as per the mail

2. Click OK.
3. The newly created SAP application server will now be available in the SAP logon pad.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

SAP Overview

SAP Navigation

ECC 6.0

Follow the procedure below to Log on to the SAP Server:


1. Launch the SAP Logon pad (

).

2. Double click on the Application Server (which you need to connect), from the SAP Logon pad.
The SAP Logon screen appears.
3. In the SAP Logon screen, the value of the default client appears automatically, if you want to
logon to a different client, then change it with the new client number.
4. Next, enter the User ID and password, which have been assigned to you.
5. Enter EN in language to logon to English settings. Generally the language is defaulted to EN or
any other language depending on the country/users. So, you may not need to enter it in the SAP
logon screen and it takes its values from the default settings.
6. After filling up the 4 fields, hit enter to logon to the SAP system.
7. During the first time logon to the system with your ID, you will be prompted to change your initial
password.
8. However, to change your password later, click on the New Password push-button and set the
password.
1. Select a new password and then confirm it by typing it again. The asterisk will remain in
the password field.
2. Click on the

icon once you are satisfied with your password selection.

The Password must contain at least 3 characters and no more than eight.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

SAP Overview

SAP Navigation

ECC 6.0

Once you have logged on to the application, the initial menu screen will appear. All menus are
displayed in the menu bar. The menus that appear in the menu bar varies according to the task you
are doing in the R/3 System. Therefore, you will see different menus as you work on different tasks.
Menus that are always available from every screen in the R/3 System:

System: This menu contains functions that affect the system as a whole, such as the
Create Session, End Session, User Profile, or Log Off options.

Help: The Help menu contains functions for accessing various forms of
online support.

Those icons which are available for use will be enabled (they will not be shaded gray).
In order to determine what each icon represents on the tool bar, place the cursor on the icon (if it is
enabled) and a floating box will appear with text and a unique Function key used to identify the icon.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

SAP Overview
ECC 6.0

Using the Layout menu:


1. Click on the Layout menu located in the standard toolbar to activate the customization option.
2. Then select the Options menu item. This will lead you to a screen where you can select the
following customization options:

Options

Cursor

Local Data

I18N

Expert

Trace

Scripting

With these options you can configure settings like:

Whether to sound Beep at message

Whether to display dialog box for success message

Whether to show keys in dropdown lists etc.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

SAP Overview
ECC 6.0

To view only an icon specific function key:


Place the cursor on top of an icon to view the floating help reference.

In order to view all available function keys while on any screen:


Click on the right mouse button (see above) and then use the left mouse button to select a
function.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

SAP Overview
ECC 6.0

Use the menu path System User Profile Own data to change user specific settings such as:

Output Device

Print controller

Date Format

Decimal Notation

Logon Language (interface and documentation)

The user profile is connected to the user ID. It will be applied to each logon session for that user,
irrespective of which PC is used or which SAP system the user connects to.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

SAP Overview
ECC 6.0

1. Change the Default settings for the User.

Change your output device to print to your Windows default printer.


1. Place your cursor in the output device field and then hit F4 to view the list of
available output devices.
2. You may also want to select the checkbox which would allow for immediate printing
capabilities, otherwise the default is to output the spool file.

Change the date format to be MM/DD/YYYY.

Change the Decimal notation to be a Decimal Point.

2. Once changes have been made, save your work, and then exit the window by using the
icon.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

SAP Overview
ECC 6.0

The R/3 System displays warning and error messages in the status bar. A system message consists
of one line; however, you can get more information about a message by doing the following:
1. On the status bar, click anywhere on the message, or position the cursor directly on the
message and click the
icon or hit F1.
2. A dialogue box will appear with help on the message.
3. If more detailed information is required, you have the option to select the Technical info
push-button. Depending on the complexity of the error message, different information will
be displayed in this dialogue box. Sometimes you will be presented with Message Data
and Program Data and sometimes you will only see Message Data.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

SAP Overview

SAP Navigation

ECC 6.0

You can create a session at any time and from any screen in the system; you will not lose any data in
sessions that are already open.
You can create up to 6 sessions. Each session you create is as if you logged on to the system again.
Therefore, the system has more work to do which can affect how fast it responds to your requests.
To create a new session from anywhere in the system, proceed as follows:
1. Choose System Create Session from the menu bar.
2. The system opens an additional window with the new session running in it.
3. The new session becomes the active session and remains the active session unless you
move to a different (open or new) session. This can be done by using the ALT + TAB
keys.
4. The new session number is shown in parentheses on the status bar. For example, one
session may be AD3 (1) and the other may be AD3 (2). AD3 is the SAP system being
used and the numbers (1) and (2) are the sessions being used by the user.
To end a session, choose the following menu path:
1. System End Session.
The remaining sessions are not re-numbered.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

SAP Overview

SAP Navigation

ECC 6.0

Before you can use a transaction code, you have to find the right transaction code for the task you
want to start.
To display transaction codes in the SAP main menu screen (the initial SAP Screen displayed after
logon) do the following :
1. Go to Extras Settings (Shift + F9)
2. Click checkbox for Show technical names
3. The Transaction codes are now displayed along with the Transaction short text in the SAP
menu.
Once a transaction is selected, you can start the task associated with it by double-clicking it.
Otherwise, you can use this transaction code to start this task from any screen in the R/3 System.
When you are in a transaction, you can find its transaction code by using the menu path:
1. System Status

Note: In order to return to the SAP main menu screen, type /N in the command field and click the
button in the screen displayed.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

SAP Overview
ECC 6.0

In the R/3 System, you can create a session and start a task in one step by using a transaction code.
When you open a session with a transaction code, the system displays the initial screen of the task in
a new session. To use this method, you must know which transaction code to use for the task you
want to perform.

To create a new session and a task at once from anywhere in the system, do the following:
1. In the command field enter a /o followed by the transaction code for the task you want to
start.
/o allows you to keep the current session and create a session without losing the
original session
/i = Kills session you are working on.
2. For example, to create a customer master record in the Accounts Receivable application,
you would use the transaction code FD01. To open a session and start this task at the
same time, then you would enter /ofd01 in the command field.
3. Hit Enter for execution or click on the green arrow.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

SAP Overview
ECC 6.0

To exit the application use the menu path:


1. System Log Off
2. A popup screen will be displayed Unsaved data will be lost. Do you want to log off ? (This
message will appear even if you have saved your data.)
Select YES to log off the system without saving any changes or updates.
Select NO to cancel the log off request.

Warning: If you have several sessions open and you log off with this method instead of end session,
it will kill all your sessions.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SAP Navigation

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

SAP Overview
ECC 6.0

The CTS is the central tool for managing changes to Customizing and Repository data that you make
in the IMG or ABAP Workbench. The CTS records all changes in change requests. The changes in
change requests can be linked together logically, or can be completely independent of each other.
Developers in a team can use a common request. You can create documentation for a change
request, where you can describe your changes in more detail. This makes it easier to see which data
was changed by which user, and to what purpose.
When you have finished your work in the IMG or ABAP Workbench, or have reached a certain stage,
you can release the request. The change request is then used to copy the changes from this client to
other clients or systems. This automatic procedure is known as a transport. Transports of changes
by the CTS allow you to develop in one environment, test your development work in a test
environment, and then, if the tests are successful, use it productively. This makes sure that
productive operations are not placed at risk by faulty settings or program errors.
Transports of changes between clients and systems are subject to rules that are set in the CTS
configuration in the system landscape. One rule may be that changes are transported into a test
environment before they can be copied to the production environment. All transports are logged, so
that you can see when a change request was imported into a client or system, and whether there
were any errors.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

SAP Overview

Change and Transport System

ECC 6.0

Transport Organizer is the set of utilities which provide for the development change
management and customization (configuration) change management.

All development changes (ABAP/4, DDIC) and Customizing are tracked through the Transport
Organizer.

The Transport Organizer is accessed via transaction SE09 or SE10.

The Development Workbench is now fully integrated with the Transport Organizer.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

SAP Overview
ECC 6.0

The initial screen provides various selection criteria for locating an individual Request. Select the
Workbench Requests checkbox to locate Development change requests and select the
Customizing Requests checkbox to display the list of change requests used to organize
Customizing objects.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

SAP Overview
ECC 6.0

The Transport Organizer displays all of the Requests which meet the selection criteria in a
graphical tree format.

Drill down features are available to allow the user to display the desired level of detail for a
Request or Task.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

SAP Overview
ECC 6.0

By drilling down to the detail level on an individual task, from within the Transport Organizer, the user
can display the list of all objects contained within the task. The object list displays all objects,
development or customizing, for which changes are recorded in the selected task. Information on
these objects include:
Desc: Category of the object.
Prg_type : Program type
Obj: Element object type.
Obj. name: Name of the object to be transported.
Funct.: Correction function for the object.
Possible values are:
M Delete and recreate in the target database.
Delete the specified object in the target database, and insert the value
from the source database.
K The object contains key values. Individual entries from the object have
been specified for transport.
D Delete the object from the target database.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

SAP Overview
ECC 6.0

ObjStatus: Object lock indicator.


Possible values are:
LOCKED Object locked.
NOT_IMP Object not imported.
ERR_IMP Error importing object.
OK_IMP Object imported.
OK_GEN Object imported and generated.
From within the Display Object List, you can drill down further on objects which have key values
associated with them (Function K).
Details regarding the table records specified by the key values are displayed on this screen.
They include:
Obj: Element object type.
TabName: Table name.
Key (beginning): Table key (abbreviated) for the object in the request/task.
F: Function for the key entry.
Possible values include:
If the key exists in the source system, it is transported to the target system. If the
key does not exist in the source system, it is deleted from the target system.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

SAP Overview
ECC 6.0

1. When entering a configuration/creating a development object, the SAP will prompt the user for a
Change Request (assuming that the client has been set to automatically record customizing
changes).
2. If the user already has an outstanding Change Request that he/she would like to place the
customizing/development change in, the Own Requests button can be selected. This will
provide the user with a tree structure view of all requests with which that user is associated.
From there, the user may select the appropriate request in which to include the
customizing/development change.
3. By selecting the Create Request button, a new Change Request will be generated, and a Task
within the new request will be generated.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

SAP Overview
ECC 6.0

4. Having selected Create Request on the previous screen, the user is prompted to enter a short
description for the new request.
5. The users id is automatically assigned to this request, and a task is generated within the Change
Request.
6. If the user is authorized, he/she may also add additional users to this request, each one receiving
their own task within it.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

SAP Overview
ECC 6.0

7. After providing a short description for the Change Request and selecting the Save button, the
SAP system returns the number of the new request.
8. As long as this request remains open, future customizing/development changes can continue to
be added to it.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

SAP Overview
ECC 6.0

All users who will be editing development objects on the R/3 system must be registered with SAP
and assigned a development key.

If a user has not been assigned a development key, the message shown above will be displayed.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

SAP Overview
ECC 6.0

By selecting the Information button from the previous screen, the user can obtain the R/3
systems installation number. This number is required for the registration process.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

ECC 6.0

A list of all registered developers can be found in table DEVACCESS.

This table displays the registered user ID and associated developer key.

IBM Global Services

SAP Overview

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

SAP Overview
ECC 6.0

A Package is a group of logically related development objects. A Package contains all the
development objects which must be developed, maintained, and sometimes transported together.
The objects that make up a transaction usually belong to one Package. Before 4.7 Package was
called Development Class.

When creating a new object in the R/3 system, the developer will be prompted to supply a
Package. By selecting a valid Package and then a CTS, changes to the object will be recorded in
the Transport Organizer.

If the Local Object button is selected, the object is classified as a local private object, and
changes are not recorded by the Workbench Organizer. Local private objects may not be
transported.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

SAP Overview
ECC 6.0

To add a new Task to an existing Request, place the cursor on the Request in the Request tree
diagram.
1. Select the Add User button.
2. Select the user ID of the individual to whom this new Task will be assigned.
3. Multiple Tasks may be created for a single user in a Request.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Change and Transport System

IBM Global Services

SAP Overview
ECC 6.0

Dec-2008

Day 2 and 3
ABAP Data Dictionary

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

There are several path to accessing the dictionary. Below is a list some of the ways to access

the Dictionary.

To access the ABAP Dictionary:

Use the menu path: Tools ABAP Workbench Development ABAP Dictionary; or

Use the menu path:

Tools ABAP Workbench Overview Object Navigator

Pull down the Workbench menu and select Other objects Select the Dictionary tab
from the pop up screen and enter the appropriate table name in the Database table
field; or

Use transaction code SE11

The ABAP Workbench was known as the ABAP/4 Development Workbench in past releases.

The Object Navigator used to be called the Object Browser and the Repository Browser.

Apr 2007

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

DATA CLASS : The data class defines the physical area of the database (for ORACLE the
TABLESPACE) in which your table is logically stored. If you choose a data class correctly, your
table will automatically be assigned to the correct area when it is created on the database.

The most important data classes are (other than the system data):

APPL0

Master data : Master data is data which is frequently read, but rarely updated.

APPL1

Transaction data : Transaction data is data which is frequently updated

APPL2 Organizational and customizing data : Organizational und customizing data is data which
is defined when the system is initialized and then rarely changed.

There are two more data classes available, USR and USR1. These are reserved for user
developments. The tables assigned to these data classes are stored in a tablespace for user
developments.

Apr 2007

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Buffering Database Tables

Buffering a table improves the performance when accessing the data records contained in the
table. The table buffers reside locally on each application server in the system. The data of
buffered tables can thus be accessed directly from the buffer of the application server. This avoids
the time-consuming process of accessing the database.

Buffering is particularly important in client/server environments, as it takes considerably longer to


access a table with the network than it does to access a table that is buffered locally.

Apr 2007

10

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

You must define whether and how a table is buffered in the technical settings for the table. There
are three possibilities here:

Buffering not permitted: We must not buffer a table if the table data is frequently modified. In this
case the cost of synchronization could be greater than the gain in performance resulting from
buffering.

We also do not buffer time critical data.

Buffering permitted but not activated:

Buffering activated: Generally custom data are buffered with full buffering or generic buffering.

Apr 2007

11

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

12

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

13

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

14

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Follow menu path Utilities - Table maintenance generator from transaction SE11.

Specify the Authorization Group. (E.g. &NC& for skipping any Authority Check)

Click one step maintenance type.

Give the Overview Screen as 9000. (You can specify any Screen Number beginning with 9)

Now, hit the Create Button to create the maintenance view for the table. Specify the Development
Class and CTS when prompted for.

Specify a Function group. (If you dont have a Function Group already, then open transaction SE80
in another session and create a Function Group)

Also remember to set the Display/Maintenance allowed value in the table attributes.

Apr 2007

15

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

If we check one step maintenance then we can create edit delete in the same overview screen

Apr 2007

16

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Only one maintenance screen is processed during extended table maintenance. The entries are
displayed in list form on this screen.

Apr 2007

17

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Two maintenance screens are processed during the extended table maintenance:

On the Overview screen the entries are displayed in list form.

On the Single screen one entry is displayed. The single screen can be called from the overview
screen, by function key, for every entry.

Apr 2007

18

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

*** IF we select two step maintenance then put the overview screen as 9000 and single screen 9001
for detail view

Go to transaction SM30 (Maintain Table Views: Initial Screen) and specify the table name.

You can Display and Maintain Table entries by clicking the Display and Maintain pushbuttons.

Click the Maintain pushbutton to maintain the entries for the table.

Apr 2007

19

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

20

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Logically A delivery class is not meant for transporting the data but technically if we choose
Standard recording

routine then it is possible to transport the data .

Apr 2007

21

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

22

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

We should create a customize transaction for the TMG this is because of the fact that if someone
has the authorization of SM 30 they can modify any table so to prevent that we create the
customizing Transaction for our TMG .

Apr 2007

23

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

The first radio-button is for dialog or for online programming transaction

The second one is for Report transaction

The third one is for Class (oops) transaction

The fourth one is for variant

Apr 2007

24

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

First go to se93 give a transaction code begin with z press create .

Choose the 5th radio button i.e. Transactions with parameters .

In the transaction we should give SM 30 to maintain the table .

Give the appropriate screen no .

Name of the screen field 1> viewname ----------- table name (eg. Ztestlk)

2> update -------------- X


Now we are able to acces the table using this Tcode .

Apr 2007

25

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

26

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

27

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

28

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

29

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

We can initialize the variable by just clearing it.

Eg. clear <variable name>.

Apr 2007

30

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

31

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

32

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

33

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

To set the default values of parameters or select options.

Eg. Suppose we have a parameter p_date where we want the default value as 30 days after the
current date.

In this case if we use the following code:

parameters: p_date type sy-datum default sy-datum + 30.

We will get syntactical error here since the default offset should be only string.

Hence in this case we can solve our problem in the following way:

parameters: p_date type sy-datum.

initialization.

p_date = sy-datum + 30.

This is one situation when the initialization event becomes necessary.

Apr 2007

34

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Steps for declaring an internal table/work area.


Type declaration.
First method
types: begin of ty_cepc,
bukrs type bukrs,
"company code
prctr type prctr,
"profit centre
datbi type datbi,
"valid to date
kokrs type kokrs,
"controlling area
end of ty_cepc.
OR
Second method
types: begin of ty_cepc,
bukrs type cepc~bukrs,
"company code
prctr type cepc~prctr,
"profit centre
datbi type cepc~datbi,
"valid to date
kokrs type cepc~kokrs,
"controlling area
end of ty_cepc.
Here the second method is preferable since in this case the data element refers to the nature of the data
element in that particular table (eg. cepc~bukrs).
In the first case search help for the field kokrs will not come automatically where as in the second case it will
come automatically.
This is because in table CEPC for field kokrs the input help is implemented with check table and when we
use the second method we refer to the data element in the table CEPC where as since there is no search
help implemented for the data element kokrs so when we use the first method it refers to this data element
which ha no input help implemented.

Apr 2007

35

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Note: It's a good practice to declare all the internal tables, all the work areas, all the variables and all
the constants together.

Apr 2007

36

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

37

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

38

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

**** Validation on input field can be checked in AT SELECTION-SCREEN EVENT as well as AT


SELECTION-SCREEN ON EVENT .

If we want to validate a single input field then we should always validate in AT SELECTIONSCREEN ON event if we validate it in AT SELECTION-SCREEN then all the other field which is
not meant for validation will also get validated so performance issue will get decreased .

Apr 2007

39

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

40

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

41

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Suppose for example we have a select option as following:

SELECT-OPTIONS: so_matnr FOR v_matnr.

Then in the multiple selections option button at the selection screen if we enter the values as
follows:

In the Select Single Values tab we enter a value say 1301.

In the Select Ranges tab we enter 1301 in the lower limit and 1400 in the upper limit.

In the Exclude Single Values tab we enter a value say 1304.

In the Exclude Ranges tab we enter 1310 in the lower limit and 1320 in the upper limit.

We can view this table through the debugging mode.

Apr 2007

42

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

A search help describes the flow of an input help. The search help can only take effect using a
mechanism that assigns the search help to this field. This mechanism is called the search help
attachment to the field.

Attaching a search help to a field has an effect on the field's behavior. It is therefore considered to
be part of the field definition.

The input help (F4 help) is a standard function of the R/3 System. It permits the user to display a
list of possible values for a screen field. A value can be directly copied to an input field by list
selection.
The fields having an input help are shown in the R/3 System by the input help key to the right of the
field. This key appears as soon as the cursor is positioned on the corresponding screen field. The
help can be started either by clicking on this screen element or with function key F4.
If the number of possible entries for a field is very large, you can limit the set of displayed values by
entering further restrictions.

Apr 2007

43

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

A search help can be attached directly to a field of a structure or table. The definition of this
attachment is analogous to that of a foreign key. You have to define an assignment (between
the interface parameters of the search help and the fields of the structure) for which the
system makes a proposal.

If a field has a check table, its contents are automatically offered as possible values in the
input help. The key fields of the check table are displayed. If a check table has a text table,
its first character-like non-key field is displayed.

If you are not satisfied with the described standard display of the data of the check table, you
can attach a search help to the check table. This search help is used for all the fields that
have this table as check table. You have to define an assignment between the interface of
the search help and the key of the check table when you define the attachment

Attaching a search help to a check table (or a data element) can result in a high degree of
reusability. However, there are restrictions on passing further values via the interface of the
search help .

With the screen event POV you can program the input help of a field by yourself. You can
adjust the design of the help to the standard help using the function modules
F4IF_FIELD_VALUE_REQUEST or F4IF_INT_TABLE_VALUE_REQUEST.

Apr 2007

44

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

45

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

46

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

47

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

48

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

49

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

50

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

51

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

52

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

53

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

54

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

55

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

56

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

57

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

58

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

59

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

60

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

61

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

62

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

The message type determines where the message is displayed and what action the user can or must
take on the current screen .

Apr 2007

63

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

64

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

65

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

66

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

67

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

68

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Documentation helps in further use and helps the user to understand the purpose of the object.

Document Should be maintain for future reference .

Documentation can be maintain GO->Documentation->Click Edit Documentation in


Documentation pop-Up ->Document->Upload.

Or by change Editor instead of upload

Apr 2007

69

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

70

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

71

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

72

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

73

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

74

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

75

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

76

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

The debugger stops only if the watchpoint variable (SY-SUBRC) changes and the additional
condition (SY-SUBRC = 4) is met.

Apr 2007

77

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

78

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Similarly we can set dynamic breakpoints at any other ABAP Commands, Methods, Functions,
forms etc.

Apr 2007

79

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

80

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

81

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

82

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

83

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

84

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

85

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

86

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

87

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

88

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Tips:

Never use local objects in a client program.

Consult your TL before using, creating a transport request.

Apr 2007

89

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

90

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

91

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

92

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

93

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

94

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

95

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Note1: The test conditions should be given in proper business terms and not in technical terms.
For instance we cannot write "validate plant from table t001w".

Note2: The UTP (Test Condition, Step Description, and Expected Result) is usually prepared
before we actually start coding. The UTP is prepared depending on the object requirement

Apr 2007

96

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

97

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

98

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

99

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Now in order to confirm whether the data in this internal table is proper or not we can verify the
data from the database table but this is not a proper method. Hence we go the standard
transactions like MM03,VA01 etc depending on the project requirement and verify the data.

After that if alv report we check whether the fieldcatalog internal table is populated and lastly we
check whether the subroutine for displaying the reports/uploading/downloading file is working
properly or not.

Apr 2007

100

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

101

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Client-dependent data is defined as data specific to an individual client. Client-independent data


can be defined as data contained across all clients in the system.

In SAP all data resides in tables. To determine if a particular table is client-dependent or clientindependent, the table structure needs to be reviewed. The table structure can be viewed by the
data dictionary (SE11). If MANDT (client in German) is the first key field of the table, then the table
is client-dependent; otherwise, the table is client-independent.

Apr 2007

102

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

103

<Programme Name>

IBM Global Business Services


<Topic Name>

<SAP Release>

Apr 2007

104

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

ABAP Dictionary
ECC 6.0

ABAP also known as ABAP/4, and /4 represents that it is a 4th


Generation language.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

ABAP Dictionary
ECC 6.0

A data dictionary is a centralized storage location for information about the data that is stored in a
database. This information is often called metadata (data about data).
A data dictionary provides answers to questions such as:
What data is contained in the database?
What are the attributes of this data: name, length, format, etc.?
What relationships exist among different data objects?
SAPs data dictionary is called the ABAP Dictionary. As an ABAP developer, it is unlikely that you will
be responsible for creating and maintaining objects within the ABAP Dictionary. ABAP Dictionary is
accessed via transaction code SE11.

The purpose of this chapter is to familiarise you with how objects are created, stored, and used by the
ABAP Dictionary.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

ECC 6.0

The ABAP Dictionary:


Enforces data integrity
Manages data definitions without redundancy
Is tightly integrated with the rest of the ABAP Workbench

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

ABAP Dictionary
ECC 6.0

Enforcing data integrity is the process of ensuring that data entered into the system is logical,
complete, and consistent.
When data integrity rules are defined in the ABAP Dictionary, the system automatically prevents the
entry of invalid data. Defining the data integrity rules at the dictionary level means they only have to be
defined once, rather than in each program that accesses that data.
The following are examples of data lacking integrity:
A date field with a month value of 13
An order assigned to a customer number that doesnt exist
An order not assigned to a customer

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

ABAP Dictionary
ECC 6.0

Managing data definitions without redundancy is the process of linking similar information to the same
data definition.

For example, a legacy customer database is likely to contain a customers ID number in several
places. The ABAP Dictionary provides the capability of defining the characteristics of a customer ID
number in only one place. That central definition then can be used for each instance of a customer ID
number.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

ABAP Dictionary
ECC 6.0

The ABAP Dictionarys integration with the rest of the development environment enables ABAP
programs to automatically recognize the names and characteristics of dictionary objects.
Additionally, the system provides easy navigation between development objects and dictionary
definitions. For example, as a programmer, you can double-click on the name of a dictionary object in
your program code, and the system will take you directly to the definition of that object in the ABAP
Dictionary.
When a dictionary object is changed, a program that references the changed object will automatically
reference the new version the next time the program runs. Because ABAP is interpreted, it is not
necessary to recompile programs that reference changed dictionary objects.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

ABAP Dictionary
ECC 6.0

The basic objects of the ABAP Dictionary are tables, data elements and domains.
Tables are the structures that actually store the information that is in the database (i.e., customer
information). Tables are composed of rows (called records) and columns (called fields).
Data elements and domains are used to describe the characteristics of fields.
More information about these objects will be covered in future chapters.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

ABAP Dictionary
ECC 6.0

The database utility provides the interface between the ABAP Dictionary and the underlying database
management system (DBMS). It supports the creation of tables and secondary indices in the database
both online and in the background. You can access the database utility using transaction code SE14.
Whenever you make a change to a dictionary object that affects the underlying database, the database
utility is activated. Usually it works silently behind the scenes, but occasionally the database utility will
prompt you for information. This occurs when an error is encountered or when existing data must be
converted.
The database utility provides the interface to the DBMS by automatically generating the Data Definition
Language (DDL) that the DBMS understands.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Overview of the ABAP Dictionary

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

There are several path to accessing the dictionary. Below is a list some of the ways to access the
Dictionary.
To access the ABAP Dictionary:
Use the menu path: Tools ABAP Workbench Development ABAP Dictionary; or
Use the menu path:
Tools ABAP Workbench Overview Object Navigator
Pull down the Workbench menu and select Edit objects Select the Dictionary tab from
the pop up screen and enter the appropriate table name in the Database table field.
or
Use transaction code SE11
The ABAP Workbench was known as the ABAP/4 Development Workbench in past releases.
The Object Navigator used to be called the Object Browser and the Repository Browser.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

The basic objects of the ABAP Dictionary are tables, data elements, and domains. These form
the active part of the ABAP Dictionary and contain all the field-related metadata of the R/3 System.
A field is not a dictionary object, but rather is a component of a table. A field cannot exist without a
table and only has meaning within that particular table.
Data elements and domains are dictionary objects. Therefore, they can be used by many tables.
They specify the characteristics of fields.
Table name is limited to 16 characters.
Data element and domain names are limited to 30 characters.
These concepts will be explained more fully in future pages.
Table, data element and domain names were limited to 10 characters in previous releases.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

Tables are the objects that actually hold the information in a database. They consist of rows (records)
and columns (fields).
For example, table KNA1 stores information about customers. Some of the columns in KNA1 are
KUNNR (customer ID number), NAME1 (customer name), and ORT02 (customer city).
Each row in KNA1 stores this information for a different customer.
Certain fields in a table are specified as the primary key of that table. The primary key is that field or
combination of fields that uniquely identifies a row in the table. In table KNA1, the SAP R/3 client
(MANDT) and the customer number (KUNNR) form the primary key.
Custom tables must start with a Y or a Z and can be 16 characters in length.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

The Object Navigator is used to organize your programming in an integrated development


environment. It can be used to create, change, and manage objects. It is the center point of entry into
the ABAP Workbench.
You can get to the Object Navigator by way of transaction SE80 or the menu path:
Tools ABAP Workbench Overview Object Navigator

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

Now, lets take a look at creating a table in the ABAP Dictionary. We will create a table called
ZXXFIRSTTABLE (where XX stands for the last two digits of your logon id). This table will hold
information about your ABAP class.
Follow the menu path:
1. Tools ABAP Workbench Overview Object Navigator
2. Pull down the Workbench menu and select Edit object. Select the Dictionary tab from the
pop up screen and enter the appropriate table name in the Database table field.
3. Click the Create button (F5).
4. You can also use Transaction Code SE11, and select radio button for Database table.
5. Remember, custom table names must begin with a Y or Z and are restricted to 16
characters. Enter a description (short text) and a delivery class.
6. If the table is to be maintained via SAP R/3-provided table maintenance screens, select the
table maintenance attribute (Tab.Maint.Allowed).
7. Click the Fields tab to begin adding Fields to the new table.
We will learn how to add Fields later in this chapter.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

ABAP Dictionary Objects

ECC 6.0

Table fields are defined in SAP R/3 by data elements and domains. This is a key difference between
SAP R/3 and many other systems. In many other systems, a field is defined only by its type (i.e.,
character, numeric) and length. These characteristics are assigned directly to each field.
In SAP R/3, a field is defined by being assigned to a data element, which is in turn assigned to a
domain. These assignments determine the fields type and length in addition to other characteristics.
SAP R/3 refers to this method of field definition as the Two-Level Domain Concept.
In addition, you can assign the field type (data type) characteristics in different ways:
You can directly assign the field a data type, length, and short text when defining the table.
You can assign a data element to a field so that the field will inherit the data elements characteristics.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

The meaning of a field name is not always obvious. For example, KUNNR may not immediately bring
the image of a customer to your mind. Data elements help resolve this problem.
A data element provides a meaningful description for a field. You will hear it called a semantic domain.
The data element description appears beside a field in a table definition. These descriptions are
language-dependent
(unlike field names).
Even more importantly, the data element provides field headings for use on screens. When you paint
a dictionary field on a screen, you can automatically have the data element field headings appear. This
permits the end user to see meaningful field descriptions.
Also in a data element, parameter id is provided. Using a Parameter ID, a screen field that can be filled
with proposed values from SAP memory.
A Search help can be assigned to a data element. A search help is an object of the ABAP Dictionary
with which input helps (F4 helps) can be defined.
The advantage of using a data element to describe fields and provide field headers is that the data
element can be used more than once.
For example, SAP R/3 contains many tables that have the field KUNNR. In cases like this, it is not
necessary to enter the description for KUNNR many times. Each instance of KUNNR can be assigned
to the same data element, and the field description only needs to be specified once. Additionally, if the
description needs to be changed, it must be changed only once, and all fields referring to that data
element automatically use the new description.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

SAP R/3 comes delivered with many pre-defined data elements. Whenever the semantic description of
a field you are creating matches with an existing SAP R/3- supplied data element, use the one that
SAP R/3 provides. Otherwise, you must create your own data element.
When using a SAP R/3-supplied data element, however, you must also use the corresponding SAP
R/3-supplied domain. If you wish to use a different domain, you must create your own data element.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

Now, lets take a look at creating a data element in the ABAP Dictionary. We will create a data element
called ZXXFIRSTNAME (where XX stands for the last two digits of your logon id). This data
element will be used in the table ZXXFIRSTTABLE which we just created.
1.

To create a data element within the ABAP Dictionary use transaction SE80 or the menu path:
Tools ABAP Workbench Overview Object Navigator. You can also use Transaction
Code SE11, and select radio button for Database Type and then Data Element.

2.

Pull down the Workbench menu and select Edit object. Select the Dictionary tab from the pop
up screen and enter the appropriate Data Element name in the Data Element field.

3.

Click the Create button (F5).

4.

Enter a description (short text) and a Domain.

5.

Enter ZXXNAME as the Domain (where XX stands for the last two digits of your logon id).

6.

We will create this Domain later in the chapter. Click the SAVE icon (Ctrl+S).

7.

Type in your development class, YXXA (where XX stands for the last two digits of your logon id).

Note : As of 4.0, a Data Element cannot have the same name as an existing table or Structure.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

Next, click the Field label tab.


Provide a descriptive text for each of the following labels; Short, Medium, Long, and Heading. These
labels are used as templates in the Screen Painter as a choice between the different label lengths.
The Heading field is used as the column heading for tabular record entries and its length should
correspond with the length of the field.
Click the SAVE icon (Ctrl+S).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

In addition to providing field descriptions and headers, data elements can provide detailed field
documentation. This documentation is maintained at the data element level and is available to a user
who hits F1 when the cursor is on a field assigned to the data element.
To maintain this documentation, navigate to the Change Data Element screen within the ABAP
Dictionary and click the Documentation push-button.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

A domain specifies the technical characteristics and the allowed values of a field.
Domains are linked to fields via data elements. In other words, fields are assigned to data elements,
and data elements are assigned to domains. You cannot directly assign fields to domains.
The technical characteristics of a field are the fields type and length. These are also referred to as the
fields format.
The allowed values of a field define what is acceptable input for that field. These may be listed
explicitly or may be specified by reference to a value table. The concept of allowed values is
explained more fully on later pages.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

Domains can exist independently in the ABAP Dictionary.


Just as multiple fields may be assigned to the same data element, multiple data elements may be
assigned to the same domain.
As with data elements, pre-defined domains exist in the system and are available for your use. If a
SAP R/3-supplied domain matches the characteristics you require, use the pre-defined domain. If you
wish to change the domains allowed values, however, you must create your own domain.
In addition to the characteristics listed previously, domains can also specify a fields output
characteristics, such as output length and whether or not lowercase letters are permitted for that
domain.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

Valid values for a domain can be explicitly listed. To create or maintain an explicit list of valid values,
use the menu path Goto Fixed Values on the Change Domain screen in the ABAP Dictionary.
Explicit values are used when the list of valid values are not likely to change
over time.
For example, if a domain was meant to contain the names of the months of the year, it would be
possible to explicitly list JANUARY through DECEMBER as the allowed values (note that this
would not work well in a multi-language environment)
Valid values for a domain can also be specified by reference to a value table. When this is done, the
records in the value table specify the valid values for the domain. In order to specify a value table for a
domain, one of the key fields of that table must point to that domain. That field is the one that
determines the valid values for the domain.
A value table is used when the list of valid values may change over time.
For example, a car maker may want to use a value table to list the valid colors for certain car
models. As new colors are developed, the value table can be updated without changing the
domain itself.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

By defining valid values for a domain, automatic validation is provided for any fields that point to that
domain. This includes validation at the ABAP Dictionary level (if a program tries to insert invalid data,
an error will occur) as well as at the screen level (users will not be permitted to enter invalid data).
Whereas in a report, suppose we have a parameter that references a domain with fixed values then
still user can give invalid data & sap ignores this validation if the addition VALUE CHECK is not
provided with the parameter declaration
Additionally, users can obtain a list of possible entries (for fields pointing to domains with allowed
values) by hitting function key F4.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

Now, lets take a look at creating a Domain in the ABAP Dictionary. We will create a Domain called
ZXXNAME (where XX stands for the last two digits of your logon id). This Domain will be attached
to the Data Element ZXXFIRSTNAME which we just created.
1.

To create a Domain within the ABAP Dictionary use transaction SE80 or the menu path:
Tools ABAP Workbench Overview Object Navigator.

2.

Pull down the Workbench menu and select Edit objects Select the Dictionary tab from the
pop up screen and enter the appropriate Domain name in the Domain field.

3.

You can also use Transaction Code SE11, and select radio button for Domain.

4.

Enter ZXXNAME as the Domain name (where XX stands for the last two digits of your logon id).

5.

Click the Create button (F5).

6.

Enter a description (short text), a data type, and the appropriate number of characters for this
Domain.

7.

Click the

8.

Type in your development class, YXXA (where XX stands for the last two digits of your logon id)

icon (Ctrl+S).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

A domain can define a value range containing the valid values for fields that refer to that domain.

Explicit values or a value table can be defined for the Domain ZXXNAME.
1. Click the Value range tab. Under both sections of this screen, we can assign valid values to
the Domain ZXXNAME. This means that SAP will only allow the values specified on this
screen to be entered into any field that references the Domain ZXXNAME.
2. A Value Table can also be assigned to the Domain ZXXNAME. If a Value Table is assigned
to ZXXNAME, SAP will only allow the values contained within the Value Table to be entered
into any field that references the Domain ZXXNAME if a foreign key is defined.
3. Once valid values are assigned, click the
icon (Ctrl+F3).
4. Navigate back to the Data Element ZXXFIRSTNAME. Click the
icon (Ctrl+F3).
5. Navigate back to the Table ZXXFIRSTTABLE. We will now add a custom field to our table.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

Now you are able to add custom fields to the table ZXXFIRSTTABLE.

Enter FIRSTNAME as the first field in the field list.

Enter ZXXFIRSTNAME as FIRSTNAMEs Field Type (Data Element).

Assigning the Data Element to the field FIRSTNAME means that the field FIRSTNAME will inherit
the same data type and characteristics that we previously assigned to its Data Element,
ZXXFIRSTNAME. The field FIRSTNAME will be a Character based field with a length of 30.

Check the Primary Key checkbox next to the field FIRSTNAME. (This will be discussed in later
chapters)

Continue to add relevant fields (such as LASTNAME, HOMETOWN, POSTBOX, etc.) to this table.
Remember to create your own Data Elements and Domains when SAP does not provide fields that
meet your exact specifications.

Click the

icon (Ctrl+F3) to activate the new table when you are done.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

ABAP Dictionary Objects

ECC 6.0

Maintain the tables Technical Settings by entering a Data Class and a Size Category. Both of these
fields will depend on what the table will be used for and how much data you expect the table to
hold. For this example, ZXXFIRSTTABLE will hold a small amount of Master Data.
1.

Select APPL0 for the Data Class.

2.

Select 0 for the Size Category.

3.

Click the

4.

The table ZXXFIRSTTABLE should now be in an active status and it should contain one field
FIRSTNAME.

IBM Global Services

icon (Shift+F8) and then the

Dec-2008

button (F3).

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

ABAP Dictionary
ECC 6.0

The Data statement:


The statement DATA declares a variable of any data type .
The SELECT ENDSELECT statement retrieves records one at a time from the database and puts
them into the work area. The SELECT-ENDSELECT syntax creates a looping structure. In other
words, all statements between SELECT and ENDSELECT are executed once for each record
retrieved from the database.
The WRITE statement writes data to the screen.

SELECT-ENDSELECT is the Elementary statement for selecting record within an


ABAP code, so this is used here to explain the basic concept of database select. But,
you should firmly remember that this statement should not be used inside programs
that you do during project work. For SELECT-ENDSELECT the database is hit
everytime a new record is found. There are efficient ways of retrieving multiple records
from a database table at one shot and storing them in Internal tables. You will learn
the technique in a future slide.
Dec-2008
IBM Global Services

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

Foreign Key Relationships

ECC 6.0

Relationships between tables are represented in the ABAP Dictionary by foreign keys.
A foreign key is a field (or combination of fields) that represents the primary key of another table.
For example, if table YORDERS has a field CUSTID indicating which customer placed the order, that
field could be established as a foreign key (assuming that CUSTID was the primary key of the
YCUSTOMERS table). Note that CUSTID is not necessarily part of the primary key of the table
YORDERS.
The table that is referenced by the foreign key (in our example, YCUSTOMERS) is called the check
table. The check table is also known as the referenced or parent table.
The table that contains the foreign key fields (in our example, YORDERS) is called the foreign key
table. The foreign key table is also known as the dependent or child table.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

ABAP Dictionary
ECC 6.0

Foreign keys are used for:


1. Maintaining data integrity
2. Providing additional texts in the online help system
3. Creating other dictionary objects that are defined over multiple tables (such as views)

Maintaining data integrity is probably the most important reason to use foreign keys. With foreign
keys, it is possible to prevent values from being entered into one table that do not already exist in
another table. For example, it becomes impossible to enter orders that do not have valid customer
numbers.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

ABAP Dictionary
ECC 6.0

In order to establish a foreign key relationship in SAP, the fields involved must share the same domain.
Therefore, foreign keys provide an additional data integrity check beyond that which is provided by the
value table.
Prior SAP versions required that Foreign Keys must have a Value Table specified.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

ABAP Dictionary
ECC 6.0

Lets review some of the key terminology relating to foreign keys.


Value table: The table containing the set of allowed values attached to a domain.
Check table: The table that is referenced by a foreign key. A check table is either
identical to a value table, or is another table containing a subset of the records in a
value table.
Foreign key table: The table containing fields that are the primary key of the other
table. The foreign key table is also known own as the dependent or child
table.

Using Foreign Keys, you can


1. Create value checks for input fields.
2. Link several tables in a view or in a lock object.

To see a full list of the allowed values for a screen field, place the cursor inside the field and hit the
F4 key.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

ABAP Dictionary
ECC 6.0

For example, suppose a foreign key relationship was established between an ORDERS table and a
PRODUCTS table in order to ensure that orders contained valid product numbers. In this case, it is
likely that the value table and the check table would both be the PRODUCTS table.
In many cases, the value table and the check table will be the same. However, it is important to
understand the distinction between the two.
The Value Table is optional in the foreign key definition.
Foreign Key definitions must always have a Check Table assigned.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

Foreign Key Relationships

ECC 6.0

For example, suppose a telephone company stores general customer information in the CUSTOMERS
table and stores specialised information about business customers in the BUSINESS_CUSTOMERS
table.
Suppose that there was also a BUSINESS_OWNERS table that listed the owners of all business
customers. The BUSINESS_OWNERS table might consist of two fields: Customer ID and the name of
each individual owner.
In this case, we would establish a foreign key relationship between the BUSINESS_OWNERS table
and the BUSINESS_CUSTOMERS table.
The value table for the customer ID field in the BUSINESS_OWNERS table would be the
CUSTOMERS table, but the check table would be the BUSINESS_CUSTOMERS table.
The foreign key table would be the BUSINESS_OWNERS table.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

ABAP Dictionary
ECC 6.0

To establish a Foreign Key in the ABAP Dictionary, begin by navigating to the field definition of the
Foreign Key Table and entering change mode.
The Foreign Key can then be established by placing the cursor on the Foreign Key Field, and then by
clicking the icon
in the Application Toolbar.
Based on the Value Table for the domain of the field you selected, the system will suggest a Foreign
Key Relationship for you.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

Foreign Key Relationships

ECC 6.0

When creating foreign key relationships, you should always specify the cardinality of that relationship.
Here is a reminder of the possible values for each side of the n : m notation that SAP uses to specify
cardinality.
For the left side:
n=1
Each record in the foreign key table refers to exactly one record in the check table.
n = C Each record in the foreign key table refers to zero or one records in the check
table.
For the right side:
m=1
Each record in the check table has exactly one dependent record.
m=C
Each record in the check table has a zero or one dependent records.
m=N
Each record in the check table has at least one dependent record.
m = CN Each record in the check table has zero, one, or many dependent entities.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

Foreign Key Relationships

ECC 6.0

Using the Object Navigator edit the Table ZXXFIRSTTABLE which we created in Chapter 2.
Place the cursor on the field for which you wish to create a Foreign Key Relationship. In this example,
we will add the Check Table T005S as a Foreign Key for the STATE field so that users will be
forced to enter a valid state into the Table ZXXFIRSTTABLE.
Click the
icon to create the Foreign Key Relationship for the STATE field. Remember the criteria
for establishing a Foreign Key Relationship: the Foreign Key Field and Check Table Field must
share the same domain.
Since the field STATEs domain (REGIO) has a Value Table (T005S),
SAP will propose T005S as the Check Table for the field STATE when we click the Foreign Key
pushbutton. Click Yes when the Create Foreign Key window appears.
You can see a graphical representation of the foreign key relationships in a table by clicking on this
icon
or from application toolbar (Ctrl+Shift+F11).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

ABAP Dictionary
ECC 6.0

Enter a description (short text).


Maintain the semantic attributes (see Data Dictionary Appendix for information on setting up the
Cardinality)
Cardinality n : m
n = 1 or C
m = 1, C, N, CN
Foreign Key Field Type (see Data Dictionary Appendix for information on setting up the Foreign
Key Field Type)
1. Not Specified
2. Non-Key Field Candidates
3. Key Field / Key Field Candidates
4. Key Fields of a Text Table
Click the Copy button at the bottom of the screen.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

ABAP Dictionary
ECC 6.0

If the primary key of a check table has multiple fields (i.e. it has a composite primary key), some
type of assignment must be made for each field when creating a foreign key relationship.
The options include:

Creating a field-by-field assignment. Every primary key field in the check table is
matched with a field in the foreign key table.

Using a partial foreign key. Some fields will not be a determining factor in deciding
what check table records provide acceptable values for the foreign key field being
checked.

Using a constant foreign key. Only check table records with a particular constant
(literal) value in a particular field provide acceptable values for the foreign key field
being checked.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

ABAP Dictionary
ECC 6.0

When performing a field-by-field assignment, all key fields in the check table are used to determine
valid entries in the foreign key table.
For example, suppose there was a YCOURSES table with the key fields faculty (academic department)
and course number. This table would provide the master list of courses that an academic institution
offers.
Suppose also that there was a YOFFERINGS table with the key fields faculty, course number, and
section number. This table would list the times and dates that different sections of each course were
offered.
In this case, we would establish a foreign key relationship from YOFFERINGS to YCOURSES using
field-by-field assignment.
In other words, the faculty and course number fields for each record in the YOFFERINGS table would
have to match the faculty and course number fields for some record in the YCOURSES table.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

ABAP Dictionary
ECC 6.0

When creating a partial foreign key, certain fields are flagged as generic. These fields are ignored by
the system when validating records that are inserted into the foreign key table.
For example, suppose that we were tracking information about new courses that were under
development in a YNEWCRS table. This table would have faculty and course number as the primary
key. However, in this table, we would not want to validate the course number against the YCOURSES
table, because by definition the new courses are not yet in the YCOURSES table.
In this case, we might use a partial foreign key from YNEWCRS to YCOURSES and flag the course
number field as generic. In other words, the table YNEWCRS would be forced to have valid values in
the faculty field, but we could enter any course number we wanted.
This example is for illustration purposes. In a real-world application, there would probably be a
separate YFACULTY table that would list valid faculties, and the YNEWCRS table would probably be
validated against that table.
Note: If additional fields are added to the primary key of a check table, the new fields are
automatically flagged as generic in any previously existing foreign keys.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

ABAP Dictionary
ECC 6.0

When creating a constant foreign key, certain fields are assigned a literal value. Only records in the
check table with that value in the corresponding field are used to determine whether records in the
foreign key table are valid.
For example, suppose there was a table YBIOCRS that contained specific information about biology
courses. The primary key of this table would be course number only (it would already be understood
that the courses were biology courses). In this case, we would want to validate the course number
against the YCOURSES table, but we would only want biology course numbers to be valid. That is, if
there was a course English 402 but no course Biology 402, we would not want 402 to be a valid
entry in table YBIOCRS. To accomplish this, we could establish a foreign key from YBIOCRS to
YCOURSES with the constant value BIO in the faculty field.

Note: Assigning a constant value to a field has the effect of restricting the values that are permissible
for the other foreign key fields in the foreign key table. Validation is actually turned off for the field that
is assigned the constant value. For example, if we changed the above example so that the table
YBIOCRS did have a faculty field, it would be possible to enter any value in that field.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

Foreign Key Relationships

ECC 6.0

Click on the checkbox provided to flag a foreign key field as generic.


Enter a constant value in quotes to define a foreign key relationship with a constant.
It is possible to combine the use of partial and constant foreign keys within the same foreign key
relationship.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Foreign Key Relationships

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

IBM Global Services

Dec-2008

ABAP Dictionary
ECC 6.0

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

IBM Global Services

Dec-2008

ABAP Dictionary
ECC 6.0

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

There are 3 different table types in the SAP ABAP Dictionary:


1. Transparent tables
2. Pool tables
3. Cluster tables

Data in the SAP R/3 system is stored in a relational database management system (RDBMS). All
tables in the SAP R/3 system are created using the ABAP Dictionary and are stored in the
relational database.

The ABAP Dictionary is SAPs tool for developers to maintain any type of table that exist in the
physical database.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

SAP uses the term master data to refer to control tables and the traditional files that are
necessary to run a business such as personnel files, general ledger accounts, customer files, etc.
There is a 1:1 correlation between the master data tables in the Dictionary and the tables in the
physical database. For each master data table in the Dictionary, the same master data table
exists in the physical database.
Commercial data or transaction data is another SAP term used to refer to data created as a result
of performing SAP business transactions such as creating: invoices, orders, production
schedules, purchase requisitions, stock transfers, etc.
SAP stores both master data and transaction data in transparent tables (TRANSP).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

Transparent (TRANSP) tables have a 1:1 correlation between the ABAP Dictionary and the
physical database. For each TRANSP table in the Dictionary, the same table name exists in the
physical database.
Since TRANSP tables exist in the physical database, you can use either Open SQL or Native
SQL to access them.
Transparent tables are created automatically in the database after you specify the tables
technical settings and activate the table using the Database Utility. The Database Utility gets
invoked automatically when you activate the table by clicking the
icon.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

ABAP Dictionary Tables in Relational Databases

ECC 6.0

Pooled tables can be used to store control data (e.g. screen sequences, program parameters or
temporary data). Several pooled tables can be combined to form a table pool. The table pool
corresponds to a physical table in the database in which all the records of the allocated pooled
tables are stored.
Cluster tables may contain continuous text, for example, documentation. Several cluster tables
can be combined to form a table cluster. Several logical lines of different tables are combined to
form a physical record in this table type. This permits object-by-object storage or object-by-object
access. In order to combine tables in clusters, at least parts of the primary keys must agree.
Several cluster tables are stored in one corresponding table on the database.
We will not be working with these two type of tables in the exercises for this course.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

Technical settings allow you to optimize the storage requirements and table access behavior of
database tables.
The Technical Settings screen appears when you click the
icon on the ABAP Table
Maintenance screen.
Data class - Designates the table to an area in the physical database where similar
tables are grouped (in ORACLE and INFORMIX only).
Size Category - Identifies the amount of disk space that will be required to hold the
data records for a table in the database (in ORACLE and INFORMIX only).
Buffering - Determines whether table records will be accessed directly from the
database server or from global memory.
Logging - Creates before and after images of changes to the table of contents.
Logging must be activated by the profile when the system is started.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

Tables in the ABAP Dictionary must be assigned to one of the following classes of data:
Master Data: Large amounts of data which do not change often. It is often read, but
rarely updated. An example of master data is the data contained in an address file,
such as the name, address and telephone number. (APPL0)
Transaction Data: Data with temporary lifecycle, not stored long. Frequently
updated. An example of transaction data is the goods in a warehouse, which change
after each purchase order. (APPL1)
Organization and Customizing Data: Specified when the system is configured and
then not often changed. An example is the table with country codes. (APPL2)
Two further data classes, USER and USER1, are provided for the customer. These are used to
define user developments.
Defining a data class has the effect of storing the table in a defined area of the database when the
table is created.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

A tables size category identifies the amount of disk space on the database that is allocated to the
table.
This amount is translated to a number of data records if you hit F4 for help, depending on the
underlying database.
If the number of records in a table exceeds the original size category, then more space will
automatically be allocated in the database. The storage space will be incremented by the amount of
the original size category.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

Buffering is only recommended for tables with data that typically does not change or get updated.
Buffering types:
Single record: Only a single record actually being processed is moved into the buffer.
This type of buffering preserves buffer space but requires more database hits in order to
load the table. Recommended for large tables when only a few records need to be
accessed.
Generic: A subset of the table records are loaded based on part of the primary key.
Recommended if only certain generic areas of the table will be needed.
Full: Results in either all of the table or none of it being loaded into the buffer.
Recommended for a) tables up to 30 K in size, b) larger tables where access is needed to
many records, and c) tables against which attempts to access data will frequently yield a
no record found result.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

On the technical settings screen you can specify Log data changes to automatically generate a log
file of details on the structure of a table, a list of the data changes made during a certain period, and
statistics.
In addition to clicking the checkbox Log data changes on the technical settings screen, you must
ensure that the System Administrator has also specified the switch or entry to allow Table Logging
On.
Log files do not rely on successful database updates to be completed before they are written.
The existing logs can be displayed with Transaction code SCU3.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

Activating tables causes the Technical Settings screen to display. Choose an appropriate data class
and size category. Use the F4 help to list the possible entries.
The Buffering and Logging settings can also be set on this screen.
When the settings are saved, SAP automatically runs the Database Utility.
A tables Technical Settings can be changed at any time.
For successful activation of tables, we need to specify the enhancement category using the menu
path Extras Enhancement Category in ECC 6.0.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

IBM Global Services

Dec-2008

ABAP Dictionary
ECC 6.0

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

IBM Global Services

Dec-2008

ABAP Dictionary
ECC 6.0

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

The Database (DB) Utility is a tool used in SAP to serve as a interface between the database
management software (i.e., ORACLE, INFORMIX, DB2, INGRES, etc.) and the ABAP Dictionary.
It is used to:
Convert data (i.e., change field lengths and data types, etc.)
Activate objects in the ABAP Dictionary
Create tables and indices
Perform all standard table operations in the database that were entered in the ABAP
Dictionary
The DB Utility automatically writes the SQL commands necessary to create, change and delete
tables and indexes in the physical database, and records the tables in the ABAP Dictionary.
As the DB Utility is operating, a log file gets created which contains information on whether or not
the conversion was successful and the point of failure during the conversion if it was not
successful.
The DB Utility can be run either online or in the background.
You can also manually run the DB Utility from any ABAP Dictionary screen under the UTILITIES
Database Object Database Utility menu or transaction SE14.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

ABAP Dictionary Tables in Relational Databases

ECC 6.0

To improve performance, SAP automatically creates a primary index (id 0) for transparent tables
based on the primary key. You can also define your own secondary indexes for transparent
tables.
Indexes accelerate the reading of tables when the system looks for records satisfying specific
search criteria. The system determines the most efficient index by which to select data for the
specific request.
An index serves as a sorted copy of the table reduced to specific fields, with a pointer to the
remaining fields.
Database indexes are defined in ABAP Dictionary and stored in the physical database.
From the ABAP table maintenance screen use the menu path GoTo Indexes.
A pop-up window appears. In pop up window press the create button and select the entry
Create Index from the dropdown. Assign a 3-character id to your index.
Provide a short text and select the field(s) by which the table needs to be indexed.
Sometimes the presence of an index causes a performance problem. You can indicate the
optionality of the index with different databases. Secondary index is used for the tables which are
not frequently changed (Eg: Master tables)
Creating an index on an SAP table requires a repair, but it will not get overwritten with an
upgrade.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

In the cases where database accesses are necessary and appropriate, it is imperative to perform
those accesses as efficiently as possible. The single most important method of optimizing a
database access is by using an index.
An index is a set of fields from a table that is sorted and then stored in a location separate from the
table itself. Each record in the index contains a pointer to matching record(s) in the actual database
table.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

This analogy is probably as old as computer science itself, but it still works well. Think of an index
like a telephone book.
If you want to find someones phone number, the first thing you might do is decide where you want to
look for that number. One thing you probably wont do is start calling all possible telephone number
combinations until you hit upon the right one! You might ask a friend, or call directory assistance, or
look up the information in a phone book.
Lets suppose you decide to use a phone book. The next thing you do is to begin searching for that
persons name in the book. Once you find the name, you then look across from the name to find the
number.
A DBMS goes through a similar process when performing a query. It first must decide how it is going
to look for the information that has been requested, just as you did when looking for a telephone
number. One option is to look at each record in the table, one at a time, until all the matching records
have been found. This would be analogous to trying all possible combinations of telephone numbers
until you found the right one.
As ridiculous as that sounds, sometimes DBMSs have to do just that. This is called performing a full
table scan.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

Another option the DBMS has is to perform an index scan. In this case, the DBMS looks in a
separate file, searching for the information by a particular key field (or fields). This is like using the
phone book, searching for the correct name.
Once the matching record(s) have been found in the index, the DBMS follows a pointer from the
index to retrieve the actual record in the table. This pointer consists of a disk address that tells the
system exactly where to find the desired record(s). In our telephone book example, the analogous
process is pretty simple: you simply look across the line from the name to the telephone number.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

This process is analogous to an index range scan that might be performed by a DBMS. Sometimes
an index doesnt point to a single record. If you have an index of customers by their last names, this
will probably be the case - you will probably have many customers with the same last name.
In this case, once the database finds matching record(s) in the index, its job isnt over. It now must
retrieve all the records that matched the selected index records, and examine each one to see if they
meet the final selection criteria for the query.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

ABAP Dictionary
ECC 6.0

In contrast, if each index record matches exactly one record in the table, and if all the fields of the
index are specified in the query, a unique index scan can be performed. Queries based on a tables
full primary key always fulfil this criterion - such as by client (implicit if using Open SQL) and
customer number in table KNA1.
In this case, once the DBMS finds the matching record in the index, its work is almost done. All it
must do is follow the pointer from the index to the solitary table record that it knows will satisfy the
query.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

ABAP Dictionary Tables in Relational Databases

ECC 6.0

In general, indexed reads are much quicker than normal table reads, and some types of indexed
reads are quicker than others. A unique index scan is generally faster than an index range scan,
because it has less data to sort through and retrieve.
The smaller the amount of data being processed by a query, the faster it will run.
Here are some guidelines:
Always make your queries as selective as possible.
Use indexed reads over full table scans.
Use unique index scans when possible.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

IBM Global Services

Dec-2008

ABAP Dictionary
ECC 6.0

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Tables in Relational Databases

IBM Global Services

Dec-2008

ABAP Dictionary
ECC 6.0

IBM Global Services - SAP Development ABAP Training


Adding Structures

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Adding Structures

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Adding Structures

ABAP Dictionary
ECC 6.0

Structure - A group of internal fields that logically belong together. A Structure consists of
components (fields) whose types are defined. A component can have an elementary type, a
structured type, a table type or a reference type.
In ABAP, you reference a Structure by its name. To access the individual fields within a Structure,
you must specify the name of the Structure followed by component selector(-) followed by the
relevant field name.
A Structures components can have an elementary type, a structured type, a table type, or a
reference type.
Structures are used especially to define the data at the interface of module pools and screens and
to define the types of function module parameters.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Adding Structures

ABAP Dictionary
ECC 6.0

Groups of fields can be added to customer tables using substructures.


Groups of fields or individual fields can be added to SAP delivered tables using append structures,
or customizing includes:
Substructures allow you to include fields from another table or structure in the table you
are creating.
Customizing includes are provided in SAP tables and structures to allow you to add
fields to these structures/tables without modifying the tables themselves.
Append structures allow you to add fields to SAP-provided structures and transparent
tables that were not provided for in the standard version.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Adding Structures

ABAP Dictionary
ECC 6.0

Rather than listing all the fields you want a table or structure to contain, you can choose to include
fields from another table or structure as a substructure. This allows you to avoid redundant field
definitions in structures/tables as well as maintain changes for these common fields in one
structure/table.
Substructures can be nested. A structure can include another structure, which in turn includes
another structure, etc.
Up to nine nesting levels are allowed.
TRANSP table types can only exist once in a nested chain.
To include a substructure in a table:
Type .INCLUDE for the Field Name field on the Table Change screen, then type in
the name of the structure/table in the Data elem. field.
You can expand and collapse substructures in the table/structure definition screens they are used.
This is an alternative way to see what fields the substructure holds, rather than double-clicking on
the substructure name to navigate to its definition.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Adding Structures

ABAP Dictionary
ECC 6.0

If it is expected customers will need to add their own fields to SAP tables or structures, some of the
standard version SAP tables and structures are supplied with customizing includes.
Customizing includes are supplied empty by SAP and are filled in by the customer with the help of
special customizing transactions. These includes make it possible to extend (add fields to) tables
without modifying the tables themselves and without the risk of additions being overwritten during a
Release Upgrade.
Names of customizing includes start with CI_. If a table does not contain a customizing include, you
can still make additions by creating an Append structure. You cannot add your own .INCLUDE CI_ to
an SAP table.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Adding Structures

ABAP Dictionary
ECC 6.0

Append structures are intended for additions not provided for in the standard version of SAP tables
via customizing includes. They are to be used with SAP transparent tables or structures, not with
customer tables.
An Append structure is a structure assigned to exactly one table. However, a single table can have
a number of append structures. It is recommended to use only one append structure in a table.
When an append structure is activated, its assigned table is also activated with all of the append
structure fields. When a table including an append structure is activated, the append structure fields
are found and added to the table.
Append structures cannot be deleted.
Append structures cannot be used with tables containing fields of data type VARC, LCHR, or LRAW
because these data types must be the last field in a table.
Use the Append structures push-button in the table display screen to add fields to SAP tables.
Fields contained in an Append structure are added to the SAP tables when an upgrade is performed
and the appropriate tables are activated.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Adding Structures

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Adding Structures

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Adding Structures

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Adding Structures

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Repository Information System

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Repository Information System

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Repository Information System

ABAP Dictionary
ECC 6.0

The ABAP Repository Information System is a tool which allows you to perform quick searches for
information on all ABAP development objects. The two basic functions available in the Repository Info
System are the Find and Where-used list functions.
The Find function allows you to search for objects from a specific object class meeting selection
criteria.
The Where-used list function allows you to determine the use of an object in other objects.
Both functions produce a list of results which met the specified search criteria.
Typical queries made to the Repository Info System include:
Find (Object searches, e.g.:)
List all domains with a specific data type (char) and length (10)
List all tables changed by user ABAPXXX since 01/01/96
List all data elements that refer to a particular domain (UPENUM)
List all tables containing a specific field (EUNR)
List all indexes for a specific table (UPERS)
Where-used list (e.g.:)
List all views containing a particular base table (UPERS)
List all tables using a particular table (UPERS) as a check table

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

ABAP Repository Information System

ECC 6.0

To access the ABAP Repository from the initial SAP screen, use the following menu path: Tools
ABAP Workbench Overview Information System.
Expand any subitems in order to perform a search on a particular object (i.e., perform a search on
Tables).
The ABAP Repository Information System can also be accessed via transaction code SE84.
In previous SAP releases, the menu path was: Overview Repository Infosys.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Repository Information System

ABAP Dictionary
ECC 6.0

To search for objects via specific attributes by providing the relevant entries in the available search
fields. Additional search fields can be used to limit search criteria by using the All Selections icon
(Shift-F9)
. When the All Selections icon is used, an Additional Selections group box with more
object attributes is displayed beneath the standard selections.
Enter a single value in the search attributes, or use the arrow pushbuttons for Multiple-Selections.
The * and + wildcards are available for input in search fields.
* represents any field string.
+ represents one character.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Repository Information System

ABAP Dictionary
ECC 6.0

It is possible to list single values as search criteria using the Selection Options screen. Use the
Selection Options icon
to obtain the list of possible Selection Options.
Use the SELECT and EXCLUDE FROM SELECTION pushbuttons to perform inclusive or exclusive
range searches.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Repository Information System

ABAP Dictionary
ECC 6.0

On all hit lists, you should see the following common options under the first menu path:
CHANGE: Changes to object's maintenance screen, assuming it is yours to edit.
DISPLAY: Changes to objects display screen.
CHECK: Checks object for syntax errors.
GENERATE/ACTIVATE: Allows you to activate an object.
TEST/EXECUTE: Lets you run the object.
PRINT: Sends list to printer.
COPY: Allows copying of selected objects .
RENAME: Changes the name of an object, assuming it is yours and doing so will not cause
cascading negative effects.
REASSIGN: Change the Package to which an object is assigned.
DELETE: Allows deletion of selected objects in list.
TRANSPORT: Include selected object in a transport request.
EXIT: Return to the Repository Information System.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Repository Information System

ABAP Dictionary
ECC 6.0

To create where-used list searches for the table name, check the table name for which search is
required and click on where-used list icon
which generates the where-used list for the tablename selected. Check programs to find out the programs where table: MARA is used. ( refer above
screen ).
The output lists of where-used searches are similar to basic output lists of Find object searches.
Where-used searches can also be performed outside the Repository, such as in an ABAP program
(i.e., to find the use of variables throughout a program), or in the ABAP Dictionary (i.e., to determine if a
particular type group was used in other ABAP programs), or in the Repository Browser, or any of the
other Workbench Tools.

The ABAP Repository Information System supports both where-used and sub-objects searches for
Dictionary objects. These searches can occur from within lists. Therefore, it is possible to navigate
both up and down as well as back and forth through the hierarchy of related objects.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Repository Information System

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Repository Information System

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

ABAP Repository Information System

ECC 6.0

The Repository can also be used to perform searches on other ABAP Workbench objects:
Business Engineering
Data modeling
Process modeling
Business Object Browser
Program Library
Function builder
Program library
Program sub-objects
Development co-ordination
(Packages)
Requests/Tasks.
Test Objects
Authorizations (authority objects)
Automatic tests (CATT procedures)

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Repository Information System

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Repository Information System

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

ABAP Dictionary
ECC 6.0

An object must be fully activated in the SAP system in order to be used by other objects (e.g., a
domain must be activated prior to being used by a data element, tables must be activated prior to being
used in an ABAP program, etc.).
ABAP Dictionary objects are activated either:
Individually (immediately after each object is saved with the activation icon) or
Mass (several objects grouped together for later activation after each one has been saved)
Two steps are required to perform a mass activation:
1. Enter the object types and names in a table named TACOB. Use the menu path: System
Services Table Maintenance Extended Table Maintenance or transaction SM30 to
access this table. Enter TACOB for the table name and click the maintain pushbutton. Some of
the object types are:
DOMA (domains)
DATA ELEMENTS (data elements)
TABL (tables)
2. Execute the mass activation program RADMASG0 via transaction SE38, or use the menu
path: System Services Reporting (transaction SA38). Enter TACOB for the external table
name and click the Execute pushbutton.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

ABAP Dictionary
ECC 6.0

The mass activation program RADMASG0 can either be run online or scheduled as a background job.
Greater efficiency is gained when objects are activated online due to the links that can occur between
subcomponents of objects. (i.e., links between data elements and various tables).
For example, if several tables attempt to use the same data elements, failures can occur when the
tables are activated because the data elements are waiting on a background job to run in order to be
activated.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

ABAP Dictionary
ECC 6.0

ABAP programs and Screen Painter screens always use the current version of a table activated in the
Dictionary.
When an object is changed and re-activated, all other objects currently linked to the changed object are
automatically updated, (i.e., when a domain is changed and activated, all data elements, tables, report
programs, module pool programs reflect the change, they do not need to be reactivated as well). As
you can see, changing and reactivating objects can greatly affect a large number of associated objects.
If appropriate, a data object is automatically checked for consistency (among data types) when the
object has been changed.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

ABAP Dictionary
ECC 6.0

Changing the primary key of a value table that is being used by a domain, requires a lengthy process
because of the embedded links between the domain and the value table.
It is not a simple process to change and reactivate a value table. The below 8 steps should be followed
to do this.
The 8 steps are:
1. Delete old value table from domain
2. Activate domain without value table
3. Change primary key
4. Maintain all dependent tables (remove check table)
5. Activate dependent tables
6. Reactivate value table
7. Type value table in affected domain: Activate domain
8. Maintain dependent tables if required: (Define foreign keys)

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

ABAP Dictionary
ECC 6.0

An object in the ABAP Dictionary can exist in various versions and a listing of them can be viewed
within the objects dictionary maintenance screen via the menu path Utilities Version
management.
There are two VERSIONS of an object that can exist in the ABAP Dictionary:
Active: valid in the dictionary and in any development objects (i.e., programs) in which it is
used.
Revised: a modified version.
You can switch between the two versions.
Once an object is activated, you can change it and save a modified (revised) version.
This can be viewed from Utilities Version management. If you activate this new revised
version, it overwrites the original activated object.
In the Version Manager, objects which are saved appear with the notation modif.
Objects which are activated appear with the notation activ.
(Continued on next page)

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

ABAP Dictionary
ECC 6.0

Versions (continued):
Temporary versions (under the heading Version(s) in the version database):
During the development process while a change request is open, several temporary
versions of an active object can be stored. Even after the object has been activated, it can
be reset to the previous status. Store versions in the maintenance screen of objects via
the leftmost menu (i.e., Table, Data Element, Program)Store version. Temporary
versions act as backup versions prior to the change request being released. When a
change request is released, all temporary versions are deleted.
Historical versions:
If an object has been changed and activated, when the corresponding change request for
the object is released for transport, the active version is stored as an historical version in a
versions database. These versions are created every time a change request is released
after an object has been changed. From the object maintenance screen, use the menu
path Utilities Version management to see an overview of all versions that exist for an
object.
Versions of non-dictionary objects (i.e., programs) can be stored. However, only active,
temporary and historical versions are possible (modified versions).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

ABAP Dictionary
ECC 6.0

Display:
List all defined attributes of object.
Compare:
Differences between this version and previous versions are highlighted.
Retrieve:
Retrieve stored version of object. Version is located in the ABAP Dictionary and takes the form
of a revised version.
Remote compare:
Comparison with versions from other systems.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

ABAP Dictionary Changes

ECC 6.0

When you activate an object any locks on the object are automatically released.
Other users can see the revised version in the Dictionary but can only access the active
version.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

ABAP Dictionary
ECC 6.0

Versions of modified (repaired) SAP standard objects can be compared with new SAP standard objects
by using the transaction SPDD.
SPDD compares an inactive SAP standard version with the active modified (repaired) version
and displays the results of the comparison in tabular form. All modifications to SAP objects made by
clients are incorporated for review and considered by SAP during a system upgrade for a new release
of SAP.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Changes

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

A view is an object, like the telescope, that provides a picture of something.


We can construct a view with special lenses or filters to allow us to look at one or more dictionary
tables. We can look at parts of one table (selected records and/or fields) or combinations of tables and
parts of tables.
A view is an ABAP Dictionary object.
In many cases, you reference a view in an ABAP program just as you would a table. For example, you
can select data from a view. However, a view does not contain data of its own rather, the view
provides specialised access to the data that exists in other tables. For this reason, views are often
called virtual tables.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

In its most basic form, a view simply mirrors an entire database table. It looks just like the table and it
acts just like the table but it isnt actually the table.
Of course, if this is all that views could do, they wouldnt be very useful. Lets take a look at some of
the other capabilities of views.
The view name cannot be the same as an existing table name.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ECC 6.0

We can use views to:


Join several tables
Project (or choose) certain fields from one or more tables
Select (or choose) certain records from one or more tables
Join, projection, and selection are called relational operations.

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

The projection operation is used to narrow a views focus to certain fields in a table.
For example, we might have a view of an employee table that does not contain the salary field.
Employees authorised to view salary data would be given authorisation to view the actual table, while
other employees might only have authorisation to use the view without the salary data.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

When designing a view, view fields need to be given names. The view field names should be the same
as the regular table fields they are reflecting, unless the view is a database view. Only in that situation
are you permitted to use different names. When referencing the view field in code, you would refer to
VIEW_NAME-VIEW_FIELD_NAME.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

ABAP Dictionary Objects: Views

ECC 6.0

The selection operation is used to narrow a views focus to certain records in a table.
For example, we might sometimes wish to view only the information about employees belonging to a
certain staff classification. This might mean creating one view containing partners and principals one
view containing principal consultants, and another view containing consultants. Each view would be
built using selection criteria that indicated which records to include in that view. As an example of why
such a view might be used, staff members might be permitted to view the billing rates of employees in
the same staff classification or lower, but not of employees in a higher classification.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

You specify selection criteria by building logical expressions that compare specific fields of a table to
hard-coded literal values.
(1 & 2) Specify the table and field on which the restricted selection should take place. Any
fields, including unprojected ones, can be indicated.
(3) Specify the relational operator used to compare the field to the value. You may use EQ, NE,
LE, LT, GE, GT, LIKE, and NOT LIKE.
(4) Specify the comparison value. Comparison values must be text or numeric literals. Text
literals must be enclosed in single quotes.
(5) You can specify multiple selection criteria (one per line) and link them using the logical
operators AND and OR. Unlike elsewhere in SAP (and most other systems), OR takes priority
over AND. Also, OR operations are only permitted between lines which refer to the same field.
If the projection and selection operations are both used within the same view, it is possible to specify
selection criteria for fields that are not included within the view. For example, it would be possible to
create a view that contained only employees making over $100,000 per year even if the view did not
contain the salary field.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

ABAP Dictionary Objects: Views

ECC 6.0

The join operation is used to combine information from multiple tables into a single view.
For example, we might wish to create a report listing employees by name, along with their salary
history. Database design considerations would probably result in the salary history being stored in one
table and basic employee information (such as the name) being stored in another. Thus, we might
create a view that would combine the data from both tables. We could write our report program using
this view, and it would seem to our program as if the data was stored in a single table.
Using the join operation within a view is generally the most efficient way to access data from multiple
tables. Well examine some other methods later on.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

Database design principles often require related data to be stored in separate tables. This is
necessary to provide flexibility in one-to-many and many-to-many relationships, and also to prevent
data redundancy.
For example, if employee name and salary history were stored in the same table, we would encounter
one of the following situations:
If we stored salary history on the employee record, we would have to create a fixed number of
previous salary fields in the employee table. For many employees, most of those fields would
be blank, and for long-term employees, we might eventually run out of fields.
If we stored employee name on the salary history record, we would have many copies of the
employees name. If the employees name changed, that change would have to be made many
times. Additionally, we would run the risk of not updating all the data correctly, and the
employee and the salary table could get out of sync. Whenever possible, redundant copies of
the same information should be avoided.
As a result, data is often broken apart into several tables. This is called normalising the database.
The join operation essentially reverses this process. The result of a join is a view that looks like a table
with redundant data.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

When data is broken apart into separate tables, it is still necessary to duplicate some data namely
the key fields of the tables involved. For example, the salary history table would contain a field for
employee ID number, so that we knew which employee each salary record belonged to. In this case,
the employee ID number becomes a foreign key in the salary history table.
The key to understanding the join operation is to understand that different tables are joined together
using foreign keys. We dont want every employees name associated with every salary history record.
Rather, we want each employees name to be associated with only those salary records belonging to
that employee.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

Therefore, in order to use the join operation in SAP, you must first ensure that the appropriate foreign
key relationships exist among the tables to be joined. Also, you must ensure that the semantic
attributes of those foreign keys have been maintained (see Chapter 4 for a discussion of semantic
attributes and foreign keys).
Other notes on the join operation:
Views are created with a primary table and up to 10 secondary tables.
The primary table can be either a check table or a foreign key table with respect to the other
tables in the view (i.e., the primary table does not have to be the check table).
Note : When a join operation is employed, only those primary table records that have a match
in all secondary tables are retrieved. For example, in a join between employees and salary
history, employees with no salary history records would not appear at all.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

You can hard code all the tables you need all at once. Then you would have to hard code the foreign
key relationships between them as well.
It might be simpler to input the first base table, and from there hit the Relationships pushbutton. Then
you can select a related table and the join conditions will be filled in automatically for you.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

The database view is the only type of view in SAP that is physically created at the database level. In
other words, the underlying database system also directly recognises the view, apart from SAP.
Therefore, database views must be created over transparent tables.
With the database view, all three of the relational operations (projection, selection, and join) can be
used.
Database views can be buffered just like transparent tables. In the technical settings you can decide
whether to have buffering off, or on with type single record, generic, or full.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

The projection view is a logical view. In this context, the word logical means that the view exists
within the ABAP Dictionary but is not recognised by the underlying database system.
Projection views must be defined over a single transparent table.
The only relational operation that is valid for a projection view is projection.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

ABAP Dictionary Objects: Views

ECC 6.0

Projection Views

Database Views

Must be built over a single table

Can be built over many tables

Data can be updated

Data can be updated if the view is built over a


single table

Data updates must use open SQL

Data updates can use open SQL or Native SQL

Updates are less efficient than using


a Database View

Updates are more efficient than using


a Projection View

Fields in the view must be named the


same as the fields in the
underlying table

Fields in the view can be named


differently from the fields in the
underlying table(s)

Cant be buffered

Can be buffered

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

Help Views: Help views can be used as selection methods for Search Helps. It might be necessary to
create a Help View if you are trying to accomplish an outer join, since database views only create inner
joins.
Maintenance Views: These views permit maintenance of base table data. Transactions SM30 and
SE54 are provided for working with maintenance views.
In previous releases, Help Views used to play a major role in matchcodes. However, matchcodes have
been replaced by Search Helps, and therefore, Help Views no longer have as big a presence.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

ABAP Dictionary
ECC 6.0

In the code above, we select data from the view YXXEMP_V to write the id, last name, and first name
fields to the screen.
The syntax to reference a view in an ABAP program is the same as that used to reference a table.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Dictionary Objects: Views

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

ABAP Dictionary
ECC 6.0

Search helps are dictionary objects those we develop to compile a set of valid values for users (Search
helps replace the functionality of matchcodes in the previous releases of SAP R/3. Matchcodes are
obsolete now and we should therefore only learn about Search Helps)
All throughout SAP, users must enter values into screen fields. These requested inputs often are
numerical codes and IDs, or abbreviations. Acceptable values might not be immediately evident, or
the user might have forgotten the necessary input.
The user has 2 paths of help available, hitting the F1 function key (which displays documentation,), and
hitting the F4 function key, which displays valid values.
Sometimes a list of valid values will appear when you hit F4, even if a search help was not defined for
that field. These valid values come from the domain that is attached to the field. If we invoke a
search help, we will see its results, not those from the domain valid values. Whether a search help
is available or not depends on whether the programmer has attached one to the field.
Search helps can return more than just the original search field to the screen.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

ABAP Dictionary
ECC 6.0

An elementary search help is exactly one combination of fields that will be used to determine the
needed value.
A collective search help is a combination of elementary search helps, so that the user has the option to
pick any path to get to the answer.
Adding an elementary search help to an SAP table is considered a modification, and you would have to
register your change.
Adding an elementary search help to an existing collective search help on an SAP table is allowed
without registering.
To get an idea about the use of Search Help, you can go to transaction XD01(Create Customer: Initial
Screen) and hit F4 after placing the cursor on the Customer Number field.
The collective Search Help DEBI is displayed, which in turn is the combination of multiple elementary
search helps(each in a different tab). The Selection Screen for the first elementary Search Help
Customers (general) is displayed.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

ABAP Dictionary
ECC 6.0

In the Selection Screen for the first Elementary Search Help Customers (general), Specify S*
against the field Customer to view all the Customers that start with S. You can specify any other
selection criteria and also a combination of selection criteria.
After this hit ENTER or click the Green arrow to display the list of Customers that starts with S.
Now you can select the particular Customer you want to be copied to the Customer field in XD01.
In this way you get assistance in the form of set of valid value, while specifying a value for an input
field.
You can select any tab of the collective Search Help to go to any of its elementary Search Helps and
perform similar kind of Search.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

ABAP Dictionary
ECC 6.0

To create a search help:


1. Go to the ABAP Dictionary: Initial Screen from the ABAP Development Workbench
(Transaction Code SE11).
2. Select the Search helps radio button.
3. Enter a name for your search help. It must begin with the letter Y or Z, and can be up to
30 characters.
4. Hit the Create pushbutton.
5. Select Elementary or Collective search help in the next screen.
Like with most objects in the Dictionary, you can also decide to make a search help at any point while
in the Repository Browser. It will assume you want to save your object under the development
class you are browsing at the time.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

ABAP Dictionary
ECC 6.0

The following are new terms you will see when you define your search help:
Hot key (optional) - Use this number to code values for the complex dialog box all in the original
search field.
Selection method - The name of the table or view that holds the data that will form your help hit
list. The fields from this table/view will be used in the interface parameters.
Text table - If there is a text table available for your main Selection Method table, it will appear
here. You can then use its fields as well in defining your search help path.
Search help exit (optional) - A function module that enhances the typical processing of the
search help. Not commonly used.
Dialog Type - Controls how you see your results. The options are:
D - immediate hit list of valid values
C - dialog box where you can narrow down your search, followed by the hit list
A - if there are less than 100 matches, acts like D, if more than 100 matches, acts like C
The interface parameters are covered in more detail on the next slide.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

ABAP Dictionary
ECC 6.0

Search help parameters - Indicate all the values you will be passing to and from the search help.
When you click in the cell, a drop down arrow will appear. This will give you a list of fields from your
selection method table. If you type in your parameters manually, be sure that they have the same
name as the fields in the table.
IMP - Indicate parameters as import if you want to pass them from the initial screen to the search help
to be used as search criteria.
EXP - Indicate parameters as export if you want them to be passed back to the screen from the search
help.
LPos - Indicate which order on the hit list you want this parameter to be displayed at. For example,
value 3 means the parameter will be the third column of information in the hit list.
SPos - Indicate which order on the dialog box you want the data associated with this parameter to be
displayed at. If you leave this empty, the parameter will not be displayed on the dialog box.
SDis - If checked, this sets the parameter to display only. That means the user will be able to see the
value, but it will be grayed out, and the user cannot enter anything in the field.
Default value - Set literal in quotes, system field, or parameter ID as default.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

ABAP Dictionary
ECC 6.0

There are three different points where you can attach a search help. You can assign a search help to
all of them if you choose. When the user hits F4, the system checks to see if there is a search help
attached to the:
Field - To attach a search help to a field, click on the field in the table (or structure) definition,
and go to Goto Search help For field. This is the first type of search help that is
checked for, if one is not found, the system checks if a search help is attached to the...
Table - To attach a search help to a table, go to Goto Search help For table. This is the
second type of search help that is checked for, if one is not found, the system checks if a
search help is attached to the...
Data element - To attach a search help to a data element, double click on the data element to
get to its definition. Here you will find fields for specifying the name of the Search Help and
the Search Help Parameter. This is the third type of search help that is checked for, if one is
not found, the system does not use a search help, but will check the domain for valid values.
If none exist, then no help is provided.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

Search Helps

ECC 6.0

You will be painting fields that respond with search helps in reports and transactions you will learn
about throughout the course.
For now, to test your search help, you can use the selection screen that appears when you view your
table contents (Utilities Table Contents Display from the table definition screen).
Upon hitting F4, the attached search help will begin processing. It will check to see if the field you are
in, the search field, is identified as an export parameter.
If it is, then the way the search help continues depends on how the dialog behavior was defined.
Dialog type C presents a complex dialog box, where you build the context data. Dialog type D
bypasses the dialog box, and immediately displays a hit list of acceptable values.
The green fields in your hit list represent the values that can be exported back to the screen.
Double-click on a green field in the hit list to return the value to the original selection screen.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

ABAP Dictionary
ECC 6.0

Creating a collective search help begins in the same way as creating an elementary search help.
Simply choose collective instead of elementary.
There are two parts to maintain in the collective search help definition, the Interface section, and the
Search helps section.
Since the collective search help is meant to be a collection of elementary search helps, you should use
the parameters section to declare all export parameters from all of the individual elementary search
helps.
Typically, the elementary search helps are returning the same export parameter, so you would indicate
just that one export parameter in the interface here.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

ABAP Dictionary
ECC 6.0

The second section of the definition screen is the Search helps section. All you have to do here is
enter the names of the elementary search helps you will include in your collective search help.
Do not forget to create parameter assignments. You need to create the link from an elementary search
help back to the collective search help. Select each elementary search help entry and hit Param.
assignment. The system will generate a suggested assignment.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

ABAP Dictionary
ECC 6.0

Collective search helps get invoked by the user the same way elementary search helps get invoked, by
hitting F4 in the questionable field.
The only visual difference is that there is now an icon that will let you switch between elementary
search helps.
Advanced users can take advantage of hot keys to enter values for a search help dialog box all in the
original search field. This works with both kinds of search helps. For example, the following two
techniques would achieve the same result:
1. - User hits F4 in FIRST_FIELD.
- User selects toggle button, and chooses elementary search help with hot key B.
- User enters the value Philadelphia for field second, and Vanilla for field third.
- User hits the check mark.
- User gets a hit list of all values for FIRST_FIELD that are Philadelphia and Vanilla.
2. - User enters B.Philadelphia.Vanilla in FIRST_FIELD.
- User hits F4.
- User gets a hit list of all values for FIRST_FIELD that are Philadelphia and Vanilla.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

Search Helps

ECC 6.0

A search help exit is a function module. Basically, it is extra code that can be included in the
processing of the search help at specific times.
When designing your own search help exits, use function module F41F_SHLP_EXIT_EXAMPLE as a
template.
You have the option to include a search help exit with your elementary and collective search helps.
A call is made to the search help exit at several times during the regular processing of the search help.
By adding code to the search help exit, you can change the appearance and functionality of how the
search help appears to the user.
Existing SAP search help exits can be found in the Information System as function modules beginning
with F4UT_. An example is F4UT_OPTIMIZE_COLWIDTH, which fits the columns of a hit list to be
as wide as the widest piece of data.
Search help exits are not recommended to be overused, to preserve the integrity of the regular search
help process.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Search Helps

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Online Help & Documentation

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Online Help & Documentation

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary
ECC 6.0

Online Help & Documentation

Documentation can be created for the following ABAP Dictionary objects:


Tables/structures (used as technical information, available in a Table manual if program
RSSDOCTB is run)
Domains (used as technical information, not displayed in online help)
Data elements (used in online help - F1)

Data element documentation and supplemental documentation is called when using F1 help on
an input field.

Allowed input values are revealed with F4 help. These values are derived from:
Domain values
Foreign keys
Search Helps

Since matchcodes used earlier (in SAP Ver. 3.0) instead of Search Helps,
matchcodes were the first line of F4 help offered to the user.
IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary
ECC 6.0

Online Help & Documentation

Documentation for tables/structures and domains can be created within the ABAP Dictionary
maintenance screen for the object. Use menu path Goto Documentation.
In this chapter, we will focus on data element documentation and supplemental documentation.
Data element documentation is field-specific and is displayed for all fields which refer to the
data element.
Data element supplemental documentation reflects screen-specific information for an input
field.
When the user hits the F1 key, both data element documentation and data element
supplemental documentation is displayed (if each is maintained).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary
ECC 6.0

Online Help & Documentation

Data element documentation and data element supplemental documentation can be created in
several ways:
Transaction SE61
Within the ABAP Dictionary ( Transaction SE11): Change Data Element maintenance
screen
Through F1 help
Through the Screen Painter (Transaction code SE51)
To create data element documentation and/or supplemental documentation from a screen:
Place the cursor on the screen field for which you want to create documentation. Click the F1
key.
Click the Edit Documentation button and you will be prompted to create
data element documentation or supplemental documentation.
To create documentation and/or supplemental documentation from the screen painter (tcode:
SE51):
Position the cursor on the appropriate input field and use the following menu path: Goto
Documentation Data element doc., or Goto Documentation DE supplement
doc.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary
ECC 6.0

Online Help & Documentation

To create data element documentation from ABAP Dictionary :


Goto transaction SE11,Select radio-button Data Type", Give the data element name
,click on Change button, click on documentation button present on the application toolbar.
To create documentation and/or supplementary documentation from transaction : SE61
Goto transaction SE61, enter the data element name, click on create", Enter the appropriate
documentation and click on Save button.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary
ECC 6.0

Online Help & Documentation

Supplemental documentation entered from the screen or screen painter is maintained automatically
in table THLPF. To view this, do the following:
On the screen for which supplemental documentation has been created, go to System
Status and find the program (GUI) and screen number.
Go to System Services Maintenance Extended table maintenance. Type THLPF
in the Table input field and click Display. Scroll to the bottom of the table display. Click the
Position button at the bottom and type the Program (GUI) and Screen Number and hit enter.
This will search for the entry which the system created in the table for your supplemental
documentation. The system will scroll through the table entries to display those entries
matching your search criteria.
Data element supplements, along with their program, screen, and table/field references, are
contained in table THLPF.
Entries in this table are created automatically if the data element supplement was created
through the Screen Painter or through F1 help.
Entries in this table must be made manually if the data element supplement was created
through the ABAP Dictionary or through transaction SE61 (System Services
Maintenance Expended table maintenance). If these entries are not made, the data
element documentation will not be displayed when the user hits F1 on the input field.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary
ECC 6.0

Online Help & Documentation

Data element documentation and supplementary documentation can be created in the ABAP
Dictionary: Change Data Element screen.
Navigate through the ABAP Dictionary to the Data Element you want to create documentation
for
Click the Documentation button to create or maintain Data Element Documentation
Click the Supplementary documentation button to create or maintain Data Element
Supplementary Documentation

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Online Help & Documentation

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Online Help & Documentation

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Online Help & Documentation

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Online Help & Documentation

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Type Groups

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Type Groups

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary
ECC 6.0

Type Groups

Type groups are used for creating customer-defined data types. These type groups are created
in the ABAP Dictionary and are available for use in all ABAP programs.
The main purpose is efficiency of coding. If there is a certain non-standard SAP type that the
programmers find themselves using often in code, it would save coding and maintenance time
to have them centrally defined. Reusability is another reason for using these type groups

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary
ECC 6.0

Type Groups

Type groups are ABAP Dictionary Objects


They are defined with the keyword TYPE-POOLS followed by the name of the type group (this
statement is created automatically in the first line of the dictionary editor). Type group names
are limited to five characters. (To display a type pool, go to R3 Repository Information System
(Tcode: SE84) ->ABAP Dictionary-> Other Objects-> Type groups.
To create a type pool, go to Object Navigator (Tcode: SE80) ->Click the Edit Object button in
the Application toolbar and Select the tab Dictionary-> Check the radio button for Type
group-> Type a name in the corresponding field-> Finally hit the create button)
Type groups can be Created/Changed/Displayed from SE11 as well
Types of a type group must begin with the type group name and an underscore (i.e., YTYP1_ for
all types in the above example). Type groups also contain constants so this statement is also
valid for constant as well
Variables can be declared in ABAP programs using the customer defined types. Type groups
are referenced in programs by using the TYPE-POOLS statement. In the example above, the
data type (character, integer, packed number, etc.) and length for each data variable is
defined by using a type from the YTYP1 type group.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Type Groups

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Type Groups

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Type Groups

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Type Groups

IBM Global Services

ABAP Dictionary

Dec-2008

IBM Global Services - SAP Development ABAP Training


Table Maintenance Generator

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Table Maintenance Generator

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

Table Maintenance Generator

ECC 6.0

Table entries can be displayed and created directly from SE11 following the menu path Utilities-> Table
Contents-> Display or Create Entries.
This is only possible when the Data Browser/Table View Maint field has got a value
Display/Maintenance Allowed.
For using table maintenance generator also, this option should be set as Display/Maintenance
Allowed.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Table Maintenance Generator

ABAP Dictionary
ECC 6.0

Maintaining table entries through SE11 using menu path (Utilities Table Contents Create entries) is
not advisable for the following reasons:
You cannot enter multiple records in the same screen.
You cannot put custom checks and validations when a table entry is being created or modified.
So, table entries are generally maintained by creating a Maintenance view for the table, using the Table
Maintenance Generator.
Another reason is in production Server users does not have authorizations to access SE11 or SE16
transactions, at that time users can maintain the table through transaction created for table
maintenance generator.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

Table Maintenance Generator

ECC 6.0

Follow menu path Utilities Table maintenance generator from transaction SE11.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

Table Maintenance Generator

ECC 6.0

1. Specify the Authorization Group. (E.g. &NC& for skipping any Authority Check)
2. Specify a Function group. (If you dont have a Function Group already, then open transaction SE80
in another session and create a Function Group)
3. Click one step maintenance type.
4. Give the Overview Screen as 9000. (You can specify any Screen Number beginning with 9)
5. Now, hit the Create Button to create the maintenance view for the table. Specify the Development
Class and CTS when prompted for.
Also remember to set the Display/Maintenance allowed value in the table attributes.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ABAP Dictionary

Table Maintenance Generator

ECC 6.0

Go to transaction SM30 (Maintain Table Views: Initial Screen) and specify the table name.
You can Display and Maintain Table entries by clicking the Display and Maintain pushbuttons.
Click the Maintain pushbutton to maintain the entries for the table.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Table Maintenance Generator

ABAP Dictionary
ECC 6.0

You will notice that the table entries are displayed in a table control.
The key fields of the table will not be editable, but you can edit the non-key fields, which are open for
input.
Use the New Entry pushbutton to insert new entries into the table.
Use the Copy button to copy one record to create another.
Use the Delete button to delete selected records.
Click on the Save button to save the new entries or the modifications.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Table Maintenance Generator

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Table Maintenance Generator

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Table Maintenance Generator

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Table Maintenance Generator

IBM Global Services

ABAP Dictionary
ECC 6.0

Dec-2008

Day 4 to 6
Introduction to ABAP

IBM Global Services - SAP Development ABAP Training


ABAP Programming Language

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Programming Language

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Programming Language

Intro to ABAP
ECC 6.0

ABAP is a programming language created and used by SAP for the development of application
programs, including:
Reports
Module Pool Programming
Interfaces
Data conversions
User Exits & BADI
All of R/3s applications and even parts of its basis system were developed in ABAP.
ABAP is an event-driven programming language. User actions and system events control the
execution of an application.
ABAP is also called ABAP/4. The 4 stands for fourth generation language.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Programming Language

ECC 6.0

The ABAP Workbench is used by SAP for the development of standard and custom application
software. The ABAP Workbench is also used to create dictionary objects. It consists of the
following components:
ABAP Editor is used to maintain programs.
ABAP Dictionary is used to maintain Dictionary objects.
Repository Browser is used to display a hierarchical structure of the components in a
package.
Menu Painter is used to develop graphical user interfaces, including menubars and toolbars.
Screen Painter is used to maintain screen components for an online program.
Repository Information System contains information about development and runtime objects,
such as data models, dictionary types and table structures, programs, and functions.
Test and Analysis Tools, such as the Syntax Check and the Debugger.
Function Builder, which allows you to create and maintain function groups and function
modules.
Data Modeler, a tool which supports graphical modeling.
Workbench Organizer, which maintains multiple development projects and manages their
distribution.

TheServices
ABAP Workbench used to beDec-2008
known as the ABAP/4 Development Workbench.
IBMNote:
Global

IBM Global Services - SAP Development ABAP Training


ABAP Programming Language

Intro to ABAP
ECC 6.0

Report programs produce lists and can be divided into classical reports and interactive reports.
Classical reports do not allow interaction by the user; therefore, the basic list contains extensive
information that the user must often sort through to find the relevant data.
Interactive reports allow interaction by the user; therefore, the user can produce secondary, detailed
lists off of the basic list by choosing the relevant data and requesting more information.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Programming Language

Intro to ABAP
ECC 6.0

Module pool programming (or online programming) involves the creation of a module pool (a collection
of ABAP modules) and one or more screens.
The modules are called by the screen processor during program execution.
Batch input processing is used to ensure the safe transfer of data into the SAP system. This process is
an automatic, protected data transfer to the SAP system which uses SAP transactions to validate data
as it populates the SAP database.
ABAP contains statements which conform to CPI-C standards (Common Program Interface Communications). These are used for programming communications programs.
ABAP can read and write sequential data sets.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Programming Language

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Programming Language

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Programming Language

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Programming Language

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

Below is a list of common ABAP program terms.


Program A series of ABAP statements
Report An ABAP program whose output is a list
Module Pool A dialog program which is a collection of screens
List The output generated by an ABAP report program

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

The ABAP Editor is used to create, maintain, and execute ABAP programs.
Some methods for executing ABAP programs include:
The ABAP Editor :
Tools->ABAP Workbench Overview->Object Navigator Or use transaction SE80
The Reporting function:
System Services Reporting Or use transaction SE38
ABAP programs that you create must start with a Y or a Z and can be up to 40 characters in length.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

The editor combines a character based text entry capability with graphical icons and menu options to
perform many of the functions necessary to build complex ABAP applications.
Move to a specific line by double-clicking on the line number.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

The ABAP development environment provides a wide variety of tools required by the programmer for
the development and testing of applications.
Pictured above is the online debugging tool which enables the programmer to watch the program
execute line by line.
The online debugging tool provides the programmer with the capability to designate watch variables.
These variables, once chosen, can be viewed as their values change from statement to statement
while the program executes. The programmer can even change their values to simulate different
processing scenarios.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

The ABAP program editor provides many functions through the use of graphical push-buttons.
Among these functions are:
Toggle from display mode to edit mode
Undo/Redo, cut, copy and paste by right-clicking on Mouse
Find and repeat find
Syntax check - with limited auto correction
Activate
Execute
Where-used list
Pretty Printer
Save program as local file
Upload program from local file
ABAP help

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

Some of the functions under the PROGRAM Menu include:

Other Object
Enables the programmer to immediately load another object without going back to the
ABAP Editor: Initial Screen.

Check

The programmer can make their program syntax error free and can also improve the
performance of the program.

Syntax

Extended program check

Code Inspector

Test

The programmer can execute or process the program in debugging mode or in direct mode .

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

The more important functions under the EDIT menu include:


Insert Statement
This option brings up a dialog box in which the user can choose a statement structure
to insert. Once chosen, the editor will insert a statement format at the location of the
cursor with all of the options and requirements set. The programmer has only to fill in
the blanks.
Note: If the statement structure required is not listed, use the drop down box in the
Other pattern option, where many more ABAP keywords are listed (eg IF, SELECT,
CASE, WINDOW) as well as comment box templates.
Use the menu path Edit Pattern or Utilities More utilities Edit pattern to set user
defined statement structures
Edit Line
This option brings up a second submenu which gives the programmer a list of line
commands. These include:
Delete line (deletes the line the cursor is on).
Split line (places all information to the right of the cursor on the line directly
below the line the cursor is on).
Insert line (inserts a line above the line the cursor is on).
Others

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

Pretty Printer
This option formats the contents of the editor in terms of indentation and spacing.
Helps with the readability of the program.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

The GOTO menu gives the programmer the ability to immediately navigate to any one of the following
functions:
Attributes (displays the particular attributes of that program).
Text elements (an editor for titles and headers, selection texts and text symbols used for
formatting reports).
Variants (an editor for the creation, change or display of variants).
Messages (an editor for message classes).
Others..
All of these options will be covered in later chapters.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

Under the UTILITIES menu the programmer can access the following utilities:
Help
This function is a repeat of the light blue i push-button
Breakpoints
The programmer can set or remove break-points that are used by the online debugging
tool (the red stop pushbutton also provides this function)
Program upload and download utilities (in More utilities)
Allows the programmer to transfer ABAP code to/from a local file
Edit Locally
Allows the programmer to edit the program in NotePad when not online. See Settings
menu to choose path. Path for local editing.
Edit Pattern
Sets regularly used user defined patterns for inserting using menu path Edit Pattern.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

Using the BLOCK/BUFFER menu, the programmer can:


Copy program code to any one of three (X, Y, Z) separately maintained clipboards (buffers).
Program code can then be inserted into another program from these clipboards (buffers).
To copy code to the windows clipboard, select the Copy to clipboard menu option.
Comments can be inserted or removed from the code using the Insert Comment *(or using
hotkey CTRL+<) and Delete Comment * (or using hotkey CTRL+>) menu options.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

Using the Settings-> user can set the settings of various parameters e.g. Workbench, ABAP Editor,
Class Builder, Screen Painter, Menu Painter, Function Builder, Repository Infosystem, Data
Browser, Internet Transaction Server, Business Server Pages, Transport Organizer, SAP script.
In the ABAP Editor and in Pretty Printer tab choose the case in which the code is displayed from either:
1. Lower case
2. Upper case
3. Key word Uppercase (only ABAP key words are in Upper case)
4. Key word Lowercase (only ABAP key words are in Lower case)
Set the path for local editing in Notepad

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

An ABAP program is comprised of a series of individual ABAP statements


Each statement must end with a period. (full-stop)
Key words are always the first word in a statement.
Words must be separated by at least one blank.
ABAP statements can be indented and extend over several lines.

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

To avoid repeating key words, ABAP allows you to chain statements together if these statements
begin with the same key word.
The key word is followed by a colon.
Each chained statement component is separated by a comma.
Blanks can be inserted before and after the separators (which may be colons, commas, or periods).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

Comments are inserted into the program in two ways:


1. By placing an asterisk (*) in column 1, the complete line is designated as a comment line.
2. By placing a double quotation mark (") within a line, the remainder of the line is considered a
comment.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

ABAP programs must start with either the PROGRAM or REPORT statement. This statement is
produced automatically when the program is created through the Repository Browser.
The REPORT statement is used for ABAP reports programs.
The PROGRAM statement is used for general ABAP programs (for example, module pool
programs).
All global data declarations must be grouped together at the beginning of the program in a declaration
section.
The statement section can consist of various processing blocks. This subject is dealt with in the
remaining chapters of this course.
Adhere to program naming standards dictated by the client.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

One way to create a new program is:


1. Go into the Program menu from the ABAP Editor: Initial Screen
2. Select the Create menu option or use the Create function key.
You can also create, maintain, and execute programs from the Repository Browser (this is the
recommended method for creating programs transaction SE80).
The program attributes must be maintained before proceeding.
ABAP programs must be assigned to a package or, if applicable, identified as a local, private object.
(This is a requirement of SAPs Correction and Transport System.)
The application, class, and type attributes are used for the management of ABAP programs.
The application, title, and type attributes are required. Other attributes
are optional, and only needed for specific read accesses or when you have additional
requirements.
F1 and F4 are help keys which allow you to search for the significance of the attributes or a list of
allowable input values.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP
ECC 6.0

Introduction to ABAP Programming

The ABAP editor's Execute function <F8> is used to start an ABAP program directly from the editor.
An ABAP module pool program is executed using transaction codes.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

ECC 6.0

Introduction to ABAP Programming

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

Intro to ABAP
ECC 6.0

The WRITE statement outputs the contents of a field or constant in a format consistent with the data
type.
Successive WRITE statements output data on the same output line. When the line is full, output
continues on the next line.
The SKIP <n> statement creates <n> blank lines.
Normally, ABAP produces two standard header lines for each page. The date and page number are
displayed on the first header line along with the program title. The second header line is an underline.
Many system fields are available in an ABAP program. These system fields are defined as the ABAP
Dictionary structure SYST. To reference system fields in a program, use SY-<field name>. For
example, SY-DATUM indicates the current date and SY-UZEIT indicates the current time.
You can use many methods to view the system ABAP Dictionary structure:

ABAP Dictionary

Repository Information System

ABAP Help in a program (use help pushbutton or F1)

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Simple Output Statements

ECC 6.0

ABAP provides many methods for formatting data.


You can specify when to start a new line of output, start columns, and/or output length with the
following statement:
WRITE /<pos(len)>. . . .
The forward slash (/) in the WRITE statement indicates to start the output on a new line.
The ULINE statement creates an underline.
You can specify the exact location for an underline by referencing a line feed, position, and/or length
with the following statement:
ULINE /<pos(len)>.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

Intro to ABAP
ECC 6.0

The UNDER addition to the WRITE statement allows you to specify a field be printed in the same
start column (left justified) directly beneath a field which has already been output.
You must still code an explicit line feed (with a forward slash) to move to the next line. The UNDER
addition does not act as a line feed.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

Intro to ABAP
ECC 6.0

The sequence for the format specification of the WRITE statement must be followed precisely if more
than one specification is used.
Formatting options include:

LEFT-JUSTIFIED

RIGHT-JUSTIFIED

CENTERED

NO-GAP (deletes the gaps between consecutively displayed fields).

USING EDIT MASK (specifies a format template).

USING NO EDIT MASK (switched off any format template specified in the ABAP Dictionary).

NO-ZERO (replaces leading zeros with blanks; if the contents of a field are equal to zero,
the output consist entirely of blanks).

There are many other formatting options. Consult the Extended Help text.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

Intro to ABAP
ECC 6.0

The NEW-PAGE statement starts a new page.


This statement will not create an empty page.
There are many interesting extensions to NEW-PAGE, such as PRINT ON. Look in Online Help for
more information.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

Intro to ABAP
ECC 6.0

Certain symbols and icons can be written on a report. You must load the include programs <ICON>
and/or <SYMBOL> (the angle brackets are part of the name) with the INCLUDE <include program>
statement. You can also directly use TYPE-POOLS: icon for icon and TYPE-POOLS: sym for symbols.
To write an icon to the report, use the following syntax:
WRITE <icon name> AS ICON.
To write a symbol to the report, use the following syntax:
WRITE <symbol name> AS SYMBOL.
To display the complete list of icons, execute the program SHOWICON. For symbols, execute the
program SHOWSYMB. You can go to the initial screen of the ABAP Editor (transaction code SE38)
to execute these programs.
The INCLUDE statement can also be used to include separate data declarations that are used by many
programs. For example: commonly used function export/import parameters, constants for
TRUE/FALSE YES/NO flags, BDC_TAB, etc.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

Intro to ABAP
ECC 6.0

Text elements can be used to maintain a programs title and column headings, selection texts, and text
symbols. These text elements can be maintained in multiple languages, so the display to the user will
depend on the users specified logon language.
We will cover text symbols on the next page. Selection texts will be covered in the next chapter when
we learn the PARAMETERS statement.
Maintain a list heading and up to four lines of column headings for a report by using the GoTo Text
elements Titles/headings menu path).
The text placed in the List header field will replace the default title (short text of the program) on the
programs standard heading output.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Simple Output Statements

ECC 6.0

Numbered texts (text symbols) are used most often for writing text to the screen that is language
dependent.
Maintain numbered texts using the GoTo Text elements Text Symbols menu path).
It is possible to maintain numbered texts separately for different languages. Consult the SAPs online
help for information on maintaining text elements in multiple languages
The two methods of using numbered texts (text symbols) are:
TEXT-xxx [where xxx is a unique three-character code]
<text string>(xxx) [where xxx is a unique three-character code]
The TEXT-xxx method allows you to assign text to a text symbol for easier maintainability and coding.
Therefore, you can refer to a long sentence as TEXT-xxx instead of writing in code the sentence
every time it needs to be written to a list. The text contained in the text symbol will be written out in the
users current logon language as long as it is maintained in that language. Otherwise nothing will be
written out.
The <text string>(xxx) method also allows for easier language maintenance. In case the text symbol
(xxx) is not maintained in the users logon language then the <text string> is used. However, this
method loses the benefit of not having to code the same sentence many times.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Simple Output Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

In an ABAP program, you can use ten system-defined, elementary data types to declare data objects:
Character Text (standard length = 1; allowed length = no maximum)
Numeric Text (standard length = 1; allowed length = no maximum)
This data type should be used for numeric fields that will not be calculated (i.e., social
security number and telephone number).
Integer (standard length is machine specific and cannot be changed)
This data type stores a binary number with a range of values from
-21477483648 to +2147483647.
Packed Number (standard length = 8; allowed length = 1 to 16)
With this data type, two digits are stored in a single byte and the last half byte is used
to store the sign. This data type is recommended for commercial calculations.
Floating Point Number (standard length is machine specific and cannot
be changed)
With this data type, two digits are stored in a single byte and the last half byte is used
to store the sign. This data type is recommended for mathematical/scientific
calculations.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

Date (standard length = 8 and cannot be changed)


This data type stores data in the YYYYMMDD format
Time (standard length = 6 and cannot be changed)
This data type stores data in the HHMMSS format
HeXadecimal (standard length = 1; allowed length = no maximum)
String (similar to data type C and refers to a variable-length string ).
XString (similar to data type X and refers to a variable-length byte sequence. Strings can
have any length).
It is not yet possible to use strings in screens. However, strings can be stored in database
tables as clusters using EXPORT and transferred using IMPORT.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

To declare a variable (or field) in an ABAP program, use the DATA statement:
DATA <name>(<length>) TYPE <data type> VALUE <default>.
The only required parameter in this statement is the <name> of the variable.
A variables name can be up to 30 characters in length.
This name should begin with a letter and the remainder of the name should
consist of letters, numbers, or an underscore.
SPACE is a reserved word in ABAP.
The variables <length> is specified in parentheses immediately after the <name> (no spaces
in between the name and the length).
If no length is specified, the variable will be the standard length for the data type (see
previous page).
The variables <data type> is specified after the TYPE addition.
If no data type is specified, the variable will be type C.
To define a default value for the variable, use the VALUE addition.
This default value is different than the initial value automatically assigned to a data
object (see next page).

In the example code above, what is the data type and length of the STARTER variable?
The function, STRLEN, can be used to find the length of a character string
IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

All data objects declared have an associated initial value. This initial value depends on the data type:
C,STRING:

blank

N: 00 (the number of zeroes depends on the defined length)


I: 0
P: 0
F: 00E+00 (the number of zeroes depends on the system length)
D: 00000000
T: 000000
X,XSTRING:

00

The CLEAR <field> statement sets a field back to its initial value, not its
default value.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

Use the following rules when assigning default values to data objects:
Default values for the character-based data types (C and N) must be a text literals (i.e.
enclosed in single quotes. ).
For example, see the NICKNAME variable above illustrates this rule.
Default integer values for the numeric data types (I, P, and F) may or may not be enclosed in
single quotes.
For example, the POINTS variable above uses single quotes, but the GAMES
variable does not.
Default fractional values for the numeric data types (P and F) must be a text literals (i.e.
enclosed in single quotes); otherwise, the decimal point would indicate the end of the
statement.
For example, the AVERAGE variable above illustrates this rule.
For a packed or floating point number to be stored with a decimal, it must be defined
with the DECIMALS addition. For example, AVERAGE(5) TYPE P DECIMALS 2
VALUE 25.5.
Default values for date (D) and time (T) variables must be enclosed in
single quotes.
For example, the ACQUIRED variable above illustrates this rule.
In the example code above, what is the value of the STARTER variable?

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Data Declarations

ECC 6.0

To declare fields with the same format (i.e. data type and length), use the LIKE <field> addition
instead of the TYPE addition to the data declaration.
Defining fields in this manner makes it easy to change the format of several fields because
you only need to make a change to the data type or length once in the program.
In the LIKE <field> addition, the <field> can be:
A previously-defined program field or field string (we will cover field strings in a future
chapter)
For example, the NICKNAME field above is defined LIKE PLAYER.
An ABAP dictionary field
For example, the ACQUIRED field above is defined LIKE SY-DATUM.
The LIKE addition only applies to the data type and length, not a default value assigned to the
referenced field.
For example, the NICKNAME field above defined LIKE PLAYER will be a 35-length
character field. However, the NICKNAME field will not have the Julius Erving default
value assigned to it.
This type of Declaration is OBSOLETE in Newer Versions of ABAP

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Data Declarations

ECC 6.0

To declare a constant in an ABAP program, use the CONSTANTS statement. The basic syntax of this
statement is:
CONSTANTS <name>(<length>) TYPE <data type> VALUE <value>.
A constants <name> can be up to 30 characters in length.
This name should begin with a letter and the remainder of the name should consist of
letters, numbers, or an underscore.
SPACE is a reserved word in ABAP.
Like the constants <name>, the VALUE addition is required because a constant must have
a value.

The constants <length> is specified in parentheses immediately after the <name> (no
spaces in between the name and the length).
If no length is specified, the constant will be the standard length for the data type.

The constants <data type> is specified after the TYPE addition.


If no data type is specified, the constant will be type C.
You cannot change the value of a constant in an ABAP program (syntax error).
Hard-coded literals should be avoided. Use CONSTANTS if this clarifies the code.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Data Declarations

ECC 6.0

To declare a user-defined data type in an ABAP program, use the TYPES statement. The basic
syntax of this statement is:
TYPES <name>(<length>) TYPE <data type>.
A user-defined data types <name> can be up to 30 characters in length.
This name should begin with a letter and the remainder of the name should consist of
letters, numbers, or an underscore.
SPACE is a reserved word in ABAP.
The VALUE addition cannot be used because this statement only defines a data type. This
statement does not allocate any memory for a field and, therefore, cannot have a value.

The user-defined data types <length> is specified in parentheses immediately after the
<name> (no spaces in between the name and
the length).
If no length is specified, the user-defined data type will be the standard length for the
data type.

The user-defined data types <data type> is specified after the TYPE addition.
If no data type is specified, the user-defined data type will be type C.
You can use the LIKE addition instead of the TYPE addition.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

With the WRITE statement, a data object written to the list will have the standard output length
associated to its data type (see above slide). If you want to change the output length of a field written to
the report, you must specify the length in parentheses before the field name. For example, to write out
a length 20 character field named VAR1 in only 10 spaces, use the following WRITE statement:
WRITE: /5 The value is, (10) VAR1.
For packed and integer fields, leading zeros are converted to blanks.
For packed and integer fields, commas are inserted between thousands.
With the WRITE statement, a data object written to the list will be justified within its field length
according to the standard justification associated to its data type (see above slide). If you want to
change a fields justification, you must use the LEFT-JUSTIFIED, RIGHT-JUSTIFIED, or
CENTERED additions after the field name. For example, to make an integer field left justified, use
the following WRITE statement:
WRITE: /5 The total count is, COUNT LEFT-JUSTIFIED.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

You can determine the number of decimal places to display in all numeric fields (i.e., integer, packed,
and floating point fields) with the DECIMALS addition to the WRITE statement:
WRITE <numeric field> DECIMALS <n>.
ABAP performs automatic rounding of numeric fields.
You can explicitly round numeric fields with the ROUND statement.
You can determine the value of the exponent to display in floating point fields with the EXPONENT
addition to the WRITE statement:
WRITE <floating point field> EXPONENT <n>.
If you want a packed field to store a decimal value, the DECIMAL addition must be used when
defining the field. For example:
DATA <packed field> DECIMALS <n>.
The DECIMALS addition can also be used when defining parameters, constants, or userdefined data types.
Coding Recommendations:
A common cause of error occurs using the WRITE command with prices/values.
Ensure to always use the CURRENCY option.
Ex: WRITE: nnnnnnn CURRENCY nnn.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Data Declarations

ECC 6.0

You have numerous alternatives to assign values to fields:


MOVE <value> TO <field>.
[COMPUTE] <field> = <value or expression>.
The key word COMPUTE is optional.
ADD <value> TO <field>.
SUBTRACT <value> FROM <field>.
MULTIPLY <field> BY <value>.
DIVIDE <field> BY <value>.
There are other alternatives that we will cover in later chapters.
The system carries out automatic type conversion if variables are not of the same type.
If a character field is to be converted to a packed field, only numbers, the plus/minus sign,
and the decimal point are allowed. The plus/minus sign will be placed at the end of the
packed field.
If a packed field is to be converted to a character field, the numerical value is formatted
(decimal point, sign) and the leading zeros are converted to blanks.
For information for all conversions between variables of different types, see the ABAP editor
documentation for MOVE (type MOVE and hit F1).
UNPACK is a specific conversion keyword moving values from a packed variable (type P) to a
character one (type C).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

The valid operators for arithmetic expressions are: +, -, *, /, **, DIV and MOD.
** indicates exponentiation (i.e., 3 ** 2 means 3 to the power of 2).
DIV indicates the quotient (i.e., 10 DIV 3 evaluates to 3).
MOD indicates the remainder (i.e., 10 MOD 3 evaluates to 1).
Arithmetic functions also exist in ABAP. Some of these functions include: SQRT, EXP, LOG, SIN,
COS, and STRLEN.
The order of operation in arithmetic expressions is:
Parentheses
Functions
Exponentiation
*, /, DIV, and MOD
+ and All operators and parenthesis in an arithmetic expression must be separated by at least one space.
Functions must be followed immediately by an opening parentheses:
Incorrect:

ANSWER=(10+SQRT(NUM1))/(NUM2 - 10).

Correct:

ANSWER = ( 10 + SQRT( NUM1 ) ) / ( NUM2 - 10 ).

Before calculations are performed, field values of non-numeric fields are automatically converted to
numerical values.
There is no limit to the nesting levels for parentheses in arithmetic expressions.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Data Declarations

ECC 6.0

ABAP allows you to display and change portions of a field by specifying an offset and length.
To display a portion of a field, use the following WRITE statement:
WRITE <field>+<offset>(<length>).
For example, to write the third, fourth, and fifth characters of a field named CUSTOMER,
the WRITE statement would be:

WRITE CUSTOMER+2(3).

To change a portion of a field, use the following statement:


<field>+<offset>(<length>) = <value>.
For example, to change the month of a date field named BIRTHDAY, the statement would
be:
BIRTHDAY+4(2) = 11.
The offset and length can be used together (as the previous examples illustrate) or separately.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

Remember that date fields are stored in YYYYMMDD format.


You can perform calculations on dates, but you must keep in mind that the system can only work in
terms of a number of days. For example:
You can add seven days to a date field.
You cannot add two weeks to a date field. This value would have to be converted into a number
of days.
If you perform calculations on a date field, the date field is converted to a packed number that
represents the number of days since the beginning of 01/01/0001.
Coding Recommendations:
There are numerous SAP function modules that will perform date calculations.
Ex: DATE_COMPUTE_DAY, DATE_GET_WEEK, DATE_CHECK_PLAUSIBILITY,
POPUP_TO_SELECT_MONTH, EASTER_GET_DATE.
Conversion function modules usually have the word CONVERT or CONVERSION in their name.
Ex: CONVERSION_EXIT_PERI_INPUT converts dates from the format MMYYYY to YYYYMM
(if passed in as MMYY, it is passed out as YYYYMM), CONVERSION_EXIT_INVDT_INPUT
converts date in format DDMMYYYY to SAP inverted date format - plus many other variations.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

To declare a variable (or field) in an ABAP program that can be given a value at runtime, use the
PARAMETERS statement. The basic syntax is:
PARAMETERS <name>(<length>) TYPE <data type> DEFAULT <default>.
The only required addition in this statement is the <name> of the parameter.
A parameters name can be up to 8 characters in length.This name should begin with a
letter and the remainder of the name should consist of letters, numbers, or an
underscore.
SPACE is a reserved word in ABAP.

The parameters <length> is specified in parentheses immediately after the <name> (no
spaces in between the name and the length).
If no length is specified, the variable will be the standard length for the data type (see
page 1).

The parameters <data type> is specified after the TYPE addition.


If no data type is specified, the variable will be type C.
To define a default value for the parameter, use the DEFAULT addition.
This default value is different from the initial value automatically assigned to a data
object (see page 3).
When you execute a program using the PARAMETERS statement, a selection screen is displayed
for you to enter values into the parameters. To continue program execution from the selection screen,
click on the Execute pushbutton (or click the F8 key).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

Text elements can be used to maintain a programs title and column headings, selection texts, and
text symbols. These text elements can be maintained in multiple languages, so the display to the
user will depend on the users specified logon language.
Maintain the selection texts by selecting the Selection texts option in the Text Elements function
(GoTo Text elements menu path).
The text placed in the Text field for a parameter will be used on the selection screen instead of the
name of the parameter. Using selection texts allows you to create meaningful text on the selection
screen.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

A field symbol is a place holder for a field (i.e. a pointer). A field symbol does not reserve space for the
field, but points to the field (i.e., a field symbol assumes the address of the field, not the value).
A field symbol can point to single fields or field strings (structures). Remember that the
TABLES statement creates a field string with the appropriate ABAP Dictionary structure.
When working with field symbols, angle brackets (< >) must be used.
The FIELD-SYMBOLS statement is used to declare a field symbol.
A field symbols name can be up to 30 characters in length including angle brakets(<>).
This name should begin with a letter and the remainder of the name should consist of letters,
numbers, or an underscore.
If a field symbol is defined without attributes, it takes on the attributes of the field assigned to it.
If a field symbol is given a data type and length (either explicitly or with the LIKE addition), the
system verifies that the field symbol has the same attributes as the field assigned to it.
The ASSIGN statement associates a field to a field symbol at runtime (i.e., when the program is
executed).
If you change the value to a field symbol, you are really changing the value of the field assigned to the
field symbol. If you write the value of the field symbol, you are really writing the value of the field
assigned to the field symbol.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

With the ASSIGN statement, you can assign a portion of a field to a field symbol by specifying the
fields offset and length.
In the example above, the field symbol FSYMBOL is assigned to five characters of the variable
TEXT_LINE starting with the third character. If a change is made to the field symbol, only these five
characters of the variable will be changed.
The output from the code above would be:
Text Line =ABCDEFGHIJK
Field Symbol = CDEFG
Field Symbol = 12345
Text Line = AB12345HIJK

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

Intro to ABAP
ECC 6.0

With the ASSIGN statement, you can assign a field to a field symbol where the name of the field is
not known until the program is executed. This is called dynamic field assignment.
For example, in the code above a field name is being entered as a parameter. The field entered
will be assigned to a field symbol.
To perform a dynamic field assignment, you must enclose in parentheses the variable that contains the
appropriate field name. For example:
ASSIGN (FIELD) TO <FSYMBOL>.
After a dynamic field assignment, the value of SY-SUBRC indicates whether a field was assigned to
the field symbol.
If the assignment was successful (i.e., the variable in parentheses contained a valid field name),
SY-SUBRC will be set to zero.
If the assignment was not successful (i.e., the variable in parentheses did not contain a valid
field name), SY-SUBRC will be set to a non-zero number.
If you are going to assign a field string created with the TABLES statement to a field symbol,
execution time is minimised if you use the ASSIGN TABLE FIELD option.
Note: in ECC 6.0 TABLES statement is obsolete

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Data Declarations

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

IBM Global Services

Dec-2008

Intro to ABAP
ECC 6.0

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

IBM Global Services

Dec-2008

Intro to ABAP
ECC 6.0

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

Intro to ABAP
ECC 6.0

Information is retrieved from the database for use in our programs via a special language known as
Structured Query Language, or SQL. SQL is a language specifically designed for use with relational
database systems. It is used in many systems, not just SAP. However, ABAP has certain SQL
commands built-in, so the connection between ABAP and SQL is fairly seamless.
SQL has three main components, which are used for different purposes:
Data Manipulation Language (DML): For retrieving and updating information in the
database.
Data Definition Language (DDL): For defining database objects and specifying the structure
of the data in the database. In SAP, these functions are handled primarily by the ABAP
Dictionary and the Database Utility.
Data Control Language (DCL): For controlling access to DML and DDL functions.
This course covers the first category only: Data Manipulation Language
The DML provides the four basic data operations:
1. Select (retrieve)
2. Insert
3. Update
4. Delete

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

Intro to ABAP
ECC 6.0

As noted on the previous page, SQL is a standard language used across many different systems. The
majority of the functionality provided by SQL remains the same across all systems, but some database
manufacturers have added their own proprietary extensions to SQL. Additionally, the syntax of SQL
has minor variations across systems.
SAP had to ensure that SQL statements in ABAP programs would be compatible with each of the
underlying database systems supported by SAP. This was accomplished through the development of
Open SQL (also called SAP SQL).
Open SQL is a subset of standard SQL with a specific syntax recognised by ABAP. The run-time
environment of the R/3 System automatically translates Open SQL statements to the appropriate
syntax for the underlying database system. Therefore, code written in Open SQL will run on any
database system supported by SAP.
Note:
Sometimes, for technical reasons, it is advantageous to know which database system an application is
intended for. However, if Open SQL is used, it is not necessary to know this. SAP itself was written
using Open SQL because it was intended to run on multiple systems.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

Intro to ABAP
ECC 6.0

In all versions of SQL, the SELECT statement is used to read records from a database table. The
most basic form of the SELECT statement is:
SELECT * FROM <table name>.
This statement retrieves all columns and all rows from the specified table. In ABAP, the data is placed
into a work area created by the TABLES statement.
The TABLES statement serves two purposes: (Note: in ECC 6.0 TABLES statement is obsolete)
1. It declares to the program which ABAP Dictionary tables will be accessed.
2. It creates a work area where individual records from the table can be stored. The work area
is an area in memory, just like a program variable, and it is sized so that it can hold exactly
one record from the specified table.
The Open SQL SELECT statement automatically places records from the database into the work area.
Since the work area can only hold one record at a time, the SELECT statement automatically creates a
looping structure. One record is transferred from the database to the work area with each loop pass.
The SELECT loop is delimited by the ENDSELECT statement. The statements inside the loop are
executed once for each record retrieved.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

Intro to ABAP
ECC 6.0

For example, to write the ID and name of all customers in the system, we could write the code that
appears on the above slide.
Note:
The SELECT statement is used in all versions of SQL. However, the specific syntax and functionality
discussed here is specific to Open SQL. Except where otherwise noted, all references in this course to
SQL are to Open SQL.
Note that individual fields within the work area are referenced by using the work area name, followed
by a hyphen, followed by the individual field name.
To see a list of the fields that are available in a table, you can:
Double-click on the name of the table in your program code in the ABAP Editor. You will be
taken to the dictionary definition of that table.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

Intro to ABAP
ECC 6.0

Suppose that, instead of displaying information for all customers, we only wanted to display information
for customers belonging to a certain account group.
We could accomplish this by using the WHERE clause of the SELECT statement. The WHERE clause
restricts the records that are retrieved from the database.
The code on the above slide demonstrates the use of the WHERE clause (KTOKD is the account
group field).
When using the WHERE clause, you must specify a logical expression.
To the left of the relational operator, you must specify a field from the table in the FROM
clause.
To the right of the relational operator, you must specify a program variable or a literal value.
Complex WHERE clauses can be built using AND, OR, and NOT.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

Intro to ABAP
ECC 6.0

The system field SY-SUBRC is set after each SELECT from the database.
If at least one record was found that matched the selection criteria, SY-SUBRC is set to zero.
Otherwise, SY-SUBRC is set to a non-zero value (currently, SY-SUBRC is set to 4).
It is good programming practice to check SY-SUBRC after each SELECT. That way, if no records are
found, an appropriate message can be displayed to the user (or your program can take appropriate
action). If no records are found, failing to check SY-SUBRC may cause your program to appear to do
nothing.
SY-SUBRC should be checked immediately after the ENDSELECT statement not inside the SELECT
loop.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

Intro to ABAP
ECC 6.0

As an alternative to SELECT *, it is possible to select only those columns required by the program.
This form has the advantage of transferring significantly less data from the database server to the
application server.
When selecting individual columns from a database table, an INTO clause is required. Data is not
automatically placed into the corresponding fields of the table work area.
The INTO clause must contain the same number of variables those match the columns in the SELECT
clause. The INTO clause may refer to individual fields from the table work area or to any other variable
in your program.
Note:
There can be no commas after column names in the SELECT clause. All of the variables in the INTO
clause are enclosed in a single set of parentheses and are separated by commas. Also, there must not
be a space between the parentheses and the variable names in the INTO clause.

Performance Tips:
SELECT INTO is much more efficient than SELECT *. This form should be used whenever
possible.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

Intro to ABAP
ECC 6.0

The above statement does exactly the same thing as the statement on the previous page: it selects
customer number and name and puts them into the KNA1 tables work area fields KNA1-KUNNR and
KNA1-NAME1.
The SELECT ... INTO CORRESPONDING-FIELDS OF <structure or internal table name> replaces
coding the individual fields that the values are selected into from the database table and results in code
that is easier to read without any performance losses.
When this statement is used with the <internal table name> the values from the database table are
placed in the work area of the internal table (i.e. the header line) and then need to be appended to the
body of the table - see chapter 8 for more information on internal tables.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

IBM Global Services

Dec-2008

Intro to ABAP
ECC 6.0

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

IBM Global Services

Dec-2008

Intro to ABAP
ECC 6.0

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

IBM Global Services

Dec-2008

Intro to ABAP
ECC 6.0

IBM Global Services - SAP Development ABAP Training


Retrieving Data with SELECT Statements

IBM Global Services

Dec-2008

Intro to ABAP
ECC 6.0

IBM Global Services - SAP Development ABAP Training


Control Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

Intro to ABAP
ECC 6.0

This chapter introduces some of the basic statements ABAP provides to control program flow.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

Intro to ABAP
ECC 6.0

The most basic flow control statement in any programming language is the IF statement. The IF
statement is used to ensure statements are executed only if certain conditions are met.
The counterpart to the IF statement is the ENDIF statement. Every IF statement must have a
corresponding ENDIF. The statements between the IF and the ENDIF are executed only if the
condition specified in the IF statement evaluates to true.
If the initial IF condition is false, the optional ELSE and ELSEIF statements can be used to execute
other blocks of statements. A period is required after every statement in the IF structure.
In the example below, only one of the WRITE statements will be execute:
IF X = 5.
WRITE: / The value of X is 5.
ELSEIF X = 6.
WRITE: / The value of X is 6.
ELSE.
WRITE: / The value of X is neither 5 nor 6.
ENDIF.

Performance Tips:
Ensure the first IF statements are most frequently true for better performance.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Control Statements

ECC 6.0

The conditions tested in IF statements are known as logical expressions. Logical expressions are
constructed using relational, logical,
and string comparison operators.
Relational operators indicate whether:
Two values are equal
One value is greater than another
A value falls within a specific range
A variable is equal to a certain pre-defined value
Logical operators link multiple logical expressions using AND, OR, and NOT.
String comparison operators are special operators used to manipulate variables of type C.
Each of these is discussed in more detail on the following pages.

Coding Recommendations:
For a logical AND statement in an IF construct, put the most likely FALSE case first, and
conversely for a logical OR statement put the most likely TRUE statement first.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Control Statements

ECC 6.0

ABAP supports all standard equality and inequality operators.


Additionally, ABAP supports the operators IN, BETWEEN, and IS INITIAL. (Certain bitwise
comparisons are also available. Consult the online help.)
The IN operator is used to test whether a value belongs to a list of values contained in a selection
table. You will learn how to use selection tables in a later chapter.
The BETWEEN operator is used to test whether a value lies within a range. The range specified by
BETWEEN is inclusive. For example, the statement:
IF X BETWEEN 1 AND 5.
is equivalent to
IF X >= 1 AND X <= 5.
The IS INITIAL operator checks to see whether a variable is equal to its initial value. ABAP
automatically initializes all data variables with an initial value. In general, the initial value for character
variables is a series of blank spaces, and the initial value for numeric variables is zero.
ABAP automatically handles type conversion when comparing or assigning variables of different data
types or lengths. More detailed information can be obtained from the online help.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

Intro to ABAP
ECC 6.0

Logical operators are used to create compound logical expressions:


The OR operator indicates only one of the component expressions must be true in order
for the whole expression to be true. For example, IF ( X = 4 ) OR ( X = 5 ) is true
whenever X is equal to 4 or 5.
The AND operator indicates all of the component expressions must be true in order for
the whole expression to be true. For example, IF ( X = 4 ) AND ( X = 5 ) is always false.
The NOT operator reverses the logic of a component expression. For example, IF NOT (
X = 5 ) is true whenever X does not equal 5. This is equivalent to the statement IF X <> 5.
Logical and relational operators (as well as the parentheses) are always separated by
spaces. This is required ABAP syntax in logical expressions.
The hierarchy of the logical operators is: NOT, AND, and then OR. This is different from the hierarchy
when creating views in the ABAP Dictionary.
Parentheses can be used to group expressions and to override the default hierarchy of operators.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Control Statements

ECC 6.0

Try to keep compound logical expressions as simple as possible.


Two rules of thumb for using logical operators are:
Code logical expressions using positive logic. In other words, use statements like IF (
DATA_RETRIEVED = 1 ) rather than IF NOT (DATA_RETRIEVED = 0 ).
Limit the number of expressions linked with AND and OR, especially if combining them with
NOT. For example, avoid statements like:
IF ( DATA_RETRIEVED = 1 )
AND ( NOT ( CHILDREN_DISP = 1 )
OR ( ( TREE_COLLAPSED = 1 ) AND ( CURR_LEVEL > 0 ) )
OR ( CURR_LEVEL = 0 ) ).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

Intro to ABAP
ECC 6.0

String comparison operators can be used to compare strings and portions of strings.
With the pattern comparison operators, the following special characters can be used:
*

This indicates a pattern of any characters

+ This indicates any single character


# This is used before a * or a + to indicate that the * or + is to be taken literally. It also has
other special uses. Consult the online help for details.
The system field SY-FDPOS is set after each string comparison. Depending on the type and outcome
of the string comparison operation, SY-FDPOS is either set to the length of one string, or to the offset
of one string within another. Consult the online help for detailed information on how SY-FDPOS is set.
The offset of a character within a string refers to the number of places from the beginning of the string
that the character occurs. For example, in the string ABAP is great!, the offset of B is 1. The offset
of the first character in any string is 0; the offset of the second character is 1; and so on.
The operators CP and NP are not case-sensitive. All other string comparison operators are casesensitive.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

Intro to ABAP
ECC 6.0

The CASE statement is used to distinguish between mutually exclusive options. It is used when a
single variable can take on one of several known values. Each of the possible known values is
specified in a WHEN clause, which heads a block of code to be executed when the variable takes on
that value.
The WHEN OTHERS clause can be used to provide a default action if the variable does not equal one
of the specified values. It is good programming practice to include a WHEN OTHERS clause in a
CASE statement.
Each clause of the CASE statement must end with a period. The entire CASE statement structure
must end with the ENDCASE statement.

Performance Tips:
Use the CASE statement instead of multiple IFs and ELSEIFs where possible. This is better for
two reasons, firstly it is easier to read, and secondly, after about five IF checks, the performance
of the CASE statement is more efficient.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

Intro to ABAP
ECC 6.0

A DO loop is used to unconditionally execute a block of code multiple times. By default, a DO


statement creates an infinite loop. For example, the following code would never terminate:
DO.
WRITE: / Hello, world!.
ENDDO.
It is possible to specify the number of loop iterations by adding the n TIMES parameter to the DO
statement (n can be a literal or a variable). For example,
the following loop executes 4 times.
J = 4.
DO J TIMES.
WRITE: / Hello, world!.
ENDDO.
Alternately, it is possible to terminate a DO loop by issuing one of the following statements inside the
loop: EXIT, STOP, or REJECT. When one of these statements is encountered, the DO loop
immediately terminates. More detail about these statements is covered later (STOP and REJECT will
be covered in future chapters).
DO loops must be delimited by the ENDDO statement.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Control Statements

ECC 6.0

In contrast to the DO loop, a WHILE loop conditionally executes a block of code, possibly multiple
times.
The WHILE statement must always be followed by a logical expression. Before each loop iteration
(including the first), the logical expression is evaluated.
If the expression evaluates to true, the code inside the loop is executed.
If the expression is false, the code inside the loop is not executed, and control moves to the first
statement after the ENDWHILE statement.
As with a DO loop, an EXIT, REJECT, or STOP statement immediately terminates the loop.
The system variable SY-INDEX represents the index of the current loop pass (starting with 1 for the
first loop pass). Outside a loop, SY-INDEX is zero.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

Intro to ABAP
ECC 6.0

It is possible to nest flow control statements.


Inside nested loops, SY-INDEX automatically reflects the correct index for each level of the nested
loop. Consider the following example:
DO 2 TIMES.
WRITE: / SY-INDEX.
DO 3 TIMES.
WRITE: /

, SY-INDEX.

ENDDO.
ENDDO.
The output from the above code would be:
1
1
2
3
2
1
2
3

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Control Statements

ECC 6.0

The CHECK statement is used to test a logical expression. If the logical expression of a CHECK
statement evaluates to true, processing continues as if the CHECK statement was not there.
If the logical expression of a CHECK statement evaluates to false, processing proceeds in one of three
ways, depending on the context of the CHECK statement:
If the CHECK statement is in a loop, control immediately returns to the top of the loop for
the next loop pass. If the loop was already in its last iteration, the loop terminates.
If the CHECK statement is outside a loop but within a subroutine, the subroutine
immediately terminates, and control returns to the calling module.
If the CHECK statement is outside a loop and outside a subroutine, the current
processing event immediately terminates. (Processing events are covered in later
chapters.)
The following code writes the numbers 1 to 4, although the loop iterates 10 times.
DO 10 TIMES.
CHECK SY-INDEX < = 4.

WRITE: / SY-INDEX.

ENDDO.
Performance Tips:
CHECK should not be used to replace functionality of the WHERE clause in a select statement
This is because CHECK increases the load on the system.
.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

Intro to ABAP
ECC 6.0

The EXIT statement unconditionally terminates a loop, subroutine, or program.


If the EXIT statement is in a loop, the loop immediately terminates, and control passes to the statement
following the end of the loop.
If the EXIT statement is outside a loop but within a subroutine, the subroutine immediately terminates,
and control returns to the calling module.
The EXIT statement is also used in event processing - this is discussed later and in the interactive
reporting section. The affect of Exit depends on what event block it is found in.

Performance Tips:
When looping at an internal table, to improve performance provide an EXIT clause to terminate
the loop when the required records have been found.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Control Statements

ECC 6.0

The CONTINUE statement is used inside a loop. CONTINUE unconditionally returns control to the top
of the loop for the next loop pass. If the loop was already in its last iteration, the loop terminates.
The following code only writes the numbers from 1 to 4, although the loop iterates 10 times.
DO 10 TIMES.
IF SY-INDEX>4.
CONTINUE.
ENDIF.
WRITE: / SY-INDEX.
ENDDO.

Coding Recommendations:
For the sake of clarity, use of the CONTINUE statement is not recommended by SMM coding
methodologies. To avoid executing a piece of code for specific loops, it is recommended to use
an IF NOT ... ENDIF statement in order to improve readability of the code.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Control Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

Structures
Structures in code are similar to structures in the Dictionary in that they are simply field strings.
However, they are not dictionary objects, but temporary objects in program memory.
Structures are used in connection with sequential datasets and
subroutines as well as a staging area for internal tables.
Internal Tables
Internal tables are comprised of records which have the same format as an individual structure.
Internal tables are tables which only exist during the execution of a program.
Unlike the ABAP Dictionary transparent tables, internal table data is not stored on the database
server. Internal table data resides in
a program specific work area.
Data can only be entered in an internal table by going through a staging area. A staging area
can either be a header line or a work area, either of which has the same structure as the internal
table itself.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

Structures are defined with the DATA statement. The start and end of the structure are indicated by
BEGIN OF <FSname> and END OF <FSname>.

Fields in a structure are defined as individual fields; you must specify the length, and data type.
You can also define default values for components of structures. With the LIKE parameter, it is
possible to adopt the attributes of internal fields which have already been declared or the attributes
of fields defined in the ABAP Dictionary.

Reference fields in a structure as follows:


<Structure>- <field name>
e.g. YCUSTOMER-COUNTRY

It is possible to reference a complete Structure (for example, WRITE: <structure>.). Note that the
complete structure is then considered as a field of type C. Type conversion does not take place. If
the structure contained any packed fields, the WRITE ADDRESS statement would, therefore, not
produce meaningful output. Thus We need to use WRITE: <structure-field1>, <structure-field2>,..)

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

A structure can also be defined using a combination of the TYPES and DATA statements.
The TYPES statement defines a data type which in this example includes the fields: flag,
id, name1, and city. It does not allocate any memory for these fields.
The DATA statement defines a variable using the data type defined with the TYPES
statement. At this point, memory is allocated and the structure is present in the
programs work area.

This method is preferable to the previous one, especially when it comes to building an internal table
from a structure.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

The statement MOVE-CORRESPONDING <f1> to <f2> transports values field by field between the
ABAP data structures f1 and f2 for all sub-fields with the same field names. The system searches in
f1 for all single fields that also occur in f2 and generates a statement for all pairs of fields found: MOVE
<f1>-<field name> TO <f2>-<field name>. The other fields remain unchanged. But this Statement is
OBSOLETE . Hence We need to pass field by field value explicitly as shown above.
The CLEAR statement resets all fields to their initial value.

Performance Tips:
MOVE-CORRESPONDING is less efficient than a specific MOVE statement for each field in the
work area/data structure. If the data structures f1 and f2 are the same and the sequence and
attributes of all fields are identical, you can just use the statement MOVE <f1> to <f2> to transport
the values of all fields from f1 to f2.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Data Structures and Internal Tables

ECC 6.0

We will see in the next few slides how to expand a structure into an object called an internal table,
that can store records of data temporarily during the processing of a program.

As of the 4.0 release, there are 3 different types of internal tables: Standard, Sorted, and Hashed.

Although we will not be discussing Sorted and Hashed tables in detail, the following are some basic
differences between the table types:
The method of appending data.
The algorithm used in retrieving data.

There are various performance benefits for each of the internal table types.

When creating any of the internal table types, we have two further options:
Defining a key
Choosing between having the work area attached to, or independent of the table.

The single kind of internal table used in the past is now considered a Standard internal table.
These are the ones we will use in the course.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Data Structures and Internal Tables

ECC 6.0

To create an internal table without a header line, the programmer must:


Create an internal table data type with the TYPES statement. This type will become the
structure of the internal table.
Once the TYPE is created, a DATA statement is coded to identify the actual internal table
object with a name and an INITIAL SIZE clause. The internal table inherits the fields and
attributes from the TYPES statement defined earlier.
In addition to the internal table definition with the INITIAL SIZE clause, the programmer
must also define an internal table work area (staging area). This work area is defined
using the same format as the table. It uses the same user-defined data type as the
internal table.
The work area is loaded programmatically then appended to the internal table.
To load an internal table without a header line, the following APPEND statement is used:
APPEND <work area> to <internal table>.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Data Structures and Internal Tables

ECC 6.0

To create an internal table without a header line, the programmer must:


Create an internal table data type with the TYPES statement. This type will become the
structure of the internal table.
Once the TYPE is created, a DATA statement is coded to identify the actual internal table
object with a name and an INITIAL SIZE clause. The internal table inherits the fields and
attributes from the TYPES statement defined earlier.
In addition to the internal table definition with the INITIAL SIZE clause, the programmer
must also define an internal table work area (staging area). This work area is defined
using the same format as the table. It uses the same user-defined data type as the
internal table.
The work area is loaded programmatically (i.e., MOVE-CORRESPONDING EMPLOYEE TO
EMPTAB_WA), then appended to the internal table. In Newer Versions, this Statement gives a
warning in case of SLIN Check.
To load an internal table without a header line, the following APPEND statement is used:
APPEND <work area> to <internal table>.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

Why would we choose to use an internal table without a header line when it is easier to code one
with a header line?
Separate Internal Table Work Area: The work area (staging area) defined for the internal table
is not limited to use with just one internal table.
Suppose you want two internal tables for EMPLOYEE one to contain all records and
one to contain only those records where country = USA. You could create both of
these internal tables without header lines and use only one work area to load data into
both of them. You would append all records from the work area into the first internal
table. You would conditionally append the USA records from the same work area into
the second internal table.
Performance Issues: Using an internal table without a header line is more efficient than one
with a header line (see how to test this below).
Nested Internal Tables: If you want to include an internal table within a structure or another
internal table, you must use one without a header line.
Performance Tips:
To test efficiency issues, go to SYSTEM UTILITIES RUNTIME ANALYSIS Execute
and click on the Tips & Tricks push-button. Here you can test various internal table
performance issues. The one dealing with header line versus no header line is entitled Using
explicit work areas. Within this area, you can measure the runtime to see that internal tables
without header lines are more efficient. In the context of classes in SAP ECC6.0 internal tables
without header line should be used .

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Data Structures and Internal Tables

ECC 6.0

REPORT YEXAMPLE2.
A

TYPES: BEGIN OF EMP,


ID

TYPE ID,

NAME1

TYPE NAME1,

COUNTRY

TYPE COUNTRY,

END OF EMP.
DATA:
B

EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 ,


EMPTAB_WA TYPE EMP.

SELECT * FROM EMPLOYEE INTO EMPTAB_WA.


APPEND EMPTAB_WA TO EMPTAB.
ENDSELECT.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Data Structures and Internal Tables

ECC 6.0

REPORT YEXAMPLE2.
TYPES: BEGIN OF EMP,
ID

TYPE ID,

NAME1

TYPE NAME1,

COUNTRY TYPE COUNTRY,


END OF EMP.
DATA:

EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 ,


EMPTAB_WA TYPE EMP.

1+2
3

SELECT * FROM EMPLOYEE INTO EMPTAB_WA.


APPEND EMPTAB_WA TO EMPTAB.
ENDSELECT.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

The example above demonstrates how to create an internal table that gets
its structure from an existing table/structure in the ABAP Dictionary (in this example, EMPLOYEE).
This is a very valuable capability. Referencing other previously defined structures can save time
(not having to code them) and problems.

The only difference between making an internal table from a TYPES statement or from an existing
dictionary structure, is the use of the word TYPE in the DATA declaration.

It is also possible to refer to other objects defined in the program.

Notice the use of MOVE instead of MOVE-CORRESPONDING. The MOVE statement is used
because the structure of EMPTAB is identical to the structure of EMPLOYEE.

The above code loads the EMPLOYEE data into the internal table EMPTAB. It does not process
the internal table (this will be covered in later slides).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Data Structures and Internal Tables

ECC 6.0

When a MOVE-CORRESPONDING is performed, type conversion occurs automatically for the


individual fields. The process is carried out on a field-by-field basis. MOVE specified field to
specified field behaves the same way.

However, the following three scenarios are handled similarly to each other:
when you MOVE a structure to a structure of a different definition
MOVE a field to a structure
a structure to a field

In these cases, the data would be converted to one long character string (type C) first, then
conversion would take place.

If a piece of data is moving to a longer space in the new structure, it will be padded with spaces or
zeroes according to its data type. Moving into a shorter length would cause truncation.

Structures with an internal table included as a component do not follow the typical rules.

See Online Help for extended information about all the data conversion rules.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

To read records from a database table directly into an internal table, you need a basic SELECT *
FROM <database> statement with one of the following variations:
INTO TABLE <internal table>
APPENDING TABLE <internal table>

The INTO TABLE <internal table> addition fills the internal table with the selected database
records. Any old entries in the internal table are overwritten.

The APPENDING TABLE <internal table> appends the selected database records to any existing
entries in the internal table.

The database records are placed in the internal table EMPTAB in a single operation rather than
one-by-one as in a basic SELECT processing loop.

Since no loop processing occurs, no ENDSELECT is needed.

The WHERE and ORDER BY additions are optional.

The internal table must be at least as wide as the database table. Records are placed in the
internal table left-justified (i.e., starting from the first field listed in the definition of the internal table),
so any additional field(s) you want in the internal table must be the last field(s) defined beyond the
width of the database table.

Coding Recommendations:
The addition INTO CORRESPONDING FIELDS OF TABLE <itab> can be used.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Data Structures and Internal Tables

ECC 6.0

An internal table is processed using the LOOP AT ENDLOOP statement. On each loop pass,
the system reads the next table entry and places it in the header line. Also, the system field SYTABIX is set to the line number of the entry read.

When internal table fields are referenced within a program (i.e., EMPTAB-COUNTRY), the data
comes from the header line, not the body of the internal table. You cannot directly access values
from inside the body of the internal table you must first read an entry into the header line.

After the WHERE parameter, you can specify a logical expression. The entire internal table is read.
If at least one entry satisfies the logical expression, SY-SUBRC is set to zero. If no table entry
satisfies the logical expression, the statements within the loop are not executed and the system
field SY-SUBRC is set to 4. For each entry that satisfies the logical expression, the statements
within the loop are executed.

The programmer can use the FROM and TO parameters of the LOOP AT statement to restrict
processing of an internal table to a specific block of lines.

When processing a table without a header line, the syntax of the LOOP statement is
LOOP AT <internal table> INTO <work area>.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Data Structures and Internal Tables

ECC 6.0

When an internal table is read, the system field SY-TABIX is set to the index value of the internal table
line which has been placed either in the header line or the work area (depending on the type of table
you are reading).
Notice the use of the FROM and TO parameters in the LOOP AT statement to restrict the processing of
the internal table to a specific set of records.
It is possible to have nested loops on internal tables. Within these loops SY-TABIX is set in a similar
manner to SY-INDEX (see previous chapter)

Performance Tips:
Looping at internal tables for processing is more efficient than processing within
SELECT ENDSELECT loops. The following is even more efficient than nested loops:
SELECT FROM <database table>
FOR ALL ENTRIES IN <internal table>
WHERE <field> = <internal table field>.
See online help for further examples.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Data Structures and Internal Tables

ECC 6.0

When the COLLECT statement is used, ABAP scans the internal table for entries which correspond
to the header line in fields which are not of type P, I or F (i.e., all of the non-numeric fields become
the key of the header line).

If such an entry is found, the system adds all P, I and F fields in the header line to the
corresponding fields in the matching entry.

If no corresponding table entry is found, the contents of the header line are added to the end of the
table the same effect as the APPEND statement.

The COLLECT statement is also used to load a table with unique key fields. Before adding a line
to the table, the system checks to see if the table has an entry with the same key value. If an entry
already exists, the record is not added, otherwise the COLLECT statement has the same effect as
an APPEND statement. If COLLECT is used to fill an internal table, duplicate entries cannot occur.

When using an internal table without a header line, the syntax of the COLLECT statement changes
to: COLLECT <work area> INTO <internal table>.

Performance Tips:
COLLECT can be very CPU intensive - when using an internal table with > 50 entries.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

An internal table is sorted using the SORT <internal table> statement. If sort criteria is not
specified, the table is sorted by all fields (except those of data types P, I, and F) in ascending order
in the sequence in which they were declared.

With the additional specifications BY <field name> and ASCENDING or DESCENDING, you can
restrict the sort process to specific fields (or to fields of type P, I, F) and can determine the sorting
sequence and hierarchy.

Where possible, the sort process should be limited by using the BY <field name> parameter. ABAP
then requires less storage space in the roll area for the sorting process.

The sort process is the same whether or not the internal table has a header line.

You have the option of using a sorted table instead of a standard table. Then the entries will be
sorted automatically on their way from the header line into the internal table.

Performance Tips:
It is advisable to always specify the fields to be sorted by rather than just SORT.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

An internal table type is defined using the TYPES statement. No memory is allocated when
defining a type.

An internal table object is created with the DATA statement by referring to an internal table type
using the TYPE parameter. It is this DATA statement occupies memory. Internal table objects can
also be created through a reference to an existing table or structure using the LIKE parameter.

The internal table object must have an INITIAL SIZE <n> parameter to indicate the initial number of
table lines for which memory will be allocated.

The above code creates a standard internal table EMPTAB of structure EMP, and then loads the
employee data from table EMPLOYEE into the internal table EMPTAB.

The APPEND <internal table> statement adds the contents of the header line to the end of the
internal
table.

The APPEND <internal table> SORTED BY <field> statement adds a new record to an internal
table and
sorts the table by a single <field> in descending order (the default and only option).

The SORTED BY clause limits the maximum number of table entries to the value in the INITIAL
SIZE
parameter. If the table is full then, the last table entry is removed.

Performance Tips:
An INITIAL SIZE 0 cannot be used with the SORTED BY option, as no entries will be saved into the
body of the internal table.

IBM Global Services

Dec-2008

In previous versions, there was only one type of internal table, so the STANDARD TABLE OF addition
was not necessary. See the appendix for extended examples of older internal table declaration

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

By default, all the records that you append to your internal table have a key. This key is the
combination of all non-numeric fields. This is the implicit key.

You can also define your own key for an internal table. You would add WITH KEY FIELD1 FIELD2
etc. to your DATA statement.

More specifically, you can make your user-defined key:


UNIQUE: additional records with the same key would not be permitted
NON-UNIQUE: additional records with the same key would be permitted

Standard tables can have:


NON-UNIQUE KEY (same as just plain KEY), or
no user-defined key at all (more likely)

Indexing is used more than keys when it comes to reading standard internal tables.

User-defined keys are new in 4.0. You would only be able to use the implicit key in previous
releases.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

INITIAL SIZE <n> parameter: With <n>, you specify an initial number of lines for the internal table.
For the number of lines specified, memory will be reserved as soon as the first line is written into an
internal table.

If more lines are added to an internal table than specified by <n>, the reserved memory will expand
automatically. Therefore, it is possible to create an internal table with the parameter INITIAL SIZE
0.

If there is not enough storage in memory for the internal table, it will be written into a buffer or on a
disk (paging area).

If the INITIAL SIZE parameter is left off, a value of INITIAL SIZE 0 is set.

The INITIAL SIZE parameter will affect the physical size of an internal table if the APPEND
<Internal table> SORTED BY <field> statement is used to load data into the internal table (see next
slide).
Performance Tips:
If you know the maximum size of an internal table and that size is less than 8K, you can increase
the systems performance by specifying the maximum size in the INITIAL SIZE <n> parameter. If
you do not know the maximum size of an internal table or if its greater
than 8K, you should let the system allocate the appropriate memory by specifying INITIAL SIZE 0
in the internal table definition. Any table larger than 8K should be declared as INITIAL SIZE 0.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

When processing an internal table with the LOOP statement, it is possible to add additional code
that will only be processed when a field changes.

This is referred to as Control Level Processing (and can be compared to the GET LATE syntax
seen later for Logical Database Programs)

Depending on the coding requirements, it is usually required that the internal table is sorted before
control level processing occurs.

For example, some of the customer details have been stored in an internal table, and these must be
printed out grouped by country, with the country only written once and with the total number for
each country at the end.

The syntaxes required to perform this type of operation are:


AT FIRST ENDAT.
Condition is true as soon as a single record is read.
AT NEW <field>.ENDAT.
AT END OF <field>.ENDAT.
AT LAST..ENDAT.
Condition is true as soon as very last record is read.

WARNING: The timing of your AT statements are crucial. For example, within a LOOP block, if
you code an AT END to print a total before the generic write statement to print the original individual
amounts, your last record will be left hanging after the total.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

The READ TABLE <internal table> statement reads a single table entry.

When using an internal table without a header line, the syntax of the READ TABLE statement
changes to: READ TABLE <internal table> INTO <work area>.

If an entry was found with the READ statement:


SY-SUBRC is set to zero,
SY-TABIX is set to the line number of the entry read,
the table entry read is placed into the internal table header line or work area.

If an entry was not found with the READ statement:


SY-SUBRC is set to a non-zero number,
SY-TABIX is undefined,
the internal table header line or work area remains unchanged.

When you perform a LOOP AT <internal table> ENDLOOP, the effect is the same as a READ
TABLE <internal table> INDEX <i> where <i> starts at one and continues incrementing until the
entire internal table is read. In other words, with each loop pass, SY-TABIX is set to the line
number of the entry read and the header line or work area contains the data from the entry read.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

READ TABLE <internal table>.


The contents of the header line determine the table entry to be read. ABAP searches for the
first entry in the internal table that matches the header lines search term which consists of
all non-numeric fields with contents not equal to space.

READ TABLE <internal table> WITH KEY <key>.


Enter the search argument after the parameter KEY (in single quotes).
Beginning with the first character of the first field of the first entry in the table, ABAP
compares each record character by character with the search argument (<key>).

READ TABLE <internal table> WITH KEY <key> BINARY SEARCH.


Like variant 2, but using a binary search (faster than linear search).
The internal table must be sorted in ascending order by the
search argument.

READ TABLE <internal table> INDEX <i>.


The i-th table entry is read.

For information on the other READ options available, see Online Help.

Performance Tips:
A BINARY SEARCH should always be used whenever possible, but the table MUST be sorted first.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

The INSERT <internal table> INDEX <i> statement generates a new table entry before line <i>
with the contents of the header line. If the table <EMPTAB> has no entries, the contents of the
header line are added to the table.

The MODIFY <internal table> INDEX <i> statement overwrites table line <i> with the contents of
the header line. Line <i> must already exist.

The DELETE <internal table> INDEX <i> statement deletes table line <i>.

Within a LOOP AT <internal table> ENDLOOP, you can make changes to an internal table. The
line affected is always the current line (SY-TABIX).
INSERT <internal table>:
A new line with the contents of the header line is inserted before the current line.
MODIFY <internal table>:
The current line is overwritten by the contents of the header line.
DELETE <internal table>:
The current line is deleted.

Check SY-SUBRC after every attempt to change a table entry. If the change was successful, SYSUBRC will be set to zero.
Performance Tips:
INSERT/MODIFY/DELETE <internal table> WHERE .... is more efficient than first LOOPing AT the
table using the WHERE clause, then maintaining the tables header line.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

A work area (staging area) is required when working with an internal table without a header line.
This work area is defined as a Structure with the same structure as the internal table. The work
area is loaded and the table is processed from the work area.

A summary of the statements used for internal tables without header lines is
the following:
APPEND <work area> TO <internal table>
Appends the contents of the work area to the end of the internal table
COLLECT <work area> INTO <internal table>
Accumulates the values on a field into the table
INSERT <work area> INTO <internal table>
Inserts a new line with the contents of the work area before the
current line
MODIFY <internal table> FROM <work area>
Overwrites a line in the table with the contents of the work area
READ TABLE <internal table> INTO <work area>
Reads a line from the table into the work area
LOOP AT <internal table> INTO <work area>
Processes an internal table. On each loop pass, a table entry is placed in the work area.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

The CLEAR <internal table> statement initialises all single fields in the header line of an internal
table according to type.

The REFRESH <internal table> statement deletes all table lines. The table storage space is not
released. The header line remains unchanged.

The FREE <internal table> statement releases the storage space required for a table. The header
line remains unchanged.
This statement is particularly useful for very large internal tables. You can improve a
programs performance by freeing the memory space allocated for the internal table.
Internal tables that are local to a subroutine are automatically freed upon leaving the
subroutine.

WARNING: If you are working with an internal table with a separate work area, and you
accidentally say CLEAR <internal table>rather than CLEAR <internal table work area >, you
will delete all the table lines. Use REFRESH to achieve this instead.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

The DESCRIBE TABLE <internal table> statement provides information about an internal tables
attributes. With this statement, the programmer must use at least one of the two parameters
available LINES and OCCURS.

The LINES parameter allows the programmer to find out the number of existing table entries.

The OCCURS parameter contains the value of the OCCURS clause specified in the internal table
definition.

Notice in the example above the internal table can have more records in it than the number
specified in the OCCURS clause.

Performance Tips:
Always use DESCRIBE to find out how many entries there are in an internal table - it is much more
efficient than LOOPing AT the internal table and incrementing a counter.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

Intro to ABAP
ECC 6.0

With the EDITOR-CALL FOR <internal table> statement, the program will
open the SAP Table Editor which allows the user to change any data in the
internal table.

Select the records (use select icon) and then edit them.

To close the Editor and return to remaining statements in the program, use one of these methods:
Type U (update) in the command line of the Editor,
Press the SAVE push-button,
Press F11,
Type BACK in the command line of the Editor,
Press the BACK, CANCEL, or EXIT pushbuttons, or
Press F3, F12, or F15.

The system field SY-SUBRC will contain one of the following return code values:
0 = Editor left with U, SAVE, or F11
4 = Editor left with BACK, CANCEL, EXIT, F3, F12, or F15.

The maximum line length for the Editor is 72 characters.

The internal table can only contain fields of type C.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Data Structures and Internal Tables

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

If your program contains several identical or similar statements, you can avoid redundancy (writing
the exact same series of statements over and over again in one program), through the use of
subroutines.
Subroutines improve the structure of your program (by means of modularization) and make it easier
to read. A subroutine is simply a mini block of code that contains a series of ABAP statements in a
defined sequence.
Subroutines can be called from various points in a program.
Programs are much easier to read or follow when you place all subroutines together after the main
program, in the order they are most likely to be called.

Coding Recommendations:
For good modularisation, code that decides whether to execute a subroutine should be made before
the subroutine is called, not inside the subroutine.
Coding standards/methodologies emphasise that modularity both simplifies maintenance and
makes the code easier to read. Where possible, divide the main program into subroutines by
identifying stand-alone processes such as data retrieval, sorting internal tables, calculating totals,
printing report headers. This makes it easier to implement changes, reduces rework,
and assists debugging.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

ECC 6.0

Subroutines are used in two different ways:


The subroutine and its call are in the same ABAP program (internal call).
The subroutine is in a different ABAP program (external call).

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

Data (variables and tables) can be transferred between the main program and a subroutine. Data
calculated in the subroutine can also be passed back to the main program.
Data is transferred by using parameters. When you declare a subroutine, you are identifying the
"formal parameters". When you call a subroutine, you must specify the "actual parameters".
Subroutines can be defined without parameters.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

When using parameters, they must be passed to the subroutine using one of the following three
methods.

Pass by value: When the subroutine is called, a copy of the value of the data variable is
passed to the formal parameter. The formal parameter has its own storage location
(memory).

Pass by value and result: In addition to the above, at the end of the subroutine, the value
of the formal parameter is passed back to the actual parameter assigned to it.

Pass by reference: The formal parameters do not have a separate storage location.
Instead, the address of the actual parameter is passed to the formal parameter. Changes to
the value of the formal parameter are immediately reflected back in the actual parameters.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Modularization Techniques

ECC 6.0

Use the keyword PERFORM to call a subroutine. Use the keywords FORM and ENDFORM to
define a subroutine. A maximum of 30 character is allowed to name a subroutine. The name must
appear after the PERFORM and after the corresponding FORM keyword.
The additional keyword USING allows you to specify the data variables to be passed as
parameters. [Example: FORM subr USING f1 f2 ]
Each formal parameter must have a corresponding actual parameter.
When specifying formal parameters, you have the option of using the VALUE clause to define a
pass by value, [Example: FORM subr USING (f1) VALUE(F2)]. You are not required to use the
VALUE clause, without it, the system will automatically define a pass by reference, [Example:
FORM subr USING f1 f2 ] .

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

You can use the CHANGING clause when specifying formal parameters to define a pass by value
and result. When the subroutine is called, the formal parameter is assigned its own storage location
(memory). At the end of the subroutine (at ENDFORM), the contents of the formal parameters are
automatically passed back to the actual parameters.
If the subroutine is terminated by a dialogue message (MESSAGE Ennn) the value of the formal
parameter is not passed to the actual parameter.
If the result of the CHECK <log.expression> statement is negative in a subroutine, the value is still
returned since processing returns to the main program via ENDFORM. The same applies to the
STOP and EXIT statements.
See Extended Help on the PERFORM and FORM statements for more help on the CHANGING
addition.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

Global data is any variable or structure that is defined in the main program.
Local data is any variable or structure that is defined within a subroutine.
Global data created by statements like DATA and PARAMETERS is recognized within subroutines.
The following would result if you tried to use these words to define local data:
DATA: this is one of the approved techniques for defining a local variable, see the next
slide for further information on the impact on the main program.
PARAMETER: you cannot use this keyword within a subroutine.
There are several motivations for declaring a variable or structure locally within a subroutine. One
is efficiency of memory. If a variable is only necessary during a subroutine, then declaring it locally
means you can release the memory storage area when it is no longer necessary. There is also the
desire to preserve values as control switches between the main program and subroutine.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

Two statements can be used to define brand new variables within subroutines, with type, lengths
and default values.
DATA: use this option if you want the variable to be re-initialized with the default value every
time it enters the subroutine.
STATICS: use this option if you want the variable to remember what the value was the last
time it was in the subroutine. It will not be re-initialized based on the definition.
If you happen to have declared a global variable in the main program with the same name, the
variables are not linked. They behave as if they are two different variables. Returning to the main
program means reverting to the value that the global variable had before it entered the subroutine.
A third option is the LOCAL statement. Unlike the first two options, it cannot be self-contained
within the subroutine. It has to have been declared globally with a DATA statement first. Since that
is the original declaration, you cannot added length and types and defaults to the LOCAL statement.
The idea is that you can manipulate the variable inside the subroutine, and not affect the value in
the main program. This is like Passing by Value. Note: It is not recommended that you use
LOCAL.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

Recall that global data is visible and accessible in subroutines. Using the PERFORM and FORM
statements with no special extensions implies a pass by reference.
If you would rather not modify the values of the global variables, you can choose to pass by value.
We saw how to do this with a simple variable by using the USING extension .
To pass a field string (which you can consider a series of separate variables) by value, you will use
the USING extension again.
The data structures (such as table work areas, header lines, field strings) are passed to
subroutines as one long string of characters. Within the subroutine, you can reference the individual
fields of the structure. At runtime, however, the structure description itself is unknown to the
System and must be explicitly stated.
In summary, you must have:
PERFORM <subroutine>USING <field string>.
FORM <subroutine> USING <field string formal parameter>
STRUCTURE <which design the field string should have>.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

The technique to pass an internal table to a subroutine is similar to the one described on the
previous page to send a field string. You will have the following syntax structure:
PERFORM <subroutine>USING <internal table name>.
FORM <subroutine> USING <internal table formal parameter>
As with the field string from the previous page, the subroutine does not initially understand the
shape of the internal table. You must specify a structure for the internal table, immediately after the
USING addition.
An internal table is always passed by reference. We did not use the word USING, which implies a
pass by value.
We can combine the syntax we learned to pass single variables, field strings, and internal tables
into one long statement. If we pass internal tables, plus anything else, the USING <internal table>
addition should always be the first parameter after the subroutine name in the PERFORM and
FORM statement.
For example, in the slide above, the subroutine receives internal table TAB by reference, and single
variable X by value for processing.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

You can call a subroutine located in another program by specifying the external programs name
after the subroutine name.
When a call to the subroutine of another program occurs (SUB1 of Report Y170D097), it is loaded
into a buffer area as a complete unit at runtime, utilising valuable storage space. For this reason,
calls to subroutines belonging to other programs should be limited.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

Function modules are general purpose ABAP routines that can be called from any ABAP program.
The benefit of function modules lies in their reusability, which saves developers from creating
redundant code and increases programming efficiency.
Function modules are stored centrally in the Function Builder as part of function groups. These
function groups are collections of logically related functions that share common program context,
such as global variables, at run time. Each function group contains all the functions that perform
similar tasks (for example, all calendar functions) or functions which point to the same data base
(firstfunction = fill internal table; second function = process internal table; and so on).
A group can be assigned to a specific application (FI, HR) or can be designated for general use (*).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

The parts of a function module include:


Administration: Attributes such as the function group and short text
are assigned
Interface: Parameters such as import/export and exceptions are defined.
Documentation: Maintain documentation of function module
Source code: Define actual ABAP code for function module
Global data: Define data available for all function modules belonging to the assigned
function group
Main program: Program where all of the function modules of a function group are stored as
well as the global data
The ABAP Workbench comes with a large number of standard function modules, and users can
develop more on their own.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

Function groups are collections of logically related functions modules. Specification of a function
group is required when creating a function module.
From the Repository Browser choose Function Group Object in order to create a function group.
Function group names can be up to 26 characters and must begin with a Y or Z. Short text is a
required field.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Modularization Techniques

ECC 6.0

Function modules can be created from the Repository Browser (SE80) or from the ABAP Function
Builder: Initial Screen.
Function module names can be up to 30 characters long and must begin with either a Y or Z (i.e.,
Y_ and Z_).
Only alphanumeric characters and the special character underscore (_) are allowed.
When creating a function module, the Administration tab is defaulted to appear first. Both Function
group and short text are required fields in the Administration screen.
A function module belongs to a function group. One person is responsible for each group and is
authorised to release the function modules.
All function modules in a function group are managed in one ABAP program.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

Unlike external subroutines, function modules have a clearly defined interface which is defined
when creating the function module.
Five different interface parameter types exist:
Import parameters
Changing parameters
Export parameters
Tables parameters
Exceptions parameters

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Modularization Techniques

ECC 6.0

Formal parameters (import, export, etc.) should not be named the same as R/3 repository objects.
Import parameters are those variables that will be imported from the
calling program.
Export parameters are those variables that will be exported to the
calling program.
Changing parameters are those variables that will be both imported from and exported to the
calling program.
By default, import/export parameters are passed by value. Changing parameters are passed by
value and result.
Parameter options:
Type spec - Specify a reference field or structure from the ABAP dictionarythe type and
length of the actual parameter is checked
Reference Type - Specify reference type from ABAP type pool which must be declared in
the function group
Default Value - Specify default value for import/changing parameter
Optional - Flag import/changing parameter as optional
Pass value. - Flag parameter as being passed by reference rather than by value
Specifying reference fields and structures improves run time of function modules.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

Internal tables can be both exported to and imported from the calling program using the tables
parameter. Internal tables are passed by reference using this parameter.
Table parameter options:
Type spec - Specify a reference structure from the ABAP dictionary
Reference Type - Specify reference type from ABAP type pool which must be declared in
the function group
Optional - Flag table parameter as optional
When passing data structures (field string, table work area, internal table), you can specify a
reference structure. The formal parameter is then based on the specified structure. All fields of the
structure can be referenced by name (that is <parameter>-<field name>).
Exception parameters are used to pass return codes back to the calling program for error handling.
Exceptions are raised in the function module code when an error has been detected
programmatically. Exceptions set SY-SUBRC in the calling program, enabling programmers to
handle multiple errors. Through the return code (SY-SUBRC) programmers can output a message
to the user that is appropriate to the type of error.
On this screen, for Exceptions, enter simple short verbal descriptions for things that can go wrong,
or other situations you will later code to detect.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Modularization Techniques

ECC 6.0

When you are done defining the interface, go to the Source Code for your function module.
For each function module, the System generates an automatic program structure. The interfaces and
exceptions defined you defined are marked as comment lines.
Between this default text, and the ENDFUNCTION statement, you will include the actual ABAP code
that will give your function module functionality.

Coding Recommendations:
When declaring variables in a calling ABAP program for import/export
parameters, they should be declared LIKE the equivalent parameters in the function module.
You can find this parameter information by looking at the import/export interface of the function
module.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

You defined exception names in the interface of your function module. In the function module
source code, you trigger an exception by using one of the following statements:
RAISE <exception>- use this version if you just want to set SY-SUBRC and let the calling
program do the logic to interpret the importance and send a message or take any other
action.
MESSAGE ... RAISING <exception> - use this version if you want the function module to
also capture specific message information that you can later access in your main program
(system fields SY-MSGID, SY-MSGTY, SY-MSGNO, SY-MSGV1 to SY-MSGV4 will capture
information). The MESSAGE statement will be covered fully later.
It is up to you as the programmer to code the detection of the situation that would need the
exception to be raised.
When you raise an exception, the system looks at the function call in the main program to make
sure the exceptions clause is there. If it is, SY-SUBRC is set to the index number of the exception.
That depends solely on which order you put the exception names in the original interface. For
example, if you raised an exception that was defined on the second line in the original exception
interface, SY-SUBRC =2.
If the exceptions clause for the specific exception is missing from the function call, you will get a
short dump.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

The above is an example of function module source code that raises exceptions.
If any of the WHENs are satisfied that have a RAISE <exception> statement, control turns over to
the calling program, and SY-SUBRC is set based on the EXCEPTIONS clause (see next slide) of
the function call.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

You should always use the Edit Insert statement menu path to insert a CALL FUNCTION
statement.
When calling a function module, use EXPORTING to pass data from the calling program to the
function module. Use IMPORTING to transfer data from the function module to the program.
The meaning of IMPORT and EXPORT must always be seen from the point of view of the function
module or the calling program.
Parameter assignment takes the form: Formal parameters = actual parameters.
When you call a function module, the values for the EXPORTING parameters are passed to the
function module. When you leave the function module, values are returned to the IMPORTING
parameters.
Export parameters with default values are optional (from the point of view of the program) and are
displayed with a comment (*). If no such parameter is specified when the function module is called,
the default value is used.
All import parameters are optional for the calling program.
The exceptions parameters are used to determine if an error has occurred in the function module.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

In the calling program SY-SUBRC is set to a non-zero value when an exception has been raised.
Check the value of SY-SUBRC to send an appropriate error message to the user.
The MESSAGE statement will be covered in a later chapter.

Coding Recommendations:
The fields that the ABAPs program variables for importing/exporting should be declare LIKE
can be found by double clicking on the name of the function (if the current code passes the
syntax check).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

You use the Function modules function (transaction code SE37) to create and maintain function
modules. ABAP manages the different programs and tables.
All of the function modules belonging to one function group get stored in one program. The program
is of type Function Pool, with the name of the program SAPL<function group name>. The
program has a top include which is used to store any global data that is shared by all function
modules within a group. For every function module added to the function group there is a new
program of type Include created. These programs names start with L<function group name>UXX,
where XX is a counter number, starting with 01. In the program body there are INCLUDE
statements referring to all of the programs included in the function pool.
You only access a single INCLUDE program directly in special cases (such as subroutines,
dialogue modules).
When you create a new function module, ABAP creates a further INCLUDE program and
determines the name (number) of this program. When you transport a function module to the
production system, make sure you always transport the entire function group. This way, you avoid
differences in the internal administration of function modules.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

Subroutines called in various function modules should be created in a separate INCLUDE program.
To do this, you have to enter the name of the INCLUDE program in the main program of the
function group (function main program).
The name of the INCLUDE program should have the formal L<group>Fxx.
The workbench will create the INCLUDE modules with correct naming conventions.
If a subroutine is called only within a function module, you can create it in the program module itself
(**after ENDFUNCTION**).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

You use the Global data function to create fields and internal tables that are meant to be available
as global data in all function modules and subroutines of a function group. Table work areas
(TABLES) are always global, no matter where they are declared.
Global fields are initialised before the first call of a function module in a function group. The global
data with the values from the previous call is then available for further calls to function modules
belonging to the same group. With the global data, you can implement a local memory for one
function group.
In addition to global data, local data can also be declared in each function module. Local fields in a
function module that are declared in the program of the function module are initialised before each
call of the function module.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

Once you have compiled a function module, you can test it using the appropriate push-button
TEST/EXECUTE in the Repository Browser and SE37. Input values can be specified for the
IMPORT parameters in an input template. The result is transported to the EXPORT parameters
and listed.
When an error occurs, the exception is flagged.
The time needed to execute the function module is displayed in microseconds.
It is possible to store test data in a test data directory.
You can test function modules with table parameters within the test environment.
You can create test sequences.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

The person responsible for a function group uses the Administration function to release a function
module.
Releasing a function module means that it has been documented and that the interface has been
defined. No further changes can be made to the interface after release of the module. However,
you can call function modules before releasing them.
If you wish to change or extend the interface of a function module that has already been released,
the person responsible for the function group has to cancel the release of the module first.
The Notes function allows all users of one function module to record their comments, points of
criticism and requests.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

ECC 6.0

The additional parameter DESTINATION is required for the remote call.


Further parameters are determined via a control table (RFCDEST).
For remote calls, the parameters for the remote function must be set.

IBM Global Services

Intro to ABAP

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Modularization Techniques

ECC 6.0

Transaction SE37 is the ABAP Function Builder: Initial Screen.


When you are using wildcards, use the Search Helps to get a list of possible entries, you can select
the appropriate function module by double-clicking.
To display programs which call the function module, use the Where-used list function (this may
also display SAP demo programs showing function usage).
A short text and more detailed documentation can be displayed for all elements of a function
module.

Coding Recommendations:
There are many valuable functions modules available in the SAP system, and it is worth
spending some time researching those available.
Ex:CONVERSION_EXIT_INVDT_INPUT (converts date ddmmyyyy to SAPs inverted)
CONVERT_TO_LOCAL_CURRENCY (determines currency/exchange rate etc.)
POPUP_WITH_TABLE_DISPLAY (popup box with values and choose/cancel)

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

Intro to ABAP
ECC 6.0

The System forces Function Modules to be coded creating includes for global data declarations,
and common subroutines.
If these are required in user defined programs, the include technique can be applied so that
common data declarations exist in one include, and this is referred to by all programs.
For example, in a project environment there may be a standard report header that will use the
same variables for every report, and print the first few lines of a report in the same way.
The variables can be defined in a separate include and the form to write this may also be in a
separate include program.
Note: This is not an external subroutine call, as the includes are seen by the system as part of the
main program.
The include programs should be created first (with a program type I = Include). Other programs
which use it are still created without a top include (I.e. a specific include just for that program - Top
Includes are used in Online Programming)
Note: You many need to use the event keyword START-OF-SELECTION before any main
processing (ie after include declaration and data declaration). Event processing and the STARTOF-SELECTION event are explained in later chapters.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Modularization Techniques

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


SELECT Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

3.09.1

IBM Global Services - SAP Development ABAP Training


SELECT Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

3.09.2

IBM Global Services - SAP Development ABAP Training


SELECT Statements

Intro to ABAP
ECC 6.0

ABAP programs (which typically generate some type of list output) read data from database tables
in order to display the data (on screen or hardcopy) or have the data available for further processing
in the program. The task of accessing the database can be accomplished with two methods.
Method 1 - GET Event: Data access in ABAP programs is often developed using logical
databases (via the GET event) where authorisation checks are carried out automatically.
Method 2 - SELECT Statement: ABAP supports using Open or Native SQL select statements to
access database tables. However, the SELECT statement does not carry out any authorisation
checks. The programmer has to manually code the proper checks for authorisation on the database
tables.
To write a report based on data inside the database, you must use either the SELECT statement or
a logical database and the GET event.

IBM Global Services

Dec-2008

3.09.3

IBM Global Services - SAP Development ABAP Training


SELECT Statements

Intro to ABAP
ECC 6.0

SAP provides the term ABAP Open SQL to provide support for using standard SQL statements to
access your database.
ABAP Open SQL has the following attributes:

It is a subset of standard SQL (its syntax is similar)

It contains SAP short forms

Provides an interface between Open SQL and Native SQL

ABAP Open SQL SELECT statement can only be used on database tables that have been defined
in the ABAP Dictionary with a primary key.
The SELECT statement can access data by three methods:

Single access with fully qualified key

Loop processing with restriction

Loop processing without restriction

IBM Global Services

Dec-2008

3.09.4

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

SELECT Statements

ECC 6.0

The SELECT SINGLE statement allows you to access a single table entry (one record).
You must include the full key (except client) of the table in the WHERE clause. Key field names do
not need to be prefixed with the table name. Only the equal (= or EQ) relational operator can be
used.
Notice that you do not code an ENDSELECT because only one record will be returned.
Create a work area of type ytabna to place the data record into it, after it has located the record.
The TABLES statement is used in conjunction with SELECT to create a work area (within memory)
for the SELECT statement to use to place the data record into, after it has located the record. This
type of declaration is used in the earlier versions but from SAP ECC 6.0 it was not preferable. So
instead of creating a work area with a tables statement, declare an explicit work area as shown in
the above slide.
The return code (SY-SUBRC) will be set to either of the following values after the SELECT
statement finishes:

0 = Read was successful

4 = Record does not exist

Performance Tips:
SELECT SINGLE should be used when possible. Even if full primary key is not
available, when selecting only one record it can be better to SELECT SINGLE,
despite syntax check warnings (viewed in Editor via Program- Check- Display
Warnings)
IBM Global Services

Dec-2008

3.09.5

IBM Global Services - SAP Development ABAP Training


SELECT Statements

Intro to ABAP
ECC 6.0

You are not limited to using the WHERE clause only for the full table key. You can also restrict an
entire volume of records to be processed in a loop, by adding a WHERE clause on any other table
fields to your SELECT statement.
In the WHERE clause, specify your selection condition. [You do not have to use a WHERE clause
if you want to read all the records in a table].
The WHERE clause is made up by comparing a table field to another field or to a value, using one
of the relational operators shown above.
AND is used to specify a selection condition for more than one table field or for more than one
unique value on the same table field.
This type of SELECT statement requires an ENDSELECT statement. A processing loop is started
with SELECT and concludes with ENDSELECT.

IBM Global Services

Dec-2008

3.09.6

IBM Global Services - SAP Development ABAP Training


SELECT Statements

Intro to ABAP
ECC 6.0

To handle multiple records we can create an internal table ( it_tabna) .


Rather than using select ..endselect and hitting the database table several times we can use SELECT *
FROM <table> into table <itab> WHERE
<table field 1> <relational operator> <field 1>
AND

<table field 2> <relational operator> <field 2>

OR

<table field 3> <relational operator> <field 3>

AND

<table field 4> <relational operator> <field 4>

:
OR

<table field n> <relational operator> <field n>.

Which will hit the database table at once and fetches the records.
After selecting the records loop the internal table to get the individual records.

IBM Global Services

Dec-2008

3.09.7

IBM Global Services - SAP Development ABAP Training


SELECT Statements

Intro to ABAP
ECC 6.0

Several other type of comparisons ( BETWEEN, LIKE, IN) can be made in the WHERE clause to
specify ranges, masked literals/templates and field lists.
It is also possible to use the negation operator NOT on any kind of comparison, (such as NOT
LIKE, NOT BETWEEN, NOT IN).

IBM Global Services

Dec-2008

3.09.8

IBM Global Services - SAP Development ABAP Training


SELECT Statements

Intro to ABAP
ECC 6.0

Code the BETWEEN addition listing, either hardcoded values or declared constants (better coding
style), with an AND between low and high values.
At the beginning of each loop pass, each record is loaded into a work area . The processing to be
done on each record must be specified between SELECT and ENDSELECT.
The following return codes are issued after the ENDSELECT:

0 = At least one record matched the criteria specified in the WHERE clause

4 = No records matched the WHERE clause criteria (none exist).

IBM Global Services

Dec-2008

3.09.9

IBM Global Services - SAP Development ABAP Training


SELECT Statements

Intro to ABAP
ECC 6.0

A masked literal contains the underscore _ for a single character and the percentage character %
for a character string.
In the above example, the table entries selected are those where the contents of the field T001BUKRS starts with any two characters followed by 01 and where the contents of the field T001BUTXT start with "SAP" followed by any string.

Performance Tips:
Using the % wildcard too liberally can impede performance. It is more efficient to narrow the
selection by using the template SMI%, rather than the template S%. In addition, if the wild card
is at the beginning of a pattern string/template, this precludes the use of an index.

Coding Recommendations:
To search for the literal character %, you must use the # to show where the literal begins and
ends - Ex: LIKE SAP#%#_ would bring back only those records that began SAP% followed by
one additional character.

IBM Global Services

Dec-2008

3.09.10

IBM Global Services - SAP Development ABAP Training


SELECT Statements

Intro to ABAP
ECC 6.0

The IN operator of the WHERE clause allows you to compare a table field with a list of single
values.
Listing single values with the IN operator is similar to linking values with OR. The list can contain
fields or literals.

IBM Global Services

Dec-2008

3.09.11

IBM Global Services - SAP Development ABAP Training


SELECT Statements

Intro to ABAP
ECC 6.0

The IN operator of the WHERE clause allows you to compare a table field with a list of values
contained in an internal table.
A convenient way to create that internal table is with RANGES. See syntax above.

The DATA statement above can be replaced by the RANGES statement.

The TYPE RANGE OF statement creates the identical internal table that is created in the DATA
statement with the columns SIGN, OPTION, LOW, HIGH.

SIGN: I (inclusive) or E (exclusive)

OPTION: BT (between) or EQ (equal)

LOW: low value for range

HIGH: high value for range

The internal table created with SELECT-OPTIONS is identical to that created with TYPE RANGE
OF statement. SELECT-OPTIONS displays on a selection screen.
Coding Recommendations:
Coding standards suggest declaration of RANGES internal tables using the prefix R_ and
SELECT-OPTIONS internal tables using the prefix S_.
Performance Tips:
Using the IN operator will reduce selectivity, and may disable the use of an index.

IBM Global Services

Dec-2008

3.09.12

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

SELECT Statements

ECC 6.0

The ORDER BY clause in a SELECT statement allows you to sort the table entries.
Table entries can be sorted in either ascending order (the default) or descending order.
Use the additional specification ORDER BY PRIMARY KEY to sort the table entries by the primary
key field(s).

Performance Tips:
Transparent tables can be sorted by any of the table fields, however, performance is always better if
you use table fields with an index.
Performance Tips:
If selecting large amounts of data (> 10 MB) and using an index, it is most efficient to use the
ORDER BY clause. However, if selecting small amounts of data and no index is suitable, filling an
internal table and then using the SORT addition can reduce the load on the database server since
the application server can handle it. For details on index use run transaction ST05 (see help on
SQL Trace Tool).

IBM Global Services

Dec-2008

3.09.13

IBM Global Services - SAP Development ABAP Training


SELECT Statements

Intro to ABAP
ECC 6.0

In SAP Systems with several instances, the SAP table buffers for buffered tables are only updated
at certain intervals. For this reason, the local table buffers may contain old contents for a certain
period of time.
If you want to be sure to select the current data directly from the database tables and bypass the
buffer, you must use the additional specification BYPASSING BUFFER.

Performance Tips:
Execution of certain statements causes direct access to the database. You may want to avoid
some of these statements when programming with buffered tables, eg: SELECT FORUPDATE,
use of native SQL, aggregate functions (SUM, AVG etc), SELECT DISTINCT,ORDER BY etc.

IBM Global Services

Dec-2008

3.09.14

IBM Global Services - SAP Development ABAP Training


SELECT Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

3.09.15

IBM Global Services - SAP Development ABAP Training


SELECT Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

3.09.16

IBM Global Services - SAP Development ABAP Training


SELECT Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

3.09.17

IBM Global Services - SAP Development ABAP Training


SELECT Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

3.09.18

IBM Global Services - SAP Development ABAP Training


SELECT Statements

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

3.09.19

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

The SELECT DISTINCT option is used to return only one record for each unique occurrence of data
in a column based on a field name (or combination of field names). All other records that have the
same matching data, will not be included in the result set.
It is recommended you use very few columns with the SELECT DISTINCT option. The result tends
to lose significance if too many columns are specified.
The SELECT DISTINCT requires an INTO clause because it is selecting individual columns.

Performance Tips:
When handling large amounts of data (>10 MB) and selecting with the support of an index,SELECT
DISTINCT is the most efficient syntax (to check for index support, use transaction ST05 - see help
on SQL Trace Tool). However, if the amount of data is small and there is no index, fill an internal
table and then use the DELETE ADJACENT DUPLICATES statement.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

The aggregate functions MIN, MAX, AVG, SUM, and COUNT are a valuable tool for accumulating
values across the entire table or a subset of the table rows based on the conditions in the WHERE
clause.
Notice there is no ENDSELECT because the aggregate SELECT statement does not return
multiple records.
Aggregate functions require an INTO clause because they return single values.
After the aggregate name, you must specify the individual columns of interest within parenthesis.
The open (left) parentheses must come immediately after the aggregate function - no space
is allowed here.
The field name inside the parenthesis must be preceded by a space and followed by a space
(before and after the open and close parenthesis).
When using DISTINCT in an aggregate expression, the aggregate function does not apply to all of
the values in the table. The function only applies to those different or DISTINCT values. In the
case above, the COUNT aggregate function is applied to only those distinct nine countries not to the
entire table.
Aggregate functions cannot be used with pooled or cluster tables.
Performance Tips:
Aggregate functions are executed at the database level and, therefore, increase efficiency -this is
further enhanced by the use of the GROUP BY statement.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

The WHERE clause is created at runtime and can be created by the user using parameters.
An internal table must be created which can only have one field. The field must be type C and
should not exceed 72 characters.
The following restrictions apply to the conditions:
Only literals can be used as values, not variables.
The IN operator cannot be used in conjunction with the internal table
[as in <field1> IN (itab) ].
The where clause internal table can be empty. In this case the SELECT statement will be executed
as if there was no WHERE clause (all rows returned).
It is possible to specify an additional condition within the WHERE clause outside the internal table.
The syntax is as follows:
WHERE <condition> AND (itab)

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

CONCATENATE is a string processing statement which enables the programmer to combine the
contents of one or more source fields into a single target field.

After the CONCATENATE statement is executed, the SY-SUBRC system field will contain one of
the following values:
1. 0 - the source field fits successfully into the target field
2. 4 - the source field is too big for the target field and was truncated to the size of the target
field

The option SEPARATED BY is useful for embedding spaces or special characters between the
multiple source fields before they are transported to the target field.

In the example above, the CONCATENATE statement is used to construct a WHERE clause in a
SELECT statement. The user enters the various options and/or conditions that make up the
WHERE clause on a parameter screen. The program takes the parameters and CONCATENATES
them into a comprehensive WHERE clauses separating each condition and operator with a space.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

Reading selected rows into an internal table in packages of a predefined size is possible using the
PACKAGE SIZE <n> option with the INTO clause.
The SELECT statement with the PACKAGE SIZE option initiates a loop which is terminated with an
ENDSELECT statement. For every package of <n> rows the system makes one pass through the
loop.
Outside the SELECT loop, the contents of the internal table are unknown. Therefore, any
processing on the rows that is to be performed, must be done inside the SELECT ENDSELECT
loop.
In the example above, all rows of table YTABNA are read into TAB in packages of 5 rows. Inside
the SELECT loop a second loop is nested in which the packages are written to the report.

Performance Tips:
The INTO TABLE statement can be used without the package size addition. This is a more efficient
code than a SELECT .... ENDSELECT, as the database access is reduced - all records meeting the
selection criteria are moved into the table in one process, so no database looping is required. The
internal table can then be looped at for further processing.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

Using dynamic table specification, it is possible to designate the name of the table to select
records at run time.
In the example above, the table name is passed to the program through a parameter and
then used in a SELECT statement.
Notice there is no TABLES statement. Specifying the table name at runtime is the only time in
Open SQL that a TABLES statement is not needed to declare the table work area.
In this form, it is required that the data be read into a work area or internal table.
Since the name of the table is not known until runtime, it is necessary to make sure the work
area is large enough to accommodate the length of the records it will be holding.
Since the generation of internal control blocks occurs only at runtime, a SELECT statement with a
dynamic name specification impairs performance more than a static name specification.
It is possible to use the ORDER BY PRIMARY KEY, but not ORDER BY f1.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

CURSOR processing enables the programmer to execute SELECT statements that produce
multiple row result sets then read/process each row of the result set sequentially.
The CURSOR is declared with a DATA statement and a type of CURSOR.
The CURSOR data type is then associated with a SELECT from a database table in the OPEN
statement.
Individual rows of the result set are processed using a FETCH statement sequentially until the end
of the table is reached.
CURSOR processing is terminated using the CLOSE CURSOR statement. At that point the result
set is destroyed.

Coding Recommendations:
This technique is rarely used, but may be required if looping at two or more database tables that
cannot be effectively combined with a join. An example of this type of parallel cursor processing is
when the choice of which table to loop at next depends on the contents of a field not known until the
previous loop has been executed.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Open SQL Extensions

ECC 6.0

A CURSOR is used to fetch the next row (or set of rows) from almost any SELECT statement that
produces a result set of more than one row.
A CURSOR must be defined using the CURSOR data type. The CURSOR name can be no more
than eight characters with no embedded special characters.
The CURSOR is associated with a SELECT statement in the OPEN CURSOR statement.
Using the WITH HOLD option allows the cursor to stay open after a database commit (which
normally destroys the result set). This is normally used with Native SQL.
A CURSOR cannot be used with a SELECT SINGLE, because it only returns one row.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

Once the CURSOR is opened, individual rows from the result set are read using the FETCH
statement.

The rows selected are read into the target work area specified in the INTO clause.

After the FETCH the SY-SUBRC will contain:


1. 0 - if the row was successfully read
2. 4 - when the end of the result set has been reached

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

The CLOSE CURSOR statement is used to terminate CURSOR processing. When the statement
is issued, the internal result set is destroyed and access is no longer possible unless a new OPEN
CURSOR statement is executed.
CURSORs are automatically closed under the following circumstances:
Execution of a COMMIT WORK or ROLLBACK statement
Execution of Native SQL commits and rollbacks
Changes of screen
Remote function calls

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

Previously, in order to access multiple tables, we used nested selects either directly coded into our
program or through a logical databases. Both of these methods have drawbacks:
Nested selects cause a significant amount of overhead when accessing the database. For
instance, a select statement, nested within a select loop, would have to be executed with
each record the outer select statement retrieves. Not only does this increase network traffic,
but each time a select is executed, process control is shifted between the DBMS and your
ABAP program. These process control shifts take time, consequently, causing inefficiency.
Logical databases, although useful and easy to code, are also inefficient due to the nested
selects they use. In fact, logical databases are more inefficient than ordinary nested selects,
to do additional process, control shifts between the primary ABAP program, and the logical
database program.
Joins have the advantage of accessing multiple tables with one Select statement, thereby reducing
the amount of server overhead.
Joins will always bypass the buffer.

Inner joins are new as of 3.1h, and left outer joins are new as of 4.x.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

Inner Joins allow access to multiple tables with a single select statement by creating a temporary
table based on the conditions in the ON statement. Inner Joins are equivalent to views created in
the Dictionary (see Data Dictionary part).
Aside: In all slides in this chapter, illustrations of scarr, sflight and sbook contain all records for the
fields displayed.
Syntax for inner join:
SELECT scarr~carrname sflight~carrid sflight~connid sflight~fldate
INTO (carrname, carrid, connid, date)
FROM scarr INNER JOIN sflight
ON scarr~carrid = sflight~carrid.
WRITE: / carrname, carrid, connid, date.
ENDSELECT.
Multiple tables are joined based on key fields specified by the join condition. The output list
displayed above is the result of an inner join on the CARRID field of the SCARR and SFLIGHT
tables. The result of an inner join will be identical, regardless of whether the condition is expressed
in an ON or WHERE clause.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

In order to access multiple tables, we must specify the table name of key fields that are found in
both tables in the field list.
E.g., SELECT sflight~carrid sflight~connid fldate carrname
fldate and carrnam do not need to be prefixed with there respective Database table name,
because each only exist in one of the two accessed tables.
However, you should consider prefixing all fields with their respective table names, for the
sake of clarity, and to avoid any conflicts if identical fields are added to one of the joined
tables in later versions of SAP.
E.g., SELECT sflight~carrid sflight~connid sflight~fldate scarr~carrname
You can specify multiple table fields in the ON clause as seen in the slide above.
Inner join can be replaced with just join.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

The table hierarchically higher in an inner join should be the driving table (A.K.A., The Left-Hand
table). In the slide above, theoretically SCARR would be hierarchically higher than SFLIGHT in the
FROM clause, since it deals with specific flight information. SCARR deals with the airline names
associated with the CARRID field.
Tables lower down in the hierarchy are usually larger and more specific than those higher.
This can also be seen when using nested selects. The code below will produce output
identical to the code on the slide above.
SELECT carrid carrname FROM scarr
INTO (scarr-carrid, scarr-carrname).
SELECT carrid connid fldate FROM sflight
INTO (sflight-carrid, sflight-connid, sflight-fldate)
WHERE carrid = scarr-carrid.
WRITE: / scarr-carrname, scarr-carrid,
sflight-connid, sflight-fldate.
ENDSELECT.
ENDSELECT.
Here and in the slide above, the driving table is scarr (it is just coincidence that the driving table is
named scarr ).

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

Like inner joins, left outer joins create a temporary table based on the conditions specified in the ON
clause.
Unlike inner joins:
Based on conditions expressed in the ON statement, fields in the driving (left-hand) table that
do not correspond to fields in the right-hand table are still added to temporary table. There
they are populated with initial values.
The non-corresponding records fields in the right-hand table are populated with initial values
in the resulting temporary table, thus producing the output displayed above.
However, this is not the case with the WHERE condition - records not found in both tables are
eliminated.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

Aside from the FROM clause, the syntaxes for inner and outer joins are identical.
The OUTER in LEFT OUTER JOIN can be omitted.
Outer joins have syntax restrictions additional to those shared with inner joins (see next slide).
Conditions in the on clause can only be =.
E.g., no sflight~carrid < spfli~carrid.
The ON condition must contain a field from the rightmost table.
The WHERE condition can only contain fields from the leftmost table.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Open SQL Extensions

ECC 6.0

Not all databases supported by SAP share a standard syntax for the ON clause. This means that
the results of a join may differ depending upon which database is being used. Because of this, the
syntax for joins have been given certain restrictions in order to insure that they produce the same
results for all SAP supported databases:
Only a table can come after the JOIN statement.
I.e., From SFLIGHT left join SBOOK left join SPFLI would give you a syntax error.
Only the AND logical operator can be used in the join condition.
Each comparison in the ON condition must have a field from the right hand table.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

Joins have the disadvantage of returning redundant data when the left and right tables have a 1:N
relationship. I.e., for every record in the driving table, there may exist multiple records in the right
hand table. For instance, a vendor in the LFA1 table may have many documents associated with it
in the BSIK table.
Because of this redundant data, the amount of data being passed between the database layer and
the application layer is quite large. For this reason, you should only select fields that are absolutely
necessary.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

In order to join multiple tables, you must: first join two tables, put them into parentheses, and then
join the next table (on slide above).
To join more than three tables, you would put the first three tables in parentheses, and then
join the next table.
E.g., ((tab1 INNER JOIN tab2 ON) INNER JOIN tab3 ON. . .) inner join tab4 ON. . .
Generally, you will not join more than three tables.
The syntax for outer joining more than two tables is the same.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

Intro to ABAP
ECC 6.0

Aliases simply allow the programmer to prefix fields with shorter table names. This comes in useful
with long field lists.
You can only use a table alias to prefix a database field not a work area (I.e., a tilde (~) must follow
the alias). E.g., A-carrname would be incorrect.
Aliases have no impact on performance.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Open SQL Extensions

ECC 6.0

Subqueries are a more efficient method of performing complex select statements.


The conventional method of coding a solution to the question posed in the slide above is:
SELECT * FROM scarr.
SELECT * FROM sflight WHERE carrid = scarr-carrid.
ENDSELECT.
IF sy-subrc <> 0.
WRITE:/ scarr-carrid, scarr-carrname.
ENDIF.
ENDSELECT.
Because of the nested select and the comparison of the scarr-carrid work area with the
sflight~carrid database table field, there is an excessive amount of data being transferred
between the application and database layer. I.e., All data from both select statements are
being sent to the application where it is then processed (in this case, by IF SY-SUBRC).
Subqueries can handle this at the database layer; therefore, the data that has to be
transferred to your program is reduced. In the case of the slide above, only three records
would have to be transferred back to the application.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Open SQL Extensions

ECC 6.0

The code in the slide above will produce identical output to the code in the previous slide.
You cannot use SELECT SINGLE with subqueries.
Some other conditions in the where statement include:
WHERE <field>IN
WHERE EXISTS ( SELECT. . .
This can be used in a select statement that will produce one record.
WHERE NOT EXISTS ( SELECT. . .
In both EXISTS and NOT EXISTS the subquery (I.e., the select in parentheses) is
executed last.
Aside: You can alias the table name with:
Select * FROM scarr as A WHERE. . .

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Open SQL Extensions

ECC 6.0

The having clause assigns the selection criteria handling to the database instead of the application
server. Similar to the subquery, the advantage of this is the reduction in the amount of data being
transferred between the two layers.
The conventional method of coding a solution to the query in the slide above would be:
SELECT carrid connid COUNT(*) SUM( luggweight )
INTO (carrid, connid, count, sum_weight) FROM sbook
WHERE carrid = 'LH'
GROUP BY carrid connid.
IF sum_weight > 25.
WRITE:/ carrid, connid, count, sum_weight.
ENDIF.
ENDSELECT.
Since we are using an IF statement at the application server level to process the selection criteria,
every record that satisfies the WHERE condition is transferred to the application. However, in the
case of the HAVING clause, only the records that satisfy the WHERE clause and HAVING clause
are returned to the application, thus reducing the amount of data being passed back and forth.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Open SQL Extensions

ECC 6.0

The code on this slide will produce identical output to the code on the previous slide.
HAVING must be used with aggregate expressions.
Any fields in the field list not using aggregate expressions must be in the GROUP BY clause.

IBM Global Services

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Open SQL Extensions

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008
2005

IBM Global Services - SAP Development ABAP Training


ABAP Native SQL

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Native SQL

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

ABAP Native SQL

ECC 6.0

In contrast to ABAP Open SQL, when referencing database tables in ABAP Native SQL the table
does not have to be in the ABAP Dictionary. The TABLES statement is not required for any tables
addressed through ABAP Native SQL.
Native SQL should be used to access data in tables outside of the SAP system.
ABAP Native SQL statements must be enclosed between EXEC SQL and ENDEXEC.
In the example above, the following ABAP Native SQL statement are used:
DROP TABLE <table name>
This statement deletes the named table and any data that may reside in that table.
CREATE TABLE <table name>
This statement creates a table object as well as all of the associated columns and
primary key fields.
INSERT INTO <table name>
This statement adds records to the named table.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Native SQL

Intro to ABAP
ECC 6.0

The SELECT statement coded above selects an individual record from the table DEMO_TABLE.
After the data is retrieved, it is transported to the program using the host variables defined by the
ABAP program in the DATA statement.
All variables defined inside the ABAP program using a DATA or PARAMETER statement and used
inside an ABAP Native SQL statement, must be preceded by a colon.
It is possible to SELECT INTO a target structure instead of individual variables.
Another ABAP Native SQL statement is :
DELETE FROM <table name>
This statement only deletes the data records in a table. The table structure remains
intact and the table name remains in the database.
In the example above, the DELETE statement will delete all rows from DEMO_TABLE
which have a ABAP4 in the CLSNAME column. Be careful when deleting rows from a
table without specifying the entire primary key.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Native SQL

Intro to ABAP
ECC 6.0

If an ABAP Native SQL SELECT statement returns more than one record, you can immediately
process each record in a loop by using the PERFORMING <form> option. For every row read, the
<form> subroutine is called.
If you need to terminate the processing loop before the ENDFORM, you can use the EXIT FROM
SQL statement within a subroutine (only). When this statement is reached, processing within the
subroutine is halted and the program continues execution from the next statement after the ABAP
Native SQL statement which initiated the PERFORM.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Native SQL

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Native SQL

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Native SQL

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


ABAP Native SQL

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Authorizations, Passing Data Between Programs, Catching Runtime Errors

IBM Global Services

Dec-2008

Intro to ABAP
ECC 6.0

IBM Global Services - SAP Development ABAP Training


Authorizations, Passing Data Between Programs, Catching Runtime Errors

IBM Global Services

Dec-2008

Intro to ABAP
ECC 6.0

IBM Global Services - SAP Development ABAP Training


Authorizations, Passing Data Between Programs, Catching Runtime Errors

Intro to ABAP
ECC 6.0

SELECT statements do not automatically perform authority checks. Therefore, the risk of users
accessing and/or modifying data to which they are not authorised are high.
An Authority Object is generally created by a security or system administrator based on the
sensitivity of certain fields.
For example the object F_KNA1_BUK is linked to company codes in the KNA1 table.
To restrict users from changing company code information outside their own company, a
security administrator will link the object F_KNA1_BUK to a users profile and assign the
relevant company codes.
It is possible to further restrict the user to only certain activities.
For example, if the user was only authorised to modify company information, but not delete,
the activity would be set to modify.
The authority object is checked in the ABAP program to ensure that the user has the appropriate
level of authority.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Authorizations, Passing Data Between Programs, Catching Runtime Errors

Intro to ABAP
ECC 6.0

Authority objects consist of fields and values.


Fields represent particular object or action types in the SAP system.
The values represent which individual objects or actions a user may access.
For example, the authority object S_DEVELOP contains authorisations regarding development
objects in the system. The first field in this object is DEVCLASS, and it contains information
regarding which Packages a particular user may access. Another field is ACTVT, which lists
particular activities a user is authorised to (such as display, change, or delete).
The AUTHORITY-CHECK statement sets SY-SUBRC based on whether the current logon user has
authorisation for the fields and values specified in the statement. SY-SUBRC is zero when the user
has the appropriate authorisation, and non-zero otherwise.
It is necessary to list all fields in the authority object in the AUTHORITY-CHECK statement.
However, if you are not interested in a particular field, the DUMMY option suppresses the check for
that field. In the example on the above slide, the user will pass the authorisation check if they have
any authorisation to Package YLJS, regardless of the values in the other fields.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Authorizations, Passing Data Between Programs, Catching Runtime Errors

Intro to ABAP
ECC 6.0

The SAP run-time environment does not automatically perform authority checks. You must code
these explicitly into each application program where they are needed.
Additionally, the AUTHORITY-CHECK statement does not automatically terminate a program if a
user fails an authority check. The statement does nothing beyond setting SY-SUBRC. You, as the
programmer, must then take appropriate action in order to prevent users from performing
unauthorised activities.
For a list of all authority objects, use the Repository Information System. You can also access
authority objects via the menu path:
TOOLS ABAP WORKBENCH DEVELOPMENT OTHER TOOLS
AUTHORIZATION OBJECTS OBJECTS.
OR Transaction SU21

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Authorizations, Passing Data Between Programs, Catching Runtime Errors

Intro to ABAP
ECC 6.0

You can pass data between different ABAP programs using the EXPORT and IMPORT statements.
The EXPORT statement moves data from your program into a ABAP memory area. The most basic
form of the EXPORT statement is:
EXPORT <variable> TO MEMORY.
This places the specified variable into a ABAP memory area that another program can later read
using the IMPORT statement.
You may specify multiple fields in the same EXPORT statement. For example:
EXPORT KNA1-KUNNR KNA1-BUKRS TO MEMORY.
You can give variables a different name in the ABAP memory area using the FROM clause. For
example, the following code exports SY-SUBRC and gives it the name RETVAL in the ABAP
memory area:
EXPORT RETVAL FROM SY-SUBRC TO MEMORY.
You can specify a cluster ID when exporting data to memory. You can freely choose the name of
the cluster ID, which can be up to 32 characters long. Each cluster ID specifies a particular area in
memory. Each time you EXPORT data to the same cluster ID, all data previously written to that ID
is erased. For example:
EXPORT SY-SUBRC TO MEMORY ID LJS1.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Authorizations, Passing Data Between Programs, Catching Runtime Errors

Intro to ABAP
ECC 6.0

To retrieve data from the ABAP memory area, use the IMPORT statement. The most basic form of
the IMPORT statement is:
IMPORT <variable> FROM MEMORY.
To give the variable a different name in your program from what it is called in the ABAP memory
area, use the TO clause. You must define the local variable name with a DATA statement in your
program.
The format is:
IMPORT <global var> TO <program var> FROM MEMORY.
As with the EXPORT statement, you can specify multiple variables per statement, and you have the
option of specifying which cluster ID you wish to import from.
After each IMPORT statement, SY-SUBRC is set to indicate whether or not the cluster ID you
specified exists (but not whether specific variables were imported specifically). SY-SUBRC is zero
if the cluster exists.
It is also possible to IMPORT and EXPORT to database tables .
ABAP memory that is used to store exported data is user and transaction specific, so when passing
data between programs in this manner you must make sure that transaction boundaries are not
crossed. Otherwise the contents of this memory will get destroyed and will not be available to the
importing program.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Authorizations, Passing Data Between Programs, Catching Runtime Errors

ECC 6.0

The CATCH ... ENDCATCH block allows a programmer to catch ABAP runtime errors and assign
these to a SY-SUBRC value so an error can be reported in a controlled manner (rather than with a
short dump). ABAP runtime errors include things like division by zero, converting a character to an
integer, etc.
Catchable ABAP runtime errors can be seen in the online help, under Alphabetical list of Catchable
Runtime Errors. Currently they are divided into two Error Classes Arithmetic Errors and
Conversion Errors. The catchable runtime errors in each class can be seen in the online help under
Assignment of Catchable Runtime Errors to ERROR classes.
To code the first part of a CATCH . ENDCATCH block, you must code:
CATCH SYSTEM-EXCEPTIONS and then specify either:
the Error Class (e.g. ARITHMETIC_ERRORS, or CONVERSION_ERRORS);
the specific Error Id (each id is assigned to each individual catchable error, e.g.
COMPUTE_INT_ZERO_DIVIDE), or ;
OTHERS which traps all catchable runtime errors.
This is then followed by the return code to which this error will be assigned, e.g.
CATCH SYSTEM-EXCEPTIONS ARITHMETIC_ERRORS = 5
CONVERSION_ERRORS = 6.
The CATCH statement can be followed by as many Error Classes or Error Ids as required - if there
is more than one exception in the runtime error, the value in SY-SUBRC will be for the first
exception reached.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Authorizations, Passing Data Between Programs, Catching Runtime Errors

ECC 6.0

Two other pieces of code are required to catch the runtime error: 1. a keyword that will trigger the
error, e.g. MOVE, ADD etc; 2. ENDCATCH.
Each Error Class has specific keywords that will trigger an error, and these can been seen in Online
help in the specific keyword documentation or in the Assignment of keywords to Error Classes
(some keywords may be found in both the ARITHMETIC_ERRROS and CONVERSION_ERRORS
error classes).
The ENDCATCH must be followed by error processing to catch the value of SY-SUBRC and give
the user an error message e.g.:
DATA: int type I, char(3) type C value ABC. [..]
CATCH SYSTEM-EXCEPTIONS CONVERSION_ERRORS = 1. [..]
MOVE char TO int.

MOVE keyword to trigger CATCH

[..]

ENDCATCH.
IF SY-SUBRC = 1.
WRITE: / Conversion error has occurred.
ENDIF.
Note: If no CATCH block was used here, the program would terminate with a short dump, and the
ABAP Runtime Error CONVT_NO_NUMBER, the Error id for a Conversion Conflict, would be
listed.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Authorizations, Passing Data Between Programs, Catching Runtime Errors

IBM Global Services

Dec-2008

Intro to ABAP
ECC 6.0

IBM Global Services - SAP Development ABAP Training


Authorizations, Passing Data Between Programs, Catching Runtime Errors

IBM Global Services

Dec-2008

Intro to ABAP
ECC 6.0

IBM Global Services - SAP Development ABAP Training


Authorizations, Passing Data Between Programs, Catching Runtime Errors

Intro to ABAP
ECC 6.0

Hints:
Activity type Possible Values:
01: Create (valid for all object types)
02: Change (valid for all object types)
03: Display (valid for all object types)
06: Delete (valid for all object types)
07: Activate (only effective with ABAP Dictionary object types)
16: Execute (valid for eCATT test configurations)
40: Create object in database (object types TABL, SQLT, VIEW, MCOB, MCID, and INDX)
41: Delete object in database (object types TABL, SQLT, VIEW, MCOB, MCID, and INDX)
42: Convert object in database (object types TABL, SQLT, VIEW,MCOB, MCID, and INDX)
70: Manage test runs (only in CATT, not in eCATT)
MA: Switch off Modification Assistant for each transport object
L0: SAP-internal: Change main packages (object type DEVC)

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

As noted in the previous chapter, programs that use a logical database program automatically gain
a selection screen where the user can enter report selection criteria.
You can extend the functionality of a selection screen that comes with a logical database program,
and you can also create your own selection screens for programs that dont use a logical database.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

The SELECT-OPTIONS statement creates selection criteria for a particular database field. The
existence of the statement in your code causes the selection screen to display at the beginning of
report execution, and it creates a line on the selection screen where the user can enter selection
criteria for that field.
The SELECT-OPTIONS statement also creates a selection table with the same name given in the
SELECTION-OPTIONS statement. A selection table is an internal table that holds the selection
criteria for that field.
The syntax for the SELECT-OPTIONS statement is:
SELECT-OPTIONS <selection name> FOR <field name>
[DEFAULT <value> [TO <value>]].
The selection name can have a maximum of eight characters.
The optional DEFAULT clause allows you to set default selection criteria.
SELECT-OPTIONS can be used in report programs even if a logical database program is not
being used.

Coding Recommendations:
Coding standards suggest declarations of SELECT-OPTIONS internal tables should use the
prefix S_ and RANGES internal tables should use the prefix R_.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

Selection criteria for each item on a selection screen are stored in a selection table. Selection
tables are system-generated internal tables that have the following standard field format:
SIGN: This field indicates whether the current row of the table is inclusive or exclusive. Each
row of the internal table represents a particular condition (i.e.., between 1 and 5). The overall
condition specified by the selection table is the union of lines marked with sign I (inclusive),
less the union of lines marked with sign E (exclusive).
OPTION: This field holds the relational operator for the current row of the selection table
(i.e.., EQ for =)
LOW: This field holds the low value for range comparisons. If the comparison is against a
single value, this field contains that value.
HIGH: This field holds the high value for range comparisons. If the comparison is against a
single value, this field is left blank.

For example, the result set of the following selection table is 1, 3, 4, 5, 6:


I

BT 3

EQ 1

GE 7

IBM Global Services

10

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

The selection screen automatically displays one line for each selection condition created with the
SELECT-OPTIONS statement. In order to access additional lines for that selection table, click on
the arrow to the right of the selection condition.
By default, all lines in the selection table are given sign I. In order to create lines with sign E, first
click on the Complex Selections pushbutton, and then scroll down to the appropriate section.
To restrict the selection table to one line, the NO-EXTENSION option of the SELECT-OPTIONS
statement is used. When the NO-EXTENSION option is used, the user will not see the arrows
pointing to the right at the far right.
If the programmer wants to limit the selection to a single value, the NO INTERVALS is used. When
this option is utilized there will be no FROM TO choices. The NO INTERVALS option may be
used in conjunction with the NO-EXTENSION option.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

When you create a selection condition using SELECT-OPTIONS, the name of the selection
condition (8-character maximum) is used as the label for that line on the screen.
Since selection condition names are designed for internal program use, they are usually not very
user friendly. Using the Goto Text Elements menu in the ABAP Editor, you can create selection
texts that will be displayed to the user instead of the selection condition name.
Selection texts are language-dependent. In other words, they can be maintained in several
languages, and if they are maintained for the current users logon language, they will automatically
be displayed for that language.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Selection Screens and User Messages

ECC 6.0

We learned previously that the CHECK statement can be used to test any
logical expression. Additionally, the CHECK statement can be used with selection conditions.
When used with selection conditions, the CHECK statement evaluates to true if the field attached to
the selection condition meets the selection criteria. Otherwise, the CHECK statement evaluates to
false.
If the CHECK statement succeeds (i.e., evaluates to true), processing continues.
As before, if the CHECK fails, the result is dependent on its context:
Inside a loop, control immediately returns to the top of the loop for the next loop pass.
Inside a subroutine but outside a loop, the subroutine terminates.
Outside a loop and outside a subroutine, the current processing event terminates.
The code on the above slide will write only the integers from 1 upto 10 that the user specified on the
selection screen.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

The REJECT statement unconditionally terminates the current event processing block. It is
normally used with a logical database program. REJECT skips any remaining processing for the
current record (and any associated records at lower database levels). Processing resumes with the
next record at the same database level.
You may specify a table name inside single quotes with the REJECT statement. In this case,
processing skips ahead to the GET LATE event for the table specified in the REJECT statement. If
that table has no GET LATE event, then processing continues with the GET event for the next
record from that table.
The code on the above slide prints only the first three invoices for each customer, with each
customer being separated by an underline.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

The PARAMETERS statement creates a single entry field on the selection screen. It also creates a
variable in your program with the same name. The value placed into the field at run-time by the
user is also placed into the variable.
As with the PARAMETERS statement, you can create user-friendly selection texts by using the
GotoText Elements menu path.
The PARAMETERS statement also has the following options:
DEFAULT: Provides a default value for the parameter.
LOWER CASE: Preserves the case of the value the user enters. Without this clause, all
parameters are converted to upper case.
OBLIGATORY: Prevents the user from leaving the field blank.
For example, the following statement asks the user to provide a file name. Since file names in
some operating systems are case-sensitive, the LOWER CASE clause is used. Additionally, a
default value is suggested, and the field is made mandatory:
PARAMETERS: FNAME(50) TYPE C DEFAULT /tmp/abap/myfile LOWER CASE OBLIGATORY.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

PARAMETERS can be made to appear on the selection screen as checkboxes or as radio buttons.
To create a parameter as a checkbox, use the AS CHECKBOX clause.
The parameter will automatically be defined as type C and length 1.
The field will contain a capital X if the user checks the box, and it will contain a space otherwise.
Note:If a parameter is declared LIKE an ABAP Dictionary field that is of type CHAR and length 1,
and if that field further has a domain that restricts
values to space and X, that parameter will automatically appear as a
checkbox on the screen.
The above slide shows code that uses a checkbox on the selection screen to turn detailed invoice
information for each customer on or off.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

To create parameters as radio buttons, use the RADIOBUTTON GROUP clause. The parameter
will automatically be defined as type C and length 1. The field will contain a capital X if the user
selects the radio button, and it will contain a space otherwise.
Radio buttons are used to select a single value from multiple possible options. You must have at
least two radio buttons per group, and radio buttons in the same group are mutually exclusive.
Therefore, only one radio button per group may be given a default of X.
It is good practice to enclose radio buttons belonging to the same group inside a frame. To do this,
use the BEGIN OF BLOCK WITH FRAME and the END OF BLOCK options of the SELECTIONSCREEN statement. Up to five blocks can be nested.
Frames can (and should) also also be given titles. This is done with the TITLE clause of the BEGIN
OF BLOCK WITH FRAME option. The title can be either a text element or can be an eightcharacter variable name which is set during the INITIALIZATION event. In this case, the title
variable is not declared with the DATA statement. The title cannot be a literal.
The above slide provides an example. (Note: The example is for illustration purposes. It could
have used two checkboxes instead of three radiobuttons, since checkboxes are not mutually
exclusive.)

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Selection Screens and User Messages

ECC 6.0

In the 4.0 version matchcodes are replaced by search helps, which can have names longer
than 4 characters which was the maximum for matchcodes. The matchcode command is still valid
for attaching search helps to parameters. It will however only recognize the first four characters of
the search help name.
To attach a Search Help to a parameter field, use the MATCHCODE OBJECT clause.
When the user hits F4, the specified Search Help will be called.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

The programmer has a great deal of control over how the selection screen is presented. Using the
options of the SELECTION-SCREEN statement the programmer can change the look and feel of
the selection screen.
SELECTION-SCREEN SKIP <n> - This option will generate <n> blank lines on the screen.
SELECTION-SCREEN ULINE - This option places an underline on the screen at a location and
length specified by the programmer.
SELECTION-SCREEN COMMENT - Will place a user defined comment on the screen at a location
specified by the programmer. The comment text may also be a variable.
SELECTION-SCREEN BEGIN/END OF LINE - This option places multiple fields immediately
adjacent to one another. The fields to be positioned must be listed between the BEGIN OF LINE
and END OF LINE parameters.
SELECTION-SCREEN POSITION - This is the position of the next comment or parameter on the
screen. For <pos> the programmer can use a number, POS_HIGH, or POS_LOW. POS_HIGH and
POS_LOW are the locations of the From and To values on the screen.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

It is possible to define further selection screens in any program (apart for type S - subroutine pool).
The same statements SELECT-OPTIONS, PARAMETERS, SELECTION-SCREEN, can be used,
but must be enclosed within:
SELECTION-SCREEN BEGIN OF SCREEN <nnnn>and
SELECTION-SCREEN END OF SCREEN <nnnn> statements, where <nnnn>can be any
four digits apart from 1000, which is reserved for the standard selection screen.
To call the screen, code CALL SELECTION-SCREEN <nnnn>.Eg.
SELECTION-SCREEN BEGIN OF SCREEN 1200.
SELECT-OPTIONS S_CUST FOR KUNNR.
SELECTION-SCREEN END OF SCREEN 1200. [.]
CALL SELECTION-SCREEN 1200.
SELECT * FROM KNA1 INTO TABLE IT_KNA1
WHERE KUNNR IN S_CUST.
NB This is particularly useful in Interactive reporting, where you may wish to introduce new user
selections at the beginning of a new event (see later section on interactive reporting)

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

The SELECTION-SCREEN FUNCTION KEY statement allows you to place pushbuttons on the
application toolbar of the selection screen. The syntax is: SELECTION-SCREEN FUNCTION KEY
<n>
The value <n> must be numbered one through five. It is not possible to create more than five
pushbuttons using this method.
A special structure, SSCRFIELDS, is associated with these pushbuttons. During the
INITIALIZATION event, you assign values for the text of each pushbutton using fields from
SSCRFIELDS. You must declare SSCRFIELDS using the TABLES statement. A more detailed
description of the fields in this structure appears on the next page.
When the user clicks on one of the pushbuttons, FC0<n> is placed into the SSCRFIELDS-UCOMM
field and the AT SELECTION-SCREEN event is triggered.
The easiest way to think of the process is that FUNCTION-KEY 1 corresponds to function code
FC01, and the text for the pushbutton is contained in SSCRFIELDS-FUNCTXT_01.
If a program contains an INITIALIZATION event, this event will always be processed before
anything else (even before the selection screen is displayed).

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

The SSCRFIELDS (Screen Fields) table is used by the selection screen to store data that can be
passed to the program for further processing.
This data might include:
Function codes
Which can trigger processing in the program
Text
Which will appear on the screen
The SSCRFIELDS-UCOMM field holds a user defined function code which is normally associated
with a pushbutton. When the user clicks the button, the program receives the function code and
initiates some sort of processing.
The SSCRFIELDS-FROM_TEXT/TO_TEXT is the text associated with the From and To range.
The SSCRFIELDS-FUNCTXT_01-05 fields hold the text that appears on the pushbuttons on the
application toolbar.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

To create a pushbutton that is actually on the selection screen (beneath the application toolbar), use
the SELECTION-SCREEN PUSHBUTTON statement. The syntax is:
SELECTION-SCREEN PUSHBUTTON /pos(len) <button name> USER-COMMAND <function
code>.
The position and length of the pushbuttons are specified just like the position and length of
text written with the WRITE statement.
The structure SSCRFIELDS is not used to specify text for buttons that appear on the body of
the selection screen. The button text is defined in the INITIALIZATION event by assigning a
value to the button name (this value becomes the text on the button).
You must assign a function code to each button using the USER-COMMAND
clause. When the button is clicked, the function code is placed into the SSCRFIELDSUCOMM field, and the AT SELECTION-SCREEN event is triggered.
Using this method, you are not limited to five bushbuttons
For example, to create a pushbutton name BUTTON 1 of length 15 starting in the third column of
an new line and with a function code of CLCK, you would code:
SELECTION-SCREEN PUSHBUTTON /3(15) BUTTON1
USER-COMMAND CLCK.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

User messages are an excellent method of communicating with the user in an interactive program.
This applies to selection screens as well as full-fledged interactive reports and online (module pool)
programs (covered in later sections).
For example, it is possible to check that a user has appropriate authorizations for particular data
before proceeding beyond the selection screen. Using a message to inform users of failed authority
checks is more elegant than writing a report that informs the user of the lack of authorization.
Normally, messages are displayed on the message line at the bottom of the screen. The only
exceptions are abend messages which terminate the program and information messages which are
displayed in a dialog box. The various types of messages will be covered in more detail shortly.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

By using error messages at the selection screen, you can prevent the user from entering invalid or
inappropriate data. Warning messages can be overridden, but error messages keep the user at the
selection screen until the inappropriate data is corrected.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

Intro to ABAP
ECC 6.0

User messages are stored in the system table T100. They are classified by language, a 20
character message class (used to group messages by application area), and a three-character
message number.
The system automatically manages the language classification (based on the current Logan
language), but you must manually maintain message classes and individual messages. Message
classes you create, like other non-SAP development objects, should begin with a Y or Z.
The easiest way to create a new message class is to double-click on the name of that message
class within ABAP program code.
When maintaining individual messages, it is possible to leave placeholders for variables with an
ampersand (&). At run-time, when the message is called, a variable must be passed for each
ampersand in the message, and the ampersand is replaced by the contents of the variable. Up to
four ampersands may be specified per message.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Selection Screens and User Messages

ECC 6.0

A single message class can be declared in the REPORT statement. When this is done, all
references to messages in that program will default to messages from the specified class. The
syntax is:
REPORT <report name> MESSAGE-ID <message class>.
When a message is displayed, the type of message must be specified. The five message types
are:
A:

Abend (the program terminates unconditionally)

E:

Error (the user is unable to leave the current screen)

I: Informational (for information only)


S:

Success/Confirmation (for information only; displayed on the follow-up screen)

W:

Warning (the user can change data or can override the message by hitting
enter)

X:
Program terminates and shot dump occurred that can be viewed from transaction
ST22
In the events START-OF-SELECTION, GET, and END-OF-SELECTION, error and warning
messages have the same effect as abend messages.
The syntax to display a message is MESSAGE <type><number> [WITH <up to four variables>].
For example:
MESSAGE E001 WITH TEXT-001.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Selection Screens and User Messages

ECC 6.0

To add user messages, decide on a message ID. Remember it must start with a Y or a Z. Once
coded, simply double click on the message ID to transfer to the Maintain Message Class screen.
On the Maintain Message Class screen, enter the required data about the message ID.
To add individual messages, from the Maintain Message Class screen simply click on the
MESSAGE push-button and enter the text for each message.
Message can be maintained via transaction SE91.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Selection Screens and User Messages

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

Intro to ABAP
ECC 6.0

Online debugging is a valuable tool for diagnosing problems with program code. This tool allows
the user to watch the program execute and determine where the problem with a statement, variable
or table occurs.
The four most common methods to start the online debugging tool include:
From the Repository Browser by executing the program in debugging mode.
From within the ABAP Editor, by setting a breakpoint using using the red stop pushbutton.
From the program code type the ABAP statement BREAK-POINT.
On any selection screen, in the OKCODE field at the top of the screen, enter a /h to turn the
debugging mode on.
Upon entering the debugger, the field screen is displayed. The source code of the program to be
debugged appears in the screens top portion. The line currently ready for processing is indicated
by a > to the left of the line of code.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

Intro to ABAP
ECC 6.0

From within the debugger, the user has several options to step through the program. The user can
choose any of the following pushbuttons:

Single Step: Executes the report line by line. This is useful if the user wants to see the
program execute one line at a time.

Execute: Processes all of the steps associated with one line of code. For example, one
line of code may be a call to a subroutine. Execute will process that line without showing all
of the activities inside the subroutine.

Continue: Processes all statements until a breakpoint or the end of the program is
reached. If no breakpoints exist, the system will execute the report in its entirety without
stopping.

Return: Returns the user to where the calling program resumes control after a called
routine/function module.

Use the arrow buttons, or type in the line number required to move in the code display (page icons
and page up and down keys can also be used)
To display the current statement (i.e. next statement to be executed) click the pushbutton next to
the line number

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

Intro to ABAP
ECC 6.0

Navigation buttons allow the user to change the display, emphasizing important factors. There are
seven views the user can choose from:
Fields: Displays the contents of the fields. This is the default view of the debugging tool.
Table: Displays the contents of an internal table. Use this view to modify entries in the
internal table.
Breakpoints: A scrolling display of up to 30 dynamic breakpoints (i.e. not hard-coded) that
have been set for the current program.
Watch points: Displays the watch points that have been set, which interrupt a program
when the contents of a particular field have changed.
Call/Call Stack: Displays an active event chain. The most recent active call appears at the
top of the list, and the previous calls appear below.
Overview: Displays the structure of the line being debugged. This view shows the events,
subroutines, and modules contained within a program and indicates which section is currently
being processed.
Settings: Shows the current settings of the debugger. You can use this view to change
these settings.
The following Display Modes can be selected via the Goto menu:
Single Field; Structured Field; Objects; Active Programs, and others

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

Intro to ABAP
ECC 6.0

To display field contents, use the default field view.


The contents of up to eight fields or field strings can be displayed. Type the field names directly in
the spaces provided, or select the appropriate field in the code display by double-clicking (when all
eight fields have been filled, the last currently visible field will be replaced by the new field selected)
The field screen can be used to display the contents of:
System fields (SY-INDEX, SY-UCOMM, etc). (The system fields SY-SUBRC, SY-TABIX and
SY-DBCNT are always displayed in this screen.)
Fields referenced in the program either globally or locally
Fields defined in the ABAP Dictionary (These fields must be referenced in the TABLES
statement of the program)
Fields from external programs
To display the contents of fields from an external program, the user must know the
name of the external program. Place the name of the external program in brackets in
front of the field name.
Field contents can be displayed in both edited and hexadecimal format.
To switch to the hexadecimal display, choose the small button directly following the value
field.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

Intro to ABAP
ECC 6.0

The contents of an internal table can be displayed using the Table function, which is reached using
the Table pushbutton.
To select a table for viewing, specify the table name in the appropriate field of the table display
screen, or double-click on the table. If the cursor is placed on an internal table name when this
screen is selected, the table is defaulted into the Tables screen.
If the internal table has a header line, this line appears before the actual table contents and is
marked in the display by
.
The table content lines are numbered.
The user can scroll through the table display using the Index field or the page up and down keys (in
this screen these keys do not scroll the code).
The type of internal table (standard, sorted or hashed) is listed next to the internal tables name.
As with the field display, the user can customise the display format for internal tables to display
either as formatted columns (E), character strings (C) or hexadecimals (X) by using the Format
field.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Online Debugging

ECC 6.0

The debugging tool allows the user to change the content of a specific field to influence the
programs flow (i.e., setting SY-SUBRC to a value other than zero to check error logic).

The user can alter the values of all fields, database tables, and internal tables referenced in a
report/program.

To replace a value, follow these steps:

1.

Go to the variable display screen. This is the debuggers default screen.

2.

Enter the new value in the second column of the variable display next to the appropriate
field.

3.

Choose the change button, the second small button to the right of the column

ABAP will write the new value back to the report field (or fields) and the system will record the
change in the system log. The system log tracks all updates done by every user in the debugger.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

Intro to ABAP
ECC 6.0

The debugging tool allows the user to manipulate the contents of an internal table at runtime.
Using the debugger, the user can:
Delete a row from an internal table.
Edit a row of an internal table. Editing a row is done using the functions Change, Insert and,
Append.
Add a new row to the internal table with the functions Append or Insert.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Online Debugging

ECC 6.0

The debugging tool allows the user to delete the contents of an internal table at runtime.

To delete a row from an internal table follow these steps:


1. Go to the table display screen.
2. Enter the table name in the appropriate field.
3. Click Enter on the keyboard.The system will display the tables contents.
4. Place the cursor on the line you wish to remove form the table.
5. Choose Delete.The line disappears from the table and the line numbering is automatically
adjusted.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Online Debugging

ECC 6.0

The debugging tool allows the user to edit the contents of an internal table at runtime.
To edit a field, the user must first decide which field to change and then:
Place the cursor on the row and field you want to edit.
Choose Change. The system will display the field of the chosen row in edit mode.
Enter a new value for the field.
Click Enter on the keyboard.The system updates the line and displays the new contents in
the table.
Note: You must make a change to the field and hit enter to leave change mode. If you do not
wish to make a change, re-type the current value.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

Intro to ABAP
ECC 6.0

To add a new row to an internal table use the Insert or Append functions.
Append places the new line at the end of the internal table.
Insert allows the user to position the line anywhere in the internal table.
To add a new row to the end of an internal table do the following:
Choose Append.
Enter a value for the first field in the line.
Hit Enter on the keyboard. The system will add a line to the internal table and fill in the first
field.
To Insert a new line in an internal table, position the cursor on the line following the line where the
inserted row is to appear. Then select the Insert button and proceed as you want to Append a line.
NOTE: The functions Change, Insert and, Append are field-specific in the debugger and can be
used for only one field at a time.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

Intro to ABAP
ECC 6.0

There are two debugging strategies from within the ABAP Workbench. The user can set
breakpoints in a program and then execute the program within the debugging tool or the user can
run a program in the debugger without breakpoints.
Setting breakpoints is a good strategy for examining the program:
After the system has processed certain events
Immediately before a specific event is carried out
By skipping specific routines or calls
Execution of a program in the debugger without breakpoints allows:
Examination of a program from the first line of code
Examination of a transaction from the first Process Before Output (PBO) module call
Examination of a program with which programmer is not familiar

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Online Debugging

ECC 6.0

A breakpoint is a signal within a programs code that tells the ABAP processor to interrupt the
program where the breakpoint is set.
Four different types of breakpoints can be set in ABAP:
Static Breakpoints: Breakpoints that are written directly into the programs code.
Dynamic Breakpoints: Breakpoints that are set from within the ABAP editor or the
debugger. Dynamic breakpoints are invisible in the ABAP editor.
Watchpoints: Watchpoints are set within the debugger and are field specific. A watchpoint
becomes a breakpoint when the contents of a field change.
Breakpoints at key words: Breakpoints set in the debugger that are key word or event
specific. The breakpoint becomes active when the ABAP runtime processor comes across
the specified keyword or event in the programs code.
For more information on the specifics of these breakpoint types consult the online help.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Online Debugging

ECC 6.0

Static breakpoints are generally user-independent. Once they are set, they are activated whenever
the program is executed.
To set a static breakpoint, enter the ABAP Editor and write the key word BREAK-POINT directly in
the program code.
Place the breakpoint on the line where you want the program to be interrupted.
When the report is executed, ABAP interrupts the processing at the breakpoint.
Static Breakpoints can be numbered (BREAK-POINT 1, BREAK-POINT 2, etc.) for easy
identification.
Static breakpoints are user specific. Use the key word BREAK followed by the user name (i.e.,
BREAK JWARREN).
The breakpoint is visible to other users if they display the programs code in the Editor but will
remain inactive when any other user activates the program.
Note: Because most static breakpoints are activated whenever the program is executed, it is
essential to remove all static breakpoints once the debugging of a program is completed.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

Intro to ABAP
ECC 6.0

Dynamic breakpoints are user-specific. To interrupt a program when it is executed, but not when
others are running it, set dynamic breakpoints.
In the ABAP Editor the user can set breakpoints in change or display mode by:
Place the cursor on the line where the breakpoint is to be positioned.
Choose <Utilities Breakpoint Set>or click on the red STOP
application toolbar.

button in the

In the debugger dynamic breakpoints can be set by:


Place the cursor on the line where the breakpoint is to be positioned.
Select the line either by choosing the <Breakpoint Create/delete> function or by doubleclicking.
Program breakpoints are indicated in the ABAP Debugger by a small stop sign in front of the
affected line.
They can be removed by clicking the STOP button again (permanent removal) in editor , or double
clicking on the line in the debugger (temporary removal).
The system allows a maximum of 30 breakpoints.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

Intro to ABAP
ECC 6.0

To obtain a display of all dynamic breakpoints use the menu path <Utilities Breakpoint
Display> in the ABAP Editor.
The dynamic breakpoint display allows the user to navigate to a certain breakpoint or delete one or
all the breakpoints from the program code.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Online Debugging

ECC 6.0

A program may be interrupted before a certain keyword, event, or subroutine is called.


This method enables the user to:
Tell the system to set a breakpoint at a specific keyword or event.
Tell the system to stop the processing whenever a return code in the
SY-SUBRC field is not equal to 0.
To set event or keyword-related breakpoints, do the following:
From the debugger, select either <Breakpoint Breakpoint at Statement >,
<Breakpoint at event/subroutine> or <Breakpoint at Function module >.
Within the screen displayed type the subroutine name, event or key word. The system will
set the breakpoint.
Select the OK button. Breakpoints are indicated by a small stop sign.
Note: To interrupt a program whenever the system return is not equal to 0, select <Breakpoint
Breakpoint at System exceptions >.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

Intro to ABAP
ECC 6.0

Watchpoints are set from the debugging tool.


Watchpoints are used to interrupt a program when there is a change in the contents of a particular
field or field string.
To set a watchpoint:
Click the Create Watchpoint button (either on the Application toolbar, on in the Watchpoint
screen by the existing watchpoints).
Select local (current program only - checkbox checked) or global (all called programs checkbox unchecked) watchpoint.
Enter field that will trigger watchpoint.
Watchpoint will now be activated every time the field changes. To specify a comparison with
another field, check comparison field checkbox, and enter field name. To specify comparison
value, uncheck comparison field checkbox and enter value.
The existing watchpoints are listed in the Watchpoint screen with the current field contents of the
last watchpoint reached displayed at the bottom.
Up to 5 watchpoints can be set at a time.
Watchpoints can be linked using the logical operators.
If no changes occur in the program after a watchpoint has been set, the program will execute
without interruption.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

Intro to ABAP
ECC 6.0

Deleting Static Breakpoints:


To deactivate a static breakpoint, remove it from the program in the ABAP Editor. Static
breakpoints cannot be removed or deactivated once the debugger has started.
Deleting Breakpoints at Keywords and Events:
Breakpoints at keywords or events can be deleted and deactivated in the same manner as
dynamic breakpoints.
Deleting Watchpoints:
Select the navigation button Watchpoints to enter the Watchpoints screen.
Click to delete button, the watchpoint will be deleted.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Online Debugging

ECC 6.0

Dynamic breakpoints can be deleted or temporarily deactivated during the debugging process.
To delete a dynamic breakpoint in the ABAP Debugger use the menu path
<Breakpoint Create/Delete>, or click on the red stop sign on the right of the line.
To delete all the dynamic breakpoints in a program use the menu path <Breakpoint Delete all>.
To temporarily deactivate a breakpoint, place the cursor on the appropriate line and select
<Breakpoint Deactivate/activate>.
Double clicking on the stop sign to the left of the code will also deactivate a breakpoint.
To execute a report without interruption, use the menu path <Breakpoint Deactivate all> when
processing in the debugger.
For an overview of all existing breakpoints, use the menu path <Goto Breakpoints>. With this
function the user can specify the number of passes that should occur before a breakpoint is
activated.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Online Debugging

ECC 6.0

Breakpoints are not necessary to debug a program. The program can also be executed in
debugging mode without them.
To debug a program without using breakpoints use one of the following three methods:
From the Repository Browser:
Start the report or transaction to be examined using the Test Icon.
In the subsequent screen specify that you want to run the program in the debugging
mode.
From the ABAP Editor:
Specify the name of the program you want to debug and choose the menu path
<Program Execute Debugging>.
From the ABAP Workbench toolset:
The system debugger must be activated. To activate this debugger, use menu path
<System Utilities Debugging system>.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Online Debugging

ECC 6.0

The user can switch from the debugging tool to the ABAP editor at any time.
This is useful if an error is discovered while debugging.
For example: The ABAP Editor can be entered immediately and the error can be corrected in the
programs code.
To return to the Editor for the program currently being debugged, use the menu path
<Development ABAP Editor>.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training

Intro to ABAP

Online Debugging

ECC 6.0

During debugging, the system normally suppresses the COMMIT which marks the end of a Logical
Unit of Work (LUW).
As a result, the system locks the appropriate database for the course of the debugging session.
If the user wants to temporarily halt debugging but does not want the debugging session to end, the
database in use should be released.
To release a database explicitly during a break in testing choose the menu path <Debugging
Database Commit>.
To undo all changes made in the database since the last COMMIT, select the menu path
<Debugging Database Rollback>.

IBM Global Services

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

IBM Global Services - SAP Development ABAP Training


Online Debugging

IBM Global Services

Intro to ABAP
ECC 6.0

Dec-2008

Day 7 to 9
Case study1 Data Dictionary
and classical report

ECC 6.0
Exercises: ABAP List Viewer

SAP Development ABAP Training

Chapter 1
Exercise 1.1
Create a program that uses REUSE_ALV_LIST_DISPLAY function module to show Airline and
Flight Schedule from SCARR (Airline) and SPFLI (Flight schedule).
1. Populate the Field Catalog before calling the AVL List display function module.
2. Display the following columns in the output.

Exercise 1.2
Create a program that uses REUSE_ALV_GRID_DISPLAY function module to show the content
of YCONCERT table.
Structure for YCONCERT table should be build with the following fields:
Carrid
carrname
connid
cityfrom
airfrom
cityto
airpto
arrtime
distance
distid
1. Modify the program so that the report displays a title Concert Information as report title.
2. Change the display position of CDATE as column 1 and ARTIST as column 2.
3. Do not show the column MAXSEATS in the output.
4. Optimize width of the output columns.

Dec-2008
Page 1

ECC 6.0
Exercises: ABAP List Viewer

SAP Development ABAP Training

Chapter 1
Exercise 1.1
Create a program that uses REUSE_ALV_LIST_DISPLAY function module to show Airline and
Flight Schedule from SCARR (Airline) and SPFLI (Flight schedule).
1. Populate the Field Catalog before calling the AVL List display function module.
2. Display the following columns in the output.

Solution: Follow the standard SAP program BALVSD03.


REPORT YALVXX01_1.
* Data declaration
TYPE-POOLS: slis.
* Global structure of list
TYPES:BEGIN OF ud_struct,
carrid TYPE S_CARR_ID,
carrname TYPE S_CARRNAME,
connid TYPE S_CONN_ID,
cityfrom TYPE S_FROM_CIT,
airfrom TYPE S_FROMAIRP,
cityto TYPE S_TO_CITY,
airpto TYPE S_TOAIRP,
arrtime TYPE S_ARR_TIME,
distance TYPE S_DISTANCE,
distid TYPE S_DISTID,
END OF ud_struct.
DATA:
DATA:
DATA:

gt_fieldcat TYPE slis_t_fieldcat_alv.


gt_outtab TYPE STANDARD TABLE OF ud_struct.
g_repid LIKE sy-repid.

* Initialization fieldcatalog
INITIALIZATION.
g_repid = sy-repid.
PERFORM fieldcat_init CHANGING gt_fieldcat[].
* Data selection
Dec-2008
Page 1

ECC 6.0
Exercises: ABAP List Viewer

SAP Development ABAP Training

START-OF-SELECTION.
PERFORM select_data CHANGING gt_outtab.
* Display list
END-OF-SELECTION.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'


EXPORTING
I_CALLBACK_PROGRAM
IT_FIELDCAT
TABLES
t_outtab

= g_repid
= gt_fieldcat[]
= gt_outtab.

*---------------------------------------------------------------------*
Forms
*---------------------------------------------------------------------* Initialization fieldcatalog
FORM fieldcat_init
CHANGING rt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
DATA: pos TYPE i VALUE 1.

CLEAR ls_fieldcat.
ls_fieldcat-col_pos
ls_fieldcat-fieldname
ls_fieldcat-key
APPEND ls_fieldcat TO

= pos.
= 'CARRID'.
= 'X'.
rt_fieldcat.

CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'CARRNAME'.
ls_fieldcat-ref_fieldname = 'CARRNAME'.
ls_fieldcat-ref_tabname
= 'SCARR'.
APPEND ls_fieldcat TO rt_fieldcat.
Dec-2008
Page 2

ECC 6.0
Exercises: ABAP List Viewer

SAP Development ABAP Training

CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'CONNID'.
ls_fieldcat-ref_fieldname = 'CONNID'.
ls_fieldcat-ref_tabname
= 'SPFLI'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'CITYFROM'.
ls_fieldcat-ref_fieldname = 'CITYFROM'.
ls_fieldcat-ref_tabname
= 'SPFLI'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'AIRPFROM'.
ls_fieldcat-ref_fieldname = 'AIRPFROM'.
ls_fieldcat-ref_tabname
= 'SPFLI'.
ls_fieldcat-no_out
= 'X'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'CITYTO'.
ls_fieldcat-ref_fieldname = 'CITYTO'.
ls_fieldcat-ref_tabname
= 'SPFLI'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'AIRPTO'.
ls_fieldcat-ref_fieldname = 'AIRPTO'.
ls_fieldcat-ref_tabname
= 'SPFLI'.
ls_fieldcat-no_out
= 'X'.
APPEND ls_fieldcat TO rt_fieldcat.

Dec-2008
Page 3

ECC 6.0
Exercises: ABAP List Viewer

SAP Development ABAP Training

CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'ARRTIME'.
ls_fieldcat-ref_fieldname = 'ARRTIME'.
ls_fieldcat-ref_tabname
= 'SPFLI'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'DISTANCE'.
ls_fieldcat-ref_fieldname = 'DISTANCE'.
ls_fieldcat-ref_tabname
= 'SPFLI'.
ls_fieldcat-no_out
= 'X'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'DISTID'.
ls_fieldcat-ref_fieldname = 'DISTID'.
ls_fieldcat-ref_tabname
= 'SPFLI'.
ls_fieldcat-no_out
= 'X'.
APPEND ls_fieldcat TO rt_fieldcat.
ENDFORM.
"fieldcat_init

* Data selection
FORM select_data
CHANGING rt_outtab LIKE gt_outtab[].
SELECT DISTINCT scarr~carrid scarr~carrname
spfli~connid spfli~cityfrom
spfli~airpfrom spfli~cityto
spfli~airpto
spfli~arrtime spfli~distance
spfli~distid
INTO CORRESPONDING FIELDS OF TABLE rt_outtab
FROM scarr INNER JOIN spfli
ON scarr~carrid = spfli~carrid
WHERE scarr~carrid BETWEEN 'AA' AND 'LH'.
ENDFORM.

" select_data

Dec-2008
Page 4

ECC 6.0
Exercises: ABAP List Viewer

SAP Development ABAP Training

The output should be displayed as follows:

Exercise 1.2
Create a program that uses REUSE_ALV_GRID_DISPLAY function module to show the content
of YCONCERT table.
1. Modify the program so that the report displays a title Concert Information as report title.
2. Change the display position of CDATE as column 1 and ARTIST as column 2.
3. Do not show the column MAXSEATS in the output.
4. Optimize width of the output columns.
Solution:
*&---------------------------------------------------------------------*
*& Report YALVXX01_2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT

YALVXX01_2.

* Data declaration
TYPE-POOLS: slis.
TYPES : BEGIN OF
artist
cdate
occupied
maxseats
location
price

t_outtab ,
TYPE char30,
" Artist Name
TYPE datum,
" Concert Date
TYPE numc2, " Occupied Seats
TYPE numc2, " Maximum Seats
TYPE char10, " Concert Location
TYPE zprice,
" Price of Concert Ticket
Dec-2008
Page 5

ECC 6.0
Exercises: ABAP List Viewer

SAP Development ABAP Training

END OF t_outtab.
TYPES : ty_outtab TYPE STANDARD TABLE OF t_outtab.
DATA:
gt_fieldcat TYPE slis_t_fieldcat_alv.
DATA:
gt_outtab TYPE STANDARD TABLE OF t_outtab.
DATA:
g_repid LIKE sy-repid.
DATA:
wa_layout TYPE slis_layout_alv, "ALV Layout
* Initialization fieldcatalog
initialization.
g_repid = sy-repid.
* Preapare the Field Catalog
PERFORM fieldcat_init CHANGING gt_fieldcat[].
* Customize the Layout
wa_layout-colwidth_optimize = 'X'.
* Data selection
START-OF-SELECTION.
PERFORM select_data CHANGING gt_outtab.
* Display Grid output
END-OF-SELECTION.

*
*
*
*
*
*
*
*
*
*
*
*

*
*
*

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
I_INTERFACE_CHECK
= '
I_BYPASSING_BUFFER
= '
I_BUFFER_ACTIVE
= '
i_callback_program
=
I_CALLBACK_PF_STATUS_SET
= '
I_CALLBACK_USER_COMMAND
= '
I_CALLBACK_TOP_OF_PAGE
= '
I_CALLBACK_HTML_TOP_OF_PAGE
= '
I_CALLBACK_HTML_END_OF_LIST
= '
I_STRUCTURE_NAME
=
I_BACKGROUND_ID
= '
I_GRID_TITLE
=
I_GRID_SETTINGS
=
is_layout
=
it_fieldcat
=
IT_EXCLUDING
=
IT_SPECIAL_GROUPS
=
IT_SORT
=

'
'
'
g_repid
'
'
'
'
'
'

wa_layout
gt_fieldcat[]

Dec-2008
Page 6

ECC 6.0
Exercises: ABAP List Viewer

SAP Development ABAP Training

*
IT_FILTER
=
*
IS_SEL_HIDE
=
*
I_DEFAULT
= 'X'
*
I_SAVE
= ' '
*
IS_VARIANT
=
*
IT_EVENTS
=
*
IT_EVENT_EXIT
=
*
IS_PRINT
=
*
IS_REPREP_ID
=
*
I_SCREEN_START_COLUMN
= 0
*
I_SCREEN_START_LINE
= 0
*
I_SCREEN_END_COLUMN
= 0
*
I_SCREEN_END_LINE
= 0
*
I_HTML_HEIGHT_TOP
= 0
*
I_HTML_HEIGHT_END
= 0
*
IT_ALV_GRAPHICS
=
*
IT_HYPERLINK
=
*
IT_ADD_FIELDCAT
=
*
IT_EXCEPT_QINFO
=
*
IR_SALV_FULLSCREEN_ADAPTER
=
* IMPORTING
*
E_EXIT_CAUSED_BY_CALLER
=
*
ES_EXIT_CAUSED_BY_USER
=
TABLES
t_outtab
= gt_outtab
EXCEPTIONS
program_error
= 1
OTHERS
= 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*---------------------------------------------------------------------*
Forms
*---------------------------------------------------------------------* Initialization fieldcatalog
FORM fieldcat_init
USING rt_fieldcat TYPE slis_t_fieldcat_alv.

Dec-2008
Page 7

ECC 6.0
Exercises: ABAP List Viewer

SAP Development ABAP Training

DATA: ls_fieldcat TYPE slis_fieldcat_alv.

*
*
*
*

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'


EXPORTING
i_program_name
= g_repid
i_internal_tabname
= 'GT_OUTTAB'
i_structure_name
= 'YCONCERT'
I_CLIENT_NEVER_DISPLAY
= 'X'
I_INCLNAME
= G_REPID
I_BYPASSING_BUFFER
=
I_BUFFER_ACTIVE
=
CHANGING
ct_fieldcat
= rt_fieldcat
EXCEPTIONS
inconsistent_interface
= 1
program_error
= 2
OTHERS
= 3
.
IF sy-subrc = 0.

* Set CDATE at Column 1


ls_fieldcat-col_pos = 1.
MODIFY rt_fieldcat FROM ls_fieldcat TRANSPORTING col_pos
WHERE fieldname = 'CDATE'.
* Set ARTIST at Column 2
ls_fieldcat-col_pos = 2.
MODIFY rt_fieldcat FROM ls_fieldcat TRANSPORTING col_pos
WHERE fieldname = 'ARTIST'.
* Hide MAXSEATS in the
ls_fieldcat-no_out
MODIFY rt_fieldcat
WHERE fieldname =

Output
= 'X'.
FROM ls_fieldcat TRANSPORTING no_out
'MAXSEATS'.

ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.

"FIELDCAT_INIT

*&--------------------------------------------------------------------*
*&
Form SELECT_DATA
Dec-2008
Page 8

ECC 6.0
Exercises: ABAP List Viewer

SAP Development ABAP Training

*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
*
-->RT_OUTTAB text
*---------------------------------------------------------------------*
FORM select_data CHANGING rt_outtab TYPE ty_outtab.
SELECT artist
" Artist Name
cdate
" Concert Date
occupied " Occupied Seats
maxseats " Maximum Seats
location " Concert Location
price
" Price of Concert Ticket
FROM
yconcert " Concert Table
INTO TABLE gt_outtab.

ENDFORM.

"SELECT_DATA

The output should be displayed as follows:

Dec-2008
Page 9

ECC 6.0
Data Modeling & ABAP Dictionary
Study Questions and Answers

SAP Development ABAP Training

1. What represents the commercially oriented model of the real world?


SAPs Enterprise Data Model (EDM) represents the commercially oriented model of the real
world, while the ABAP Dictionary contains the data processing-oriented model. The EDM is the
top-level overview of the entire system. At this level the exact characteristics of the relationships
between entities are not important, merely knowing that the relationships exist is what matters.
2. What is an entity? How are entities represented in the ABAP Dictionary?
An entity is an object that is of interest and is uniquely identifiable. It is an object about which
information must be stored. Within the ABAP Dictionary, entities are stored as records in a table.
3. What is an entity type? How are entity-types represented in the ABAP Dictionary?
Entity types describe a set of entities with common attributes. Each entity type has a unique
name and unique description. For example, the set of all customers would be an entity type, while
each individual customer would be an entity in that type. Within the ABAP Dictionary, entity types
are stored as tables.
4. What is an attribute? How are attributes represented in the ABAP Dictionary?
Attributes describe an entitys (or entity types) features or characteristics. Within the ABAP
Dictionary, attributes are represented as fields in a table.
5. How are business-rules represented in a data model?
Business rules are represented in a data model by relationships between entity types. The
cardinality and category of those relationships help define those rules. Within the ABAP
Dictionary, these relationships are implemented as foreign key relationships.
6. Name and describe the 5 entity relationship categories.
A. Hierarchical: an entity type is dependent on the existence of exactly one other entity type. In
this case the primary key of the referenced entity type is inherited by the
Dependent entity type.
B. Aggregating/Associative: an entity type is dependent on the existence of multiple other entity
types. This type is used to resolve many-to-many relationships. The full primary keys of the
referenced entity types are inherited by the dependent entity type.
C. Referential: an entity type refers to another entity type but is not identified by the relationship.
It is possible to change or eliminate the relationship, but as long as the relationship exists, it is
non-optional. The primary key of the referenced entity type is passed onto the dependent entity
type as a non-key field.
D. Conditional-Referential: the same as a referential relationship, but the relationship is optional.
E. Specialization: an entity type that represents a subset of the referenced entity type but also has
additional attributes. In this case the referenced entity type is called the generalization, and the
dependent entity type is called the specialization. Generalizations and specializations have the
same primary key fields but are used to store different information in non-key fields.

Dec-2008
Page 1

ECC 6.0
Data Modeling & ABAP Dictionary
Study Questions and Answers

SAP Development ABAP Training

7. How is the SAP Enterprise Data Model linked to the ABAP Dictionary?
Via the SAP Data Modeler.
8. What within R/3 manages data definitions?
The ABAP Dictionary manages data definitions so that all data is described centrally and without
redundancy, thereby maintaining data integrity (all changes take immediate effect in all relevant
modules and need only be entered in one location).
9. What is the DB Utility? What is its transaction code?
The database utility is the interface between the data dictionary and the relational database that
underlies the SAP system. It is used to create underlying tables in the database that will be used
in SAP. The DB utility supports tables, table indexes, views, search helps, pools/clusters. Certain
overview functions are provided: background logs, background jobs, restart logs. The processing
options offered are online, background and generate program (where the program that is to
execute the selected function is generated without actually executing the function). The basic
functions of the DB utility are created, delete and convert, and delete, create again. There is a
lock mechanism associated with the DB utility in order to ensure that an existing operation may be
completed before another is triggered.
The transaction code for the DB utility is SE14.
10. Explain the concept of tables, domains and data elements.
A domain is used to group together fields of similar technical characteristics. Attributes such as
format (data type), length, and output characteristics are specified by the domain. A data element
must be associated with a domain, and it gives a meaningful description to a field in a particular
context. Tables consist of records (rows) and fields (columns). Each field in a table must be
assigned to a data element (which is in turn assigned to a domain).
11. At the domain level, what within R/3 prevents the user from entering invalid data?
1. Value table
2. Explicit values
12. Within the ABAP Dictionary, what ensures data integrity between tables?
Foreign key relationships.
13. Which attributes of the answer to #12 help further define relationships between tables?
Name and describe the two components of those attributes.
The semantic attributes of foreign key relationships help further define business rules and enforce
data integrity. Those two attributes are cardinality (how many of one item relate to how many of
another) and foreign key field type (similar to relationship categories in the Data Modeler).
14. What is the purpose of the ABAP Repository Information System?
The ABAP Repository Information System allows the retrieval of information about development

Dec-2008
Page 2

ECC 6.0
Data Modeling & ABAP Dictionary
Study Questions and Answers

SAP Development ABAP Training

objects.
15. What are the basic types of queries made to the Repository Information System?
-- Find
-- Where-Used
-- Modification analyses (i.e. all objects X modified by user Y)
16. What four basic types of objects can you search for using the R/3 Repository
Information System?
Modeling objects, programming objects, ABAP Dictionary objects, and environment objects.
17. What is a foreign key and how is it used?
A foreign key is a field that provides a link between two tables by including a reference in the first
table (dependent or foreign key table) to the primary key of the second table (check table).
The dependent (foreign key) table may use only those values contained in the check table. The
foreign key relationship is set up in the ABAP Dictionary at the field level. The foreign key field
and the check table field must have the same domain. An important function of foreign keys is to
support data integrity.
18. What is a search help? What are the two stages of creating a collective search help?
A search help is a tool to help find data records stored in the SAP system. It is used as online
help (F4) or as a search aid when an entry field calls for a key and only certain other (non-key)
fields of the object are known. (i.e. You want to research an employee and know his name but
cant remember his personnel number, so a F4 search on his name can help you find the
number).
First the elementary search helps are defined with the relevant table and fields specified. The
collective search help is then defined using multiple elementary search helps.
19. Tables defined in the ABAP Dictionary can be assigned to what 5 specific data classes
(via the technical settings screen)?
Master data, transaction data, organization and customizing data, system data, and user
(customer) data.
20. Name and describe the five table types. Which one is sometimes not considered
a true table type?
STRUCTURE (INTTAB):
Internal structure without mapping to an underlying database table.
Field strings used by ABAP as structures.
Can be used in multiple tables.
TRANSP:
SAP data dictionary table that is mapped 1:1 to the database.
Dec-2008
Page 3

ECC 6.0
Data Modeling & ABAP Dictionary
Study Questions and Answers

SAP Development ABAP Training

Designed to hold SAP data in a database.

POOL:
Logical pooled table used to store internal control data not relevant externally.
Mapped as many database tables to one SAP table.
CLUSTER:
Logical cluster table used to store continuous texts (documentation data).
VIEW:
A method of viewing database tables.
Can combine data from multiple tables into one view, and/or can restrict the view to
certain records or fields within a table.
Views are sometimes not considered true table types.
21. What are the four technical settings of a transparent table?

Data class: physical area in the database to which the table is assigned.
Size Category: space required for the table in the db (defines the size of the disk space
allocated for the table)
Buffering: whether and how to be buffered (suggested for tables not changed very often);
tables can have full or partial buffering.
Log data changes: (on or off) keeps track of the modifications to a table. If logging is on a
copy of data is saved from before changes as well as after.

22. After a table is created, can its technical settings be changed? If so, when?
Yes. It is now possible to change the technical settings of an active table and reactivate the table
at any time. This is a change from version 2.2 to version 3.0 of SAP.
23. What utility supports the creation of tables and secondary indexes?
The database utility. This utility is invoked automatically upon table activation or can be invoked
directly from the ABAP Dictionary maintenance screens.
24. What are the possible cardinalities of a foreign key?
The relationship is n:m where n refers to the relationship from the foreign key table to the check
table and can have values 1 or C (none or 1), and m refers to the relationship from the check
table to the foreign key table and can have values 1, C (none or 1), N (1 or many) or CN (none, 1
or many).
The possible cardinalities are 1:1, 1:C, 1:N, 1:CN, C:1, C:C, C:N, and C:CN. The most commonly
used cardinalities are 1:1, 1:C, 1:CN, and C:CN.
25. Names of data dictionary objects are limited to how many characters?
Restricted to 30. 30 characters are allowed for tables. Search Helps -- 30, logical databases--20,
program names -- 40, type groups -- 5.
26. What is the purpose of a type group?

Dec-2008
Page 4

ECC 6.0
Data Modeling & ABAP Dictionary
Study Questions and Answers

SAP Development ABAP Training

Type groups allow the user to define their own data types within the ABAP dictionary. These data
types are then available for use in any ABAP program.

Dec-2008
Page 5

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary


Naming Conventions

SAP has agreed to never create development objects whose names begin with a Y or a Z. SAP
customers (thats you!) must give all objects that they create names that do begin with a Y or a Z.
This prevents the possibility of naming conflicts during an upgrade from one release of SAP to
another.
Also, in the following exercises you will see suggested object names. Each suggested object
name will contain XX or ZZ. To ensure that objects you create have different names from objects
that your classmates create, replace the XX or ZZ that you will see in the suggested object names
with the last two digits of your SAP Logon ID.
[When you are in a situation, where a dictionary object of your selected name already exists in the
system, then ask the instructor if you can delete the existing one, otherwise ask him to suggest a
new name for yours.]
In short: Begin all object names with a Y or a Z, and replace the XX or ZZ with the last two digits
of your SAP logon ID.

Developer Access Keys vs. Object Access Keys


The first time you try to create an object in SAP, the system will respond with a dialog box that
says, You are not a registered developer. The dialog box will prompt you for a 20-digit
Developer Access Key. The request for a developer access key will only appear once. After you
enter the key correctly, you will not be prompted for it again.
However, if you try to change an SAP-delivered object (or if you forget to name your object
beginning with a Y or a Z), you will be prompted for an Object Access Key. This is because SAP
registers and controls all customer changes to SAP-delivered objects. If you see this dialog box
during this course, you have made a mistake; click the cancel button in the dialog box.
It is easy to confuse a request for a developer access key with a request for an object access key.
One way to remember the difference is to remember the phrase, You are not a registered
developer. If the request contains this phrase, it is asking for a developer access key. If it does
not contain this phrase, it is asking for an object access key.

Dec-2008
Page 1

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary


Chapter 2 Exercises

The exercises for this chapter will teach you how to create and manipulate the basic objects of the
ABAP Dictionary: tables, data elements, and domains. You will also enter data into one of your
tables, and you will learn how to write a simple program that extracts data from an ABAP
Dictionary table.
If you require assistance at any point, please ask an instructor. Try to do the solutions for the
exercises yourself and if you find any difficulty consult the hands on instructor. Also, solutions are
provided in this book, but only refer to them as a last resort.

Exercise 2.1 Create the YXXEMP table.


This table will store basic information for all employees. All employees will have one entry in this
table.
Step 1: From SAP Initial Screen -> Go to Tools -> ABAP Workbench -> Development -> ABAP
Dictionary (tcode: SE11) to go to the ABAP Dictionary Initial Screen.
Step 2: Choose Database table and type YXXEMP in the space provided (replacing XX with your
2-digit id). Then click the Create button.

Dec-2008
Page 2

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

Choose Database
Table and type
YXXEMP in the
space provided.
Then click the
Create button.

Note: The name of the table in the ABAP Dictionary does not have to be the same as the name
of the corresponding entity type in the data model. However, in many cases, for claritys sake, it
may be logical to make them the same. Here, we are naming them the same.
Step 3: The table definition screen appears. Begin by entering some of the tables general
attributes: short text, Delivery Class, and whether or not table maintenance is allowed. Enter C
for the Delivery Class, and click on the Tab.Maint.Allowed field.
Question 1: What is the primary function of the Delivery Class attribute? What does a value of
C in this field indicate?
Hint: Turning on the Tab.Maint.Allowed attribute permits the tables data to be edited by SE16,
SE11, ideally you should turn off Tab.Maint.Allowed and create a Table Maintenance Generator
for the table (See appendix to know about Table Maintenance Generator) to maintain entries
through SAP Table Maintenance Transactions such as SM30 and SM31.

Dec-2008
Page 3

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

1. Enter a short description for


the table.
2. Then, enter C the Delivery
Class.
3. Finally, select
Display/Maintenance Allowed

Dec-2008
Page 4

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

Step 4: Next, enter the name of the first field in the table. This will be the Employee ID Number.
Call this field EMP_ID. Since this field is part of the primary key of this table (in fact, it is the only
field in the primary key of this table), click on the Key attribute.

Enter the first field name (EMP_ID).


Then click on the Key attribute.

Hint: Depending on your monitor and depending on the font you have selected in SAP, you may
not see very many fields in the field definition area.
Hint: Notice that names of customer-created fields do not have to begin with a Y or a Z. Fields
only have meaning within the particular table for which they are defined, and they are not
individual objects within the ABAP Dictionary. Names of customer-created tables, data elements,
and domains, however, must begin with a Y or a Z. Tables, data elements, and domains exist as
individual objects within the ABAP Dictionary.
Step 5: Next, enter the data element for this field. In this case, use a new data element called
YXXEMP_ID. Once you have entered the data element name, double-click on the name of the
data element.

Enter the name of the data


element (YXXEMPID). Then
double-click on the name of
the data element

Step 6: Double-clicking on the name of the data element brings up the Create Data Element
dialog box. Click the green check mark to indicate that you wish to continue creating the data
element.
Step 7: Next, you see the data element definition tab. Enter a short text. This will appear beside
the name of the field on the table definition screen. Then, enter YXXEMPID as the domain name.

Dec-2008
Page 5

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

1. Enter a short
description.
2. Then, enter
YXXEMPID as the
domain name

Step 8: Next, enter the field labels in the Field label tab. These are the labels that will appear on
end-user screens when fields are painted onto those screens from the dictionary. Fill in short,
medium and long field labels. It is also advisable to fill in a header label (which is used if the
field is painted into something known as a table control).

Dec-2008
Page 6

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

Enter fields labels:


short, medium, and
long, and a header
label

Step 9: Next, double-click on the name of the domain that you entered in Step 7. Click the green
check mark in the Create Domain dialog box that appears.
Step 10: Enter a short text, and a data type and length for the domain. You may see the various
data types available by hitting F4 in the Data type field. For this domain, use type CHAR and
length 10.

Dec-2008
Page 7

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

Enter a short
text, data type,
and a field
length

Step 11: Now you are ready to activate your domain. Click the activation symbol on the
application toolbar. You will be prompted to enter a package and a change request. After the
domain is activated, you will see a message at the bottom of the screen, and the status of the
domain change to Active and Saved.

Dec-2008
Page 8

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

Click the activation


symbol

After entering a
Package & a
change request,
the status of the
domain will
change.

Hint: ABAP Dictionary Objects must be activated before they are visible to other objects in the
system. After you make changes to a dictionary object, you must re-activate it. A common
mistake is to revise an object and then forget to re-activate it.
Step 12: Next, click the green arrow to return to your data element. Now that the domain has
been activated, you may activate the data element. Click the activation symbol. Enter your
package & change request when prompted. You should see a message at the bottom of the
screen saying that the data element was activated, and the status will change to Active and
Saved.
Step 13: Click the green arrow to return to the table definition screen.
Hint: If you are unable to complete your work on a table in one sitting, save the table without
activating it (make sure you are on the table definition screen). To return to the table later, go to
your package. Drill down through Dictionary objects, and then Tables, until you see the name of
your table. Double-click on the table name. This will bring you back to the table definition screen.
Enter change mode by clicking the Display<->Change button on the toolbar. To add new fields to
the table, click the New rows button. You may need to reduce the size of your font in order for the
field display to work appropriately.

Dec-2008
Page 9

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

Display <-> Change


button

To add new fields to


the table click the New
rows button.

Dec-2008
Page 10

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

Step 14: Complete the definition for table YXXEMP by entering the following fields, data
elements, and domains. You will create your own data elements for each field. For some fields,
you will use pre-defined domains, and for other fields, you will create your own domains.

Field Name
LAST_NAME
FIRST_NAME
HLTH_PLAN

Data Element
YXXLNAME
YXXFNAME
YXXHLTHPLN

Domain
CHAR25
CHAR25
YXXHLTHPLN

Type
pre-defined
pre-defined
NUMC

Length
pre-defined
pre-defined
4

Note: The HLTH_PLAN field is to contain the ID of the health plan the employee has selected.
This field will eventually point to the YXXHEALTH table.
Note: In reality, this table would contain more fields than this. To save time, you are only creating
these three fields.
Step 15: Click the activation symbol. Enter your Package and Change request when prompted.

Dec-2008
Page 11

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

Step 16: The Maintain Technical Settings screen will appear. Enter USER as the data class
and 0 as the size category. Save the technical settings and click the green arrow. You will return
to the table definition screen, and the tables status will change to Active and Saved.
Second, click the save icon.
Then, click the green arrow.

First, enter the data


class and size category.

Question 2: What does the data class control? What does a value of USER indicate?
Question 3: What does the size category control? In this case, what does a value of 0
represent?
Step 17: From the table definition screen, click the green arrow to return to the ABAP Dictionary:
Initial Screen.
Dec-2008
Page 12

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary


Exercise 2.2 Create Additional Tables

Create the YXXHEALTH, YXXHOURLY, YXXSALARIED, and YXXPARTNER tables. Use the
following fields, data elements, and domains. The YXXHOURLY, YXXSALARIED, and
YXXPARTNER tables will each have one entry for every employee assigned to that particular type
of earnings. Each employee must belong to one and only one type of earnings table. The
YXXHEALTH table has one entry for each type of health plan to which the employees could
belong.
Important Note: As of SAP Release 4.6C, you may not have a table and a data element with
the same name.
YXXHEALTH
Field Name
PLAN_ID
DESCR
ANN_PREM

Ke
y
X

Data Element

Domain

Type

Length

YXXHLTHPLN
YXXDESCR
YXXANNPREM

YXXHLTHPLN
YXXDESCR
YXXANNPREM

NUMC
CHAR
DEC

4
80
6

PLAN_ID is the health plan ID.


DESCR is a description of the health plan.
ANN_PREM is the annual premium for belonging to this health plan.
YXXHOURLY
Field Name
EMP_ID
HOUR_RATE

Key
X

Data Element
YXXEMPID
YXXHOURRAT

Domain
YXXEMPID
YXXHOURRAT

Type
CHAR
NUMC

Length
10
4

Even though type CURR would be more appropriate for HOURLY_RAT, the system will not
administer a check on the fixed values that you will create in future exercises. You will
learn how to perform necessary checks programmatically in the next module.
EMP_ID is the employee ID.
HOUR_RATE is the hourly rate the employee is paid.
YXXSALARIED
Field Name
Ke
y
EMP_ID
X
SALARY

Data Element

Domain

Type

Length

YXXEMPID
YXXSALARY

YXXEMPID
YXXSALARY

CHAR
DEC

10
8

EMP_ID is the employee ID.


SALARY is the annual salary the employee is paid.
YXXPARTNER
Field Name
EMP_ID

Ke
y
X

Data Element

Domain

Type

Length

YXXEMPID

YXXEMPID

CHAR

10
Dec-2008

Page 13

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary


NUM_SHARES

YXXNUMSHAR

DEC7

pre-defined

pre-defined

EMP_ID is the employee ID.


NUM_SHARES is the number of shares the partner owns.

Exercise 2.3 Explicitly Limit Values for Domains


Valid values for domains can be restricted two ways: by explicitly listing (hard-coding) fixed
values in the domain itself, and by specifying a value table.
Hourly employees are always paid between $5.00 and $35.00 per hour. Explicitly list this
restriction in the domain for the hourly rate.
Step 1: From SAP Initial Screen -> Go to Tools -> ABAP Workbench -> Development -> ABAP
Dictionary (tcode: SE11) to go to the ABAP Dictionary Initial Screen.
Step 2: Choose Domain and type YXXHOURRAT in the space provided (replacing XX with your
2-digit id).
Step 3: Then click the Change button.
Step 4: Go to the Value range tab.
Step 5: Enter 5 as the lower limit and 35 as the upper limit. Enter a short text describing the limit.

Step 6: Click the Save icon to save your changes. Then click the green arrow to return to the
primary domain definition screen.
Step 7: Click the activation symbol to re-activate your domain.

Exercise 2.4 Limit a Domains Values by Using a Value Table


The only valid employee IDs are the ones contains in the YXXEMP table. Change the
YXXEMPID domain so that the value table is listed as YXXEMP.
Step 1: Proceed to the definition screen for domain YXXEMPID. Enter change mode.
Dec-2008
Page 14

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

Step 2: Enter YXXEMP as the value table in the space provided (about halfway down the
screen).

Step 3: Re-activate your domain.


Similarly, the only valid health plan IDs are those that are listed in the YXXHEALTH table.
Step 4: Modify domain YXXHLTHPLN so that the value table is YXXHEALTH. Re-activate the
domain when you are finished.

Chapter 3 Exercises
In the previous exercises, you established the basic objects to be used for a simplified payroll
processing system. In addition to establishing the tables, data elements, and domains, you also
established value tables for certain domains in order to ensure data integrity within the system.
Now you will take this a step further by establishing appropriate foreign keys in the ABAP
Dictionary.

Exercise 3.1 Establish a Foreign Key Relationship between the YXXEMP


and the YXXHOURLY Tables
Step 1: Proceed to the dictionary definition of the YXXHOURLY table. Enter change mode.
Step 2: Establish a foreign key relationship to the YXXEMP table on the EMP_ID field. Be sure
to specify the appropriate cardinality and foreign key field type
Step 3: When you are finished, re-activate the YXXHOURLY table.

Dec-2008
Page 15

ECC 6.0
Exercises: The ABAP Dictionary
SAP Development ABAP Training
Exercise 3.2 Establish Foreign Key Relationships from Tables
YXXSALARY, YXXPARTNER, and YXXEMP
Step 1: Establish the following foreign key relationships:
From:
Table
YXXSALARIED
YXXPARTNER
YXXEMP

Field
EMP_ID
EMP_ID
HLTH_PLAN

To:
Table
YXXEMP
YXXEMP
YXXHEALTH

Field
EMP_ID
EMP_ID
PLAN_ID

Chapter 4 Exercises
The purpose of these exercises is to give you familiarity with manipulating existing tables, their
structures, and their data.

Exercise 4.1 Use of the Table Copy Capability.


Often times you must create a table and there is already a similar table on the database. So why
reinvent the wheel? In the ABAP Workbench you can create a table then copy the elements of
another table into your new table. Additionally it is possible to copy complete tables and then add
fields.
Step 1: From SAP Initial Screen -> Go to Tools -> ABAP Workbench -> Development -> ABAP
Dictionary (tcode: SE11) to go to the ABAP Dictionary Initial Screen.
Step 2: Choose Database table and type YXXEMP in the space provided (replacing XX with your
2-digit id).
Step 3: Click the Copy icon
on the application toolbar. In the dialog box that appears, enter
YXXEMP_CP as the new table name. Then click the green check mark.
Step 4: Enter your package and change request when prompted.
Step 5: Go to SE11 again and open the newly created table YXXEMP_CP and activate it.

Question 1: To what package does the SAP standard table KUNNR belongs?

Dec-2008
Page 16

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary


Exercise 4.2 Creating Indexes

Step 1: In the employee table (YXXEMP), there is often a need to access records by employee
name. To improve the efficiency of this process, create a secondary index on the last name and
first name fields. (Create one index NAM that sort by last name, then by first name.)

Exercise 4.3 Adding Data to Your Table


From SAP Initial Screen go to Tools --> ABAP Workbench --> Overview --> Data Browser
(transaction SE16) to add records to your health plan and employee tables.
Step 1: Create two fictitious health plans. Give them IDs, names (descriptions), and annual
premiums.
Step 2: Create three fictitious employees. Make one a partner, one a salaried employee, and one
an hourly employee. Give each one of them, appropriate pay information. (You will need to access
four tables: YXXEMP, YXXPARTNER, YXXSALARIED, and YXXHOURLY.)
Note: It is also possible to add entries to a table by accessing the table through your package.
Go into the ABAP Dictionary: Change Table/Structure Fields screen and choose menu option
Utilities Table contents Create Entries.

Dec-2008
Page 17

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary


Chapter 5 Exercises

The exercises for this chapter will familiarize you with creating and using structures (tables of type
INTTAB) in SAP.

Exercise 5.1 Create an Address Structure


Your employee table, YXXEMP, does not yet contain information about employees addresses.
Because address information is likely to be stored in several tables (for example, in customer and
vendor tables as well as the employee table), you will create a structure to provide the appropriate
field definition. That structure can then be included into the employee table, as well as into any
other tables where it may be needed in the future.
Step 1: Create the structure YXXADDR. (In SE11 select radio button Data Type and select
Structure in the popup that appears.
YXXADDR
Field Name
ADDR1
ADDR2
CITY
REGION
POST_CODE
COUNTRY

Data Element
YXXADDR1
YXXADDR2
YXXCITY
YXXEGION
YXXPOSTCD
LAND1_GP

Domain
CHAR50
CHAR50
CHAR50
CHAR10
CHAR15
Pre-defined

Type
Pre-defined
Pre-defined
Pre-defined
Pre-defined
Pre-defined
Pre-defined

Length
Pre-defined
Pre-defined
Pre-defined
Pre-defined
Pre-defined
Pre-defined

ADDR1 is the first line of the address.


ADDR2 is the second line of the address.
CITY is the city.
REGION is the province or state.
POST_CODE is the postal code.
COUNTRY is the country.
Step 2: Activate the structure
Step 3: Include the structure YXXADDR in the table YXXEMP. Do not forget to re-activate table
YXXEMP.

Exercise 5.2 Add Data to YXXEMP Using the Structure


Step 1: Go to transaction SE16.
Step 2: Enter YXXEMP as the table name and click the Display push button on the toolbar.
Step 3: A selection screen appears. Click the Execute push button on the toolbar (or hit F8)
without entering any selection criteria.
Step 4: Choose one of your entries, and then click the Change push button on the toolbar.
Dec-2008
Page 18

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

Step 5: Notice that you now have additional fields to enter the employees address. Enter an
address, and then save your work.

Chapter 6 Exercises
The purpose of these exercises is to give you experience using the ABAP Repository Information
System. This facility can provide a great deal of information on objects created and maintained
within SAP.

Exercise 6.1 Researching the University Data Model


SAP provides a sample data model called the University Model. Corresponding dictionary objects
have also been created by SAP for this data model.
Step 1: Create and print a list of all tables in the university model. Tables in this data model all
have names beginning with the letter U. Their delivery class is A.
Step 2: Choose one table from the result list for Step 1. For that table, find the list of all fields,
domains, and data elements used in that table.

Exercise 6.2 Miscellaneous Queries


1) Search for all tables beginning with the string KNA*.
2) Display field list for table KNA1.
3) Display only KNA1 fields with the string *Customer* in the short description.
4) Display all fields in tables beginning with KNA*, with CHAR data types, lengths less than 20,
and *Customer* in the short description.
5) Display all tables that uses the check table UPERS.
6) Display all search helps that begin with M*.
7) Find a NUMC domain of field length 4, where the output length is different than the field length.
8) Find all data elements that use domain NUMC4.

Dec-2008
Page 19

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary

Exercise 6.3 Finding Tables that are related to One Another


Step 1: In the customer master tables the country key is kept in table KNA1. Find the table
where the country description/name is kept (e.g., for country key US --> United States).
Note: This exercise is especially similar to the type of research you may be required to do on a
project.
Hints:
1) Concentrate on the foreign key relationship.
2) Related tables are often named with the same base prefix and a different suffix
TXXX, TXXXA, TXXXB would all be related text tables).

(i.e.

Dec-2008
Page 20

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary


Chapter 7 Exercises

Exercise 7.1 Changing a Dictionary Structure


Step 1: Shorten the City field in your YXXADDR structure. To do this, navigate to the YXXCITY
data element. Change the domain from CHAR50 to CHAR60.
Step 2: Re-activate the YXXCITY data element. You may get a warning about the length of the
header label. If so, hit Enter to navigate past this warning.
Step 3: Next you will see a warning that dependent tables may need to be converted. Click
Continue.
Step 4: Next you will see a log of messages from the Database Utility. These messages will tell
you that it was possible to successfully alter/adjust the YXXADDR structure and the YXXEMP
table.

Exercise 7.2 Changing a Table Type


Step 1: Change the type of your table YXXEMP_CP from Transparent to Structure. You may do
this by selecting Extras -> Change table category from the menu in the table definition screen
(you must be in change mode). Do not forget to re-activate the object.

Exercise 7.3 Maintaining Versions


Choose one of your transparent tables and maintain various versions of the object. Refer to
Chapter 8 in your manual for additional guidance. Remember that only temporary versions of
active objects can be stored. Therefore, in order to have different temporary versions, you will
need to 1) store a temporary version of your active object, 2) change that active object and
reactivate it, 3) then store another temporary version.

Dec-2008
Page 21

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary


Chapter 8 Exercises
Exercise 8.1 Creating a View

Hint: Follow the step-by-step instructions contained in the appendices in your manual as you
complete this exercise.
Step 1: Using the University Data Model, create a view that provides an overview of courses
(identified by course number), the course titles, faculties that offer them (need both faculty number
and name), and the professors (identified by professor number) responsible for teaching those
courses. Define a view (YXXKU) that fulfills those requirements.
Choose the type of view carefully. The requirement calls for multiple tables to be included in the
view. Maintenance status is R for read-only. The tables you will need to use are UKURS and
UFACH.
Step 2: Using the data that exists in the tables, test your view via one of the following methods:
Method 1: Use a simple ABAP program.
Refer to Appendix on view.
Method 2: Execute the View.
Go to SE16. Give the name of the view and click on the table contents push button
application toolbar.

in the

Dec-2008
Page 22

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary


Exercise 8.2 Changing a View

Step 1: The view is now to include course descriptions as well as course titles. You will need to
add table UKRSB to your view. The course descriptions in table UKRSB are languagedependent. Establish selection criteria for the view so that course descriptions are limited to
either German or English (choose one).
Note: Course titles, as well as faculty titles, are not language-dependent, and they only exist in
German. Course descriptions, however, are in the database in both German and English. You
must choose which language you would like to use in your view.

Dec-2008
Page 23

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary


Chapter 9 Exercises
Exercise 9.1 Creating Search Help

Lets assume your employee table is used in a transaction. More than likely, you will need to enter
the employee ID number rather than the employee name on a screen. You want to provide the
user with the ability to search for the appropriate employee ID based on the employee name.
Design a search help to attach to the employee ID field.
Step 1: Create an elementary search help using the workbench. Name your search help
YXX_SEARCH_HELP. The selection method should be your employee table (YXXEMP).
Step 2: Indicate the dialog type setting that will create a complex dialog where you can narrow
your search.
Step 3: Select the appropriate fields so that your search help will return the employee ID based
on the specified employee last or first name.
Step 4: List the Employee ID and full name on this hit list.
Step 5: Do not have Employee ID appear on the complex dialog.
Step 6: Activate the search help.
Step 7: Attach the search help to your employee ID field in the YXXEMP table.
Step 8: Test your search help using the following method:
Execute the Table.
Go to SE16. Give the name of the table YXXEMP and click on the table contents push button
in the application toolbar. The Selection screen appears. Place the cursor on Employee ID field
and hit the F4 function key.
QUESTION: How would you design a search help to retrieve an employee ID only if the
employee is salaried?

Dec-2008
Page 24

ECC 6.0
SAP Development ABAP Training

Exercises: The ABAP Dictionary


Chapter 10 Exercises

Exercise 10.1 Create Data Element Documentation


You will add documentation to your tables YXXEMP and YXXHEALTH. Pick a field from each
table. (E.g. EMP_ID from YXXEMP and PLAN_ID from YXXHEALTH)
Step 1: Maintain the documentation for the data elements. (E.g. YXXEMPID and YXXHLTHPLN)
Step 2: Maintain supplemental documentation for the data element. Follow instructions in Chapter
11 of your manual to create data element supplemental documentation.

Exercise 10.2 Create a Type Group


Step 1: Create a Type Group YTYXX in the ABAP Dictionary, which contains the fields shown
below. This type group will be used later in the exercises for the programming portion of the
course.
Type Group
YTYXX

Field Name
YTYXX_PACK7
YTYXX_PACK9

Type
P
P

Length
7
9 (Decimals = 2)

Dec-2008
Page 25

ECC 6.0
Solutions: Data Modeling
& ABAP Dictionary Exercises

SAP Development ABAP Training

Chapter 2 Questions
Question 1: What is the primary function of the Delivery Class attribute? What does a value of
C in this field indicate?
Answer:

The primary function of the Delivery Class attribute is to specify who is responsible
for maintaining the table (either SAP or the customer), and how the table behaves
during an upgrade (for example, should the tables data be overwritten, or merely the
tables structure? Or nothing at all?).
A value of C indicates that the table is maintained exclusively by the customer, and
that nothing should be overwritten during an upgrade.

Question 2: What does the data class control? What does a value of USER indicate?
Answer:

The data class controls the physical area on the database where the table is stored.
A value of USER indicates that the table should be stored in the disk area allocated
for customer-created tables.

Question 3: What does the size category control? In this case, what does a value of 0
represent?
Answer:

The size category controls the amount of disk space that is allocated for the table. In
this case, a value of 0 indicates that we expect to have less than 2,600 records in
this table.

Chapter 4 Questions
Question 1: To what Package does the SAP standard table KUNNR belongs?
Answer:

KUNNR belongs to the Package BV. The Package, that a table belongs to can be
found in the attributes section of the table definition screen.

Dec-2008
Page 1

ECC 6.0
Solutions: Data Modeling
& ABAP Dictionary Exercises

SAP Development ABAP Training

Chapter 9 Questions
Question 1: How would you design a search help to retrieve an employee ID only if the employee
is salaried?
Answer:

Use a view that joins YXXSALARY with YXXEMP as your selection method.

Dec-2008
Page 2

You might also like