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

difference between standard table and internal table

Former Member
0 Likes
2,765

please explain with example the difference between standard table and internal table?

I have created a structure with types(e.g. TYPES_STRUCT). I have created an internal table TYPES_T_STRUCT standard table of TYPES_STRUCT. Again an internal table IT_TYPES_STRUCT of type TYPES_T_STRUCT. What exactly is TYPES_T_STRUCT then? Is it an internal table or a header of internal table IT_TYPES_STRUCT? Is it necessary to write this statement if we donot use OCCURS 0 and why?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,746

its an internal table without header line.

in this case u need to handle workarea/header explicitly.

or add <b>With header line</b> for that statment to get implicit workarea.

9 REPLIES 9
Read only

Former Member
0 Likes
1,747

its an internal table without header line.

in this case u need to handle workarea/header explicitly.

or add <b>With header line</b> for that statment to get implicit workarea.

Read only

Former Member
0 Likes
1,746

hi sangeeta,

1. What exactly is TYPES_T_STRUCT then?

Its nothing but

a TYPE

ie. is a definition of how the table should be,

which-which fields should be in that table.

(types is only definitino, and not an

object/variable which holds memory)

2. we use occurs 0,

to say to abap that

we are trying to create a INTERNAL table

(with manyf fields, and multiple rows)

(instead of just 1 row)

regards,

amit m.

Read only

Former Member
0 Likes
1,746

IT_TYPES_STRUCT is an internal table without header line, if u want to create an internal table with header line use

data: IT_TYPES_STRUCT type TYPES_T_STRUCT with header line.

Read only

Former Member
0 Likes
1,746

HI

1 <u>INTERNAL TABLE</u>

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, <i>but unlike a database table, it cannot hold data after the program ends</i>. Use it as temporary storage for manipulating data or as a temporary private buffer.

2 TYPES_T_STRUCT IS AN INTERNAL TABLE WITHOUT HEADER LINE.

The <i>header line</i> 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.

3 <u>OCCURS n</u>

To define an internal table body, use occurs n on the definition of any field string except tables. occurs creates the body of the internal table. The memory for the body is not allocated until the first row is added to it. <i>Without occurs</i>, you only have a field string.

IF THIS FINDS USEFUL PLEASE REWARD POINTS

REGARDS

ANOOP

Message was edited by: ANOOP R.S

Read only

Former Member
0 Likes
1,746

Hi Sangeeta,

<b>Difference</b>

Internal table: It is a standard data type object, which exists only during the runtime of the program.If we don't want to use any explicit work area then its better to go for an internal table with header line.

Say for processing an internal tables we need to have a line type of the same which we call it as work area.

IT_ITAB is an internal table <b>without header line</b>.

In order to have a work area we make use of with <b>header line</b>.

Hope this will make you clear .

Cheers

Sunny

Rewrd points, if found helpful.

Message was edited by: Sunny

Read only

vinod_gunaware2
Active Contributor
0 Likes
1,746

<b>Internal Tables as Dynamic Data Objects</b>

Data objects that are defined either with the data type of an internal table, or directly as an internal table, are always fully defined in respect of their line type, key and access method. However, the number of lines is not fixed. Thus internal tables are dynamic data objects, since they can contain any number of lines of a particular type. The only restriction on the number of lines an internal table may contain are the limits of your system installation. The maximum memory that can be occupied by an internal table (including its internal administration) is 2 gigabytes. A more realistic figure is up to 500 megabytes. An additional restriction for hashed tables is that they may not contain more than 2 million entries. The line types of internal tables can be any ABAP data types - elementary, structured, or internal tables. The individual lines of an internal table are called table lines or table entries. Each component of a structured line is called a column in the internal table.

<b>Choosing a Table Type</b>

The table type (and particularly the access method) that you will use depends on how the typical internal table operations will be most frequently executed.

<b>

Standard tables</b>

This is the most appropriate type if you are going to address the individual table entries using the index. Index access is the quickest possible access. You should fill a standard table by appending lines (ABAP APPEND statement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command). The access time for a standard table increases in a linear relationship with the number of table entries. If you need key access, standard tables are particularly useful if you can fill and process the table in separate steps. For example, you could fill the table by appending entries, and then sort it. If you use the binary search option with key access, the response time is logarithmically proportional to the number of table entries.

<b>Sorted tables</b>

This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.

<b>

Hashed tables</b>

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.

regards

vinod

Read only

Former Member
0 Likes
1,746

Hi,

<b>Internal tables</b> are a standard data type object which exists only during the runtime of the program. They are used to perform table calculations on subsets of database tables and for re-organising the contents of database tables according to users need.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm

<b>Standard Tables:</b>

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3646358411d1829f0000e829fbfe/content.htm

Regards,

Anjali

Read only

0 Likes
1,746

Hi,

check this link ... you can find brief description of the same...

http://www.sapgenie.com/abap/tips/itab/Internal%20Table%2027-02-06.htm

Hope this helps,

Regards,

Kalyani

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,746

Hi,

Types : begin of TYPES_STRUCT,

matnr type mara-matnr,"Field

....

end of TYPES_STRUCT.

This is the structure.THis is not the internal table and not the header line.If you want only some of the specific fields in a database table,you can use this types to define those fields instead of referring the database table fully.If you want to some of the fields in one table and other fields from some other tables,you can use this types definition for that purpose.

data itab type standard table of TYPES_STRUCT.

Here itab is the internal table without header line of the type TYPES_STRUCT.That is it will hold multiple records.But for handling each record in the internal table,we need an work area.

data wa type TYPES_STRUCT.

*Here wa is the workarea.

select * from database_table into corresponding fields of table itab.

*Here we are populating the data from database table *into internal table.

loop at itab into wa.

*Using the loop we are writting each record into *workarea from internal table

write wa.

*Here we are writting each record through the workarea.

endloop.

Hope this helps you.If so,kindly reward points by clicking the star on the left of reply.