Chapter 4 (Data Objects)

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

Chapter 4:Data Objects

What are Data Objects?

• Data objects are fundamental elements that store and manage data within a
program. Data objects represent pieces of information and can take various
forms.
Common data objects used in SAP ABAP
Variables Variables are used to store and manipulate data within
a program. They can be of various data types, such as
integers, strings, dates, or user-defined types.
Variables are essential for performing calculations and
holding temporary data during program execution.

Internal Tables Internal tables are data structures used to store and
manage data in memory. They are similar to arrays in
other programming languages and are often used for
data processing and manipulation

Database Tables Database tables are used to persistently store


structured data in the SAP system. They define the
structure of database records and are essential for data
storage, retrieval, and reporting.

Structures Structures are user-defined data types that group


multiple fields together under a single name. They are
used for organizing related data fields, and they can be
nested within other structures or tables.
Common data objects used in SAP ABAP
Constants are data objects whose values remain fixed
Constants throughout the program's execution. They are
typically used for defining values that should not
change during program execution.
Fields represent individual data elements within a
Fields structure or table. Fields can be defined with specific
data types, lengths, and attributes, and they are used
to store data within records.
Literals can be considered a specific type of data
object in programming. They are constants that
Literals represent fixed values of various data types directly
within your code. These values do not change during
program execution, and they are used to provide
specific data to variables, data structures, or
expressions.
Literals
• Literal is a data object that specifies character like values. Literal
defined in the source code of the program. Literals are fully
defined by their values.
• The value of the literal can’t be changed. The fixed values assigned
to a constant can also consider as literals. There are two types of
literals and those are -
• Numeric literals
• Character literals
Numeric Literals

• Numeric literals represent numerical values. They can be integer literals


(e.g., 42), decimal literals (e.g., 3.14), or hexadecimal literals (e.g., X'1A'). You
can use these literals when assigning values to numeric variables or fields.
• The numeric literals are supported by either Integer(i) or packed (p) data
types.
Character Literals

• Character literals are sequence of alphanumeric characters.


Character literals enclosed with single quotation marks(').
Character literals can be of two types and those are -
• Text field literals
• Text string literals
Text Field Literals

• Text field literals are sequence of alphanumeric characters and


enclosed with single quotation marks (‘).
• The text field literal length must be in between 1 to 255 characters.
Text String Literals

• Text string literals are sequence of alphanumeric characters and enclosed


with single backquotes (`). Text string literal should not be empty (For
example, the text string literal `` is an empty string of length 0).
• The text string literal length must be in between 1 to 255 characters.
Constants
• Constants are named objects that are used to store a fixed value and the
value is fixed during program execution from beginning to ending. The
difference between constants and variables are, variables value can change
any time however the constant value is fixed and can't be changed.
• Constants are similar to variables and allows to store data under a particular
name within the memory area of a program. Constants must have a VALUE
clause coded and value should be assigned during the declaration itself.
Constants can't be changed during the execution of the program. If tries to
change the value of a constant, a syntax error or runtime error gets occured.
How to Declare a Constant?

• CONSTANTS keyword used to declare constants. Constants declared in


class or interface are static variables of that class or interface.
• CONSTANTS {constant-name} TYPE {data-type} VALUE fixed-value.
Constant Types

• Elementary constants
• Complex constants
• Reference constants
Elementary Constant Type

• If a single variable is declared as constant, those called as elementary


constants.
Complex Constant Types

• Complex constants are group of elementary constants combined together.


Reference Constant Type

• Reference constants are the references to the constants. Reference


constants are used in comparisons and while passing data to procedures.

• Syntax:
CONSTANTS constant_pointer TYPE REF TO object_name VALUE IS

INITIAL.

You might also like