BC ABAP User's Guide
ABAP Basics
The R/3 Basis System: Overview
Overview of the Components of Application Programs
The ABAP Programming Language
Creating and Changing ABAP Programs
Opening Programs in the Repository Browser
Entering the Program Name Directly
Creating a New Program
Displaying or Changing an Existing Program
Display Programs of a Development Class
Open Programs Using the ABAP Editor
Opening Programs With Forward Navigation
Maintaining Program Attributes
Program Attributes
Editing Your Program
Assigning Transaction Codes to Executable Programs
Naming Conventions
Basic Statements
ABAP Program Syntax and Layout
Syntax Elements
Statements
Keywords
Comments
Syntax Structure
Structure of Statements
Structure of Comments
Concatenating Similar Statements
ABAP Program Layout
Indenting Blocks of Statements
Using Modularization Tools
Inserting Program Comments Correctly
Pretty Printer
Inserting Predefined Structures
Inserting Predefined Keyword Structures
Inserting Predefined Comment Lines
Declaring Data
Introduction to Data Types and Objects
Data Types
Elementary Data Types - Predefined
Numeric Data Types
Elementary Data Types - User-Defined
Structured Data Types
Compatibility of Data Types
Data Objects
Literals
Variables
Constants
System-Defined Data Objects
Creating Data Objects and Data Types
The DATA Statement
Basic Form of the DATA Statement
Naming a Variable
Specifying the Data Type and the Length of the Var
Specifying a Start Value
Specifying the Number of Digits after the Decimal
DATA Statement for Structures
The CONSTANTS Statement
The STATICS Statement
The TABLES Statement
The TYPES Statement
Summarizing Examples
Example of Predefined Elementary Data Types and Ob
Example of User-Defined Elementary Data Types and
Example of Structures
Example of Internal Tables
Type Groups
Determining the Attributes of Data Objects
Determining the Field Length
Determining the Data Type
Determining the Output Length
Determining the Decimal Places
Determining the Conversion Routine
Working with Text Elements
Text Elements - Concept
Creating and Changing Text Elements
Titles and Headers
Changing the Title of a Program
Creating and Changing List and Column Headers
Selection Texts
Text Symbols
Comparing Text Elements
Comparing Selection Texts
Comparing Text Symbols
Copying Text Elements
Translating Text Elements
Processing Data
Assigning Values
Assigning Values with MOVE
Basic Assignment Operations
Assigning Values with Offset Specifications
Copying Values between Components of Structures
Assigning Values with WRITE TO
Basic Form of the WRITE TO Statement
Specifying the Source Field at Runtime
Writing Values with Offset Specifications
Resetting Values to Initial Values
Numerical Operations
Performing Arithmetic Operations
Basic Arithmetic Operations
Performing Arithmetic Operations on Structures
Adding Sequences of Fields
Using Mathematical Functions
Functions for all numeric data types
Floating-Point Functions
Processing Packed Numbers
Processing Date and Time Fields
Processing Character Strings
Shifting Field Contents
Shifting a Structure by a Given Number of Position
Shifting a Structure up to a Given String
Shifting a Structure According to the First or Las
Replacing Field Contents
Converting to Upper/Lower Case and Substituting Ch
Converting into a Sortable Format
Overlaying Character Fields
Searching for Character Strings
Obtaining the Length of a Character String
Condensing Field Contents
Concatenating Character Strings
Splitting Character Strings
Assigning Parts of Character Strings
Specifying Offset Values for Data Objects
Type Conversions
Convertibility of Elementary Data Types
Source Type Character
Source Type Date
Source Type Floating Point Number
Source Type Numeric Text
Source Type Packed Number
Source Type Time
Source Type Hexadecimal
Convertibility of Structures
Compatible Structures
Incompatible Structures and Elementary Fields
Structures with Internal Tables as Components
Convertibility of Internal Tables
Alignment of Data Objects
Controlling the Flow of an ABAP Program
Programming Logical Expressions
Comparisons with All Field Types
Comparisons with Character Strings and Numeric Str
Comparisons of Bit Structures
Checking Whether a Field Belongs to a Range
Checking for the Initial Value
Checking Selection Criteria
Combining Several Logical Expressions
Programming Branches and Loops
Conditional Branching using IF
Conditional Branching with CASE
Unconditional Looping using DO
Conditional Loops using WHILE
Terminating Loops
Terminating a Loop Pass Unconditionally
Terminating a Loop Pass Conditionally
Terminating a Loop Entirely
Creating and Processing Internal Tables
What are Internal Tables?
Internal Tables as Data Types
Internal Tables as Dynamic Data Objects
Using Internal Tables
Accessing Internal Tables
Operations on Internal Tables
Choosing a Table Type
Declaring Internal Tables
Internal Tables as Parameters for Routines
Creating Internal Tables
Creating Internal Table Data Types
Creating Internal Table Data Objects
Creating Internal Tables by Referring to Another T
Creating Internal Tables by Referring to a Structu
Creating Internal Tables with a New Structure
Working with Internal Tables
Filling Internal Tables
Appending Lines
Appending Lines Depending on the Standard Key
Inserting Lines
Appending Lines of an Internal Table
Inserting Lines of an Internal Table
Copying Internal Tables
Reading Internal Tables
Reading Internal Tables Line by Line
Reading Single Lines Using the Index
Reading Single Lines Using a Key
Reading Single Lines With User-Defined Keys
Reading Single Lines with the Standard Key
Binary Search
Comparing the Contents of Single Lines
Reading Parts of Single Lines
Searching Internal Tables for Character Strings
Determining the Attributes of Internal Tables
Changing and Deleting Lines of Internal Tables
Changing Lines with MODIFY
Changing Lines with WRITE TO
Deleting Lines in a Loop
Deleting Lines Using the Index
Deleting Adjacent Duplicate Entries
Deleting Selected Lines
Sorting Internal Tables
Creating Ranked Lists
Loop Processing
Calculating Totals
Using Control Levels for Groups of Lines
Comparing Internal Tables
Initializing Internal Tables
Working with Field Symbols
Field Symbols - Concept
Defining Field Symbols
Defining Field Symbols for Internal Fields
Field Symbols Without Type Specifications
Typing Field Symbols
Defining Structured Field Symbols
Defining Local Field Symbols
Assigning Data Objects to Field Symbols
Basic Form of the ASSIGN Statement
Static ASSIGN
Static ASSIGN with Offset Specifications
Dynamic ASSIGN
Dynamic ASSIGN of Table Work Areas
Assigning Field Symbols to Other Field Symbols
Assigning Components of Field Strings
Defining the Data Type of a Field Symbol
Changing the Number of Decimal Places
Assigning a Local Copy of a Global Field
Runtime Checks
Saving and Reading Data
Storing Data Objects as Clusters
Data Clusters in ABAP Memory
Storing Data Objects in ABAP Memory
Reading Data Objects from Memory
Deleting Data Clusters in Memory
Data Clusters in Databases
Cluster Databases
Structure of Cluster Databases
Example of a Cluster Database
Storing Data Objects in Cluster Databases
Creating a Table of Contents for a Data Cluster
Reading Data Objects from Cluster Databases
Deleting Data Clusters from Cluster Databases
Accessing Cluster Databases with Open SQL statemen
Working with Files
Working with Files on the Application Server
File Handling in ABAP
Opening a File
Basic Form of the OPEN DATASET Statement
Opening a File for Reading
Opening a File for Writing
Opening a File for Appending
Specifying Binary Mode
Specifying Text Mode
Opening a File at a Specific Position
Sending Operating System Commands
Receiving the Operating System Message
Closing a File
Deleting a File
Writing Data to Files
Reading Data from Files
Automatic Checks before File Operations
Authorization Check for particular Programs and Fi
General Check before File Access
Working with Files on the Presentation Server
Writing Data to the Presentation Server With User
Writing Data to the Presentation Server Without Us
Reading Data from the Presentation Server With Use
Reading Data from the Presentation Server Without
Checking Files on the Presentation Server
Using Platform-Independent File Names
Maintaining Syntax Groups
Assigning Operating Systems to Syntax Groups
Creating and Defining Logical Paths
Creating and Defining Logical File Names
Using Logical Files in ABAP Programs
Modularization
Modularizing ABAP Programs
Source Code Modules
Defining and Calling Macros
Include Programs
Creating Include Programs
Using Include Programs
Subroutines
Defining Subroutines
Calling Subroutines
Calling Internal Subroutines
Calling External Subroutines
Specifying the Subroutine Name at Runtime
Calling Subroutines from a List
Passing Data Between Calling Programs and Subrouti
Declaring Data as Common Part
Passing Data by Parameters
Passing by Reference
Passing by Value
Passing by Value and Result
Typing Formal Parameters
Passing Structures to Subroutines
Passing Internal Tables to Subroutines
Defining Local Data Types and Objects in Subroutin
Defining Dynamic Local Data Types and Objects
Defining Static Local Data Objects
Defining Local Data Objects Explicitly
Terminating Subroutines
Terminating Subroutines Unconditionally
Terminating Subroutines Conditionally
Function Modules
Working with Existing Function Modules
Calling a List of Available Function Modules
Displaying Attributes of Function Modules
Documentation
Interfaces
Source Code
Testing Function Modules
Calling Function Modules
Creating and Programming Function Modules
Creating Function Modules
Programming Function Modules
Function Groups
Special Techniques
Checking the Runtime of Program Segments
GET RUN TIME FIELD
Runtime Measurement of Database Accesses
Generating and Running Programs Dynamically
Creating a New Program Dynamically
Changing Existing Programs Dynamically
Running Programs Created Dynamically
Creating and Starting Temporary Subroutines
ABAP Objects
What are ABAP Objects?
What is Object Orientation?
From Function Groups to Objects
Classes and Class Components
Reference Variables and Object Instances
Interfaces
Triggering and Handling Events
Inheritance
Further Reading
ABAP Database Access
Reading and Processing Database Tables
Database Tables and SQL Concepts
Reading Data from Database Tables
Defining the Result of a Selection
Selecting All Data from Several Lines
Selecting All Data from a Single Line
Selecting and Processing Data from Specific Column
Specifying the Database Table to be Read
Specifying the Database Table Name in the Program
Specifying the Database Table Name at Runtime
Specifying the Target Area for the Selected Data
Reading Data into a Work Area
Reading Data into an Internal Table
Reading Data Component by Component
Choosing the Lines to be Read
Specifying Conditions for Line Selection in the Pr
Specifying Conditions for Line Selection at Runtim
Grouping Lines
Specifying the Order of Lines
Changing the Contents of Database Tables
Adding Lines to Database Tables
Adding a Single Line
Adding Several Lines from an Internal Table
Changing Lines in Database Tables
Changing a Single Line
Changing Several Lines
Changing Several Lines Using an Internal Table
Adding or changing lines
Inserting a Single Line
Inserting Several Lines
Deleting Lines from Database Tables
Deleting a Single Line
Deleting Several Lines
Deleting Several Lines Using an Internal Table
Reading Lines of Database Tables Using a Cursor
Opening a Cursor
Using a Cursor to Read Data
Closing the Cursor
Example of Reading Data Using a Cursor
Writing or Undoing Changes to Database Tables
Specifying Clients for Processing Database Tables
Performance Notes
Using Native SQL Statements in an ABAP Program
Native SQL for Informix
Native SQL for DB2 Common Server
Locking Database Objects During Program Execution
Checking the Authorization of Program Users
Using Contexts
What are Contexts?
The Context Builder in the ABAP Workbench
Creating and Editing a Context
Using Tables as Modules
Using Function Modules as Modules
Using Contexts as Modules
Testing a Context
Buffering Contexts
Fields
Modules
Interfaces
Using Contexts in ABAP Programs
Finding and Displaying a Context
Creating an Instance of a Context
Supplying Context Instances with Key Values
Querying Data from Context Instances
Message Handling in Contexts
Message Handling in Table Modules
Message Handling in Function Module Modules
Working With Contexts - Hints
Programming Database Updates
Transactions and Logical Units of Work
Database Logical Unit of Work (LUW)
SAP LUW
SAP Transactions
The R/3 Lock Concept
Example Transaction: SAP Locking
Update Techniques
Asynchronous Update
Updating Asynchronously in Steps
Synchronous Update
Local Update
Creating Update Function Modules
Calling Update Functions
Calling Update Functions Directly
Adding Update Task Calls to a Subroutine
Special LUW Considerations
Transactions that Call Update-Task Functions
Dialog Modules that Call Update-Task Functions
Error Handling for Bundled Updates
ABAP User Interfaces
Screens
Processing User Input on a Screen
Programming with Function codes
Setting up Function codes
Handling Function codes
Handling Field Selections
Sharing GUI Statuses
Programming with Radio Buttons
Programming with Check Boxes
Controlling the Screen Flow
Introduction to Screen Flow Control
Setting the Next Screen
Calling a New Screen Sequence
Leaving the Current Screen
Example Transaction: Setting and Calling Screens
Processing Screens in the Background
Modifying the Screen
Setting Screen Field Attributes
Changing Screen Field Attributes with the Function
Field Selection - Overview
Calling Field Selection
Combination Rules For Attributes
Screen Painter Attributes
Generating the Field Selection
Function Modules for Field Selection
Linking Fields
The Display Attribute 'Active'
Authorization for Field Selection
Using Subscreens
Manipulating the Cursor
Tab strips
Using a tab strip
Tab strip components
Programming tab strips
Defining a tab strip in the Screen Painter
Further Notes
Using Tables in a Screen
Introduction
Using the LOOP Statement
Looping Directly Through a Screen Table
Looping Through an Internal Table
How the System Transfers Data Values
Scrolling and the Scroll Variables
Using Table Controls
Declaring Table Controls in ABAP
Setting Table Control Attributes
Example Transaction: Table Controls
Using Step Loops
Checking User Authorizations
Defining an Authority Check
Defining Authorization Objects
Defining Authorization Fields
Programming Field- and Value-Help
User-specific F1 Help
Context-sensitive Value Help
Selection Screens
Working with Selection Screens
What are Selection Screens?
Standard Selection Screens and Logical Databases
Defining Selection Screens
Standard and User-defined Selection Screens
PARAMETERS - Defining Input Fields for Variables
Basic Form of the PARAMETERS Statement
Assigning Default Values to Parameters
Suppressing Display of Parameters
Allowing Parameters to Accept Upper and Lower Case
Making Parameters Required Input Fields
Creating Checkboxes on the Selection Screen
Creating Radio Button Groups on the Selection Scre
Using Default Values from SAP Memory
Assigning Matchcode Objects to Parameters
Assigning Parameters to a Modification Group
SELECT-OPTIONS - Defining Selection Criteria
Selection Tables
RANGES
Program-specific Selection Criteria and Logical Da
Basic Form of the SELECT-OPTIONS Statement
Assigning Default Values to Selection Criteria
Restricting the Selection Table to One Line
Restricting the Selection Table to Single Value Se
Preventing the Transfer of Selection Criteria to L
Further Options for Selection Criteria
SELECTION-SCREEN - Formatting
Specifying Blank Lines, Underlines, and Comments
Blank Lines
Underlines
Comments
Example of Blank Lines, Underlines, and Comments
Placing Several Elements On a Single Line
Positioning an Element
Creating Blocks of Elements
Creating Pushbuttons in the Application Toolbar
Creating Pushbuttons on the Selection Screen
Calling Selection Screens
Calling Standard Selection Screens
Calling User-defined Selection Screens
Call From a Program
Call as a Report Transaction
Call as a Dialog Transaction
Using Selection Criteria in Programs
Using Selection Tables in the WHERE Clause
Using Selection Tables in Logical Expressions
Using Selection Tables with the CHECK Statement in
Pre-Setting Selections Using Variants
What is a Variant?
Creating and Changing Variants
Displaying a List of all Variants
Creating Variants
Attributes of a Variant
Changing Variants
Deleting Variants
Printing Variants
Using Variables with Variants
Using Variable Date Calculations
Using User-Specific Values
Changing Values of User-Specific Variables Interac
Changing Values of User-Specific Variables from th
Using Table TVARV
Creating New Entries in Table TVARV
Changing Entries in Table TVARV
Running an Executable Program (Report) with a Vari
Lists
Creating Simple Lists with the WRITE Statement
The WRITE Statement
Positioning WRITE Output on the Screen
Formatting Options
Outputting Symbols and Icons on the Screen
Lines and Blank Lines on the Output Screen
Outputting Field Contents as Checkboxes
Using WRITE via a Statement Structure
Formatting Data
Example for Refined Data
Refining Data During Reading
Refining Data Using Internal Tables
Refining Data Using Flat Internal Tables
Refining Data Using Nested Internal Tables
Refining Data Using Extract Datasets
Creating and Filling Extract Datasets
Defining Extract Records as Field Groups
Assigning Fields to a Field Group
Extracting a Dataset
Processing Extract Datasets
Processing Control Levels
Calculating Numbers and Totals
Reading Extract Datasets
Sorting Extract Datasets
Example for Refining Data Using Extract Datasets
Creating Complex Lists
The Standard List
Example for a Standard List
Structure of the Standard List
Standard Page Header
Standard Page
Width of the Standard List
User Interface of the Standard List
Printing the Output List
Saving a List
Saving the List in SAPoffice
Saving the List in the Reporting Tree
Saving the List as Local File on the Presentation
Modifying List and Column Headers
The Self-Defined List
Individual Page Header
Determining the List Width
Determining the Page Length
Defining a Page Footer
Lists with Several Pages
Programming Page Breaks
Unconditional Page Break
Conditional Page Break- Defining a Block of Lines
Standard Page Headers of Individual Pages
Page Lengths of Individual Pages
Page Width of List Levels
Scrolling from within the Program
Scrolling Window by Window
Scrolling by Pages
Scrolling to the List's Margins
Scrolling by Columns
Laying Out List Pages
Positioning the Output
Absolute Positioning
Horizontal Positioning
Vertical Positioning
Positioning Output Beneath the Page Header
Example for Absolute Positioning
Relative Positioning
Producing a Line Feed
Positioning Output Underneath Other Output
Positioning Output in the First Line of a Line Blo
Examples for Relative Positioning
Formatting Output
The FORMAT Statement
Colors in Lists
Demonstrating the Colors Available in Lists
Example for Using Colors in Lists
Enabling Fields for Input
Outputting Fields as Hotspots
Special Output Formats
Country-specific and User-specific Output Formats
Currency-specific Output Formats
Unit-specific Output Formats
Creating Blank Lines
Drawing Lines, Frames, and Grids
Straight Lines
Corners
T Sections
Crosses
Using Special Lines
Programming Frames
Programming Grids
Determining Which Part of a Page to Scroll Horizon
Excluding Lines from Horizontal Scrolling
Left Boundary for Horizontal Scrolling
Interactive Lists
What is Interactive Reporting?
Event Control for Interactive Lists
Basic Lists and Secondary Lists
Creating the Basic List
Creating Secondary Lists
Maintaining Lists
System Fields for Secondary Lists
Page Headers for Secondary Lists
Messages in Lists
User Interfaces of Interactive Lists
Allowing Line Selection
Allowing Function Key Selection
Defining Individual User Interfaces
Defining a Status for Interactive Lists
Starting the Menu Painter Tool for Interactive Lis
Using the Menu Painter for Interactive Lists
Defining Titles for Interactive Lists
Using Your Own Function Codes in the Program
Setting a Status
The AT USER-COMMAND Event
Displaying Lists in Dialog Windows
Triggering Events from within the Program
Passing Data from List to Report
Passing Data Automatically
Data from System Fields of Interactive Lists
Using SY-LISEL
Passing Data by Program Statements
The HIDE Technique
Reading Lines from Lists
Reading Lists at the Cursor Position
Passing List Attributes
Manipulating Interactive Lists
Scrolling through Interactive Lists
Setting the Cursor from within the Program
Setting the Cursor Explicitly
Setting the Cursor to a Field
Setting the Cursor to a Line
Modifying List Lines
Modifying Line Formatting
Modifying Field Contents
Modifying Field Formatting
Calling Programs
Calling Executable Programs (Reports)
Exiting the Executable Program Called from Within
Manipulating the List Structure of the Called Exec
Filling the Selection Screen of the Called Executa
Calling Transactions
Transferring SPA/GPA Parameters to Transactions
Printing Lists
Printing a List after Creating it
Printing a List while Creating it
Print Parameters
Print Parameters- Overview
Print Parameters -Pre-setting Values
Setting Print Parameters from within the Program
GET_PRINT_PARAMETERS - Overview
Import Parameters of GET_PRINT_PARAMETERS
Export Parameters of GET_PRINT_PARAMETERS
Exception Parameters of GET_PRINT_PARAMETERS
How to Use GET_PRINT_PARAMETERS
Executing and Printing
Printing from within the Program
Printing Lists of Called Executable Programs (Repo
Print Control
Determining Left and Upper Margins
Determining the Print Format
Indexing Print Lists for Optical Archiving
Switching Between Dialog Screens and List Display
Using LEAVE TO LIST-PROCESSING
Using GUI Statuses in List-Mode
Returning to Dialog Mode
Returning to a Different Screen
Example Transaction: Branching to List-Mode
Messages
Handling Errors and Messages
Introduction to Error Processing
Checking Screen Fields for Validity
Understanding Automatic Field Checks
Checking Fields in the Screen Flow Logic
Checking Fields in ABAP
Checking a Single Field
Checking Multiple Fields
Making Module Calls Conditionally
Conditional FIELD Statements
Conditional CHAIN Statements
Avoiding Automatic Field Checks
Issuing Messages
Sending a Message
Message Processing in Dialog-Mode
Restarting PAI after an error dialog
Creating a Message Class
Creating Messages
Example Transaction: Checking Field Input
Messages on Selection Screens
Messages in Lists
Running ABAP Programs
Directly Executable Programs
Executable Programs (Reports) and Logical Database
Accessing Data with SELECT
Accessing Data Using Logical Databases
Comparison of Access Methods
Advantages of Logical Databases
Controlling the Database Accesses from the Executa
Controlling the Flow of ABAP Programs by Events
Defining Processing Blocks
Events and their Event Keywords
INITIALIZATION
AT SELECTION-SCREEN
Processing a Particular Input Field
Processing Multiple Selection
Creating a List of Input Values
Creating Help for Input Fields
Processing a Group of Radio Buttons
Processing a Block of Input Fields
PBO of the Selection Screen
START-OF-SELECTION
GET <table>
Specifying Fields of the Database Table Explicitly
GET <table> LATE
END-OF-SELECTION
Terminating Processing Blocks
Leaving Processing Blocks Unconditionally
Branching to END-OF-SELECTION
Branching to the Output Screen
Leaving AT Events
Leaving Processing Blocks Conditionally
Leaving GET Events Unconditionally
Branching to the Next Line of the Current Database
Branching to the Next Line of a Superior Database
Leaving GET Events Conditionally
Features and Maintenance of Logical Databases
Features of Logical Databases
Tasks of Logical Databases
Basic Features of Logical Databases
Structure of Logical Databases
Logical Database Selections
Database Program of a Logical Database
Logical Databases and Reports
Authorization Checks with Logical Databases
Performance Aspects of Logical Databases
Example of a Logical Database
Creating and Maintaining Logical Databases
Creating a Logical Database Creating a Logical Dat
Processing the Structure
Displaying Structures
Changing Structures
Editing Selections
Editing the Database Program
Working with Dynamic Selections
Working with Field Selections
Editing Selection Texts
Editing Matchcode Selections
Editing Documentation
Further Editing Options
Editing the Data Model
Checking Logical Databases
Copying Logical Databases
Deleting Logical Databases
Dialog Mode
Dialog Mode
Dialog Mode Programs - Transactions
A Sample Program
Screen
ABAP Module Pool
Interaction between Dialog Screen and ABAP Module
Calling Programs Externally
Calling External Program Components
Embedding Program Calls
Calling Function Modules
Handling Exceptions
Calling Other Transactions
Calling Dialog Modules
Using Transactions as Dialog Modules
Submitting Executable Programs (Reports)
Passing Data to the Called Program
Saving or Printing the List
Passing Data Between Programs
Passing Data with SPA/GPA Parameters
Syntax Conventions