Skip to Content

Create ABAPDoc Comments in Your Class in ABAP Environment

test
0 %
Create ABAPDoc Comments in Your Class in ABAP Environment
Details

Create ABAPDoc Comments in Your Class in ABAP Environment

April 21, 2020
Created by
April 20, 2020
Learn how to maintain ABAPDoc documentation for your class in SAP Cloud Platform, ABAP Environment so your comments appear in the Outline view.

You will learn

  • How to maintain ABAPDoc comments
  • How to synchronize comments so they appear in the Outline View
  • How to add an sorted list
  • How to create a link to other development object documentation within ADT

Prerequisites

ABAPDoc comments are used to document your code. This makes it more readable. If other developers use one of your development objects, they can find out more about it by selecting the object name in the code and choosing Element Info ( F2 ).

All ABAPDoc comments begin with "!.

Always replace XXX with your initials or group number.


Step 1: Open ABAP class

First, open the ABAP class ZCL_AMDP_DEMO_XXX from the tutorial Create an AMDP and Analyze Its Performance

Image depicting step-1-open-class
Log on to answer question
Step 2: Create ABAPDoc comment
  1. Immediately before the class definition, add an ABAPDoc comment to the class by entering "! and choosing Auto-complete ( Ctrl+Space ).

  2. From the dropdown list, choose Paragraph, then add the following comment:

    "!<p>Class tests AMDP</p>

    step2a-choose-paragraph

    You must insert the ABAPDoc comment immediately before the declaration; otherwise you will get a warning from ADT.

  3. Add the following to the paragraph ( <p> ) tag: class="shorttext synchronized", so your code looks like this:

    "!<p class="shorttext synchronized">Class tests AMDP: </p>
    
  4. Add the following comments to the table type ty_result_line and to the method GET_FLIGHTS respectively:

    "!<p class="shorttext synchronized">Table type of Flights from HANA DB</p>
    "! <p class="shorttext synchronized"> Method reads flights from HANA DB using AMDP</p>
    
  5. Save and activate your class.

The comments should now appear in the Outline View:

step2b-shorttext-synch-class
Log on to answer question
Step 3: Add sorted list
  1. Choose Enter. The system automatically inserts the ABAPDoc comments annotation "!" for you.

  2. Again, choose Auto-complete ( Ctrl+Space ). Then choose Sorted list.

    step3a-add-sorted-list
  3. Add the following two statements, so that your code looks like this:

    "! <ol>
    "!    <li>Reads flights from HANA DB</li>
    "!    <li>Converts currency to EUR</li>
    "! </ol>
    
    
Log on to answer question
Step 4: Add link
  1. Immediately after the sorted list, choose Enter.

  2. Now enter the following comment:

    "! <p>Implements the interface { @link INTF: if_oo_adt_classrun } </p>

This creates a link to the Element information for that interface.

Log on to answer question
Step 5: Check comment
  1. Save and activate your class ( Ctrl+S, Ctrl+F3 ).

  2. Select your class and choose Show code element information (F2).

  3. Your comments should appear look like this:

    step4a-element-info
  4. If you choose the link to the interface, its documentation appears:

    step6b-interface-abapdoc
Log on to answer question
Step 6: Test yourself
Which of the following object types can you link to, specifically using the syntax { @link kind:name }
Choose all that apply.
Use the ABAP Keyword Documentation for help, if necessary.
×

More Information


Next Steps

Back to top