Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
horst_keller
Product and Topic Expert
Product and Topic Expert

Where do we come frome?

We come from Release 7.0. ABAP was statement oriented then.

Say, we have the task to output a string concatenated from a column value of an internal table with some literal contents using a given method. In 7.0 that would look as follows:

DATA itab TYPE TABLE OF scarr.
SELECT * FROM scarr INTO TABLE itab.

DATA wa LIKE LINE OF itab.
READ TABLE itab WITH KEY carrid = 'LH' INTO wa.

DATA output TYPE string.
CONCATENATE 'Carrier:' wa-carrname INTO output SEPARATED BY space.

cl_demo_output=>display( output ).


Where do we stay?

Hopefully most of you stay already on Release 7.02 or 7.03/7.31. With Release 7.02 ABAP took the first large step into the direction of expression enabling. Lots of new built-in functions, string expressions with concatenation operator && combined with string templates, and the capability of writing expressions at many operand positions opened a new realm of ABAP programming. In Release 7.02 the above task can already be writtten as follows:

DATA itab TYPE TABLE OF scarr.
SELECT * FROM scarr INTO TABLE itab.

DATA wa LIKE LINE OF itab.
READ TABLE itab WITH KEY carrid = 'LH' INTO wa.

cl_demo_output=>display( |Carrier: { wa-carrname }| ).

One helper variable and a statement less thanks to curly brackets in ABAP :wink: .

Where do we go?

With Release 7.40 we go into the direction of real expression orientation: More expressions and more expression positions.

Example, inline declarations in declaration positions. Let's rewrite the above code in 7.40:

DATA itab TYPE TABLE OF scarr.
SELECT * FROM scarr INTO TABLE itab.

READ TABLE itab WITH KEY carrid = 'LH' INTO DATA(wa).

cl_demo_output=>display( |Carrier: { wa-carrname }| ).

The compiler knows the data type needed for wa. Therefore, we can declare the structure inline at an operand position. You can imagine that there are lots of such positions.

Again one line less. But wa-carrname is still a helper variable. Let's go one step further using a table expression:

DATA itab TYPE TABLE OF scarr.
SELECT * FROM scarr INTO TABLE itab.

cl_demo_output=>display( |Carrier: { itab[ carrid = 'LH' ]-carrname }| ).

Gee! Square brackets within curly brackets and no READ-statement any more :cool: .

More details later ....

 

29 Comments