Tuesday, July 22, 2025

📘HOW TO CREATE INDEXES IN SAP ABAP


🔹 Types of Indexes

  • Primary Index

  • Secondary Index


🔸 Primary Index

  • The Primary Key will act as a Primary Index.

  • When we assign a primary key to a database table and activate the table:

    • SAP automatically creates the primary index.

  • Example:

    • When we search order based on order number, we always get high performance.

    • This is because SAP uses the primary index, which is fast and optimized.

🔸 Why Secondary Index?

  • If we want to search order number based on order date, this is a non-primary key field.

  • In such cases:

    • If the table has a huge number of records, performance may drop.

    • To improve performance, we create a Secondary Index.

🔹 Secondary Index

  • Helps to directly navigate to a particular record.

  • Example:

    • Create a secondary index on Order Header Table for field Order Date.

🛠️ Steps to Create a Secondary Index

  1. Go to Change Mode of the table.

  2. Click on “Indexes”.

  3. Click on Create Index.

  4. Index Name must be 3 characters long.

    • Example: ODT for Order Date

  5. Provide a Short Description for the index.

  6. Choose the Field Name you want to index (e.g., Order Date).

  7. Initially, the system shows:

    • Index does not exist in database system ORACLE.

  8. Click Save, Check, and Activate the index.


📝 Important Notes

  • Index will be stored in the format:
    TableName~IndexName
    Example: ZEMPTABLE~ABC
    (ZEMPTABLE = Table Name, ABC = Index Name)

⚙️ Index Creation Options

  • Index for all database systems
    ➤ Index will be created on all supported databases.

  • Index for selected database systems
    ➤ You can select specific databases where the index is to be created.

  • No database index
    ➤ Index will be removed from the database, but the definition remains.

⚠️ Disadvantage of Indexes

  • Indexes occupy space on the database layer, which can increase storage usage.

No comments:

Post a Comment