Skip to Content
Author's profile photo Jerry Wang

An ABAP tool to get ABAP source codes line number

You can use this tool ( an ABAP report ) to get the line number of your ABAP source code.

How to use this tool

Just specify the criteria based on which the source code will be scanned and line number will be calculated.

/wp-content/uploads/2016/04/clipboard12_921223.png

Execute and it will show you detail statistics about line number and the total count. Double click on the ALV list item and you can navigate to method source code.

/wp-content/uploads/2016/04/clipboard13_921293.png

How to get the source code of this tool

This tool consists of the following ABAP objects ( as also listed in above picture):

  • report ZTOOL_CODE_LINE_COUNT
  • include ZTOOL_DEV_OBJ_SELSCR1
  • class ZCL_TOOL_RS_SERVICE
  • class ZCL_TOOL_SRC_CODE_ANALYZE
  • class ZCL_TOOL_SRC_CODE_LOCATION
  • class ZCL_TOOL_SRC_CODE__ANALYSIS
  • interface ZIF_TOOL_SRC_CODE__ANALYSIS
  • table ZTOOL_METRICS_LO

You can get all their source code from this github repository. Feel free to change the source code to fulfill your own requirement.

Text Symbols:

/wp-content/uploads/2016/04/clipboard1_921294.png

Selection Texts:

/wp-content/uploads/2016/04/clipboard2_921295.png

/wp-content/uploads/2016/04/clipboard3_921296.png

Table structure

/wp-content/uploads/2016/04/clipboard4_921297.png

Assigned Tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sandra Rossi
      Sandra Rossi

      Thanks 🙂 . It adds the count of comment lines to the tool of Andrea Olivieri/Sergio Ferrari (http://scn.sap.com/community/abap/blog/2011/10/25/how-many-lines-of-custom-abap-code-are-inside-your-system-part3). Maybe a future enhancement could be the statistics for procedures  By the way, I'm surprised that you don't use SCAN ABAP-SOURCE for avoiding parsing errors (I see you have a simplified method for counting comments based on " in the line which could not be correct sometimes). Is that on purpose (because SCAN is an internal statement)?

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hello Sandra,

      I agree with you that it is better to use SCAN ABAP-SOURCE as it is more accurate and efficient. Thanks a lot for pointing this out 🙂

      Best regards,

      Jerry

      Author's profile photo Juwin Pallipat Thomas
      Juwin Pallipat Thomas

      Would you be able to tell, what is the practical use of this tool?

      Thanks,

      Juwin

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hello Juwin,

      I use this internally in our team to get a very draft estimation about the effort spent on a project once finished. Meanwhile when I provide support to our customers, I will do this scan in their system, if they allow me to do this. The purpose is to get an estimation on how many codes customer has done for their custom development. Normally we can assume that the more code they write, it proves the more business gaps customer have faced between their business process and SAP standard implementation.

      Best regards,

      Jerry

      Author's profile photo Sebastian Lenz
      Sebastian Lenz

      Sadly the repository isn't available anymore. This kind of code would be very helpful for me so maybe you could reupload it?

       

      Thanks,

       

      Sebastian

      Author's profile photo Sandra Rossi
      Sandra Rossi

      Probably it's there: https://github.com/wangzixi-diablo/abap/tree/master/ABAP/abapsourcecodetool