Do you know what this ABAP code line does?
DATA(lt_t) = VALUE tt_t( FOR ls_s IN lt_s ( CORRESPONDING #( BASE ( VALUE #( paramnr = '1' ) ) ls_s ) ) ).
It replaces three variable definitions, a loop, two value assignments and a table append in a single line of code. The corresponding “traditional” code could look something like this:
Semantically speaking: it will copy the contents of table lt_s into table lt_t for each column that exists in both tables, and fill the column ‘paramnr’ (which only exists in lt_t) with the hardcoded value ‘1’. It is a good – but probably a bit extreme – example of the new ABAP 7.40 language features like inline data declarations, the VALUE constructor operator etc. that can shorten your code and make your programming more effective. Is this line of code straightforward and easy to understand? Probably not, unless you wrote it yourself. With an additional line of comment above it, you could let your fellow colleagues grasp it quickly when they are reading your code – even then it might still feel unnatural. But how about this one:
Isn’t that a lot more convenient than defining a helper variable, filling its four components one by one and then appending it to the range table? One line of code instead of six – one line of code for one logical step – one line of code that is way easier to read. Neat, short, simple, and natural. If you would like to learn more on these (not so) new keywords just google ‘ABAP 7.40’ and ‘ABAP 7.50’, there are quite a few good examples out there. You can also book us for a one or two day training workshop covering this topic and/or other interesting topics like runtime type creation, hash tables or ABAP development with Eclipse ADT.