Skip to Content
avatar image
Former Member

internal table & work area

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 17, 2008 at 08:30 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 17, 2008 at 08:18 AM

    Hi,

    work area holds single record

    internal table holds group of records

    Regards

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 17, 2008 at 08:21 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 17, 2008 at 08:22 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 17, 2008 at 08:43 AM

    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

    Add comment
    10|10000 characters needed characters exceeded