Dense ABAP Syntax Cheatsheet

When learning a new programming language it’s desirable to write down its syntax for if you can’t remember, for example, how to declare a class, you can always take a peek at your notes and remind yourself of the keywords that will make it happen.

After writing a few notes, they will need to be organized into groups, for if they aren’t, it will be hard to quickly find related syntactic notes. A piece of paper on which these notes are organised are commonly known as a cheatsheet or reference sheet.

Every programming language, from C to Python and beyond has a cheatsheet and they are all different depending on which person designed them and for what purpose. Some cheatsheets are aimed at language learners; these cheatsheets have lots of comments that explain what are the consequences of using a statement and omit complicated syntactic features. Some cheatsheets are aimed at proficient users; these cheatsheets rarely have comments as they try to fit as many syntactic notes as possible onto a single piece of paper, for such users already know what are the consequences of invoking a statement, they just need to remind themselves of the proper statement syntax.

During the process of learning ABAP, I’ve noticed a distinct lack of ABAP cheatsheets of the Internet, especially those aimed at proficient users, so I’ve written my own ABAP cheatsheet.

The first page is complete and is an example of how I want the other pages to look like. It is dense: every line is filled with characters and there are 6,8 characters per square centimeter. Similar syntax is close to each other: class declaration near data declaration, internal tables near OpenSQL.

The other pages have room for additional notes and are not complete, which is part of the reason why I’m publishing the cheatsheet. I’d like to hear your feedback on how I can improve the cheatsheet: what notes should be on there and how can I write the syntax more concisely. My email address can be found at the bottom of the cheatsheet.

7 Comments

OK – in Java and other languages this would be useful, but with ABAP and the help built in, I’m not so sure. Even when I was a newbie, I just used ABAP F1 help to get the syntax. I still do that 20 years later (or use the ADT code completion).

In reference to the ABAP F1 built-in help being better or more useful compared to this cheatsheet: I’m not sure that’s obviously true. One of the reasons why I’ve decided to write the cheatsheet is precisely because I was dissatisfied with the built-in help.

When I am writing an ABAP program, I want to write the simplest, most basic statements with the least amount of keywords, but that will still get executed. I believe programs in general should be made up of statements that are as simple as possible, so that the program can be read easily by both learners and experts. This is where the built-in doesn’t help me.

The built-in help is far too verbose for my taste. Take for example the most basic of statements: DATA. After pressing F1, you will be shown information about every possible optional keyword and told that DATA can take many forms, with links to other pages that are also chock full of information. Expert users will, I’m sure, appreciate the fullness of syntax the help provides and I do too if I’m looking for some very specific language construct, but most of the time, I’d just like to know what is the minimum number of keywords that I have to write to make the statement work.

I believe this will more clearly elucidate the purpose of the cheatsheet. It is not a replacement for the built-in help or the online version (7.51) of it, but a supplement that will help you write easily readable programs made up of simple statements.

and of course the list will be different tomorrow. I use a reference book (1000+ pages) for older statements, the online help for newer statement and Horst Keller’s blogs in this forum.

The ABAP language evolved from a reporting tool to a swiss army knife. Now with over 700 keywords and growing, the developer targeting a moving target (Netweaver 7.0, or 7.02 or 7.31 or 7.40 or 7.5x) must remember today’s state of the art method to shoot yourself in the foot in ABAP will be obsolete tomorrow.

Modern ABAP introduced expressions, creating a conflict almost by design as new features were hitherto added to ABAP as new statements.

A statement does something: statements work on data, they are imperative and must be applied in sequence.

An expression returns some value: a pure functions (without side effect) is composable. They can be functional, but the ABAP type system does not support complex data types.

With this, we can discuss expressive ABAP code. What do the ABAP developer need?

A developer create Useful Software(TM) in ABAP using a subset of the language. This works well for the typical ERP expert with an understanding of business processes and domain specific database tables wo do not think of herself as language expert but as a data professional. Those ABAPers do not plan to rewrite the SORT statement to increase performance by 10% in some special case, they add value by translating functional requirements into queries, with ABAP acting as a glue around the query language without getting in the way.

We understand what to build/change, even if they are struggling on how to do it. I think SAP is committed to support this user base, e.g a new programming model as seems to makes sure the Data Professional can produce modern Fiori UI without spending years to learn JavaScript.

This makes business sense for SAP, but this means ABAP will continue to evolve and the keyword list will grow.

It’s a very good initiative, very helpful for developers new to ABAP. The embedded ABAP help (F1) is very good but at the beginning developers spend a lot of time to find the right statements or functions, and the syntax is very rich, so difficult to remember. It will accelerate the education for sure.

Maybe it would be best to present the statements in an HTML format so that people can easily copy/paste the document and adapt it to their needs + add hyperlinks to the official documentation. Moreover, it could be helpful to indicate the release number as not all people use the latest ABAP version. I think that your statements mostly correspond to the old 4.6C, but with exceptions for RTTS (6.10).

I’m learning C# right now, and I do a cheatsheet too, as I do for any new language (when I come back to a language years after my last program, I’m always happy to find my cheatsheet).