6 Columns with Active Background
Active List Item Background

24DDIC2107 – SAP ABAP Internal Tables: Standard, Sorted and Hashed

Internal tables are a cornerstone of ABAP programming offering powerful tools for data manipulation and processing. There are three primary types of internal tables in ABAP: Standard, Sorted and Hashed. Each type has distinct characteristics and use cases. Let’s explore these in detail.

Standard Internal Table: The Basic Workhorse

Characteristics:

  1. Accepts Duplicate Records: Standard internal tables allow duplicate entries.
  2. Non-Unique Fields: All fields can be non-unique.
  3. Appending Data: Use the APPEND keyword to add data.
  4. Linear Search: Records are searched using a linear search method.

Syntax:

DATA <Internal Table> LIKE STANDARD TABLE OF <Work Area>.

Example:

DATA IT_STANDARD LIKE STANDARD TABLE OF WA.

 

Use Case:

Standard internal tables are ideal for general data processing tasks where duplicates are acceptable and a simple sequential access method is sufficient.

Sorted Internal Table: The Sorted Performer

Characteristics:

  1. Duplicate Records: May or may not accept duplicates based on key definition.
  2. Key Specification: At least one field must be specified as unique or non-unique.
  3. Inserting Data: Use the INSERT keyword to add data.
  4. Binary Search: Utilizes a binary search algorithm for faster searches.

Syntax:

DATA <Internal Table> LIKE SORTED TABLE OF <Work Area> WITH UNIQUE/NON-UNIQUE KEY <Field>.

Example:

DATA IT_SORTED LIKE SORTED TABLE OF WA WITH UNIQUE KEY Eid.

 

Use Case:

Sorted internal tables are useful for datasets that need to be automatically sorted upon insertion, providing quicker search capabilities than standard tables.

Hashed Internal Table: The Speed Specialist

Characteristics:

  1. No Duplicate Records: Duplicate entries are not allowed.
  2. Unique Fields: At least one field must be specified as unique.
  3. Collecting Data: Use the COLLECT keyword to add data.
  4. Hash Algorithm Search: Employs a hash algorithm for the fastest search performance.

Syntax:

DATA <Internal Table> LIKE HASHED TABLE OF <Work Area> WITH UNIQUE KEY <Field1> <Field2>.

Example:

DATA IT_HASHED LIKE HASHED TABLE OF WA WITH UNIQUE KEY Eid.

 

Use Case:

Hashed internal tables are perfect for scenarios where unique records are required and the highest search efficiency is needed.

Making the Right Choice

Choosing the appropriate type of internal table depends on the specific requirements of your application:

 Standard Internal Tables are best for basic data processing where duplicates are allowed and simple searches are adequate.

 Sorted Internal Tables are advantageous when data needs to be sorted automatically and faster search performance is required.

Hashed Internal Tables are the optimal choice for ensuring unique entries and achieving the quickest search results.

By understanding the characteristics and best use cases of each internal table type ABAP developers can enhance their programs performance and functionality.

Author : Aniket Pawar, 9373518385                            

6 Columns with Active Background

24DDIC2107 – SAP ABAP Internal Tables: Standard, Sorted and Hashed

Internal tables are a cornerstone of ABAP programming offering powerful tools for data manipulation and processing. There are three primary types of internal tables in ABAP: Standard, Sorted and Hashed. Each type has distinct characteristics and use cases. Let’s explore these in detail.

Standard Internal Table: The Basic Workhorse

Characteristics:

  1. Accepts Duplicate Records: Standard internal tables allow duplicate entries.
  2. Non-Unique Fields: All fields can be non-unique.
  3. Appending Data: Use the APPEND keyword to add data.
  4. Linear Search: Records are searched using a linear search method.

Syntax:

DATA <Internal Table> LIKE STANDARD TABLE OF <Work Area>.

Example:

DATA IT_STANDARD LIKE STANDARD TABLE OF WA.

 

Use Case:

Standard internal tables are ideal for general data processing tasks where duplicates are acceptable and a simple sequential access method is sufficient.

Sorted Internal Table: The Sorted Performer

Characteristics:

  1. Duplicate Records: May or may not accept duplicates based on key definition.
  2. Key Specification: At least one field must be specified as unique or non-unique.
  3. Inserting Data: Use the INSERT keyword to add data.
  4. Binary Search: Utilizes a binary search algorithm for faster searches.

Syntax:

DATA <Internal Table> LIKE SORTED TABLE OF <Work Area> WITH UNIQUE/NON-UNIQUE KEY <Field>.

Example:

DATA IT_SORTED LIKE SORTED TABLE OF WA WITH UNIQUE KEY Eid.

 

Use Case:

Sorted internal tables are useful for datasets that need to be automatically sorted upon insertion, providing quicker search capabilities than standard tables.

Hashed Internal Table: The Speed Specialist

Characteristics:

  1. No Duplicate Records: Duplicate entries are not allowed.
  2. Unique Fields: At least one field must be specified as unique.
  3. Collecting Data: Use the COLLECT keyword to add data.
  4. Hash Algorithm Search: Employs a hash algorithm for the fastest search performance.

Syntax:

DATA <Internal Table> LIKE HASHED TABLE OF <Work Area> WITH UNIQUE KEY <Field1> <Field2>.

Example:

DATA IT_HASHED LIKE HASHED TABLE OF WA WITH UNIQUE KEY Eid.

 

Use Case:

Hashed internal tables are perfect for scenarios where unique records are required and the highest search efficiency is needed.

Making the Right Choice

Choosing the appropriate type of internal table depends on the specific requirements of your application:

 Standard Internal Tables are best for basic data processing where duplicates are allowed and simple searches are adequate.

 Sorted Internal Tables are advantageous when data needs to be sorted automatically and faster search performance is required.

Hashed Internal Tables are the optimal choice for ensuring unique entries and achieving the quickest search results.

By understanding the characteristics and best use cases of each internal table type ABAP developers can enhance their programs performance and functionality.

Author : Aniket Pawar, 9373518385