Beautify, Change case and Indent your ABAP

Advertisements

I guess you may already know about the pretty print functionality within ABAP development which helps make you code more readable, but did you know you can change the pretty print settings so that all your statement keywords are changed to upper case and everything else is changed to lowercase. You can also decide if you want it to indent or not.

To pretty print your ABAP code simply click the pretty print button at the top of the editor. Also a good idea to make sure your sure your code syntax checks and activate it it first.

Advertisements

pretty print abap code

Access and assign Pretty Print Settings

To access the pretty print settings simply choose the main menu option Utilities->Settings

abap pretty print settings

Then within the next screen you need to choose tab 'ABAP Editor' and then 'Pretty Printer' in the sub section.

Advertisements
abap pretty printer settings

​Here you can select your desired code layout from the available indent and uppercase/lowercase options

Advertisements

Indent

This option allows you to decide if you want your code to be indented or not

Advertisements

ABAP code with indent

loop at it_text into wa_text.
   write:/ 'hello'.
   skip 2.
   write:/ 'indented code'.
endloop.

ABAP code without indent

loop at it_text into wa_text.
write:/ 'hello'.
skip 2.
write:/ 'indented code'.
endloop.

Lowercase

If you choose the 'Lowercase' option then as you would expect everything will be converted to lowercase.

loop at it_text into wa_text.
write:/ 'hello'.
skip 2.
write:/ 'indented code'.
endloop.

Uppercase

If you choose the 'Uppercase' option then the result will be that everything will be converted to Uppercase.

LOOP AT it_text INTO wa_text.
WRITE:/ 'hello'.
SKIP 2.
WRITE:/ 'indented code'.
ENDLOOP.

Keyword Uppercase

This is where it gets interesting because if you choose the 'Keyword Uppercase' option, all keywords will be converted to uppercase but this will mean that all variables will be converted to lowercase.

LOOP AT it_text INTO wa_text.
WRITE:/ 'hello'.
SKIP 2.
WRITE:/ 'indented code'.
ENDLOOP.

Keyword Lowercase

Now choose the  'Keyword Lowercase' option, this will then convert all keywords to lowercase but as a result all variables will be converted to Uppercase.

loop at IT_TEXT into WA_TEXT.
write:/ 'hello'.
skip 2.
write:/ 'indented code'.
endloop.

Advertisements

Leave a Comment: