practical use of ABAP Doc in legacy code
Dear community, lately I’ve been searching for practical use cases with ABAP Doc. I think I’ve found one in connection with legacy code. That’s what today’s blog is about. And of course your opinion on it: Helpful or not?
Ok, let’s start. Has anyone ever seen such lines? Or even written yourself 😉
TYPES t_t_type TYPE STANDARD TABLE OF T000. CONSTANTS c_i TYPE p LENGTH 8 DECIMALS 14 VALUE '3.14159265358979'. CONSTANTS x TYPE c LENGTH 1 VALUE 'X'. CONSTANTS con_np TYPE REF TO object VALUE IS INITIAL. DATA g_dmbtr TYPE dmbtr. DATA gv_x TYPE char1. DATA: lt_result TYPE t_t_type, wa LIKE LINE OF lt_result.
Unfortunately you can find something like that quite easily. Often in legacy code. A good place to start your search is the TOP include of report/function group or some often implemented user exits like MV45A. For more examples of hard to understand lines check the ABAP gore coffee corner discussion.
What’s the problem with these lines? The names say nothing or are even confusing. This is the opposite of what Clean ABAP recommends with regard to naming. A real, lost opportunity to simply incorporate additional information in the source code 🙁 This is what it can look like during an analysis.
element information during an analysis
Another good point: Adding ABAP Doc comments has very little effect on the source code. The source code gets bigger, but that’s all. ABAP Doc comments are no ABAP instructions 🙂
How could our lines now look like with ABAP Doc comments?
"! table type for client customizing TYPES t_t_type TYPE STANDARD TABLE OF T000. "! number Pi CONSTANTS c_i TYPE p LENGTH 8 DECIMALS 14 VALUE '3.14159265358979'. "! used like abap_true CONSTANTS x TYPE c LENGTH 1 VALUE 'X'. "! null pointer CONSTANTS con_np TYPE REF TO object VALUE IS INITIAL. "! amount in local currency DATA g_dmbtr TYPE dmbtr. "! test switch, <strong>clear to write to database</strong> DATA gv_x TYPE char1. "! table with client customizing DATA: lt_result TYPE t_t_type, "! line of table lt_result (client customizing) wa LIKE LINE OF lt_result.
And here the view of our example via ADT element information.
Ok, I admit the Boolean example is simple. However, you can also include more information in an ABAP Doc comment. Here’s an example, not so obvious.
more information to transport via ABAP Doc comment
That’s all for today. What do you think?
Best regards, thanks for reading and stay healthy
P. S.: Not tired of reading? Check this blog.
That sure helps on the cases renaming is not an option!
I've been using ABA Doc to some success. Not sure it is applicable to SAP GUI, but with Eclipse ADT you can even export this documentation in HTML format..so this can serve as an API documentation too.
I think SE80 (SAP GUI) don't have an element information. Not really sure. Maybe the ABAP Doc comment in it's output style isn't shown at all in SE80? I'm working most of my time with ADT for years and I'm still happy about that decision. The export function of ABAP Doc in ADT is exactly a great tool if an API documentation is needed.
HTML export works in ADT only: https://blogs.sap.com/2015/10/21/new-abap-doc-features-with-netweaver-75/