How to insert record in to SAP ABAP Internal table in five different ways

Lets consider the following table as an example

Contact_IdContact_NameContact_Address
101MikeStrasse 11
102ThiruStrasse 12
103ManiStreet 22
104MiruStreet 23
105ManojStreet 25
  • Insert records from a database table in to an Internal table in SAP ABAP
    • Example: SELECT contact_id contact_name contact_address FROM ztt_table1 INTO TABLE lt_internal_table

  • Append the contents of a structure(work area) to an Internal table in SAP ABAP

Example:

ls_structure-contact_id = 200.

ls_structure-contact_name = ‘Virat kohli’

ls_structure-contact_address = ‘Street 200’.

APPEND ls_structure TO lt_internal_table.

  • APPEND the contents of an internal table1 to an another internal table 2

APPEND LINES OF lt_internal_table1 TO internal_table2

  • Insert the work area contents in to an Internal table

INSERT ls_structure INTO TABLE lt_internal_table1.

  • Insert the work area contents at a particular position in an internal table

INSERT ls_structure INTO lt_internal_table1 INDEX 4.

  • Insert the lines of an internal table 1 in to an internal table 2

INSERT LINES OF lt_internal_table1 INTO TABLE lt_internal_table2.

  • Insert the lines of an internal table 1 at a particular position of an internal table 2

INSERT LINES OF lt_internal_table1 INTO lt_internal_table2 INDEX 3.

  • Inserting records in to an internal table directly using VALUE command

DATA lt_internal_table1 TYPE TABLE OF ztt_table2.

lt_internal_table1 = VALUE #( ( contact_id = 300 contact_name = ‘Rishi’ contact_address = ‘Street 33’ ) ).