Supported by
Supported by Inetum

exclamation-point

images/thumbnail.jpg - Thumbnail

When looking at ABAP source code, the declaration of methods always prefixes parameters with an exclamation mark. This has always puzzled me. Now I finally know why.

This is a method signature generated by SE24:

METHODS get_amount_with_tax
  IMPORTING
    !price TYPE wrbtr
    !tax_code TYPE c003
  RETURNING
    VALUE(result) TYPE wrbtr .

What’s with the exclamation marks?

The exclamation mark is an ABAP escape character. It can prefix any name and warns the compiler that it is not a reserved word but a name. Normally they are not needed because the compiler can conclude by itself what are names and what are commands and operators. But there will be cases when it may be necessary to make it explicit.

Imagine for instance that someone had the bad idea to use ABAP reserved words as variables. In that case it might be better to be careful to use exclamation marks to help the compiler:

METHODS !methods
  IMPORTING
    importing TYPE wrbtr
    !type TYPE c003
  CHANGING
    !changing TYPE wrbtr.

And this is why SE24 uses exclamation marks: just in case!

Greetings from Abapinho