<-- previous rule | overview | next rule -->
Moves all commands and comments to the correct indentation.
Relative indents within the lines of a command (or command chain) are not changed by this rule.
This rule is part of the essential profile, as it is explicitly demanded by the Clean ABAP Styleguide.
- Clean ABAP Styleguide: Use the Pretty Printer before activating
- Clean ABAP Styleguide: Use your Pretty Printer team settings
- Code Pal for ABAP: Comment Position
- Execute on CLASS ... DEFINITION sections
- Align with following ELSEIF or ELSE [if comment is preceded by blank line]
- Align with following WHEN [if comment is preceded by blank line]
- Align with following CATCH or CLEANUP [if comment is preceded by blank line]
METHOD pretty_print_indent.
DO 4 TIMES.
LOOP AT its_table ASSIGNING FIELD-SYMBOL(<ls_row>).
IF <ls_row>-ignore = abap_true.
" comment
CONTINUE.
ENDIF.
TRY.
" comment
IF iv_value = 1.
" comment on next line
iv_value += 3.
" comment with no empty line above it
ELSEIF iv_value = 2.
iv_value += 2.
" comment on ELSE branch with an empty line above it
ELSE.
iv_value += 1.
ENDIF.
CASE iv_value.
" comment on WHEN
WHEN 1.
" comment on next line
iv_value += 1.
" comment on WHEN with an empty line above it
WHEN 2.
iv_value += 2.
" comment with no empty line above it
WHEN 3.
iv_value += 3.
ENDCASE.
" comment on CATCH with an empty line above it
CATCH cx_any.
" no handler
ENDTRY.
ENDLOOP.
ENDDO.
ENDMETHOD.
Resulting code:
METHOD pretty_print_indent.
DO 4 TIMES.
LOOP AT its_table ASSIGNING FIELD-SYMBOL(<ls_row>).
IF <ls_row>-ignore = abap_true.
" comment
CONTINUE.
ENDIF.
TRY.
" comment
IF iv_value = 1.
" comment on next line
iv_value += 3.
" comment with no empty line above it
ELSEIF iv_value = 2.
iv_value += 2.
" comment on ELSE branch with an empty line above it
ELSE.
iv_value += 1.
ENDIF.
CASE iv_value.
" comment on WHEN
WHEN 1.
" comment on next line
iv_value += 1.
" comment on WHEN with an empty line above it
WHEN 2.
iv_value += 2.
" comment with no empty line above it
WHEN 3.
iv_value += 3.
ENDCASE.
" comment on CATCH with an empty line above it
CATCH cx_any.
" no handler
ENDTRY.
ENDLOOP.
ENDDO.
ENDMETHOD.