Prepared by J Kreie
New Mexico State University
ABAP Tables and Structures
This lesson and others assume you are comfortable with relational database concepts and terminology.
Explanations for these terms and concepts are not covered. (If you are not familiar with relational database
concepts you should get book about database management or systems analysis and design and read the
chapter on data modeling.)
In this lesson you will learn about structures, internal tables, and external tables. You will create a program that
reads data from a table and displays it in an output screen.
Tables and Structures
Since youre familiar with SAP you understand that a lot of data support the SAP modules (Financial Accounting,
Logistics, etc.) and these modules were written in ABAP. From the outset ABAP offered features to facilitate
processing huge amounts of data.
External tables are tables in the database that support the SAP modules. For example, some customer data
are kept in a table called KNA1 and sales order data are kept in VBAK (header data) and VBAP (sales order
item data). When we talk about tables in ABAP, an external table is maintained in the SAP database, it used
indirectly through an internal table defined in an ABAP program, which is described in the next paragraph. It is
possible to manipulate data directly in external tables with SQL but that is not recommended. Typically, data is
retrieved from an external table and stored temporarily in an internal table, manipulated within an ABAP program
then written back to the external table, if changes to the data need to be kept. Transparent is another term
SAP uses for standard relational tables in the SAP database. Youll see this term again near the end of this
lesson. There are other types of tables within SAP which we will not use in these lessons.
When you work with table data in ABAP, typically, you will use structures/work areas and internal tables. In your
program you define a structure also called a work area variables that are grouped together and each variable
is like a column or field in a table. The combined variables in the work area are like a single row to hold data.
An internal table is defined by referencing the structure (group of variables) that makes up the columns in this
temporary table. The data in an internal table exists only during program execution. During execution the
internal table must be populated (data retrieved from an external table or input by a user) and the program must
take care of storing any data that should exist after the programs end, i.e. transferring the data from the internal
table to an external table.
Work area
Internal table
Just like a real table except that it only exits in RAM during program execution.
Page 1 of 10
Page 2 of 10
Description
Customers
Travel Agencies
Business Partners
Airline Carriers
Flight Schedule
Flights
Flight bookings
In the search dialog box enter *bc_* as the search string and
click the checkmark.
Page 3 of 10
Page 5 of 10
It would be nice not to have to guess the country code, wouldnt it? Make a small change to your program, as
shown here.
Save, activate, and test your program. Youll see the value search list option to the right of the input box. As it
turns out, this list box isnt all that useful in this program using the flight/airline data because there are very few
countries in this sample data. Many country codes you might try will not have any data to display for travel
agencies. However, this code modification shows how you can use data defined in the ABAP Data Dictionary to
provide search lists for input.
To finish off this program, create Spanish translations for your
program based on the examples shown below. (Goto
Translations .)
Remember, you dont have to worry about the message that
there is still text to be processed.
Page 6 of 10
Finally, create a transaction code for your program. Use the naming convention but, otherwise, you decide the
name. Add it to your Favorites.
ABAP Dictionary
The ABAP Dictionary is the interface to the metadata in SAP. Metadata is data about the data which means it
is information about how data is stored in the databases. Example metadata about a table would be its name, its
columns (each name, data type, field size, etc.), which column(s) is the primary key, which column(s) is a foreign
key. You can view existing transparent tables in the ABAP Dictionary.
The ABAP Dictionary is in the path: ABAP Workbench
Development ABAP Dictionary (SE11). Open this
transaction.
Click the value search for Database table then type
strav* as the search string.
This will bring up the STRAVELAG table we just worked
with. Accept that item then click the Display button back
in the Initial Screen.
Page 7 of 10
Practice
Create a program that displays customers in the travel database. Assign this program to your other package for
practice after a lesson. In this program get input for what country then show only customers in that country.
Show the customers name, ID, type, city and country. Make the program screens multilingual.
Page 8 of 10
Terms to Know
ABAP Dictionary..................................................................................................................................................... 4
airline/flight scenario............................................................................................................................................... 1
external table.......................................................................................................................................................... 1
forward navigation.................................................................................................................................................. 5
internal table........................................................................................................................................................... 1
metadata................................................................................................................................................................. 4
structures................................................................................................................................................................ 1
transparent table..................................................................................................................................................... 5
Page 9 of 10