Friday, March 11

ABAP Data Types and Objects

There are physical units with which ABAP statements work at runtime. These units are called program data Objects. Data object occupy space in memory.
There are some technical attributes associated with each ABAP data object. Like Data type, field length,
and number of decimal places.

The data type tells how the contents of a data object should be interpreted by ABAP statements.
data type can also be defined independently.
This can be done in the declaration part of an ABAP program using the TYPES statement. This can also be done in the ABAP Dictionary.
The data types you will use in a program depend on how you will use your data objects.
ABAP program can pass simple input data to the database also it can process
and out a large quantity of structured data from the database. following
data types are present in ABAP.

Predefined Types
Five predefined non-numeric data types:
Date (D), Time (T), Character string (C), Numeric character string (N) and
Hexadecimal (X)

Three predefined numeric types:
Packed number (P), Integer (I) and Floating-point number (F).
For D, F, I, and T,field length is fixed. For C, N ,X and P field length gets determined when you declare the data object in your program.
in a business context , Data type P is useful as it can give exact calculations. number of decimal places should be specified When you define an an object of type P.

User-defined Types
Own elementary types can always be defined using the TYPES statement.the basis of elementary data types will be predefined data types.For eg: we can define a data type P_3 with three decimal places. This is based on the predefined data type P. So now elementary data objects can be defined using elementary data types. Elementary data types can be used to form Aggregated data types
An aggregated data type can be an internal table or a structure.

Structures
ABAP does not have predefined
structures. We need to define structures, either in the ABAP program in
or in the ABAP Dictionary.
What is a structure used for ? structures can group work areas that belong together logically. For example,
Structures can contain elementary as well as aggregated data types
Internal Tables
Internal tables is a series of lines that all have same data type.
Characteristics of internal table are :

line type.
The line type can be any ABAP data type - a
Structure, an elementary type or an internal table.
key
key is used to identify lines in the internal table.
Access type
How ABAP statements will access the entries of the internal table is determined by the access type.
three access types are unsorted tables, sorted index tables and hash tables.
For index tables, access to the table entires is done by specifying the index or the key.
Hashed tables can only be accessed by specifying the key.
The system has its own hash algorithm for managing the table.

Data Types for Reference
in ABAP Objects , references are used to refer to objects. There are reference variables where we store the references. The way the program handles a reference is determined by it data type. there are various types of interface and class reference variables.
Reference variable can become component of a internal table or a structure.

Declaring Data Objects
Declaration of data objects in done using the declarative statements of ABAP. This is done before actual execution of the program starts.
The interface parameters of the routine become local data objects as soon as the routine is called. If technical attributes for the data type of these data objects is defined during interface definition then it is ok otherwise the data object take up the attributes of the parameter assigned to it at runtime.

Related Articles :

Basics of Web Dynpro ABAP
ABAP Statements
WD4A - Topics to be covered in the upcoming posts
WD4A - Introduction
WDA - SAP Logon Procedures
WD4A-Format the Values appearing on value Axis of Business Graphic
WD4A-Navigate from one view to another and back to previous view
WD4A - How to Calculate next 12 months from current month in web dynpro ABAP
WD4A - Validate Inputs in a web dynpro ABAP Application

No comments:

Post a Comment

You are welcome to express your views here...