View previous topic :: View next topic |
Author |
Message |
sudhtech Beginner
Joined: 27 Mar 2003 Posts: 6 Topics: 2 Location: Chennai
|
Posted: Wed Apr 02, 2003 7:32 am Post subject: Count number of lines of code |
|
|
Hi,
I would like to know how to count the number of lines of code for all my COBOL programs lying in 1 particular library. Say I have 100 programs in library1 and want to count the lines of code (LOC) in a single strech using REXX program/ any tool /JCL syncsort would be fine.
Thanks in advance ! _________________ Sudheer Nelluri |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Apr 02, 2003 8:02 am Post subject: |
|
|
Sudheer,
If you have file-aid at your shop then you can use the following JCL to get the desired results.
Code: |
//STEP0100 EXEC PGM=FILEAID
//*
//SYSLIST DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//DD01 DD DSN=YOUR SOURCE LIBRARY,
// DISP=SHR
//SYSIN DD *
$$DD01 TALLY
/*
|
Look at the sysprint messages in your job output and you will find the count of lines in the entire PDS
Hope this helps...
cheers
kolusu |
|
Back to top |
|
 |
CaptBill Beginner
Joined: 02 Dec 2002 Posts: 100 Topics: 2 Location: Pasadena, California, USA
|
Posted: Wed Apr 02, 2003 1:18 pm Post subject: |
|
|
I have a REXX which will do this. But "Lines of Code" is really not an accurate way of determining the functionpoints or actual work done. Think of this as just a raw count.
For example, I could write a field description on more than one line. But is it really more work than one line -- most likely not. Just someone wanting to make the formatting fit some standard.
Same can be said for SEARCH, PERFORM, IF and so on.
Then what about the program that has a COPY and the one that doesn't?
No, line counts are not really useful IMHO. |
|
Back to top |
|
 |
sudhtech Beginner
Joined: 27 Mar 2003 Posts: 6 Topics: 2 Location: Chennai
|
Posted: Thu Apr 03, 2003 12:04 am Post subject: |
|
|
Wow ! THis is working fine as an interactive command as well. But I am getting the problem in Batch mode (MXRC=255).Need to check this. Definitely an useful command for online mode. _________________ Sudheer Nelluri |
|
Back to top |
|
 |
sudhtech Beginner
Joined: 27 Mar 2003 Posts: 6 Topics: 2 Location: Chennai
|
Posted: Thu Apr 03, 2003 12:29 am Post subject: |
|
|
I have got a REXX t tool to find the total LOC of a program excluding comments..
Here I am posting the source code of the same..
Code: |
/********** REXX ************/
DETACH B
'CLRTERM'
'EXECIO * DISKR SMISUTI1 TEXT A (STEM VAL.';
SYED.='';
DO I=1 TO VAL.0
'CLRTERM'
VAL.1=VAL.I
FILE1=STRIP(VAL.1);
DETACH B
CALL ATT_T$SISA;
IF (RETURN_CODE=0) THEN
CALL PROCESS;
ELSE
DO
CALL ATT_T$SISB;
IF (RETURN_CODE1=0) THEN
CALL PROCESS;
ELSE
DO
CALL ATT_T$SISC;
IF (RETURN_CODE2=0) THEN
CALL PROCESS;
ELSE
DO
CALL ATT_T$SISD;
IF (RETURN_CODE3=0) THEN
CALL PROCESS;
ELSE
DO
CALL ATT_T$SISE;
IF (RETURN_CODE4=0) THEN
CALL PROCESS;
ELSE
DO
CALL ATT_T$SISF;
IF (RETURN_CODE5=0) THEN
CALL PROCESS;
END
END
END
END
END
END
/*********************************************************************/
/*********************************************************************/
ATT_T$SISA:
DETACH B
ATTACH T$SISA M AS B
'EXECIO * DISKR 'FILE1' PREPLI B (STEM SYED.';
RETURN_CODE=RC
RETURN;
ATT_T$SISB:
DETACH B
ATTACH T$SISB M AS B
'EXECIO * DISKR 'FILE1' PREPLI B (STEM SYED.';
RETURN_CODE1=RC
RETURN;
ATT_T$SISC:
DETACH B
ATTACH T$SISC M AS B
'EXECIO * DISKR 'FILE1' PREPLI B (STEM SYED.';
RETURN_CODE2=RC
RETURN;
ATT_T$SISD:
DETACH B
ATTACH T$SISD M AS B
'EXECIO * DISKR 'FILE1' PREPLI B (STEM SYED.';
RETURN_CODE3=RC
RETURN;
ATT_T$SISE:
DETACH B
ATTACH T$SISE M AS B
'EXECIO * DISKR 'FILE1' PREPLI B (STEM SYED.';
RETURN_CODE4=RC;
RETURN;
ATT_T$SISF:
DETACH B
ATTACH T$SISF M AS B
'EXECIO * DISKR 'FILE1' PREPLI B (STEM SYED.';
RETURN_CODE5=RC;
RETURN;
PROCESS:
LEN=SYED.0;
No_of_lines = 0
comment_flag = 0
do k=1 to len
pline = strip(syed.i)
comment_flag = pos('/*',pline)
if comment_flag = 0 then
do
No_of_lines = No_of_lines + 1
end
end
FILE_LINE.1= FILE1 || ' ' || No_of_lines;
'EXECIO 1 DISKW SMISUTI1 LINES A (STEM FILE_LINE.';
SYED.='';
DETACH B
RETURN;
|
Hope this will help us all .
Thanks to kolusu for FILEAID solution.
Cheers!
Sudheer _________________ Sudheer Nelluri |
|
Back to top |
|
 |
