Application Development and Automation 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: 
Read only

Finding number of lines in a program/function module

Former Member
0 Likes
2,118

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

10 REPLIES 10
Read only

GauthamV
Active Contributor
0 Likes
1,655

Dont violate forum rules with duplicate posts

Read only

Former Member
0 Likes
1,655

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

Read only

Former Member
0 Likes
1,655

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

Read only

kiran_k8
Active Contributor
0 Likes
1,655

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.

Read only

Former Member
0 Likes
1,655

Hi,

Check this funtion module.

SVRS_GET_VERSION_REPS_40

Read only

Former Member
0 Likes
1,655

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

Read only

daixiong_jiang3
Active Participant
0 Likes
1,655

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

Read only

Former Member
0 Likes
1,655

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.

Read only

andrea_olivieri
Contributor
0 Likes
1,655

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

Read only

former_member386202
Active Contributor
0 Likes
1,655

Hi,

Try this

READ REPORT p_prog INTO it_report.

DESCRIBE TABLE it_report lines lv_lines.

Regards,

Prashant