"
Supported by

Finally, expressions can be concatenated

Finally, the SAP NetWeaver 7.0 Enhancement Package 2 makes ABAP start to seem like a normal programming language.

It even allows expressions to be concatenated, no less!

Admittedly, EhP2 was released a long time ago but there are many projects that still don’t have it. It only came to mine last month. Even among those who already have it, I believe they may have no idea of the countless possibilities now available to them in ABAP.

When you wanted to concatenate expressions in ABAP up to now, it would say: syntax error. And then you would have to do things in instalments. For instance:


x = a + b
y = c + d
IF x > y.
  z = e + f.
  DO z TIMES.
    CONCATENATE g h INTO i.
  ENDDO.
ENDIF

Now (or rather when your project is upgraded to EhP2) you can do the following:


IF a + b > c + d.
  DO e + f TIMES.
    i = g && h.
  ENDDO.
ENDIF.

And instead of having to do this:


DATA o_cl1 TYPE REF TO cl1.
o_cl1 = cl2=>da_cl1( ).
o_cl1->faz_algo( ).

you can do:


cl2=>da_cl1( )->faz_algo( ).

Did you notice above that && takes the place of the infamous CONCATENATE? There are also countless innovations in the processing of strings, but I’ll leave that for another article.

If you still don’t have EhP2, keep on dreaming. If you already have it, keep on experimenting because there are many new possibilities of this kind.

Thanks to KayVee.INC for the photo.

Greetings from Abapinho.

2 comentários a “Finally, expressions can be concatenated”

  1. Programista ABAP Diz:

    Well this is one of those “nice to know” but 90% of my clients are still using lower version than 7.0EP2 so to have elastic code it’s probably better to keep it in “non chain version”.

    Best regards,
    PG

  2. Nuno Godinho Diz:

    In generic code which can be reused in many systems, yes, better keep it in the old form. But since most of the code I write is specific, I’ll definitely start putting this chaining thing to good use.

Deixe um comentário


About Abapinho
Abapinho runs on WordPress
Articles (RSS) e Comments (RSS).