Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Count lines of code present in methods of a class

0 Kudos

Hi Friends,

Can anyone suggest how to count lines of abap code in methods of a class?I have used the function module 'SEO_CLASS_GET_INCLUDE_SOURCE' but this function module doesnt counts the code for methods of a class.

Kindly help.

Regards

ST

6 REPLIES 6

Former Member
0 Kudos

just use a describe table on that source table and count the lines

0 Kudos

Hi,

The methods cant be used with Describe table.I want to count lines of code for the methods in a Class.

Thanks

ST

Former Member
0 Kudos

Hi siji,

once try the below info.

data: itab type table of string.

data: w_lines type i.

read report <reportname> into itab.

describe table itab lines w_lines.

write: / 'Report lines:', w_lines.

It is however important to find the exact report name.

For standard ABAP reports it is easy, it is the name of the report itself.

For classes and function modules this is somewhat different.

Correct report name for function modules can be found as follows :

Use table TFDIR, field FUNCNAME is your function module.

PNMAME contains the main program name of the function group, not of the function module.

Function module report can be created as follows PNAME+3 concatenated with 'U' and field INCLUDE.

Example for the function module RFC_PING this will be

'LSRFC' + 'U' + 07 = report name LSRFCU07

Also take a look at the function module FUNCTION_INCLUDE_CONCATENATE

Hint: lines( ) is a built-in (system class) static function returning the number of lines in a given internal table. You will like it much better than old-fashioned DESCRIBE TABLE statement where you make us of a count variable an need one more statement for the summing up.

Note: If you dont want to count blank line and comments, try this code

delete itab where table_line is initial or table_line(1) = '*'.

add lines( itab ) to total_linecount.

Regards,

Ravi

0 Kudos

HI Ravi,

The above you mentioned is about Report program's and Function Module, but in case of CLASS I couldn't get how to count for the code lines for Methods present in them.

Like in case of cl_exithandler there is method called Get_instance.How to count in this case?

Thanks,

ST

kesavadas_thekkillath
Active Contributor
0 Kudos

Hi check function module SEO_METHOD_GET_SOURCE and use a describe statement to determine the LOC.

For ex: pass

MTDKEY-CLSNAME = 'CMD_EI_API' and CPDNAME = 'MAINTAIN_BAPI' and STATE = 'A' "Active

0 Kudos

Thanks Keshav, It worked.