ARTICLE
Comments
A comment is an explanation that is added to the source text of a
program to help the person reading the program to understand it. C
omments are ignored when the program is generated by the ABAP Compiler.
From a technical perspective, a comment can have any type of content.
Two language elements are available for creating comments:
The * character at the start of a program line indicates that the
entire line is a comment.
The " character, which can be entered at any position in the
line, indicates that the remaining content in the line is a comment.
This rule does not apply to the " character in
character literals and
pseudo comments .
These language elements enable create two categories of comment to be
created:
Comment Lines
A comment line contains a comment and nothing else. It can be defined
either by the * character at the start of the program line, or by
the " character at any point of an otherwise blank program line.
End of line comments
An end of line comment is a comment that is added using the "
character and that appears after an ABAP statement or part of an ABAP
statement.
ABAP_PGLS Arrange comments correctly
Write program comments in English
Make meaningful comments
Character Set in Source Code
Note
A special category of line end comments are
ABAP Doc comments introduced
using "! . These comments can be evaluated by an ABAP development
environment and support ABAP Doc .
Example
The following example demonstrates how to use comments. Comment lines
added with * are used to structure the program. End of line
comments are added after declarations and statements at the end of
blocks. All other comments appear before the statements described and
are indented accordingly.
*----------------------------------------------------------*
* Class implementations *
*----------------------------------------------------------*
CLASS application IMPLEMENTATION.
METHOD main.
DATA: items TYPE STANDARD TABLE
OF REF TO item, "Item table
item_ref LIKE LINE OF items. "Item reference
DATA: amount TYPE i, "Amount per item
total_amount TYPE i. "Total amount of items
...
"Loop over all items to compute total amount
LOOP AT items INTO item_ref.
IF item_ref IS BOUND AND
item_ref->is_valid( ) = abap_true.
"Compute total amount for valid items
amount = item_ref->get_amount( ).
ADD amount TO total_amount.
...
ELSE.
...
ENDIF. "item_ref IS BOUND AND...
ENDLOOP.
...
ENDMETHOD. "main
ENDCLASS. "application
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved