Show TOC

ABAP DocLocate this document in the navigation structure

In SAP NetWeaver 7.4 SP03 or higher, ABAP Doc allows you to document declarations in ABAP programs, based on ABAP Doc comments.

Note In the ABAP Language Help (through F1 in the source editor), you will find further information about using the syntax of ABAP Doc comments.
Editing ABAP Doc Comments

A comment for ABAP Doc is introduced using the string "!.

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 in 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, and so on.

Example

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

"! ABAP class that contains <em>ABAP Doc</em>
CLASS cl_demo_importing_description DEFINITION PUBLIC.  
 PUBLIC SECTION.
    
  "! Attribute 1  

  DATA myself TYPE REF TO cl_demo_importing_description .
  "! Attribute 2  

  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.

Note In addition, ABAP Development Tools (ADT) analyzes the content of ABAP Doc comments, converting it to HTML, and displays it appropriately. Consequently, special characters such as ", ', <, > and @ must be escaped using &quot; , &apos; , &lt; , &gt; , and &#64; .
Displaying ABAP Doc Comments

ABAP Doc comments are used to display the ABAP element info in the source code editor, code element information pop-up, and ABAP Element Info view. 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.

The extent of documentation is displayed on the availability of the respective content:

  • ABAP Development Tools for SAP NetWeaver (ADT) checks if an ABAP Doc comment is available. If it is available, the ABAP Doc comment related to the source code is displayed.
  • Otherwise, ADT checks whether a description has been saved. If one available, the description related to the source code is displayed also.
  • Otherwise, ADT only displays the definition.