ABAP Operation on Internal Tables
COPYING (Adding Multiple Records):
- Copy at the END of Internal Table
APPEND LINES OF <ITAB1> FROM <N1> TO <N2> TO <ITAB2>.
- Copy From the given Location
INSERT LINES OF <ITAB1> FROM <N1> TO <N2> TO <ITAB2> INDEX <N>.
With NO INDEX Acts as APPEND Only.
FROM <N1> TO <N2> is Optional, If We Ignore it, All the Records are Transferred, Else Only the records from <N1> TO <N2> are transferred.
ADDING SINGLE RECORD:
- ADD at the END of Internal Table
ADDPEND <WA> TO <ITAB>.
- ADD at the given Location
INSERT <WA> INTO <ITAB> INDEX <N>. ( N>0 )
NOTE: INSERT With NO INDEX Acts as APPEND Only.
NOTE: Fill the Data into <WA> and Transfer to <ITAB>.
Finding No Of Records
DESCRIBE TABLE <ITAB> LINES <V_LINES> ( V_LINES TYPE I).
The no of records from <ITAB> is collected into V_LINES.
SORTING: To arrange the records into Ascending / Descending Groups.
SORT <ITAB> ASCENDING / DESCENDING BY <F1><F2>……
NOTE: Sorting is Asecnding by Default.
NOTE: The default key is made up of the Non-Numeric fields of the table line in the order in which they occur.
Accessing/ Reading Single Record:
READ TABLE <ITAB> INTO <WA> INDEX <N>.
READ TABLE <ITAB> INTO <WA> WITH KEY <Condition> BINARY SEARCH.
NOTE: Make sure that the Internal Tabel is Sorted to Apply BINARY SEARCH.
Accessing Multiple Records:
LOOP AT >ITAB> INTO <WA> FROM <N1> TO <N2>.
*Process the Data from <WA>
LOOP AT <ITAB> INTO <WA> WHERE <Condition>
*Process the Data From <WA>
Single Record: DELETE <ITAB>
Multiple Record: DELETE <ITAB> WHERE <Condition>
DELETE <ITAB> FROM <N1> TO <N2>.
DELETING ADJACENT DUPLICATES:
NOTE: Make Sure that the Duplicates should be Adjacent, which can be done through SORTING.
So that, Sorting the <ITAB> is Mandatory.
NOTE: The Duplication of Records(s) depends on the comparing fileds.
DELETE ADJACENT DUPLICATES FROM <ITAB>
NOTE: Make sure that the <ITAB> is Sorted by all the comparing fields in the same order…
Either Single/Multiple records modification is always through <WA>.
*Fill the new data into <WA> fields.
MODIFY <ITAB> FROM <WA> TRANSPORTING <F1><F2>…
NOTE: The Where condition, decides the no of records to be modified.