Skip to Content
avatar image
Former Member

difference between structures and internal tables

Hi

what is the difference between structures and internal tables.

And also i want to know about work area, header and body in detail.

Thanks&Regards,

S.Gangi Reddy.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

9 Answers

  • avatar image
    Former Member
    Dec 19, 2007 at 04:28 AM

    Internal Table :

    is a structure which is defined with a 'OCCURS 0' extension with the definition of the structure and can hold data.

    Structure:

    is a definition with the field details and which can not hold any data in it.

    in the case given by you:

    1) Data: lt_filetable TYPE filetable, (Table type)

    The 'filetable' is a table declaration with 'OCCURS 0' parameter.

    2) ls_file TYPE file_table. (Structure).

    the 'file_table' is a structure definition.

    Rewards if useful.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 19, 2007 at 04:29 AM

    hai,

    see abap 21 days book

    there it all explained very clearly.

    reward points usefull

    regards,

    jai.m

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 19, 2007 at 04:33 AM

    a structure do not occupy any memory

    until a variable is declared of its type

    an internal table is like a buffer with a structure similat to a table or a stucture

    internal table can be declared in two ways with or without header lines

    header lines work as an work area

    no row from a table is inserted directly into an internal table

    if an internal tabl eis without header line you have to declare a worrk area and append the desired row in the internal table through work area

    but in internal table with header lines fulfil this purpose automatically

    reward if useful

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 19, 2007 at 04:38 AM

    hi,

    check this link very usefull...

    http://www.erpgenie.com/abaptips/content/view/104/62/

    Reward points if usefull..

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 19, 2007 at 04:44 AM

    Hi,

    Structure: The object structure refers to the defination of object that does not have any contents. It is like table or view . but it never has entriues i.e it is only a structure. the basic difference between structure and table is tht the structure doesnot exist in the underlying database whereas table data exist in the underlying database..

    Internal Table: long life data is stored in database tables . u cant afford to lose data frm database tables in such cases where u can not work directly with database table. Hence need of intermediate table where u can put all the data from database tables where u can put in alll the data frm the database table and work with this data frm database table and work without accidentral lose of data these intermedaite tabels are called as internal tables.

    NO memory is reserved for these tables. they created duriong run time only.

    internal table has both work area and body .

    There are two kinds of internal tables they are

    1. With header and

    2. Without header.

    With header here both the name of work area and body will be same.

    Without Header: here the name of work area and body have different name..

    work area or header : is one where only one record can be stored .at once and it is the one which will stored first.

    Body: here the list of records will be stored.but initailly it willl be stored into the work area abd then into the body of internal table.

    Regards,

    Sana.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 19, 2007 at 04:58 AM

    astructure do not occupy any memory

    until a variable is declared of its type

    an internal table is like a buffer with a structure similat to a table or a stucture

    internal table can be declared in two ways with or without header lines

    header lines work as an work area

    no row from a table is inserted directly into an internal table

    if an internal tabl eis without header line you have to declare a worrk area and append the desired row in the internal table through work area

    but in internal table with header lines fulfil this purpose automatically

    Edited by: santhosh goud on Dec 19, 2007 5:59 AM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 19, 2007 at 05:13 AM

    Hi Satti,

    Structure : If you want the data type with combination of any data types we can create structure in the it can not occupy any memory, it create memory when we creare any variable by using this structure, we can create the structure by using Type .

    Internal Table: When we want to store more than one line (like Arry or Table) with same type we use internal table.

    We can create internal table by refer the structure .

    Header line: Header line is nothing but a work area we can read and insert any data by using this work aread work area we con't insert records directly to internal table fist we asign data to header line and then we append the header line to our internal table.

    EX-

    This is work area for internal table

    Data: Begin of fs_stru,

    num type i,

    name type c,

    end of fs_stru,

    This is our internal table

    Data : t_table type table of fs_stru.

    fs_stru-num = 1.

    fs_stru-name = 'Satti'.

    append fs_stru to t_Table. ( We can append like this)

    Plz Reward if useful,

    Mahi.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 19, 2007 at 06:08 AM

    Structures:

    A structure is a sequence of any elementary types, reference types, or complex data types. You use structures in ABAP programs to group work areas that logically belong together. Since the elements of a structure can have any data type, structures can have a large range of uses. For example, you can use a structure with elementary data types to display lines from a database table within a program. You can also use structures containing aggregated elements to include all of the attributes of a screen or control in a single data object.

    Eg.

    TYPES :BEGIN OF x_item,

    shinum(17) TYPE c,

    inponum(20) TYPE c,

    scode(1) TYPE c,

    rdate(8) TYPE c ,

    End of x_item.

    Internal Table: Internal tables consists of a series of lines that all have the same data type.

    BEGIN OF t_vttk OCCURS 0 ,

    tknum TYPE vttk-tknum ,

    shtyp TYPE vttk-shtyp ,

    tplst TYPE vttk-tplst ,

    erdat TYPE vttk-erdat ,

    erzet TYPE vttk-erzet ,

    vsart TYPE vttk-vsart ,

    dtabf TYPE vttk-dtabf ,

    uzabf TYPE vttk-uzabf,

    tdlnr TYPE vttk-tdlnr ,

    END OF t_vttk ,

    Work Area: w_likp_vttk LIKE LINE OF t_likp_vttk,

    It will store small amount of datas.

    Regards,

    Ari

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 19, 2007 at 06:33 AM

    Dear Gangireddy,

    A structure is just another data type. We have data types i, p, n, c etc which specify the format in which a single data item can be stored. Similarly, a structure is a complex type, built based on the basic types like i, p etc so that it is suitable for storing multiple data items.

    Now using these complex types (structures), we can declare variables which are called work areas and internal tables.

    Eg:

    DATA jan type i.

    declares a single variable of type integer. You can assign only a single value to it at a time using the statement

    jan = 31.

    When you need to store a set of values to a variable, say the number of days of all months in an year. Here, we'll use a complex type called structure.

    TYPES: begin of my_stru,

    jan type i,

    feb type i,

    mar type i,

    .....

    dec type i,

    end of my_stru.

    So, the structure definition above is just a format which in plain language says "This is a type to be used to declare variables that can hold together 12 data items of type integer."

    Note that this time we declare data with type my_stru.

    DATA month type my_stru.

    Which means that you can assign multiple values at a time to this variable using the series of statements:

    month-jan = 31.

    month-feb = 28.

    month-mar = 31.

    ..........

    month-dec = 31.

    Hope you can imagine now a box containing 12 columns having data 31, 28, 31, .... , 31.

    Now here, only one row of data can be stored. This is a work area. If you want to hold together multiple work areas having the similar structure, instead of maintaining separate work areas, you can create another category of variable called an Internal table.

    DATA year type stru occurs 0.

    or

    DATA year type table of stru.

    or

    DATA year type <table_type>

    (table type is another complex data type that is used for internal tables alone)

    Now assigning data to an internal table is done one row at a time using either a work area or a header line. You need a LOOP AT <ITAB> INTO <WA>. --- ENDLOOP block here. Hope you are aware of this.

    A header line is used as a substitute to a work area. You must be aware that to operate an internal table, you need to have a work area. Now when this work area is directly built into the internal table, it is called a header line. In this case, the the name of the internal table itself denotes the built-in work area. More clearly, if <ITAB> has a header line, LOOP AT <ITAB> means that each iteration will have the corresponding record available in the built-in work area.

    Thats my understanding about structures, work areas, internal tables and header lines.

    Just bear one thing in mind. Structures/Table types are different from work areas/internal tables in the same way how data types (c, n, p, i etc.) are different from variables.

    Add comment
    10|10000 characters needed characters exceeded