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:

Notes

Syntax

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

but not using SHADOW[FIND].

Positioning 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:

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

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 (selection of the i button).