- SAP ABAP - Web Dynpro
- SAP ABAP - Business Add-Ins
- SAP ABAP - User Exits
- SAP ABAP - Customer Exits
- SAP ABAP - SAPscripts
- SAP ABAP - Smart Forms
- SAP ABAP - Dialog Programming
- SAP ABAP - Report Programming
- SAP ABAP - Object Events
- SAP ABAP - Interfaces
- SAP ABAP - Encapsulation
- SAP ABAP - Polymorphism
- SAP ABAP - Inheritance
- SAP ABAP - Classes
- SAP ABAP - Objects
- SAP ABAP - Object Orientation
- SAP ABAP - Deleting Internal Tables
- SAP ABAP - Reading Internal Tables
- SAP ABAP - Copying Internal Tables
- ABAP - Populating Internal Tables
- SAP ABAP - Creating Internal Tables
- SAP ABAP - Internal Tables
- SAP ABAP - Native SQL Overview
- SAP ABAP - Open SQL Overview
- SAP ABAP - Include Programs
- SAP ABAP - Function Modules
- SAP ABAP - Macros
- SAP ABAP - Subroutines
- SAP ABAP - Modularization
- SAP ABAP - Lock Objects
- SAP ABAP - Search Help
- SAP ABAP - Views
- SAP ABAP - Structures
- SAP ABAP - Tables
- SAP ABAP - Data Elements
- SAP ABAP - Domains
- SAP ABAP - Dictionary
- SAP ABAP - Exception Handling
- SAP ABAP - Formatting Data
- SAP ABAP - Date & Time
- SAP ABAP - Strings
- SAP ABAP - Decisions
- SAP ABAP - Loop Control
- SAP ABAP - Operators
- SAP ABAP - Constants & Literals
- SAP ABAP - Variables
- SAP ABAP - Data Types
- SAP ABAP - Basic Syntax
- SAP ABAP - Screen Navigation
- SAP ABAP - Environment
- SAP ABAP - Overview
- SAP ABAP - Home
SAP ABAP Useful Resources
- SAP ABAP - Discussion
- SAP ABAP - Useful Resources
- SAP ABAP - Quick Guide
- SAP ABAP - Questions Answers
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SAP ABAP - Data Types
While programming in ABAP, we need to use a variety of variables to store various information. Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. You may pke to store information of various data types pke character, integer, floating point, etc. Based on the data type of a variable, the operating system allocates memory and decides what can be stored in the reserved memory.
Elementary Data Types
ABAP offers the programmer a rich assortment of fixed length as well as variable length data types. Following table psts down ABAP elementary data types −
Type | Keyword |
---|---|
Byte field | X |
Text field | C |
Integer | I |
Floating point | F |
Packed number | P |
Text string | STRING |
Some of the fields and numbers can be modified using one or more names as the following −
byte
numeric
character-pke
The following table shows the data type, how much memory it takes to store the value in memory, and the minimum and maximum value that could be stored in such type of variables.
Type | Typical Length | Typical Range |
---|---|---|
X | 1 byte | Any byte values (00 to FF) |
C | 1 character | 1 to 65535 |
N (numeric text filed) | 1 character | 1 to 65535 |
D (character-pke date) | 8 characters | 8 characters |
T (character-pke time) | 6 characters | 6 characters |
I | 4 bytes | -2147483648 to 2147483647 |
F | 8 bytes | 2.2250738585072014E-308 to 1.7976931348623157E+308 positive or negative |
P | 8 bytes | [-10^(2len -1) +1] to [+10^(2len -1) 1] (where len = fixed length) |
STRING | Variable | Any alphanumeric characters |
XSTRING (byte string) | Variable | Any byte values (00 to FF) |
Example
REPORT YR_SEP_12. DATA text_pne TYPE C LENGTH 40. text_pne = A Chapter on Data Types . Write text_pne. DATA text_string TYPE STRING. text_string = A Program in ABAP . Write / text_string. DATA d_date TYPE D. d_date = SY-DATUM. Write / d_date.
In this example, we have a character string of type C with a predefined length 40. STRING is a data type that can be used for any character string of variable length (text strings). Type STRING data objects should generally be used for character-pke content where fixed length is not important.
The above code produces the following output −
A Chapter on Data Types A Program in ABAP 12092015
The DATE type is used for the storage of date information and can store eight digits as shown above.
Complex and Reference Types
The complex types are classified into Structure types and Table types. In the structure types, elementary types and structures (i.e. structure embedded in a structure) are grouped together. You may consider only the grouping of elementary types. But you must be aware of the availabipty of nesting of structures.
When the elementary types are grouped together, the data item can be accessed as a grouped data item or the inspanidual elementary type data items (structure fields) can be accessed. The table types are better known as arrays in other programming languages. Arrays can be simple or structure arrays. In ABAP, arrays are called internal tables and they can be declared and operated upon in many ways when compared to other programming languages. The following table shows the parameters according to which internal tables are characterized.
S.No. | Parameter & Description |
---|---|
1 | Line or row type Row of an internal table can be of elementary, complex or reference type. |
2 | Key Specifies a field or a group of fields as a key of an internal table that identifies the table rows. A key contains the fields of elementary types. |
3 | Access method Describes how ABAP programs access inspanidual table entries. |
Reference types are used to refer to instances of classes, interfaces, and run-time data items. The ABAP OOP run-time type services (RTTS) enables declaration of data items at run-time.
Advertisements