Skip to Content
Author's profile photo Thomas Krügl

Old and new ABAP syntax – overview sheet

Motivation:

With release 7.40 and 7.50 several new ABAP language elements have been introduced. Learning them in theory is one thing, using them in daily life quite another. While working on that, the idea of an overview sheet came up, comparing “old” and “new” syntax, in the form of: “When i notice things are done in this “old” way, can we use some new elements here?”

This overview is meant to be printable, to have it right on the desk or wall beside you for a quick reference.

Because of that, the overview is quite brief, and does  not explain how any of the new (or old) syntax elements work. In this online version, i linked explanatory blog entries, mostly from Horst Keller, obviously this won’t help if you print the list. This and the ABAP keyword documentation will help you out if you don’t know about specific elements, or need more details.

Also, i wrote below “Consider using this”. The list does not say when or if it is a good idea to use the new syntax elements, it’s just a reminder that there maybe is another option for the coding.

And one more thing, i do not mention or care about releases and service packs here. Depending on your system, some or all of the new features will not be available.

Here we go:

If you see this Consider using this
DATA and FIELD-SYMBOLS declarations Inline declarations
MOVE CORRESPONDING Constructor expression CORRESPONDING, or CL_ABAP_CORRESPONDING

struc1-field1 = struc2-fielda
struc1-field2 = struc2-fieldb

Constructor expression CORRESPONDING, or CL_ABAP_CORRESPONDING;

Constructor expression VALUE

CREATE DATA / CREATE OBJECT Constructor expression NEW
GET REFERENCE OF Constructor expression REF
variable only used once, e.g. parameter for a method call Constructor expression VALUE; Inline declarations
helper variable for type conversion Constructor expression CONV
?= Constructor expression CAST

assigning a value to a single variable within several case or if blocks, e.g. IF cond. var = 1. ELSE. var = 2. ENDIF.

Constructor expressions SWITCH or COND
READ TABLE Table expressions; Note: throws exception, while READ TABLE sets sy-subrc. Catch exception and handle error case, or use a standard value
READ TABLE … TRANSPORTING NO FIELDS line_exists( … ) or line_index( … )
internal table WITH DEFAULT KEY suitable key, or WITH EMPTY KEY
LOOP AT… FOR … IN in constructor expressions
[result of method call] IS (NOT) INITIAL, or [result of method call] = abap_true/abap_false predicative method call ( omit the ” = abap_true” part )
DO / WHILE FOR … UNTIL / WHILE in constructor expressions
calculating or otherwise assembling one result from input data, e.g. from table rows Constructor expression REDUCE; Note: “one result” can be a value, but also a table or complex object
LOOP AT … AT NEW, or other means of going through grouped data LOOP AT … GROUP BY … / LOOP AT GROUP
LOOP + DELETE Constructor expression FILTER
type checking (?= with TRY/CATCH block, or usage of CL_ABAP_TYPEDESCR) IS INSTANCE OF, CASE TYPE OF
CONCATENATE; string literals String templates
SELECT new SQL expressions; use @ to escape host variables

There are several links to new options in Open SQL statements. To keep the list clean, i decided to put them down here:

ABAP News for 7.40, SP08 – Open SQL

ABAP News for Release 7.50 – Host and Other Expressions in Open SQL

ABAP News for Release 7.50 – SELECT UNION

ABAP News for Release 7.50 – INSERT FROM Subquery and GTTs

And one more link i think is really helpful, a list of built-in functions:

Reminder: ABAP Built-in Functions

Edit: I just came across another quick reference / overview for the new syntax elements, it gives more details about the elements: ABAP 7.40 Quick Reference

PS: Please let me know if you know a way to start the table on a new page in the pdf version of this document. I recommend copying and formatting the list yourself as you like it, if you want to print it for now.

Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo CHABBI Mustapha
      CHABBI Mustapha

      Hello,

      It's very useful , Thank you for sharing,

      Best Regards,

      Author's profile photo Weikang Peng
      Weikang Peng

      rookie from china, thanks for sharing

      Author's profile photo Ruthiel Trevisan
      Ruthiel Trevisan

      Really useful!

       

      Thanks a lot!|

      Author's profile photo Charles Ryan G. Fang
      Charles Ryan G. Fang

      Bookmarked! really useful!

      Author's profile photo Robert Schulz
      Robert Schulz

      Hi Thomas,

      Thanks a lot!

      It's very useful!

      Best regards.

       

      Author's profile photo EBS Technology
      EBS Technology

      Thank you very much. this is very helpful.

       

      Can you make such list official? to tracking ABAP change since 740 at least. some features I see were added but not on your list I suppose.

       

      Thanks.

      Author's profile photo Thomas Krügl
      Thomas Krügl
      Blog Post Author

      You can find the official changes in the ABAP keyword documentation, portal version here:

      https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm

      (section ABAP - Release-Specific Changes)

       

      Unfortunately i am no longer actively developing ABAP at the moment, i won't look into additional changes or adapt this overview, and i don't know if there is any other list or overview of changes.

       

      regards,
      Thomas

      Author's profile photo Joseph Pamisetti
      Joseph Pamisetti

      Helpful collection of links

      Author's profile photo João Batista Flores
      João Batista Flores

      Thank You Thomas,  this is very helpful. Congrats!

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Thanks for sharing! This post is as helpful in 2023 as it was in 2016. 🙂