“Functional comments”: What commented ABAP-Code can do
Alleged most ABAP Developers have encountered the fact that even commented code can work for forward navigation.
- Under which circumstances does this work, when not?
- Can we use it to increase readability of our code or to improve its handling?
The following snippets should work to comprehend via double click in your ABAP Editor.
* or “
The ABAP Editor finds the navigation target in commented code.
The crux seems to be that it makes a differences if you comment with * or “:
” call function ‘POPUP_TO_SELECT_MONTH’. Doesnt´t find a navigation target
* call function ‘POPUP_TO_SELECT_MONTH’. Jumps in the FM
Beyond Navigation
It seems as if the Editor handles the code artefact like if you would double click on not commented code.
Thus, you get the where-used-list with the following comment:
* function ‘POPUP_TO_SELECT_MONTH’.
Let´s be creative
Armed with this knowledge, we can help the reader of our code with “functional comments”, as:
* refer to CL_GUI_CFW=>DISPATCH( ).
or
* also look at fields: mara-matnr, mara-blatt
One more thing to mention is that it can help to make clear where the command starts, respectively where the last command ends. See this:
* we could raise exception type cx_some_error. does not work
* we could. raise exception type cx_some_error. works
One last example:
* check usages of program ZWOL_COMMENT_NAVIGATION. does not work
* check usages of. program ZWOL_COMMENT_NAVIGATION. works
What a bummer that double click does not resolve macros. Imagine what would have been possible with macros…
What I didn´t figure out is why this works even without the . after can:
* you can include mara in your thougts.
More possibilities?
- Do you know more tricks / possibilities?
- Did “functional comments” help you anyhow?
Disclaimer
All examples did work as described in my SAPGUI. No guarantee that this works on every GUI and in all (future) versions.
Apart from that, it is better to write code which doesn´t need additional explanations by any comments…
Hi Stefan,
good post.
I'm just pondering, weather this is bug or feature 😉 .
Regards,
Dirk
I had the same thought - when is SAP going to "fix" it? 🙂
Thanks for sharing!