Abap Internal Table Append and Read statement with example

This ABAP Report explains how to work with ABAP Internal tables. It uses the APPEND statement - which is used to append work area to the internal table. It also uses READ statement which is used to read the data from an internal table based on key. READ statement reads a single record and stores it in work area.

REPORT ztest_report.
*Data declaration
DATABEGIN OF wa_emp,
       eid
(10TYPE c,
       ename
(25TYPE c,
      
END OF wa_emp.
DATA it_emp LIKE TABLE OF wa_emp.
DATABEGIN OF wa_sal,
        eid
(10TYPE c,
        esal
(10TYPE c,
END OF wa_sal.
DATA it_sal LIKE TABLE OF wa_sal.
DATABEGIN OF wa_final,
eid
(10TYPE c,
ename
(25TYPE c,
esal
(10TYPE c,
END OF wa_final.
DATA it_final LIKE TABLE OF wa_final.
* filling the employee information
wa_emp-eid 
'1'.
wa_emp-ename 
'Vidya'.
APPEND wa_emp TO it_emp.
wa_emp-eid 
'2'.
wa_emp-ename 
'Satish'.
APPEND wa_emp TO it_emp.
wa_emp-eid 
'3'.
wa_emp-ename 
'Latha'.
APPEND wa_emp TO it_emp.
wa_emp-eid 
'4'.
wa_emp-ename 
'Sanjay'.
APPEND wa_emp TO it_emp.
LOOP AT it_emp INTO wa_emp.
  
WRITEwa_emp-eidwa_emp-ename.
ENDLOOP.
ULINE.
* Filling the data salary internal table
wa_sal-eid 
'2'.
wa_sal-esal 
'20000'.
APPEND wa_sal TO it_sal.
wa_sal-eid 
'3'.
wa_sal-esal 
'10000'.
APPEND wa_sal TO it_sal.
wa_sal-eid 
'4'.
wa_sal-esal 
'15000'.
APPEND wa_sal TO it_sal.
wa_sal-eid 
'1'.
wa_sal-esal 
'16000'.
APPEND wa_sal TO it_sal.
LOOP AT it_sal INTO wa_sal.
WRITEwa_sal-eidwa_sal-esal.
ENDLOOP.
ULINE.
* Based on emp and salary table fill the final table
LOOP AT it_emp INTO wa_emp.
wa_final-eid 
wa_emp-eid.
wa_final-ename 
wa_emp-ename.
READ TABLE it_sal INTO wa_sal
  
WITH KEY eid wa_emp-eid.
wa_final-esal 
wa_sal-esal.
APPEND wa_final TO it_final.
CLEAR wa_final.
ENDLOOP.
LOOP AT it_final INTO wa_final.
WRITEwa_final-eidwa_final-enamewa_final-esal.
ENDLOOP.

Output: