Interesting (but less useful) information about ABAP

Sometimes you stumble across things, which, though not mind blowing, could turn out to be useful one day, but for the time being you just have to file under “trivia”. I recently made two such discoveries.

The first thing actually has nothing to do with ABAP but with the SAP GUI. I found out that in the SAP GUI, you can delete entries in the “recent values” dropdown of a field (the one that appears if you start typing or press backspace, and which is only enabled if you don’t set “low speed connection” on the connection options), by selecting it with the arrow keys and pressing delete.

It’s actually not such a useless feature, mind you. If you accidentally typed your password in the user field on the logon screen (like I did) and don’t want people to see it, being able to delete it out of there is quite handy.

Secondly, I discovered something interesting about string literals in ABAP. I didn’t know that you could enclose them in grave accents (a.k.a. backticks) as well as single quotes. So

'my lovely string literal'

is treated the same as

`my lovely string literal`

Using backticks to enclose string literals can be mildly useful as it prevents you from having to escape single quotes and vice versa.

A somewhat obscure quirk though is that you can’t mix the two when joining string literals with the & operator (and I use the term loosely).

So while

var = 'This is a good' & 'test'.

is acceptable,

var = 'This is a good' & `test`.

is not.

Another, even more obscure quirk is that while you can insert a string literal enclosed in backticks directly into a table of type STRING, doing the same with a single-quote-enclosed literal will fail a syntax check (and therefore compilation). Weird, no? This means that

INSERT `my line of text` into lt_stringtab.

is completely acceptable, while

INSERT 'my line of text' into lt_stringtab.

will bring the ire of the ABAP syntax checker upon you.

That’s all folks.

Tags: ,

  • Very cool! Thanks mater.

  • Weird Peculiar Geeky.
    This is what I need.

  • vlad

    Thx for the info. Useful stuff. Keep posting! 😀

  • vlad

    Oh, apparently, backticks enclose a string literal, while the single quotes enclose a character literal…..