Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
schneidermic0
Advisor
Advisor

ABAP Doc can be used to provide developer documentation for ABAP source code development objects (like classes, interfaces, function modules, programs) within the ABAP source code by using ABAP comments.

I would like to give you a short overview how you can document your ABAP source code development objects using ABAP Doc and where you can read the documentation written in ABAP Doc. I hope you like the new way of documenting your source code.

Please be aware that ABAP Doc has been introduced with SAP NetWeaver Application Server ABAP 7.4 (support package 2).

How can you write ABAP Doc?

With ABAP Doc, you can write your documentation directly within your source code using special comments in front of a declarative statement. This means you can document globally available artifacts (like classes, interface and their method and attribute), but also local artifacts (like local variables and field-symbols).

ABAP Doc comment block

An ABAP Doc comment block is introduced by the character combination "!. It has to be located directly in front of a declarative statement.

Example

"! This is a documentation for the following constant

constants co_initial_value type i value 0.


You can use multiple lines for your documentation to document your source code elements. In this case you have to add the character combination "! in front of each line.

Example

"! This documentation for the following constant is documented"! in multiple lines.

"! constants co_initial_value type i value 0.

If you want to document a block of statements by using the ABAP colon-comma-semantic the ABAP Doc comment block must be located in front of the identifier but after the colon.

Example

constants:  

  "! Initial value 

  co_initial_value type i value 0, 

  "! Invalid value 

  co_invalid_value type i value -1.


Document Parameters and Exceptions

For methods, events, function modules and form routines you can also document the parameters and exceptions. The following syntax is used to document parameters and exceptions:

Documentation for Syntax
Parameters @parameter <parameter name> | <parameter documentation>
Class-based exceptions @raising <exception name>   | <exception documentation>
Classic exceptions @exception <exception name> | <exception documentation>

Example

"! This method compares two sources and returns whether they

"! are identical.

"!

"! @parameter source1           | First source code text

"! @parameter source2           | Second source code text

"! @parameter ignore_case       | X = text will be compared case insensitive

"! @parameter result            | X = sources are identical

"! @raising   cx_invalid_source | Is raised if an empty source code text is passed

"! @raising   cx_invalid_source | Is raised if an empty source code text is passed

methods compare

  importing

      source1     type text

      source2     type text

      ignore_case   type abap_bool

  returning

      value(result) type abap_bool

  raising

      cx_invalid_source.

You can use quick fixes (Ctrl+1) within a ABAP Doc comment block to generate templates for all parameters and exceptions that have not been documented, yet.

Formatting options

The following tags can be used to format the output of your ABAP Doc documentation:

Formattingoption tag
Line break <br/> or <br></br>
Paragraph <p>...</p>
Emphasized text <em>...</em>
Strong emphasized text<strong>...</strong>
Unsorted lists <ul><li>...</li></ul>
Sorted lists <ol><li>...</li></ol>
Headers <h1>...</h1>
<h2>...</h2>
<h3>...</h3>

Example

"! This method compares <em>two</em> sources and returns whether they

"! are <strong>identical</strong>.

"!

"! @parameter source1           | First source code text

"! @parameter source2           | Second source code text

"! @parameter ignore_case       | X = text will be compared case insensitive

"! @parameter result            | X = sources are <strong>identical</strong>

"! @raising   cx_invalid_source | Is raised if an empty source code text is passed

"! @raising   cx_invalid_source | Is raised if an empty source code text is passed

methods compare

  importing

      source1     type text

      source2     type text

      ignore_case   type abap_bool

  returning

      value(result) type abap_bool

  raising

      cx_invalid_source.

Write correct ABAP Doc

To ensure that your ABAP Doc can be interpreted and rendered correctly by the system, we added some new additional checks when you execute the syntax check for your source code. If the position, the syntax or the formatting of your ABAP Doc comment is incorrect you will receive a warning:

Where can you read the documentation?

The documentation will be displayed in the source code element information that is displayed when you press F2 on an identifier or when you use the ABAP Element Info view:

Import ABAP Doc from descriptions

