Documenting ABAP Code


After completing this lesson, you will be able to:

  • Document ABAP code

ABAP Code Documentation

If you place the cursor on the name of a class, method, function module, or type in ADT, you will see a popup window containing the corresponding type information – the parameters of the method or function module, or the description of a data type.

You can also add documentation to this window using ABAP Doc. You create this documentation by adding special comment lines to your code. With ABAP Doc, you can document the following declarative statements:

  • DATA

You can also document the individual parameters and exceptions of methods and function modules.

Let's see how your ABAP Doc comments can become a part of the element documentation.

Once you have activated the class, your ABAP Doc comments become part of the element documentation.

ABAP Doc uses a subset of HTML tags to allow you to format your documentation. The example uses the <strong> tag for emphasis, and a <br> tag for a line break (Note that two lines of ABAP Doc are displayed next to each other if you leave out the line break tag).

As well as emphasis, you can use the following tags:

  • Header, level1 <h1>...</h1>
  • Header, level2 <h2>...</h2>
  • Header, level3 <h3>...</h3>
  • Paragraph <p>...</p>I
  • Italic text <em>...</em>
  • Unnumbered list <ul><li>...</li>...<li>...</li></ul>
  • Numbered list <ol><li>...</li>...<li>...</li></ol>
  • Line break <br>

You can add ABAP Doc for a method and its signature using a quick fix. Once you have declared the method, press Ctrl + 1 to open the possible quick fixes, and choose Add ABAP Doc. ADT then generates the corresponding documentation.

With ABAP Doc, you can document both a method and its individual parameters. To document the method, use the normal "! comments. To document a parameter, use the notation "! @parameter <name> | and add your comment after the pipe character.

If the signature of a method changes, you can use quick fixes to delete the ABAP Doc comments of delete parameters, and to add ABAP Doc comments for new parameters.

You can ensure that an ABAP Doc description of an object is replicated in the description in the object properties, and in the object list. To do this, use a paragraph tag <p> with the addition class="shorttext synchronized".

Changes that you make to the description in the object properties are replicated to the ABAP Doc comment.

You can add links to the ABAP Doc of other objects. To do so, use the notation {@link <object_name>}.

As well as linking to the ABAP Doc of an object, you can also link to its individual elements. Here for example, there is a link to the ABAP Doc of the method get_airports. The link "! {@link zif_s4d401_constants.DATA:auth_create} links to the ABAP Doc of the constant auth_create in interface zif_s4d401_constants. You can link to individual elements as follows:

  • DATA for constants, variables, and procedure parameters in the appropriate context
  • DOMA for DDIC domains
  • FUNC for function modules in function pools
  • FUGR for function pools
  • INTF for interfaces implemented in a class to access its components.
  • METH for methods

How to Use ABAP Doc to Document Code

Watch this video to know how to use ABAP doc to document code.

Log in to track your progress & complete quizzes