Show TOC

ABAP Doc CommentsLocate this document in the navigation structure

ABAP Doc enables you to document code elements (for example, attributes, methods, local variables) as ABAP Doc comments. Such a comment consisting of one or more comment lines, each of which is prefixed by "!.

Note

ABAP Doc is supported if your Eclipse-based IDE is connected with SAP NetWeaver 7.4 SP03 or higher.

Editing ABAP Doc Comments

ABAP Doc comments consist of a single comment line or a coherent block of several comment lines. In the source code editor, they can be placed in an empty line directly in front of a declarative statement like data declarations, method definition, class definitions, and so on.

ABAP Doc comments can be added in ABAP classes, ABAP interfaces, ABAP programs, or ABAP function groups to describe functionality of the code element. In addition, you can generate ABAP Doc by:
  • importing the existing descriptions of global classes and interfaces including their attributes, methods, parameters,
  • performing the quick assist "Add missing parameters to documentation",
  • and so on.
Example

In the following example, the ABAP Doc comments are added one line before the corresponding declarative statements:

"! <p class="shorttext synchronized" lang="en">ABAP class that contains ABAP Doc</p>
CLASS cl_demo_importing_description DEFINITION PUBLIC.  
 PUBLIC SECTION.
    
  "! <p class="shorttext synchronized" lang="en">Attribute 1</p>
  DATA myself TYPE REF TO cl_demo_importing_description .
  "! <p class="shorttext synchronized" lang="en">Attribute 2</p>
  DATA any_string1 TYPE c .
  "! Method to check if two sources are identical
  "!  
  "! @parameter source1 | First source
  "! @parameter source2 | Second source
  "! @parameter ignore_case | Pass abap_true to ignore case
  "!
  "! @parameter result | Returns abap_true if sources are identic
  "!
  "! @raising cx_aab_static | One of the sources is empty
  METHODS method_with_variable
  IMPORTING
   source1 TYPE text
   source2 TYPE text 
   ignore_case TYPE abap_bool DEFAULT abap_false
  RETURNING
   VALUE(result) TYPE abap_bool
  RAISING
   cx_aab_static.
ENDCLASS.

If you show the ABAP Element Info view in the ABAP perspective and select the method name in the source code editor, the corresponding ABAP Doc comment is displayed:

In the ABAP Element Info view, the ABAP Doc comment of the method_with_variable method is displayed
Figure 1: In the ABAP Element Info view, the ABAP Doc comment of the method_with_variable method is displayed
Checking ABAP Doc Comments

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.

Displaying ABAP Doc Comments

ABAP Doc comments can be displayed in the code element information popup, ABAP Element Info view, and code completion list in order to provide developers further information about the source code. In the SAP GUI, they are displayed in the ABAP editor. They contain descriptions, parameter definitions, and such like as well as describe code elements (for example, classes, attributes, methods, local variables) of a development object.

To display documentation, ABAP Development Tools for SAP NetWeaver (ADT) checks the availability of the respective content:

  • If an ABAP Doc comment is available, the ABAP Doc comment related to the source code is displayed.
  • If not, ADT checks whether a description has been saved. If one is available, the description related to the source code is displayed also.
  • Otherwise, ADT only displays the definition.
Note

To predefine the formatting of ABAP doc comments, open the Start of the navigation path General Next navigation step Appearance Next navigation step Colors and Fonts End of the navigation path preference page. From there, expand the Start of the navigation path ABAP Next navigation step Syntax Coloring End of the navigation path folders and edit the ABAP Docu Font entry.