Skip to Content
author's profile photo Former Member
Former Member

Finding number of lines in a program/function module

Hi Expets,

I would like to know is there any way to find the number of code lines in a ABAP program/function module.

Additionally, can i extend this to a package such that the utility will find the number of codelines in all the programs/function modules/include programs in that package.

Any hints regarding the same would be appreciated.

Regards,

Ramanath

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Posted on Aug 27, 2009 at 05:33 AM

    Dont violate forum rules with duplicate posts

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I understand the forum rules very well but because of some bug in the Forum framework, whenever the thread is edited, it will create another question instead of updating the same thread.

      I hope the forum experts are already looking into this issue.

      Regards,

      Ramanath

  • Posted on Aug 27, 2009 at 05:36 AM

    Ramnath,

    Check the syntax and F1 help of READ PROGRAM,may be you can get some lead.I remember a SAP standard program using such concept.

    K.Kiran.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 27, 2009 at 05:38 AM

    Hi,

    Check this funtion module.

    SVRS_GET_VERSION_REPS_40

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 27, 2009 at 05:49 AM

    Hi

    You can do it using the statement given below

    P_report is a parameter which holds the program name.

    data : it_report type standard table of string,"String

    • Read the report into internal table

    read report p_report into it_report.

    Describe the itab it_report to get the total lines

    Regards

    Ansari

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 27, 2009 at 06:29 AM

    1. First using Read report to load the source code to your internal table.

    2. Using SCAN statement to do analysis about the source code. pls refer to the sap keyword help about "SCAN".

    Syntax Diagram 
    SCAN 
    
    Note 
    This statement is for internal use only. 
    It cannot be used in application programs. 
    
    
    
    Variants: 
    1. SCAN ABAP-SOURCE itab1 ...TOKENS INTO itab2 
                           ...STATEMENTS INTO itab3. 
    
    2. SCAN AND CHECK ABAP-SOURCE itab1 ...RESULT INTO itab2. 
    
    
    Variant 1 
    SCAN ABAP-SOURCE itab1 ...TOKENS INTO itab2 
                           ...STATEMENTS INTO itab3.
    
    
    Parts marked with " ..." are interchangeable 
    
    
    
    Extras: 
    1. ... FROM n1 
    
    2. ... TO   n2 
    
    3. ... KEYWORDS   FROM itab4 
    
    4. ... LEVELS     INTO itab5 
    
    5. ... STRUCTURES INTO itab6 
    
    6. ... OVERFLOW INTO c1 
    
    7. ... WITH ANALYSIS 
    
    8. ... WITH COMMENTS 
    
    9. ... WITH INCLUDES [IMPLEMENTATIONS FROM itab] 
    
    10. ... WITH TYPE-POOLS 
    
    11. ... WITH LIST TOKENIZATION 
    
    12. ... PRESERVING IDENTIFIER ESCAPING 
    
    13. ... WITHOUT TRMAC 
    
    14. ... [INCLUDE] PROGRAM FROM c2 
    
    15. ... INCLUDE INTO c3 
    
    16. ... MESSAGE INTO c4 
    
    17. ... WORD    INTO c5 
    
    18. ... LINE    INTO n3 
    
    19. ... OFFSET  INTO n4 
    
    20. ... WITH EXPLICIT ENHANCEMENTS [IMPLEMENTATIONS FROM itab] 
    
    21. ... FRAME PROGRAM FROM c2 
    
    22. ... ENHANCEMENTS INTO itab

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 27, 2009 at 08:13 AM

    Use READ REPORT.............statement to get the number of program line.

    Example

    read report ztest into itab.

    describe table itab lines lin. it will give you the number of program lines

    To get the program line of all the objects inside the package use the following example

    Suppose you want to get the program line of all the programs inside a package 'ZPACK'

    Thne fetch all the program names insde this package from table TADIR

    select objname from tadir into itab_tadir

    where

    devclass = zpack and

    object = prog and

    pgmid = r3tr.

    loop at itab_tadir into wa_itab_tadir.

    read report wa_itab_tadir-obj_name into table itab1 (table length 2000 type c).

    describe table itab1 lines lin.

    write: lin

    endif.

    By this way you can get lines of all the program inside a package. for function module change object = FUNC PGMID = LIMU.

    Hope this will help you.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 27, 2009 at 08:51 AM

    Hi,

    check this blog:

    [How many lines of custom ABAP code are inside your system?|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/12853] [original link is broken] [original link is broken] [original link is broken];

    Kind Regards.

    Andrea

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 27, 2009 at 08:53 AM

    Hi,

    Try this

    READ REPORT p_prog INTO it_report.

    DESCRIBE TABLE it_report lines lv_lines.

    Regards,

    Prashant

    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.