Friday, June 27, 2025

πŸ“˜ SAP ABAP – Internal Tables: Interview Questions & Answers

✅ 1. How to delete duplicates from an internal table?

  • Use DELETE ADJACENT DUPLICATES FROM i_tab after sorting.

  • Use COMPARING to restrict which fields determine duplicates.

πŸ”Ή Example:

SORT i_tab BY matnr werks logort. DELETE ADJACENT DUPLICATES FROM i_tab COMPARING matnr werks.

✅ 2. What are the types of internal tables?

  1. Standard Tables – Linear index, slower for large data.

  2. Sorted Tables – Maintains order, binary search, fast read by key.

  3. Hashed Tables – No index, uses hash algorithm, fastest for key-based access.

✅ 3. What is the size of an internal table?

  • Controlled using OCCURS n (commonly OCCURS 0).

  • Memory is allocated dynamically as entries increase.

  • Affects performance, not actual size.

✅ 4. What is the effective way of using internal table records?

  • Define internal table without header line.

  • Use a work area to perform operations.

  • Always CLEAR the work area after use.

✅ 5. Explain Sorted Tables.

  • Entries inserted in sorted order using INSERT.

  • Uses binary search.

  • Duplicate keys not allowed.

  • Best for partially sequential processing.

✅ 6. What is the difference between internal table and structure?

  • Internal Table holds multiple records.

  • Structure holds a single record during runtime.

✅ 7. What are field groups and internal tables?

  • Field Group: Logical group of similar fields.

  • Internal Table: Temporary memory used to store records at runtime.

✅ 8. What is SAP internal table key?

  • Identifies rows; can be:

    • Standard Key

    • User-defined Key

  • Keys can be UNIQUE or NON-UNIQUE.

  • Sequence of key fields matters for sorting and performance.

✅ 9. Explain Hashed Tables.

  • Best for key-based access.

  • Constant response time regardless of size.

  • Cannot access by index.

  • Must have a unique key.

✅ 10. What do you mean by table types?

  • Defines how data is accessed (index/key/hashed).

  • Types: Standard, Sorted, and Hashed.

  • Selection depends on performance and access needs.

✅ 11. What are control levels in internal tables?

Used in LOOPs:

  1. AT FIRST

  2. AT NEW

  3. AT END OF

  4. AT LAST

  5. ON CHANGE OF

✅ 12. How can you specify internal tables as data objects?

  • Defined by line type, key, and access method.

  • Dynamic in size.

  • Memory limit ≈ 2 GB (500 MB realistic).

  • Hashed tables: Max ~2 million entries.

✅ 13. What is a generic internal table?

  • Key or line type can be unspecified.

  • Used for field symbols or interface parameters.

  • Cannot declare regular data objects this way.

✅ 14. Explain Standard Internal Tables.

  • Ideal for index-based operations.

  • Use APPEND, READ INDEX, MODIFY INDEX, etc.

  • Linear access time, can use binary search if sorted.

✅ 15. Explain:

  • Internal Table: Runtime-only table in memory.

  • Value Table: Domain-level validation.

  • Check Table: Field-level validation (foreign key).

  • Transparent Table: Same structure in DB and ABAP Dictionary.

✅ 16. How to choose a table type?

  • Depends on access pattern:

    • Frequent index access → Standard Table

    • Sorted inserts → Sorted Table

    • Key-only access → Hashed Table

✅ 17. What is row type and line type?

  • Line Type: Structure of each row (data type).

  • Row Type: Actual content (data instance).

  • Helps in reuse and DDIC-defined tables.

✅ 18. Difference between internal table and work area?

FeatureInternal TableWork Area
PurposeHolds multiple recordsSingle data row holder
UseStore/loop/modify/delete dataMove data to/from table rows

✅ 19. Difference between database tables and internal tables?

AspectDatabase TableInternal Table
StorageStored in DB ServerRuntime memory (App server)
LifetimePermanentTemporary (during program run)
AccessPersistent SQL operationsSAP program operations

✅ 20. Difference between COLLECT and APPEND?

  • APPEND: Adds row unconditionally.

  • COLLECT: If duplicate key exists, sums numeric fields instead of appending.

No comments:

Post a Comment