Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  ABAP Syntax →  Program Directives 

Pragmas

Pragmas are program directives that can be used to hide warnings from various check tools. The following are supported:

For more information, see:

Other versions: 7.31 | 7.40 | 7.54


Notes

  • You can determine whether a pragma exists for a warning from the system check using the long text of the message (which in this case always exists). The description of a message for the enhanced program check is also listed by the pragma, which can be used to hide it.

  • Do not use statement SET EXTENDED CHECK and the pseudo comment #EC * in programs that use pragmas to deactivate warnings. This causes an extended program check warning that cannot be deactivated.

Syntax of Pragmas

A pragma is structured as follows:

##code[par][par]... ,

is not case-sensitive and does not contain spaces. The pragma code (code) specifies the effect; parameters (par) may further limit the effect.


Note

Pragmas replace the previously common pseudo comments to hide warnings from the enhanced program check. Pseudo comments are now obsolete and should no longer be used. The program ABAP_SLIN_PRAGMAS shows which pragmas are to be used instead of the obsolete pseudo comments.

Examples

An example of a pragma for syntax check warnings is:

##SHADOW

This pragma can be used to hide a syntax warning in a method definition that warns of the shadowing of a predefined function. The pragma has an optional parameter in which the name of the function can be specified as well.

##SHADOW[SUBSTRING]

An example of pragmas for hiding warnings from the enhanced program check is provided below.

DATA TEXT TYPE STRING   ##needed.
text  = 'Hello Pragmas' ##no_text.

Parameterization and the Effect of Pragmas

A message is affected by a pragma if all the parameters specified match the concrete parameters. The concrete parameters can also be found in the long text of the message. Compulsory parameters are underlined in the long text and must not be omitted. Some parameters are optional. Optional parameters can be omitted by using an empty pair of brackets [] in the appropriate position or by completely omitting an end part.


Example

In the example a warning for "SUBSTRING" is hidden using

  • ##SHADOW
  • ##SHADOW[SUBSTRING]
  • ##SHADOW[]

but not using SHADOW[FIND].

Positioning of Pragmas in ABAP Source Code

A pragma applies for the current statement, that is, for the statement that ends at the next "." or ",". Pragmas in front of the ":" of a chained statement apply to the whole chained statement. Pragmas that occur when calling a macro apply to all statements of the macro.

Pragmas must only occur at certain positions in the source code for reasons of readability:

  • at the start of a line, after any number of spaces
  • at the end of a line, at the most followed by ".", ",", or ":".
  • but not after ".", ",", or ":".
    Multiple pragmas may be entered one after another (separated by spaces) at permitted positions.

Unknown, formally incorrect, or incorrectly parameterized pragmas lead to a syntax warning.


Note

A pragma in a type definition made using TYPES (for example, for hiding the warning about redundant secondary keys of table types) can also be applied to data declarations using DATA (in the case of non-generic types) and associated statements that reference the data type using TYPE. In the case of references to a generic data type defined using TYPES (that is a table type for which no primary table key is defined), a specified pragma is not applied to the data declaration. This is because the declaration uses a full table type implicitly and the pragma must potentially be specified again.

Examples

In some examples for key accesses to internal tables (read, delete), syntax warnings are hidden by the relevant pragma. The pragmas were found in the long text of the syntax warnings (i button selected).