SAP COMMENT



Get Example source ABAP code based on a different SAP table
  


• * ABAP_COMMENT
• ' ABAP_COMMENT

Comments
A comment is a description inserted in the source code of a program that helps the user better understand the program and that is ignored when the program is generated by the ABAP Compiler. From a technical perspective, a comment can have any content. Two language elements are available for creating comments:
The * character in the first position of a line in a program defines the entire line as a comment.
The ' character at any position defines that all of 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 make it possible to create two types of comments :
Comment lines A comment line contains nothing but a comment. It can be defined either by the * character in the first position in the program line or by the ' character at any position of an otherwise blank program line.
Line end comments A line end comment is a comment started with the ' character and that stands behind an ABAP statement or parts thereof.

ABAP_PGLS
Arrange comments correctly
Write program comments in English
Make meaningful comments
Character set in source code
ABAP_PGL_END



Latest notes:

BEGIN_SECTION SAP_INTERNAL_HINT
The characters #R2 at the beginning of a line also create line comment, while a #R3 is ignored.
END_SECTION SAP_INTERNAL_HINT
NON_V5_HINTS
A special type of line end comments are ABAP Doc comments started by '! . These comments can be evaluated by tools of an ABAP development environment to support ABAP Doc.
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following example demonstrates the recommended use of comments. Comment lines started by * are used to structure the program. Line end comments occur after declarations and statements at the end of blocks. All other comments stand in front of the described statements 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
ABAP_EXAMPLE_END