Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Internal table and work area

Former Member
0 Likes
2,713

Hi,

can anybody explain the concepts of Internal table and work area.Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,793

there are two types of internal tables .

one with header line and the other wothout header line.

the internal table occupies memory only at run time.

In case of internal table with header line , the first line of the table is the header or the workarea where the manipulations are done.

For an internal table without header line , the work area is not a part of the internal table . it is a seperate area where the manipulations are done and the internal table is updated.

there are two types of internal tables .

one with header line and the other wothout header line.

the internal table occupies memory only at run time.

In case of internal table with header line , the first line of the table is the header or the workarea where the manipulations are done.

For an internal table without header line , the work area is not a part of the internal table . it is a seperate area where the manipulations are done and the internal table is updated.

6 REPLIES 6
Read only

Kanagaraja_L
Active Contributor
0 Likes
1,793

internal tables are used for storing records which are obtained as a result when we use select statement on database. internal tables are run time entities and doesn't occupy any memory. they are dynamic.

internal tables are of types.

1. internal tables with header line. header and body

2. internal tables with out header line. only body

workarea is the concept which is mainly useful when working with internal tables with out header line.

at any point of time we can access only one record through header of a internal table. every thing should be done inserting,modifying, reading through header only.

ex: data: itab like standard table of mara with header line.

for internal tables with out header line we will create a work area explicit header as type of table for storing data into internal table.

ex: data: itab like mara,

wa like mara.

Internal tables are of 4 types

1) Standard table

2) Sorted table

3) Hashed table

4) Index table

Standard table

Defines the table as a standard table. This will always strore the data into internal table in the sorting order on Key Field using Linear search. This means that the time taken for searching records would be based on no. of records we are reading from the database. You should use index operations to access standard tables.

Syntax:

data : itab type standard table of vbak.

Sorted table

Always defines the table in a sorted order. The records stored in this table will always be sorted using binary saerch on Key Field. If the key is not unique, the system takes the entry with the lowest index. The runtime required for key access is logarithmically related to the number of table entries. You can also access sorted tables by index operations.

Syntax:

data : itab type sorted table of dfkkop with unique key vkont.

(or)

data : itab type sorted table of dfkkop with non-unique key vkont.

Hashed table

Defines the table as one that is managed with an internal hash procedure. You can imagine a hashed table as a set, whose elements you can address using their unique key. Unlike standard and sorted tables, you cannot access hash tables using an index. All entries in the table must have a unique key. Access time using the key is constant, regardless of the number of table entries.

Syntax:

data : itab type hashed table of dfkkop with unique key vkont.

(or)

data : itab type hashed table of dfkkop with non-unique key vkont.

Index table

An index table is one that you can access using an index. Hashed tables are not index tables, and cannot therefore be passed to parameters defined as INDEX TABLE.

Kanagaraja L

Read only

0 Likes
1,793

Hi Kanagaraj /Priya raj

Thank you for your immediate responses , can you please give the syntax , In which cases can we use internal table and in which cases can we use wa.I am expecting your reply.................

Read only

0 Likes
1,793

Syntax is as folows:

DATA : LIT_TEST TYPE YCUSTOMER OCCURS 0 WITH HEADER LINE .

DATA : WA_TEST LIKE LIT_TEST .

Hope u find it usefull.

Please awqrd points.

Regards,

Rahul

Read only

Former Member
0 Likes
1,794

there are two types of internal tables .

one with header line and the other wothout header line.

the internal table occupies memory only at run time.

In case of internal table with header line , the first line of the table is the header or the workarea where the manipulations are done.

For an internal table without header line , the work area is not a part of the internal table . it is a seperate area where the manipulations are done and the internal table is updated.

Read only

Former Member
0 Likes
1,793

u cannot use the internal table with header line when u deal with abap objects. no big difference other than that.

refer help document-980 for syntax.

Read only

Former Member
0 Likes
1,793

hai,

This may help u.

WORKAREA is a structure that can hold only one record at a time. It is a collection of fields. We use workarea as we cannot directly read from a table. In order to interact with a table we need workarea. When a Select Statement is executed on a table then the first record is read and put into the header of the table and from there put into the header or the workarea(of the same structure as that of the table)of the internal table and then transferred top the body of the internal table or directly displayed from the workarea.

Each row in a table is a record and each column is a field.

While adding or retrieving records to / from internal table we have to keep the record temporarily.

The area where this record is kept is called as work area for the internal table. The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.

Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.

e.g.

data: begin of itab occurs 10,

ab type c,

cd type i,

end of itab. " this table will have the header line.

data: wa_itab like itab. " explicit work area for itab

data: itab1 like itab occurs 10. " table is without header line.

Internal tables are used for storing records which are obtained as a result when we use select statement on database. internal tables are run time entities and doesn't occupy any memory. they are dynamic.

internal tables are of types.

1. internal tables with header line. [header and body]

2. internal tables with out header line. [only body]

Workarea is the concept which is mainly useful when working with internal tables with out header line.

at any point of time we can access only one record through header of a internal table. every thing should be done [inserting,modifying, reading ] through header only.

ex: data: itab like standard table of mara with header line.

for internal tables with out header line we will create a work area [explicit header] as type of table for storing data into internal table.

ex: data: itab like mara,

wa like mara.

more about internal table types:

Standard table:

The key access to a standard table uses a sequential search. The time required for an access is linearly dependent on the number of entries in the internal table.

You should usually access a standard table with index operations.

Sorted table:

The table is always stored internally sorted by its key. Key access to a sorted table can therefore use a binary search. If the key is not unique, the entry with the lowest index is accessed. The time required for an access is logarithmically dependent on the number of entries in the internal table.

Index accesses to sorted tables are also allowed. You should usually access a sorted table using its key.

Hash table:

The table is internally managed with a hash procedure. All the entries must have a unique key. The time required for a key access is constant, that is it does not depend on the number of entries in the internal table.

You cannot access a hash table with an index. Accesses must use generic key operations (SORT, LOOP, etc.).

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.

TYPES VECTOR TYPE HASHED TABLE OF I WITH UNIQUE KEY TABLE LINE.

TYPES: BEGIN OF LINE,

COLUMN1 TYPE I,

COLUMN2 TYPE I,

COLUMN3 TYPE I,

END OF LINE.

DATA ITAB TYPE HASHED TABLE OF SPFLI

WITH UNIQUE KEY CARRID CONNID.

with regards,

B.Sowjanya,

reward points if helpful.