DAY 13 β Internal Table Operations, Transactions & Memory Handling in ABAP

On a journey of continuous learning π I share the concepts I learn daily through blogs. Learn concepts with me β one topic at a time.
#LearningInPublic #ContinuousLearning
Todayβs session is one of the most important practical topics in ABAP development.
You will understand:
Internal Table Operations (READ, APPEND, INSERT, DELETE, MODIFY, SORT)
Memory Handling (CLEAR, FREE)
CALL TRANSACTION
HOTSPOT & Interactive Output
SAP Memory vs ABAP Memory
EXPORT / IMPORT
SUBMIT
Parameter ID Handling
This is core report programming knowledge used in real SAP projects.
π§ PART 1 β Internal Table Operations
Before databases, before UI β ABAP developers work heavily with internal tables.
Think of an internal table as:
A temporary Excel sheet stored in program memory.
πΉ 1. TYPE & DATA Declaration
TYPES: BEGIN OF ty_student,
id TYPE i,
name TYPE string,
marks TYPE i,
END OF ty_student.
DATA: gt_student TYPE STANDARD TABLE OF ty_student,
gs_student TYPE ty_student.
What happens here?
ty_studentβ Structure (like one row)gt_studentβ Internal table (multiple rows)gs_studentβ Work area (one row at a time)
πΉ 2. APPEND β Add Record at End
gs_student-id = 1.
gs_student-name = 'HARISH'.
gs_student-marks = 85.
APPEND gs_student TO gt_student.
π Meaning:
Adds a new row at the end of internal table.
πΉ 3. INSERT β Insert at Specific Position
INSERT gs_student INTO gt_student INDEX 2.
π Inserts record at position 2.
If index does not exist β Runtime error.
πΉ 4. READ TABLE β Fetch Specific Record
READ TABLE gt_student INTO gs_student WITH KEY id = 2.
IF sy-subrc = 0.
WRITE: / 'Read Success:', gs_student-name.
ENDIF.
Important:
sy-subrc = 0 β Successsy-subrc β 0 β Record not found
πΉ 5. MODIFY β Update Existing Row
gs_student-marks = 95.
MODIFY gt_student FROM gs_student INDEX sy-tabix.
Updates existing record at given index.
πΉ 6. DELETE β Remove Record
DELETE gt_student WHERE id = 3.
Deletes record matching condition.
πΉ 7. SORT β Arrange Records
SORT gt_student BY marks DESCENDING.
Sorts table by marks from highest to lowest.
πΉ 8. LOOP & SUM β Process Table
DATA gv_total TYPE i.
LOOP AT gt_student INTO gs_student.
gv_total = gv_total + gs_student-marks.
ENDLOOP.
WRITE: / 'Total Marks:', gv_total.
π± PART 2 β HOTSPOT & CALL TRANSACTION
πΉ HOTSPOT β Clickable Text
FORMAT HOTSPOT ON.
WRITE: / 'Click Here to Open SE11'.
FORMAT HOTSPOT OFF.
When user clicks β You can trigger AT LINE-SELECTION.
πΉ CALL TRANSACTION
CALL TRANSACTION 'SE11'.
Opens transaction programmatically.
π PART 3 β SAP Memory vs ABAP Memory
Here is the conceptual difference:
π· SAP Memory (SPA/GPA)
Used for:
Passing small values across transactions.
Example:
SET PARAMETER ID 'DTB' FIELD 'SFLIGHT'.
CALL TRANSACTION 'SE11'.
'DTB' = Parameter ID for table name
Opens SE11 with SFLIGHT automatically filled
Lifetime:
Until user logs off.
π· ABAP Memory
Used within same internal session.
EXPORT Example:
EXPORT gv_total TO MEMORY ID 'ZTOTAL'.
IMPORT Example:
IMPORT gv_total FROM MEMORY ID 'ZTOTAL'.
π‘ Real Life Analogy
SAP Memory β Locker assigned to you in office.
ABAP Memory β Notebook used inside meeting room.
π PART 4 β SUBMIT
Used to call another report program.
SUBMIT z_other_program AND RETURN.
If you want to pass values:
SUBMIT z_other_program
WITH p_carr = 'LH'
AND RETURN.
π§Ή PART 5 β CLEAR vs FREE
πΉ CLEAR
Resets value but memory remains allocated.
CLEAR gs_student.
πΉ FREE
Releases memory completely.
FREE gt_student.
π PART 6 β Full Combined Working Example
REPORT z_day13_demo.
TYPES: BEGIN OF ty_data,
id TYPE i,
name TYPE string,
END OF ty_data.
DATA: gt_data TYPE STANDARD TABLE OF ty_data,
gs_data TYPE ty_data.
DATA gv_count TYPE i.
* Append
gs_data-id = 1.
gs_data-name = 'ABAP'.
APPEND gs_data TO gt_data.
* Read
READ TABLE gt_data INTO gs_data INDEX 1.
IF sy-subrc = 0.
WRITE: / 'Record Found:', gs_data-name.
ENDIF.
* Export to memory
EXPORT gv_count TO MEMORY ID 'ZCNT'.
* Call Transaction
SET PARAMETER ID 'DTB' FIELD 'SFLIGHT'.
CALL TRANSACTION 'SE11'.
* Free memory
FREE gt_data.
π Complete Keyword Summary
| Keyword | Purpose |
| APPEND | Add row at end |
| INSERT | Add row at specific position |
| READ TABLE | Fetch row |
| MODIFY | Update row |
| DELETE | Remove row |
| SORT | Arrange rows |
| CLEAR | Reset value |
| FREE | Release memory |
| SET PARAMETER | Store SAP memory |
| EXPORT | Store ABAP memory |
| IMPORT | Retrieve ABAP memory |
| CALL TRANSACTION | Open transaction |
| SUBMIT | Call program |
π― Final Understanding
Today you learned:
How internal tables behave like temporary databases
How to manipulate records dynamically
How SAP Memory differs from ABAP Memory
How to open transactions programmatically
How to pass data between programs
How to properly manage memory



