SAP ABAP Indexes
In SAP ABAP, indexes are used to avoid the duplicate data and improve the performance while accessing the table. The different types of indexes are
- Primary Indexes
- Secondary Indexes
Primary Indexes: Primary indexes in SAP are created automatically by the SAP system using key fields of database tables.
Secondary Indexes: Secondary Indexes are created manually and managed by the SAP ABAP consultant. We can create up to 9 secondary indexes. In real time, secondary indexes are not advisable, it is allowed based on the requirements of project.
How to Create secondary indexes in SAP ABAP
Transaction code | SE11 |
SAP Menu Path | SAP Menu > Tools > ABAP Workbench > Development > SE11 – ABAP Dictionary |
Step 1: Execute tcode “SE11” in the SAP command field.
![SAP Tcode SE11](https://www.tutorialkart.com/wp-content/uploads/2019/06/SAP-Tcode-SE11.png)
Step 2: In next ABAP Dictionary: Initial screen, enter the database table name and click on change button.
![ABAP dictionary - Indexes](https://www.tutorialkart.com/wp-content/uploads/2019/06/ABAP-dictionary-Indexes.png)
Step 3: In next screen, Dictionary maintain table, click on indexes button as shown below image.
![Choose indexes in SAP](https://www.tutorialkart.com/wp-content/uploads/2019/06/Choose-indexes-in-SAP.png)
Step 4: Now a window opens “Indices for the Table ZEMPLOYEE” click on create icon.
![create indexes in SAP](https://www.tutorialkart.com/wp-content/uploads/2019/06/create-indexes-in-SAP.png)
Step 5: Choose “Create Index”
![create index](https://www.tutorialkart.com/wp-content/uploads/2019/06/create-index.png)
Step 6: Enter the name of index, allowed up to 3 character. Press enter to continue.
![create index in sap abap](https://www.tutorialkart.com/wp-content/uploads/2019/06/create-index-in-sap-abap.png)
Step 7: In next screen “Dictionary: Maintain Index” update the following details.
- Short description: Enter the description of secondary indexes.
- Choose the table fields for choosing the required fields.
![Maintain index in SAP ABAP](https://www.tutorialkart.com/wp-content/uploads/2019/06/Maintain-index-in-SAP-ABAP.png)
Choose the required fields and click on copy button.
![Field selection for SAP indexes](https://www.tutorialkart.com/wp-content/uploads/2019/06/Field-selection-for-SAP-indexes.png)
Step 8: Now click on activate icon to activate the created indexes in SAP ABAP.
![Activate SAP ABAP Indexes](https://www.tutorialkart.com/wp-content/uploads/2019/06/Activate-SAP-ABAP-Indexes.png)
Choose the local object and save the created SAP ABAP indexes.
How to delete secondary indexes in SAP
Step 1: Refer above step 1, step 2 and step 3. i.e enter the database table and click on change option. Now choose the indexes option.
Step 2: Now choose the unwanted indexes and click on delete icon to delete the secondary indexes in SAP.
![delete secondary indexes in SAP ABAP](https://www.tutorialkart.com/wp-content/uploads/2019/06/delete-secondary-indexes-in-SAP-ABAP.png)
Step 3: A warning message displays on the screen, choose Yes to delete index.
![delete index in SAP](https://www.tutorialkart.com/wp-content/uploads/2019/06/delete-index-in-SAP.png)
Successfully index was deleted in SAP.
![ZEM index deleted](https://www.tutorialkart.com/wp-content/uploads/2019/06/ZEM-index-deleted.png)