What would you least expect to find in an ABAP class? Take your time to think about it and create your own top three. Let your creativity flow. That feels good.
Here are my top three:
- Grandma’s apple pie recipe written in shorthand
- A clue to the location of the Amber Room
- A phone number where the class code is sung to you as an Italian opera
What did I find in a class the other day? SAPscript statements. No joke. Apparently, I’ve been at it for too long now, so that this surreal and actually improbable situation has become a probable and ultimately real situation.
As a reminder, here’s what SAPscript looks like:
/: DEFINE &variable& = 'ABC'
/: IF &SAPSCRIPT-COUNTER_1& = 5
[..]
/: ELSE
[..]
/: ENDIF
How can you insert SAPscript statements into an ABAP class? Only via comments. Fortunately, the syntax check (“You shall not pass!”) prevents anything else. Comments have always been, and will always be, a kind of storage space for anything and everything in every programming language. A bit like your garage, which eventually becomes too small to park a car. The reason: everything that’s no longer needed in the house has been put in the garage. Eventually, it’s full, and logically speaking, you need a new, bigger house.
Well, the real topic is comments. They should contain high-quality information about the “why.” Much has already been written about this, so fortunately, I only need to refer to existing sources. A recommended resource is the CleanABAP guide.
Personally, I write significantly fewer comments than I used to. This is a conscious decision. I look for ways to explain a concept clearly using the standard ABAP features (excluding comments). Small, focused methods with descriptive names are always an important building block.
My general aim is to create clarity from ABAP language elements that are actually processed at runtime, which, among other things, makes them testable. This isn’t possible with comments. That’s why you could also stash SAPscript or Grandma’s apple pie recipe there.
Thank you for reading. If you enjoyed the post, please share the article with your community. Thanks in advance.
Michael (a mind forever voyaging)
