12-13-2011 4:42 AM
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
12-13-2011 4:52 AM
just use a describe table on that source table and count the lines
12-13-2011 4:56 AM
Hi,
The methods cant be used with Describe table.I want to count lines of code for the methods in a Class.
Thanks
ST
12-13-2011 5:34 AM
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
12-13-2011 5:55 AM
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
12-14-2011 6:06 AM
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
12-14-2011 10:34 AM