Internal Tables


What are the internal tables?
What are internal tables?
What is an internal table?

Internal table is a temporary table that is created, used during the program execution, and deleted before the program terminated. Internal tables used to store the dynamic data sets from a fixed structure in the main/working memory in ABAP. The lifetime of the table is until end of the program execution. Internal tables fulfill the function of arrays in ABAP.

Explain the different types?
How many types of internal table?
What types of Internal tables exist?

The Internal table type are -
Standard Internal Tables -
This table type is particularly appropriate if we 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. Standard tables have a linear index. We can access them using either the index or the key. If we 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 we may not include any specification for the uniqueness in the table definition.

Sorted Internal Tables -
Sorted tables are always saved sorted by key. They also have a linear key. Like standard tables, we can access them using either the table index or the key. The key of a sorted table can be either unique, or non-unique, and we should 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 we want the table to be sorted while we are still adding entries to it.

Hashed Internal Tables -
Hashes tables have no internal linear index. We 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 we must specify UNIQUE in the table definition. This table type is particularly suitable if we want mainly to use key access for table entries. We cannot access hashed tables using the index.

Index Tables -
Index table is only used to specify the type of generic parameters in a FORM or FUNCTION. That means we can't create a table of type INDEX. Internal tables are not DB tables. Standard and Sorted tables in combined are basically called as Index tables and there nothing else.

What do you understand by work area and internal tables in ABAP? Why do we use it?

Both are temporary memory areas and are used to store the data at run-time.
Internal tables and work areas represents the instances of database tables.

Explain the use of insert and append statement in SAP ABAP?
Why are insert and append statement used in SAP ABAP?

Append statement used to add a record at the end of internal table in work area.
Insert statement used to add a record at specified location of internal table in work area.

How memory management happens for internal tables and work areas in ABAP?

8KB memory is allocated to internal table and work areas initially and increases dynamically when required.

What are the Data Types of Internal Tables?

There are three types of internal tables and those are -

  1. Line
  2. Key
  3. Table

If internal table used in for all entries in empty, then what happens?

No, records will be displayed.

What Is the difference between Sum and Collect?

Sum: We can only use this statement within a LOOP. If we use SUM in an AT - ENDAT block, the system calculates totals for the numeric fields of all lines in the current line group and writes them to the corresponding fields in the work area. If you use the SUM statement outside an AT - ENDAT block, the system calculates totals for the numeric fields of all lines of the internal table in each loop pass and writes them to the corresponding fields of the work area.
COLLECT: It allows us to create unique or summarized datasets. The system first tries to find a table entry corresponding to the table key. The key values are taken either from the header line of the internal table itab, or from the explicitly specified work area wa.

What are Internal Tables? How do you get the number of lines in an Internal Table? How to use a specific number occurs statement?

  • It is a standard data type object, that exists only during the runtime of the program. They are used to perform table calculations on subsets of database tables and for re-organizing the contents of database tables according to users need.
  • Using SY-DBCNT.
  • The number of memory allocations the system needs to allocate for the next record population.

Do you know about the different data types of internal tables?

Key, Line, and Table are the three different data types of internal tables.

What are the uses of append statement and insert in SAP ABAP?
State the two methods needed to modify the standard tables of SAP.

The append statement is used to add a record at the end of the internal table.
The Insert statement used to add a record at a specific location.

What is the meaning of Data Clusters?

Data clusters provides a way to group every type of complex internal data object from an application in ABAP/4. They are also placed in the memory of ABAP/4 for a limited time or for a longer time. The databases of this type have the name accordingly, they are named cluster databases and their construction as predefined. The placing of this type of data clusters is a feature of ABAP/4. With the support of SQL statements, it is possible to enter cluster databases and the data clusters that have been placed in ABAP/4 can be decoded only by ABAP/4.

At the creation of internal tables what is the criteria configuration of the value of an occurs?

We should configure the occurs value to make optimizations. Below are some notes to keep in mind before configuration -

  • The default size declared should maintain in the roll area for the faster program access.
  • The whole data area of the application should be less than 64 kilobytes.
  • The data inserted that is bigger than the default size is placed in the roll file and the program getting accessed slow. So the data should be lesser size than default size for insertion.

What is the best way for reading database table lines in an internal table in the form of packs of a known size?

SELECT * FROM SPFLI INTO TABLE ITAB PACKAGE SIZE N (N being the variable). We should give a name to the WILDCARD (*) characters that are meant to be compared with numeric and character strings.

How can we describe the following commands: MODIFY LINE and READ LINE?

The MODIFY LINE statement is meant for changing the lines of a full list from inside the program.
READ LINE statement is used for reading data on the lines from the current levels. READ LINE is the same as READ CURRENT LINE and they are both related to HIDE.

Which are the buffering types?

Buffering types are full, generic, or single record.

  • In Full buffering, the entire table or nothing found in the buffer.
  • In Generic buffering, the generic locations are buffered entirely.
  • In Single record buffering, the currently accessed records loaded into buffers.

What is generic key and generic area?

The generic key is the left part of the table key. The generic area represents every record that correspond to generic key fields.

What is an internal table and work area in SAP ABAP?

Internal tables and work areas are temporary memory areas that are used to store data at run-time. Internal tables and work areas are instances of database tables.

How much memory will be allocated for internal table and work area?

8KB memory allocated for both internal tables and work areas and can increased dynamically.

What is difference between append and insert statements in SAP ABAP?

Append statement is used to add a record at bottom of a internal table from work area .
Insert statement is used to insert a record at a specified position of an internal table from work area.

What is occurs in internal table?

Occurs addition to the declaration gives initial size to that table. Occur statement allocates 8kb of memory to the internal table.

What is the difference between CHECK TABLE and VALUE TABLE?

CHECK TABLE -
A foreign key links two tables T1 and T2 by assigning fields of table T1 to the primary key fields of table T2. Table T2 is then known as the check table of the foreign key.

VALUE TABLE -
Sometimes when we define a domain, we already know that all fields of the domain need to be checked against a table. We can store this information in the domain definition by specifying a value table.
If we try to define a foreign key for a field that points to this domain, the value table of the domain is proposed as the check table for the foreign key.

What is the difference between SY-INDEX and SY-TABIX?
What is the difference between SY-TABIX and SY-INDEX?

SY-TABIX is a system variable that stores the index current processing record of an internal table.
SY-INDEX is a system variable that acts as a loop iteration counter, it stores loop iteration number.

So, when we are looping over an internal table, we use SY-TABIX.
LOOP AT ITAB INTO WA. **SY-TABIX stores index number of internal table record
ENDLOOP.

When we use DO ENDDO / WHILE for looping, there is no table involved. So, we use SY-INDEX.
DO 10 times. **SY-INDEX stores number of iterations of loop
ENDDO.

Can we sort internal table without using SORT statement? Explain?

We can sort internal table without using SORT statement by declaring sorted internal table. For ex - DATA <new-sort-table> TYPE SORTED TABLE OF <input-table>.

What is difference between Internal Table without Header Line and Internal Table with Header Line.

Internal Table without Header Line creates an internal table and work area separately. When the Internal Table with header table creates the work area automatically with the same name of the internal table.

Describe Internal Table and Work area?

An Internal table is a temporary table that contains the records of an ABAP Program while the program is being executed. An internal table exists only during run time of a SAP program. Internal table are used to process large volumes of data by using the ABAP language. We should declare an internal table in an ABAP program when we need to retrieve data from database tables. Internal table can act as data type and data object.
A work area is a temporary memory space that helps in reading and modifying the data of an internal table line by line.

What will happen if I sort a sorted internal table?

Nothing will happen because the table is already sorted.