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

Internal Table Doubt!!!

Former Member
0 Likes
849

Hi!

I ve doubt on the following,

1) Data: Begin of itab occurs 10

......, end of itab.

In the above what will happen if i store records more than 10 & less than 10 records

if more than 10 where records will be stored .

if i store 5 then whats the remaining storage space.

2) Types of internal Table

SOrted, Hashed, index, standard

Can u pls explain in short terms(i dont want big details) good understanding

&&&

which one from above improve performance

3) see this,

types: begin of ty_itab occurs 0,

mara like mara-matnr.

.............

end of ty_itab,

ty_t_itab type standard table of ty_itab with default key.

Data: it_itab type ty_t_itab.

it_itab2 like it_itab

or it_itab2 type ty_t_itab.

i want to know,

ty_t_itab is an internal table with header line or not

&

it_itab, it_itab2 has header line or not

Pls reply guys, looking for your reply.

Thanks In Advance.

Rahul.

1 ACCEPTED SOLUTION
Read only

former_member189059
Active Contributor
0 Likes
780

1) occurs 10 means that SAP reserves space for 10 rows initially

so you store 5 rows then the remaining space goes to waste

if you store more than 10 rows then the number of rows gets incremented automatically

6 REPLIES 6
Read only

Former Member
0 Likes
780

Hi,

<b>if more then 10 then records will be stored in the table itself

if less than 10 then space willbe reserved for 10 records</b>

<b>Standard Tables:</b>

Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.

This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to

the number of table entries.

<b>Sorted Tables:</b>

Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.

This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of

table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.

<b>Hashed Tables:</b>

Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.

This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and

using internal tables that are similar to database tables.

<b>it_itab, it_itab2 has header line</b>

Regards,

ravish

plz dont forget to reward points if useful

Read only

former_member189059
Active Contributor
0 Likes
781

1) occurs 10 means that SAP reserves space for 10 rows initially

so you store 5 rows then the remaining space goes to waste

if you store more than 10 rows then the number of rows gets incremented automatically

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
780

HI,

1) Data: Begin of itab occurs 10

......, end of itab.

<b>In the above what will happen if i store records more than 10 & less than 10 records

if more than 10 where records will be stored .</b>

At the runtime your internal table will get 10 more records every time there is a need to store more.

<b>if i store 5 then whats the remaining storage space.</b>

Initially you have got memory for 10 rows so your 5 rows will remain there as the program has already allocated the memory to you.

2) Types of internal Table

SOrted, Hashed, index, standard

<b>Can u pls explain in short terms(i dont want big details) good understanding

&&&

which one from above improve performance</b>

STANDARD TABLE: Indexed and Ordered ( Means you can access using INDEX and ORDER is preserved). Cannot have unique key.

SORTED TABLE: (Sorted by key, so order changes as per the sorting, can be accessed using INDEX). Cn have both Unique and non-unique key.

HASHED TABLE: No order and no index access, accesss only using KEY. ANd always UNIQUE key no duplicatse possible.

IF you want to READ using KEY HASHED is better, followed by SORTED and lastly STANDARD.

IF you want to READ BY INDEX then STANDARD followed by SORTED.

3) see this,

types: begin of ty_itab occurs 0,

mara like mara-matnr.

.............

end of ty_itab,

ty_t_itab type standard table of ty_itab with default key.

Data: it_itab type ty_t_itab.

it_itab2 like it_itab

or it_itab2 type ty_t_itab.

i want to know,

<b>ty_t_itab is an internal table with header line or not

&

<b>it_itab, it_itab2 has header line or not</b>

<b>YOU CANNOT USE TYPES and OCCURS with BEGIN OF.</b>

Regards,

Sesh

Read only

Former Member
0 Likes
780

Hi,

1) More than10 records will be stored in the table itself.

less than 10 will also be stored as the sapce will be allocated for 10 records.

2)1. Types of internal tables

1.1 STANDARD table

Key access to a standard table uses a linear search. This means that the time required for a search is in linear relation to the number of table entries.

You should use index operations to access standard tables.

1.2 SORTED table

Defines the table as one that is always saved correctly sorted.

Key access to a sorted table uses a binary key. If the key is not unique, the system takes the entry with the lowest index. The runtime required for key access is logarithmically related to the number of table entries.

1.3 HASHED table

Defines the table as one that is managed with an internal hash procedure

You can only access a hashed table using the generic key operations or other generic operations ( SORT, LOOP, and so on). Explicit or implicit index operations (such as LOOP ... FROM oe INSERT itab within a LOOP) are not allowed.

3) ty_t_itab is an internal table without header line

it_itab, it_itab2 has no header line . You need to declare a work area.

Regards,

Priyanka.

Read only

former_member189059
Active Contributor
0 Likes
780

<i>types: begin of ty_itab occurs 0,

mara like mara-matnr.

.............

end of ty_itab,

ty_t_itab type standard table of ty_itab with default key.

Data: it_itab type ty_t_itab.

it_itab2 like it_itab

or it_itab2 type ty_t_itab.</i>

few points

1. in types declaration, we cannot have occurs 0. ie: we cannot define a type as an internal table

2. it_itab and it_itab2 are tables without header lines

you will have to declare

Data: it_itab type ty_t_itab with header line.

to make it have a header line

Read only

former_member189059
Active Contributor
0 Likes
780

To check if a table has a header line or not, use this method

make a program with your code (im using your same code here with errors commented out)

report ztest12345.

types: begin of ty_itab," occurs 0,
mara like mara-matnr,
*.............
end of ty_itab,
ty_t_itab type standard table of ty_itab with default key.

Data: it_itab type ty_t_itab with header line,
it_itab2 like it_itab.
*or it_itab2 type ty_t_itab.

write: 'hi'.

Save and activate your program and then put a break point at the 'Hi' statement

run the program and let it reach the break point

then double click on it_itab and it_itab2

if you see a blue and orange square symbol to the left of the tablename in the display that means its a table, else it is a structure

for a table, double click on that blue and orange symbol

if you see a 'cap' symbol (looks a bit like a cup of coffee) under the number 1, then it means that the table has a header line