CORRESPONDING and LINES Syntax in ABAP 7.4/7.5
Corresponding Operator
In the older ABAP syntax, move corresponding is used to copy
the content of one internal table to another internal table. In the new syntax
the move corresponding is replaced with corresponding #( ).
$ads={1}
Below are few examples.
- Copy records from one internal to another
internal table.
MOVE CORRESPONDING ITAB1 TO ITAB2. “Old syntax
ITAB2 = CORRESPONDING #( ITAB1 ). “New syntax
- Copy content from another internal while
preserving the existing records.
MOVE-CORRESPONDING it_tab1 TO it_tab KEEPING TARGET LINES.
it_tab = CORRESPONDING #( BASE ( it_tab ) it_tab1 ).
- To discard duplicate lines and avoid runtime
errors.
itab = CORRESPONDING #( itab2 DISCARDING DUPLICATES ).
- Specify mapping fields from source to target or
exclude some fields.
it_tab2 = CORRESPONDING #( itab1 MAPPING a = c b = d EXCEPT e ).
- To copy content from deep internal tables.
itab_deep2 = CORRESPONDING #( DEEP BASE ( itab_deep2 ) itab_deep1 ).
MOVE-CORRESPONDING itab_deep1 TO itab_deep2 EXPANDING NESTED TABLES.
MOVE-CORRESPONDING itab_deep1 TO itab_deep2 EXPANDING NESTED TABLES KEEPING TARGET LINES.
LINES instead of DESCRIBE TABLE
To check the no. of records in internal table use the below
code.
DATA(lv_lines) = lines( it_tab ). “New Syntax DESCRIBE TABLE it_tab LINES lv_lines. “Old Syntax