Show TOC

Adding ABAP Doc CommentsLocate this document in the navigation structure

A single ABAP Doc comment or a block of several ABAP Doc comments is introduced by the character combination "!.

Positioning ABAP Doc Comments in the Definition

In the editor, ABAP Doc comments are added one row above the related element in the definition part.

So, the ABAP Doc comment has to start before the element, directly in front of a declarative statement (for example, data declaration, method definition, class definition). Otherwise a warning will be displayed because the source code editor verifies the position and the content structure of ABAP Doc comments when you execute the ABAP syntax check. So, if comments are added at the wrong position or contain incorrect syntax, a warning is displayed in the Problems view.

Example

Example of a single ABAP Doc comment:

"! ABAP Doc test
METHODS method_with_variable.

Example of an ABAP Doc of a constant:

"! This is documentation for the following constant
CONSTANTS co_initial_value TYPE i VALUE 0.
Using a Quick Fix to Synchronize Method Documentation Between the Back End and ABAP Development Tools

In the implementation of a global class, you can document a method. You can use the Add ABAP Doc quick assist to add the <p class="shorttext synchronized"> tag. Then an ABAP Doc comment block containing the relevant tag is added. If a description already exists for this method in the back end, its short text, parameters, and exceptions will be synchronized and updated in the source code.

To do this, proceed as follows:

  1. In the definition, position the cursor on the method name for which you want to perform Ctrl + 1.

    The Quick Fix dialog box is opened.

  2. Choose Add ABAP Doc.

An ABAP Doc comment block is added to your source code, which contains the relevant tag:

"! <p class="shorttext synchronized" lang="en"></p>
"! 

Enter the relevant short text before the closing </p> tag.

Adding Statements over Multiple Lines

You can use multiple lines to document source code elements. In this case, you have to add the character combination "! in front of each line.

Example

Example for a multi line constant definition:

"! This documentation for the following constant is documented
"! in multiple lines.
CONSTANTS co_initial_value TYPE i VALUE 0.
Documenting a Block of Statements

If you want to document a block of statements using the ABAP colon comma semantics, the ABAP Doc comment block must be located in front of the identifier and after the colon.

Example
CONSTANTS:
  "! Initial value
  co_initial_value TYPE i VALUE 0,
  "! Invalid value
  co_invalid_value TYPE i VALUE -1.