Application Development 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: 

internal table & work area

Former Member
0 Kudos

Hi all,

What is the purpose of defining work area,

why we are using the work area and internal table in the same program,Please explain me with simple example

1 ACCEPTED SOLUTION

Former Member
0 Kudos

example of declaring internal table without header line and with header line.

DATA:t_flight TYPE STANDARD TABLE OF ty_flight WITH HEADER LINE.

DATA:t_flight TYPE STANDARD TABLE OF ty_flight,

wa_flight TYPE ty_flight.

itab does not have work area it means workarea has same name of itab no explicit work area.

5 REPLIES 5

Former Member
0 Kudos

Hi,

work area holds single record

internal table holds group of records

Regards

Former Member
0 Kudos

Hi Kumar,

An internal table is a temporary table stored in RAM on the application server. It is created and filled by a program during execution and is discarded when the program ends. Like a database table, an internal table consists of one or more rows with an identical structure, but unlike a database table, it cannot hold data after the program ends. Use it as temporary storage for manipulating data or as a temporary private buffer.

Definition of an Internal Table

An internal table consists of a body and an optional header line(work area)

The body holds the rows of the internal table. All rows within it have the same structure. The term "internal table" itself usually refers to the body of the internal table.

The header line is a field string with the same structure as a row of the body, but it can only hold a single row. It is a buffer used to hold each record before it is added or each record as it is retrieved from the internal table.

Former Member
0 Kudos

Hi,

Workarea is like structure and at a time, it can handle only one record whereas internal table can hold many records.

In previous releases, workarea was not used explicitly whereas now that way of coding is obsolete and workarea should be explicitly defined now.

Regards,

kamalapriya

Former Member
0 Kudos

example of declaring internal table without header line and with header line.

DATA:t_flight TYPE STANDARD TABLE OF ty_flight WITH HEADER LINE.

DATA:t_flight TYPE STANDARD TABLE OF ty_flight,

wa_flight TYPE ty_flight.

itab does not have work area it means workarea has same name of itab no explicit work area.

Former Member
0 Kudos

Hi Kumar,

Difference between Internal Tables and Work Areas

INTERNAL TABLES

- Internal tables are used to obtain data from a fixed structure for

dynamic use in ABAP.

- Each line in the internal table has the same field structure.

- The main use for internal tables is for storing and formatting data from

a database table within a program.

WORK AREAS

- Work areas are single rows of data.

- It should have the same format as any of the internal tables.

- It is used to process the data in an internal table one line at a time.

Internal Tables with Header Line : Here the system automatically creates the work area. The work area has the same data type as internal table. This work area is called the HEADER line. It is here that all the changes or any of the action on the contents of the table are done. As a result of this, records can be directly inserted into the table or accessed from the internal table directly.

Internal Tables without Header Line : Here there is no work area associated with the table. Work area is to be explicitly specified when we need to access such tables. Hence these tables cannot be accessed directly.

HEADER LINE----

CREATED EXPLICITLY------

1.Internal table created by referring to another table

Syntax: Data <f> <type> [with header line].

<type> refers to a table data type or table data objects using type or like.

Here internal table <f> is created of the type <type>.

Example:

DATA t_line TYPE line OCCURS 10 with header line.

2. Internal table created by referring to existing structure

Syntax: Data<f> <type> occurs n [with header line].

The lines of the internal table <f> have the data type specified in <type> (Can use either like or type).

Example:

DATA flight_tab LIKE sflight OCCURS 10.

CREATED BY DEFAULT---

3. Internal table created With a new structure

Syntax: Data : Begin of <f> occurs <n>,

<component declaration>,

……………………………,

End of <f>.

Work area is created by default.

Example:

Data : Begin of itab occurs 10,

column1 type I,

column2(4) type C,

column3 like mara-ernam,

End of itab.

reward if useful

thanks and regards

suma sailaja pvn