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

abap line code counter

Former Member
0 Likes
4,610

HI Guru,

I have a problem.

I need to count line of my program or function module or module pool without empty line for calculate a percentage of total line with a commnet line ('*')

you know a tool sap or external or you have a similar custom program?

thanks in advances.

Valerio

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,948

>

> I need to count line of my program or function module or module pool without empty line for calculate a percentage of total line with a commnet line ('*')

>

HI ,

Use the follwing Code ..

------------------------------------------------------------------------------------------------
TYPES: BEGIN OF T_TYPE,
         LINE(72),
       END OF T_TYPE.

data: ITAB    TYPE STANDARD TABLE OF T_TYPE WITH
                            NON-UNIQUE DEFAULT KEY INITIAL SIZE 500 ,
      WA      TYPE T_TYPE,
      count   type i.

parameters: program type sy-repid default 'ZTEST''.

READ REPORT PROGRAM INTO ITAB.
IF SY-SUBRC = 0.
LOOP AT ITAB INTO WA.
if wa-line+0(1) = '*'.
count = count + 1.
endif.
ENDLOOP.
ENDIF.

Write:/ 'No of Comment Lines is ' , count .

--------------------------------------------------------------------------------------------------------------

Regards,

Rajesh

7 REPLIES 7
Read only

hymavathi_oruganti
Active Contributor
0 Likes
1,948

Write the below statement in another report and run.

READ REPORT prog INTO itab [MAXIMUM WIDTH INTO wid]

[STATE state].

maximum width "wid" contains the lines in the report.

Read only

Former Member
0 Likes
1,949

>

> I need to count line of my program or function module or module pool without empty line for calculate a percentage of total line with a commnet line ('*')

>

HI ,

Use the follwing Code ..

------------------------------------------------------------------------------------------------
TYPES: BEGIN OF T_TYPE,
         LINE(72),
       END OF T_TYPE.

data: ITAB    TYPE STANDARD TABLE OF T_TYPE WITH
                            NON-UNIQUE DEFAULT KEY INITIAL SIZE 500 ,
      WA      TYPE T_TYPE,
      count   type i.

parameters: program type sy-repid default 'ZTEST''.

READ REPORT PROGRAM INTO ITAB.
IF SY-SUBRC = 0.
LOOP AT ITAB INTO WA.
if wa-line+0(1) = '*'.
count = count + 1.
endif.
ENDLOOP.
ENDIF.

Write:/ 'No of Comment Lines is ' , count .

--------------------------------------------------------------------------------------------------------------

Regards,

Rajesh

Read only

0 Likes
1,948

thanks guru,

but this instruction work only for a report, but for a FM or module pool?

there is an another instruction?

V

Read only

0 Likes
1,948

Just put SAPL in front your FM name.

Read only

0 Likes
1,948

i have just try, but don't work

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,948

Hello,

For Module Pool: Put SAPM* infront of module pool program.

For func. modules i am checking

BR,

Suhas

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,948

Hello,

I got the FM: RPY_FUNCTIONMODULE_READ, which will read the source code for the FM.

Pass the FM name to it & enjoy !!!

Added:

You can get the report name of the corresponding Func. Module from the table TFDIR. (TFDIR-PNAME)

BR,

Suhas

Tip: Check the "TABLES" SOURCE (structure RSSOURCE)