Everything you need to know about SAP ABAP New Syntax 7.5

Introduction

Hey, code enthusiasts! Remember the days when SAP ABAP felt a bit like trying to chat using an old-school rotary phone? Well, not anymore! With SAP ABAP 7.5, we’ve entered the age of smartphones! (Okay, not literally, but in the syntax sense.)

Comparison between old and new syntax with example

Before I bore you with words, let’s see a quick example to show off this shiny new syntax.

Old Way:

DATA: lt_materials TYPE TABLE OF mara,
      ls_material  TYPE mara.
SELECT * FROM mara INTO TABLE lt_materials WHERE matnr = '1000'.
READ TABLE lt_materials INTO ls_material WITH KEY matnr = '1000'.

New, Cooler Way in 7.5:

DATA(lt_materials) = VALUE #( SELECT * FROM mara WHERE matnr = '1000' ).
DATA(ls_material)  = VALUE #( lt_materials[ matnr = '1000' ] ).

See the difference? The new syntax is more concise and feels modern. It’s like comparing texting with emojis to writing a full-blown letter. Both get the message across, but one’s definitely snazzier!

Why we should use the new SAP Syntax

So, you might be thinking, “Cool example, but why should I change?” Well, here are some compelling reasons:

  • It’s Efficient: The new syntax is more streamlined, which means less code and quicker results. And let’s be honest, who doesn’t want that?
  • Readability: If you’ve ever tried deciphering someone else’s code (or even your own from months ago), you know the struggle. With the new syntax, the code structure is clearer, making it easier to read, understand, and maintain.
  • It’s Modern: Just like updating your phone or your favorite app, updating your syntax keeps you current. It aligns with the latest programming paradigms and makes sure you’re ready for whatever SAP throws next.

 

Old and new ABAP syntax – overview sheet

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 VALUEInline 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

The above difference is taken from here.

ABAP Syntax 7.5

You can read the latest updates over here.

And there you have it – a quick trip down SAP ABAP 7.5 lane. So, next time you’re about to dive into an ABAP project, give this new syntax a spin. You might just find it as refreshing as a cold drink on a hot day! 🍹🔆 Happy coding! 🚀

Author

  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.