‎2008 Feb 18 6:53 AM
‎2008 Feb 18 6:56 AM
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
‎2008 Feb 18 6:57 AM
Hi,
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.
Hope this helps.
Reward if helpful.
‎2008 Feb 18 6:57 AM
hi,
You access internal tables line by line. You must use a work area as an interface for transferring data to and from the table.
When you read data from an internal table, the contents of the addressed table line overwrite the contents of the work area.
When you write data to an internal table, you must first enter the data in the work area from which the system can transfer the data to the internal table.
hope it is useful.
regards,
sreelakshmi
‎2008 Feb 18 6:58 AM
Hi
Hope it wil help you.
Pls reward if help.
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.
‎2008 Feb 18 7:12 AM
Hi,
Internal tables can be defined with or without a header line. An internal table with header line consists of a work area (the header line) and the actual body of table, both of which are addressed with the same name.
How this name is interpreted depends on the context in which it is used. For example: at MOVE the name is interpreted to mean the header line, while at SORT it is interpreted as
the table body
In the case of Internal tables without a header line we have to define work area explictly of type same as the internal table .
The data coming into body of the internal table going out of the internal table will be through the Work area.
Regards
vikram
‎2008 Feb 18 7:19 AM
Hi phanidhar,
The Tables: <name> statement declares an ABAP Dictionary table in the ABAP program and allocates a table work area with the structure of <name>. These work areas can hold single row of data.
The Select statement reads the table <name> line by line and places each line read in the table work area.
The structure of the workarea is same as that of the table.
Note: Double-clicking on the Tables: statement in the editor will display how the table is defined in the data dictionary.
Thanks
Anand D
‎2008 Feb 18 7:24 AM
Hi
Actually an Internal Table is 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.
But 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.
Explicit work area is when you declare a work area separately from the table
Implicit work area is the header line of the table (if the table is declared to have a header line)
For which is the better approach, refer to this thread
Regards,
Rohini.
‎2008 Feb 18 7:28 AM
Hi,
Internal table consists of work area and body.
it is not possible to display records from internal table body it self.
so it is must to have a internal table work area for displaying records,
suppose you have one select statement.if the select statement executes the internal table body will fill up
with data.now the data is in internal table body.As we said that it is not possible to display data from internal
table body it self that time we use internal table work area.
see
loop at it_itab into wa_itab.
here it_itab is internal table body.
wa_itab is internal table work area..
reply post if you have any dought regarding work area.
regards,
swami.