Skip to Content

Count lines of code present in methods of a class

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2011 at 04:52 AM

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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2011 at 05: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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • Posted on Dec 14, 2011 at 06: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.