14.01.2020 Views

ABAP_to_the_Future

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Internal Tables 2.6

This saves you a few lines of code and is wonderful for when the line structures

of the two tables are flat. However, it still doesn’t solve the problem for deep

structures. As you’ve seen, MOVE-CORRESPONDING on its own will dump the contents

of an internal table component, such as LT_RESULT, into the identically

named component in the ta rget structure. If the LT_RESULT in the target has differently

named columns, then all sorts of bizarre results might ensue. To counteract

this, SAP has come up with two new additions to MOVE-CORRESPONDING in

release 7.4. The next subsections look at them first one at a time and then combine

them.

MOVE-CORRESPONDING EXPANDING NESTED TABLES

In MOVE-CORRESPONDING EXPANDING NESTED TABLES , anything that might happen

to be in the target internal table alread y is deleted. Columns with simple values,

like numbers, are copied to their iden tically named friends. However, when it

comes to complex columns such as LT_RESULT, only fields that have the same

column name inside the nested tables would get copied. For example, the

MONSTER_NAME would get copied, because there is an equivalently named column

in the target, but MONSTER_IBAN_CODE would not, because there is no column with

the same name, only the LOCKBOX.

MOVE-CORRESPONDING KEEPING TARGET LINES

What happens in MOVE-CORRESPONDING KEEPING TARGET LINES is quite strange; if

there is anything already in the target internal table, then it stays there. Then, at

the end of the target table, extra rows are added—which is what would happen if

you just performed a MOVE-CORRESPONDING between the two tables. This is rather

like APPEND LINES OF itab1 TO itab2 , except that the two tables have different

structures, and only identically named components come across.

MOVE-CORRESPONDING EXPANDING NESTED TABLES

KEEPING TARGET LINES

As might be imagined, MOVE-CORRESPONDING EXPANDING NESTED TABLES KEEPING

TARGET LINES does both of the previous tasks at once; it acts like APPEND LINES OF

itab1 TO itab2 , copying only identically named components to the new rows,

but is also a bit clever with any intern al table components and only copies identically

named components within these structures.

119

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!