Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to easily position comments in ABAP

james3
Explorer
0 Kudos
820

Hello everyone,

I was wandering if there's an easy way to align comments belonging to different lines, to a determinate column in an ABAP program.

This is very useful when you want to mark some lines of code that you are adding to an existing program, so that they can be easily found when you search them in the program. For example, if I mark with a sign like "AB001 the lines I add, putting it at the end of each line, I can easily find the lines added by searching AB001.

Now, I can quickly copy and paste the sign at the end of each line I want to mark, but, as each line in general has a different length, if I want (as I want, to have a tidy program) to have the signs ("AB001) aligned, I have to manually insert the needed number of spaces at the end of each line. This is very annoying.

Do you know a way to do this more easily?

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
669

2 solutions:

1) It's a feature of pretty print, provided that you respect an unknown convention but it's easy to try different possibilities. Of course it works only on actual ABAP code, not lines which are already comments, so if you want to comment an ABAP line of code, first add the comment, then pretty print and comment the whole line.

For instance below "-abc1111 t will be aligned after pretty print, starting at position 61:

ASSERT 1 = 1. "-abc1111 t
ASSERT 1 = 1. "+abc1111 t

NB: it won't work on lines longer than 60 characters! (workaround is to first split, then add comment)

2) Another solution is to use the "column insertion" which you can use in both backend editor and ADT: with your mouse, you draw a vertical line at a given column on several lines, type your text, it will be repeated on all the lines, and starting at the same column:

  • backend editor (SE38, etc.): Alt + left click on several lines (drag and drop) + type text
  • ADT: Shift+Alt+A + left click on several lines (drag and drop) + type text (and Shift+Alt+A to exit the mode)

NB: This mode also works for copy and paste.

2 REPLIES 2

Sandra_Rossi
Active Contributor
670

2 solutions:

1) It's a feature of pretty print, provided that you respect an unknown convention but it's easy to try different possibilities. Of course it works only on actual ABAP code, not lines which are already comments, so if you want to comment an ABAP line of code, first add the comment, then pretty print and comment the whole line.

For instance below "-abc1111 t will be aligned after pretty print, starting at position 61:

ASSERT 1 = 1. "-abc1111 t
ASSERT 1 = 1. "+abc1111 t

NB: it won't work on lines longer than 60 characters! (workaround is to first split, then add comment)

2) Another solution is to use the "column insertion" which you can use in both backend editor and ADT: with your mouse, you draw a vertical line at a given column on several lines, type your text, it will be repeated on all the lines, and starting at the same column:

  • backend editor (SE38, etc.): Alt + left click on several lines (drag and drop) + type text
  • ADT: Shift+Alt+A + left click on several lines (drag and drop) + type text (and Shift+Alt+A to exit the mode)

NB: This mode also works for copy and paste.

0 Kudos
669

Thank you Sandra!

Solution 2 for SE38 works for me.

P.S.: instead, solution 1 doesn't work for me, as when I click "pretty print", the comments (i.e.: characters ' " ' ) aren't moved to the same column.