moyeenkhan Beginner
Joined: 04 Dec 2002 Posts: 64 Topics: 21
|
Posted: Thu Apr 03, 2003 9:50 am Post subject: |
|
|
Here is a quick solution
If your PDS member has statistics stored, it uses those statistics otherwise it reads a PDS member to give you the count
Code: |
/* ---------------- Rexx ------------------- */
xFromDsn="'Your.Pds.Name'"
Address ISPEXEC "LMINIT DATAID(xNameInp) DATASET("xFromDsn") ENQ(SHR)"
Address ISPEXEC 'LMOPEN DATAID('xNameInp') OPTION(INPUT)'
Do Forever
Address ISPEXEC 'LMMLIST DATAID('xNameInp') OPTION(LIST) MEMBER(xNextMem) STATS(YES)'
If Rc<>0 Then Leave
If ZLCNORC='' Then Call CountRecs
Else Say xNextMem "Has" Strip(ZLCNORC) "Records"
End
Address ISPEXEC 'LMCLOSE DATAID('xNameInp')'
Exit
CountRecs:
xDsName=Strip(xFromDsn,'T',"'")'('Strip(xNextMem)")'"
Address TSO
'FREE DD(xInpDsn)'
'ALLOC DD(xInpDsn) DSN('xDsName') SHR KEEP'
'EXECIO * DISKR xInpDsn (STEM XREC.'
'EXECIO 0 DISKR xInpDsn (FINIS'
'FREE DD(xInpDsn)'
Say xNextMem "Has" xRec.0 "Records"
Return
|
|
|
Back to top |
|
 |
Rahull Beginner

Joined: 29 Jan 2004 Posts: 62 Topics: 19
|
Posted: Tue Sep 20, 2005 12:28 pm Post subject: Count lines of active code |
|
|
Hi,
If I just want to calculate the total active code in PDS with 1000 of cobol programs. How will I do it ??
Key to differentiate active and inactive is 7th column will have asterisk (*) sign for inactive code.
Rahul |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Sep 20, 2005 12:45 pm Post subject: |
|
|
Rahul,
You can use IEBPTPCH to flatten the PDS to a sequential file and then use sort to eliminate the comments line.
When you IEBPTPCH, it inserts a new line "MEMBER xxxxxx' and creates a FBA file. so your contents are moved to the right by a byte.
Code: |
//STEP1 EXEC PGM=IEBPTPCH
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=YOUR PDS,
// DISP=SHR
//SYSUT2 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(10,10),RLSE)
//SYSIN DD *
PUNCH TYPORG=PO
//*
//STEP2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&T1,DISP=OLD
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OMIT COND=(2,6,CH,EQ,C'MEMBER',OR,8,1,CH,EQ,C'*')
SORT FIELDS=COPY
OUTFIL NODETAIL,REMOVECC,
TRAILER1=('TOTAL NO: LINES OF ACTIVE CODE: ',COUNT)
/*
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
|
|