2023 Feb 03 7:12 PM
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?
2023 Feb 04 10:38 AM
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:
NB: This mode also works for copy and paste.
2023 Feb 04 10:38 AM
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:
NB: This mode also works for copy and paste.
2023 Feb 06 10:42 AM
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.