Anda di halaman 1dari 5

SAP OO-ABAP defenities:

1. Public attributes
2. Private attributes
3. Instance attributes
4. Static attributes
5. Public methods
6. Private methods
7. Constructor method
8. Static constructor
9. Protected components
10. Polymorphism

Public attributes

Public attributes are defined in the PUBLIC section and can be viewed and
changed from outside the class. There is direct access to public attributes. As
a general rule, as few public attributes should be defined as possible.

PUBLIC SECTION.
DATA: Counter type i.

Private attributes

Private attributes are defined in the PRIVATE section. The can only be viewes
and changed from within the class. There is no direct access from outside the
class.

PRIVATE SECTION.
DATA: name(25) TYPE c,
planetype LIKE saplane-planetyp,

Instance attributes

There exist one instance attribute for each instance of the class, thus they
exist seperately for each object. Instance attributes are declared with the
DATA keyword.

Static attributes

Static attributes exist only once for each class. The data are the same for all
instances of the class, and can be used e.g. for instance counters. Static
attributes are defined with the keyword CLASS-DATA.

PRIVATE SECTION.

CLASS-DATA: counter type i,


Public methods

Can called from outside the class

PUBLIC SECTION.

METHODS: set_attributes IMPORTING p_name(25) TYPE c,

p_planetype LIKE saplane-planetyp,

Private methods

Can only be called from inside the class. They are placed in the PRIVATE
section of the class.

Constructor method

Implicitly, each class has an instance constructor method with the reserved
name constructor and a static constructor method with the reserved name
class_constructor.

The instance constructor is executed each time you create an object


(instance) with the CREATE OBJECT statement, while the class constructor
is executed exactly once before you first access a class.

The constructors are always present. However, to implement a constructor


you must declare it explicitly with the METHODS or CLASS-METHODS
statements. An instance constructor can have IMPORTING parameters and
exceptions. You must pass all non-optional parameters when creating an
object. Static constructors have no parameters.

Static constructor

The static constructor is always called CLASS_CONSTRUCTER, and is


called autmatically before the clas is first accessed, that is before any of the
following actions are executed:

• Creating an instance using CREATE_OBJECT


• Adressing a static attribute using <classname>-><attrbute>
• Calling a ststic attribute using CALL METHOD
• Registering a static event handler
• Registering an evetm handler method for a static event

The static constructor cannot be called explicitly.

Protected components

When we are talking subclassing and enheritance there is one more


component than Public and Private, the Protected component. Protected
components can be used by the superclass and all of the subclasses. Note
that Subclasses cannot access Private components.
Polymorphism

Polymorphism: When the same method is implemented differently in different


classes. This can be done using enheritance, by redefining a method from the
superclass in subclasses and implement it differently.

the difference between standard, sorted, and hashed tables

1.Standard Internal Tables: These tables have a linear index


and can be accessed using the index or the key. The response
time is in linear relationship with number of table entries.
These tables are useful when user wants to address
individual table entries using the index.
2.Sorted Internal Tables: These tables also have an index
and the key. But, the response time is in logarithmic
relationship with number of table entries, since it uses
binary search algorithm instead of linear search. These
tables are useful when user wants the table to be sorted
while additional entries have to be added.
3.Hashed Internal Tables: These tables have no index, but
have the key. The response time is constant irrespective of
number of table entries, since it uses a Hash algorithm.
These tables are useful when user wants to access the
entries with key only.

Standard tables
This is the most appropriate type if you are going to address the individual
table entries using the index. Index access is the quickest possible access.
You should fill a standard table by appending lines (ABAP APPEND
statement), and read, modify and delete entries by specifying the index
(INDEX option with the relevant ABAP command). The access time for a
standard table increases in a linear relationship with the number of table
entries. If you need key access, standard tables are particularly useful if you
can fill and process the table in separate steps. For example, you could fill the
table by appending entries, and then sort it. If you use the binary search
option with key access, the response time is logarithmically proportional to the
number of table entries.

Sorted tables

This is the most appropriate type if you need a table which is sorted as you fill
it. You fill sorted tables using the INSERT statement. Entries are inserted
according to the sort sequence defined through the table key. Any illegal
entries are recognized as soon as you try to add them to the table. The
response time for key access is logarithmically proportional to the number of
table entries, since the system always uses a binary search. Sorted tables are
particularly useful for partially sequential processing in a LOOP if you specify
the beginning of the table key in the WHERE condition.

Hashed tables

This is the most appropriate type for any table where the main operation is
key access. You cannot access a hashed table using its index. The response
time for key access remains constant, regardless of the number of table
entries. Like database tables, hashed tables always have a unique key.
Hashed tables are useful if you want to construct and use an internal table
which resembles a database table or for processing large amounts of data.

Standard Internal Tables

Standard tables have a linear index. You can access them using either the
index or the key. If you use the key, the response time is in linear relationship
to the number of table entries. The key of a standard table is always non-
unique, and you may not include any specification for the uniqueness in the
table definition.

This table type is particularly appropriate if you want to address individual


table entries using the index. This is the quickest way to access table entries.
To fill a standard table, append lines using the (APPEND) statement. You
should read, modify and delete lines by referring to the index (INDEX option
with the relevant ABAP command). The response time for accessing a
standard table is in linear relation to the number of table entries. If you need to
use key access, standard tables are appropriate if you can fill and process the
table in separate steps. For example, you can fill a standard table by
appending records and then sort it. If you then use key access with the binary
search option (BINARY), the response time is in logarithmic relation to
the number of table entries.

Sorted Internal Tables

Sorted tables are always saved correctly sorted by key. They also have a
linear key, and, like standard tables, you can access them using either the
table index or the key. When you use the key, the response time is in
logarithmic relationship to the number of table entries, since the system uses
a binary search. The key of a sorted table can be either unique, or non-
unique, and you must specify either UNIQUE or NON-UNIQUE in the table
definition. Standard tables and sorted tables both belong to the generic group
index tables.

This table type is particularly suitable if you want the table to be sorted while
you are still adding entries to it. You fill the table using the (INSERT)
statement, according to the sort sequence defined in the table key. Table
entries that do not fit are recognised before they are inserted. The response
time for access using the key is in logarithmic relation to the number of
table entries, since the system automatically uses a binary search. Sorted
tables are appropriate for partially sequential processing in a LOOP, as long
as the WHERE condition contains the beginning of the table key.

Hashed Internal Tables

Hashes tables have no internal linear index. You can only access hashed
tables by specifying the key. The response time is constant, regardless of the
number of table entries, since the search uses a hash algorithm. The key of a
hashed table must be unique, and you must specify UNIQUE in the table
definition.

This table type is particularly suitable if you want mainly to use key access for
table entries. You cannot access hashed tables using the index. When you
use key access, the response time remains constant, regardless of the
number of table entries. As with database tables, the key of a hashed table is
always unique. Hashed tables are therefore a useful way of constructing and
using internal tables that are similar to database tables.

STANDARD TABLE

1. Liner Index.
2. Time is directly proportional to table enteries.
3. Operations-APPEND,READ,MODIFY,DELETE.
4. READ is used only in Standard enteries.

SORTED TABLE

1. Binary Search.
2. Time logmathrically proportional to table enteries.
3. Operations-INSERT.
4. It is used in LOOP with WHERE clause.

HASHED TABLE

1. UNIQUE key.
2. RESPONSE time is independent from table entries i.e CONSTANT.
3. It is useful to construct a table,resembles a database table.
4. It is processing large data.

Anda mungkin juga menyukai