It is possible to generate ABAP Doc by importing the existing descriptions of global class and interfaces including their attributes, methods, parameters, etc.

To import the description in your class or interface, just open the class or interface and use the (context) menu entry "Source > Import ABAP Doc from Descriptions".

Afterwards, the corresponding ABAP Doc is inserted into your coding and you can save the changes.

ABAP Doc Features with NetWeaver 7.5

The blog New ABAP Doc Features with NetWeaver 7.5 describes following features which have been added with SAP NetWeaver Application Server ABAP 7.5:

  • How can you export your ABAP Doc from the ABAP server?
  • How can you synchronize ABAP Doc with short text descriptions?
64 Comments
Former Member
0 Kudos

Hello Thomas,

Any news about your thoughts for a downport to 7.40? Thanks and    

Kind regards

Holger

ThFiedler
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Holger,

sorry no additional downports planned for 7.40.

Regards,

Thomas.

Former Member
0 Kudos
Great to find this,
Hello missing 1 thing, what are the Escape chararacters for ABAP-Doc?
For example parameters/constants/... one gives descriptions like, 'ReceivingQty@Wharehouse' in SE37, SE24, SE80, ....
Then in Eclipse import the descriptions a described => problem with the fact the character '@' is in the text.  So what is the escape to put before the @ to avoid this?
Dirk
 
lukasbartek
Explorer
0 Kudos
Hi Michael,

Is the ABAP Doc meant only for the global objects like function modules and global classes/interfaces or is it possible to be able to use it with local classes?

Thank you,
Lukas
schneidermic0
Advisor
Advisor
0 Kudos
Hi Lukas,

Yes, you can use ABAP Doc also for local definitions like local classes or local interfaces. It is even possible to use ABAP Doc for local variables, types or constants.

Michael
0 Kudos
Is there also a possibility to add ABAP Doc to CDS views?

Comments in CDS start with // instead of "
but commenting with //! didn't make any difference...
former_member205436
Participant
0 Kudos
Hi Jakob,

currently there is no ABAP Doc for ABAP CDS.

Given that CDS is a specification that is implemented in both the ABAP Application Server (ABAP CDS) and again natively in HDB (HANA CDS) and that any Doc is expected to be consistent and work in both these environments, you can imagine that any future functionality in this regard will probably not be fully consistent with ABAP Doc as you know it today. As you already mentioned, the begin-comment delimiter will probably be different.

However, currently there are no immediate plans to enable source code Doc for CDS.

Regards

Chris
Former Member
0 Kudos
In ABAP Doc comments, the special characters ", ', <, > and @ must be escaped using ", ', <, > and @.

For more details please visit SAP Help: https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abendoccomment.htm
0 Kudos
Hi Michael

You probably do not know about ABAP Docs that I have developed in 2008 and many SAP customers wanted to add it to Standard ABAP Workbench. It was available for a year or two on SAP Software Website on a trail basis.

https://blogs.sap.com/2008/07/31/custom-abap-development-methodology/

You can read some comments of SAP customers in link above.

The above blog was the 3rd best blog of 2008: https://wiki.scn.sap.com/wiki/display/Community/Top+Ten+Blogs+for+2008

Unfortunetly, ABAP Docs was not included in SStandard ABAP Workbench.

 
mmcisme1
Active Contributor
0 Kudos
Very nice - 2019 and still relevant!
k_gorin
Participant
0 Kudos
Hey, Adam.

Is your code still available? I'm looking into developing some similar system for some times now. May be I could be of help to maintain or improve on your code basis.

Best regard, K
0 Kudos
Hi Michael,

Do you have an update regarding adding links in the ABAP Doc body?

Regards,

Silvia
schneidermic0
Advisor
Advisor
0 Kudos
Hi Silvia,

It is possible to add links which can be used in element info for releases with SAP_BASIS 7.52 or higher.

See also: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/de-DE/abendoccomment.htm

Unfortunately, the links won't work in ABAP Doc export, yet.

I hope this information helps.

Regards,
Michael
0 Kudos
Thanks for this fast reply!