Site icon DataFlair

SAP ABAP Tables – Types and Fields

SAP ABAP Tables

FREE Online Courses: Enroll Now, Thank us Later!

In this tutorial, we’ll be learning what are Tables, Table Fields in ABAP, Types of SAP ABAP Tables, How to create Tables in Data Dictionary, What are Internal Tables, Purpose of Internal Tables, Types of Internal Tables and How to create, modify internal tables.

Let’s start our journey!!!!

What are Tables in ABAP?

Table Fields in ABAP

Tables can have several fields, which in turn contain many elements. Let’s look at a few of these fields –

FIELD  DESCRIPTION
Field Name Field name is the name of the field, beginning with a letter and containing alphabets, numbers and/or underscore ‘_’. The maximum length allowed is 16 characters
Key Flag This is a checkpoint use to determine if a particular field is part of a key field or not.
Field type It is the data type of a field
Field Length This is the length or count of characters that can be used for a field.
Decimal Places Decimal places are the number of integers that can be added after the floating point.
Short Text This is used for description of whatever field it is related to

Types of Tables in ABAP

There are three types of tables in ABAP. They are –

1. Transparent tables in SAP ABAP

2. Cluster tables in SAP ABAP

3. Pooled tables in SAP ABAP

How to create Tables in Data Dictionary

Here are the steps to create a new table in SAP ABAP –

1. Open the SAP application system

2. Enter t-code ‘SE11’ to open the Data Dictionary screen

3. Click on the first radio button ‘Database Table’ and enter the name you want to give the table (must start with ‘Z’ or ‘Y’!)

Technology is evolving rapidly!
Stay updated with DataFlair on WhatsApp!!

4. Click on the ‘Create’ button below. This opens a popup window

5. Give a short description of what the table will be about

6. Enter Delivery Class as ‘A’ (default)

7. Click on the option – ‘Display/Maintenance Allowed’ so that you can edit it later if needed

8. Click on ‘Save’

9. Select the tab called ‘Fields’ and enter field & data element name

10. Click on ‘Save’

11. Table is created – you can now activate it

What are Internal Tables in SAP ABAP?

Purpose of ABAP Internal Tables

There are many uses that an internal table can embibe. Here are some of them –

Types of SAP ABAP internal tables

1. Standard Tables in ABAP

2. Sorted Tables in ABAP

3. Hashed Tables in ABAP

How to create and modify internal tables in ABAP

In the ‘DATA’ statement in ABAP, internal tables can be created by using keywords ‘TABLE OF’ as shown –

REPORT ZR_SS_DATAFLAIR_SAMPLE_001.

TYPES: BEGIN OF ty_dataflair,
       id(5)    TYPE n,
       name(10) TYPE c,
       END OF ty_dataflair.

DATA: df_dataflair TYPE ty_dataflair.

"Referring to local data type
DATA: df1 TYPE TABLE OF ty_dataflair.
"Referring to local data object
DATA: df2 LIKE TABLE OF df_dataflair.
"Referring to data type in ABAP dictionary
DATA: df3 TYPE TABLE OF mara.

To add to the internal table, use APPEND statement as follows – 

REPORT ZR_SS_DATAFLAIR_SAMPLE_001.

TYPES: BEGIN OF ty_dataflair,
       id(5)    TYPE n,
       name(10) TYPE c,
       END OF ty_dataflair.

DATA: df_dataflair TYPE ty_dataflair.

DATA: it TYPE TABLE OF ty_dataflair.

df_dataflair-id    = 1.
df_dataflair-name  = 'DATA'.
APPEND df_dataflair TO it.

df_dataflair-id    = 2.
df_dataflair-name  = 'FLAIR'.
APPEND df_dataflair TO it.

df_dataflair-id    = 3.
df_dataflair-name  = 'ABAP'.
APPEND df_dataflair TO it.

Summary

Hence in this tutorial we learnt about the building blocks of a relational database – tables. We learnt about the different types and uses of database tables.

We also learnt about internal tables, why they are important and how to create both types of tables in SAP.

Exit mobile version