14.01.2020 Views

ABAP_to_the_Future

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Internal Tables 2.6

monster_name TYPE zde_monster_Name

t_results TYPE ztyp_monster_results,

END OF l_typ_monster_results.

DATA: lt_results TYPE STANDARD TABLE OF l_typ_monster_results.

Listing 2.53 Deep Structure

Recently, SAP has clearly been thinking about what happens when you perform a

MOVE-CORRESPONDING between two slightly different structures that are both deep

but that are defined slightly differently. As you know, MOVE-CORRESPONDING compares

the field names of two stru ctures, and if a field called RESULT is a string in

one and a number in another and the value is XYZ in the first structure, then trouble

looms (i.e., a short dump). Take this one step further, and say you have two

internal tables in two deep structures with the same name but defined differently.

What is going to happen when you perform a MOVE-CORRESPONDING?

To start off with, the next examples examine what happens in release 7.02 when

moving from one structure to another, and then expand this to look at how the

same process behaves in 7.4. Spoiler: In 7.4, you can do a MOVE-CORRESPONDING

between internal tables as a whole, which was not possible in lower versions.

Say that in Europe it is important to keep track of something called an IBAN code

for each monster, which is meaningless anywhere else in the world, and in the

United States it is important keep track of a LOCKBOX code for each monster, which

likewise is meaningless anywhere else in the world. Listing 2.54 sets up structures

to store data for each region and then tries to do a MOVE-CORRESPONDING to

move some European monster data to the US equivalent.

TYPES: BEGIN OF l_typ_european_monsters,

monster_name TYPE string,

monster_iban_code TYPE string,

END OF l_typ_european_monsters.

DATA: ls_type_iban_codes TYPE l_typ_european_monsters.

TYPES: BEGIN OF l_typ_us_monsters,

monster_name TYPE string,

monster_lockbox_code TYPE string,

END OF l_typ_us_monsters.

DATA: BEGIN OF ls_european_monsters,

laboratory TYPE string,

t_result TYPE STANDARD TABLE OF l_typ_european_monsters,

117

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

Saved successfully!

Ooh no, something went wrong!