‎2009 Jul 14 5:21 AM
Hi,
We have a list of programmes and Transaction codes. We would like to know the number of lines of code in each object. Is there any standard program or table which can give us this data?
Thanks in advance.
Mick
‎2009 Jul 14 5:35 AM
hi Mick,
i have written a code for downloading the source code in wiki
hope it will be usefull for you to identify the lines of code
this code is for downloading the source code
TABLES: TRDIR, TADIR.
DATA: BEGIN OF REPLIST OCCURS 200, NAME(40) TYPE C, END OF REPLIST.
DATA: BEGIN OF BUFFER OCCURS 0, LINE(72) TYPE C, END OF BUFFER.
DATA: FILENAME(128) TYPE C, FILELENGTH(40) TYPE C.
SELECT-OPTIONS : SO_NAME FOR TADIR-OBJ_NAME.
SELECT-OPTIONS : SO_DEVC FOR TADIR-DEVCLASS.
PARAMETERS : PATHNAME(40).
PARAMETERS: P_AUTHOR LIKE SY-UNAME DEFAULT SY-UNAME.
SELECT * FROM TADIR
WHERE DEVCLASS IN SO_DEVC
AND OBJECT = 'PROG'
AND OBJ_NAME IN SO_NAME
AND AUTHOR = P_AUTHOR.
SELECT * FROM TRDIR
WHERE NAME = TADIR-OBJ_NAME
AND CNAM = P_AUTHOR.
MOVE TRDIR-NAME TO REPLIST-NAME.
APPEND REPLIST.
ENDSELECT.
ENDSELECT.
LOOP AT REPLIST.
READ REPORT REPLIST-NAME INTO BUFFER.
FILENAME = PATHNAME.
FILENAME+40 = REPLIST-NAME.
FILENAME+70 = '.'.
FILENAME+71 = 'txt'. "helpful to replace with SY-SYSID
* filename+51 = sy-sysid.
CONDENSE FILENAME NO-GAPS.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'ASC'
IMPORTING
FILELENGTH = FILELENGTH
TABLES
DATA_TAB = BUFFER
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2.
CASE SY-SUBRC.
WHEN 0.
WHEN 1.
WRITE : / 'did not download', FILENAME, 'error opening file.'.
WHEN 2.
WRITE : / 'did not download', FILENAME, 'error reading file.'.
WHEN OTHERS.
ENDCASE.
ENDLOOP.so in this code the final table will be having the source code
so its table index gives you the lines of code
hope it will be useful for you
The link to the above code is here
https://wiki.sdn.sap.com/wiki/display/Snippets/TodownloadABAPsourcecode
cheers
S.Janagar
‎2009 Jul 14 5:35 AM
hi Mick,
i have written a code for downloading the source code in wiki
hope it will be usefull for you to identify the lines of code
this code is for downloading the source code
TABLES: TRDIR, TADIR.
DATA: BEGIN OF REPLIST OCCURS 200, NAME(40) TYPE C, END OF REPLIST.
DATA: BEGIN OF BUFFER OCCURS 0, LINE(72) TYPE C, END OF BUFFER.
DATA: FILENAME(128) TYPE C, FILELENGTH(40) TYPE C.
SELECT-OPTIONS : SO_NAME FOR TADIR-OBJ_NAME.
SELECT-OPTIONS : SO_DEVC FOR TADIR-DEVCLASS.
PARAMETERS : PATHNAME(40).
PARAMETERS: P_AUTHOR LIKE SY-UNAME DEFAULT SY-UNAME.
SELECT * FROM TADIR
WHERE DEVCLASS IN SO_DEVC
AND OBJECT = 'PROG'
AND OBJ_NAME IN SO_NAME
AND AUTHOR = P_AUTHOR.
SELECT * FROM TRDIR
WHERE NAME = TADIR-OBJ_NAME
AND CNAM = P_AUTHOR.
MOVE TRDIR-NAME TO REPLIST-NAME.
APPEND REPLIST.
ENDSELECT.
ENDSELECT.
LOOP AT REPLIST.
READ REPORT REPLIST-NAME INTO BUFFER.
FILENAME = PATHNAME.
FILENAME+40 = REPLIST-NAME.
FILENAME+70 = '.'.
FILENAME+71 = 'txt'. "helpful to replace with SY-SYSID
* filename+51 = sy-sysid.
CONDENSE FILENAME NO-GAPS.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'ASC'
IMPORTING
FILELENGTH = FILELENGTH
TABLES
DATA_TAB = BUFFER
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2.
CASE SY-SUBRC.
WHEN 0.
WHEN 1.
WRITE : / 'did not download', FILENAME, 'error opening file.'.
WHEN 2.
WRITE : / 'did not download', FILENAME, 'error reading file.'.
WHEN OTHERS.
ENDCASE.
ENDLOOP.so in this code the final table will be having the source code
so its table index gives you the lines of code
hope it will be useful for you
The link to the above code is here
https://wiki.sdn.sap.com/wiki/display/Snippets/TodownloadABAPsourcecode
cheers
S.Janagar
‎2009 Jul 14 5:49 AM
Thanks Janagar.
I have a list of 600 reports and 500 TCodes. I would like to know the no of liness of code in each of these objects. I do not want the source code, as tht would be very time consuming to count the lines in the source code for so many objects.
Mick
‎2009 Jul 14 6:32 AM
hi mick,
u can use the same code for this purpose,
just neglect the last function module part and final internal table named Buffer is there right..
put describe statement on that gives you the total lines of your code.
it is more than enough i guess.
any guidance please get back to me
cheers
s.janagar
‎2009 Nov 06 4:29 AM