IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Code to count number of lines in a PDS


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Akash Sharma

New User


Joined: 13 Jan 2009
Posts: 36
Location: India

PostPosted: Fri Apr 17, 2009 4:18 pm
Reply with quote

Hi All,

Is it possible to write a code in REXX or CLIST which would could perform following operation:

1. Input: PDS Name

2. Functionality: Compute number of lines of code for each member in that PDS.

3. Output: A report in following format.

Code:

PDS: DEV.BAT.SOURCE
PROGRAM NAME                   LOC
PROG1                                 000456
PROG2                                 001173
PROG1                                 008702
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Fri Apr 17, 2009 4:21 pm
Reply with quote

Yes, of course. It'll have to be up to you to determine what constitutes a "line of code" and how to count it.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Fri Apr 17, 2009 4:22 pm
Reply with quote

Search for "LOC" to find other similar topics.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Apr 17, 2009 4:33 pm
Reply with quote

yes, suggest you read some of the documentation provided by this link:

www-01.ibm.com/software/awdtools/ispf/library/

and look for rexx documentation at:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/library

as well as search this forum for similarly titled exercises.

or if you are only looking for someone to provide you code in order to avoid learning something:

www.lbdsoftware.com/ispftools.html

home.roadrunner.com/~mvsrexx/REXX/

or

or mainipulate the data presented by a pds index listing
Back to top
View user's profile Send private message
Akash Sharma

New User


Joined: 13 Jan 2009
Posts: 36
Location: India

PostPosted: Fri Apr 17, 2009 4:53 pm
Reply with quote

HI Dick,

Thanks a lot for the effort and time u have put in replying to the query.
Well, a beginner just expects that some pro could give him a clue whether it is possible or not. I have looked into previous posts for LOC and then posted a new one.
Thanks anyway. Help is much appreciated.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Fri Apr 17, 2009 9:34 pm
Reply with quote

Quote:
a beginner just expects that some pro could give him a clue whether it is possible or not.


If you want lines of text, it is fairly easy. Search the ISPF manuals for the LMMLIST service.

Lines of code is not well defined. For example, some lines might be continued to another line. Is it counted as one line of code or two? Are comments considered lines of code?
Back to top
View user's profile Send private message
Akash Sharma

New User


Joined: 13 Jan 2009
Posts: 36
Location: India

PostPosted: Mon Apr 20, 2009 10:17 am
Reply with quote

Hi Pedro,

Quote:

Is it counted as one line of code or two? Are comments considered lines of code?


Yes, Comments are considered in LOC and continuation of a command in second line also considered as 2 lines.
Its just counting no. of lines in a program blindly.

Thanks for the help.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Tue Apr 21, 2009 5:26 am
Reply with quote

LMMLIST relies on the ISPF statistics being turned on. Sometimes they are not.
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Fri May 15, 2009 1:46 pm
Reply with quote

Akash,

Though belated I think I have solution for your problem, let me know if this solves your problem

/*REXX*/
/*ARG DSN */
DSN='XXXX.YYYY.ZZZZ'
DSN0='AAAA.BBBB.CCCC'
ADDRESS TSO "ALLOC DA('"DSN0"') DD(OUTDD) MOD REUSE"
"EXECIO 0 DISKW OUTDD (OPEN" /* OPEN INDD */
X = OUTTRAP('VAR.')
"LISTDS '"DSN"' MEMBERS"
G = 0
/*SAY 'THE NUMBER OF LINES TRAPPED IS' VAR.0 */
DO I = 7 TO VAR.0
MEM=DSN || '(' || STRIP(VAR.I) || ')'
DSE=SYSDSN("'"MEM"'")
IF DSE <> 'OK' THEN
"FREE DD(INDD)"
ADDRESS TSO "ALLOC DA('"MEM"') DD(INDD) SHR REUSE"
EOFFLAG = 2 /* RETURN CODE TO INDICATE END-OF-FILE */
RETURN_CODE = 0 /* INITIALIZE RETURN CODE */
IN_CTR = 0 /* INITIALIZE # OF LINES READ */
"EXECIO 0 DISKR INDD (OPEN" /* OPEN INDD */
DO WHILE (RETURN_CODE ¬ = EOFFLAG) /* LOOP WHILE NOT END-OF-FILE */
'EXECIO 1 DISKR INDD' /* READ 1 LINE TO THE DATA STACK */
RETURN_CODE = RC /* SAVE EXECIO RC */
IF RETURN_CODE = 0 THEN /* GET A LINE OK? */
DO /* YES */
IN_CTR = IN_CTR + 1 /* INCREMENT INPUT LINE CTR */
PARSE PULL LINE.1 /* PULL LINE JUST READ FROM STACK*/
END
END
SAY IN_CTR
G = G + 1
REPORT.G = MEM || ''LINES OF CODE'' IN_CTR
"EXECIO 0 DISKR INDD (FINIS" /* CLOSE THE INPUT FILE, INDD */
"FREE FI(INDD)"
END
X = OUTTRAP('OFF')
DO M = 1 TO G
END
'EXECIO 'G 'DISKW OUTDD(FINIS STEM 'REPORT.
"FREE FI(OUTDD)"
EXIT
END
Back to top
View user's profile Send private message
Akash Sharma

New User


Joined: 13 Jan 2009
Posts: 36
Location: India

PostPosted: Fri May 15, 2009 2:04 pm
Reply with quote

Prasad,

Thanks a lot for the code.
In the meantime i was too working on it.
The below code which i wrote is working too... icon_smile.gif
I have also written an ISPF Panel from where im taking the PDS name as input...performing some validations on it.

Code:

X = OUTTRAP(LISTMEM.,"*")
"LISTDS '"DASN"' MEM "    /* DASN--> PDS NAME

DO CNT = 7 TO LISTMEM.0                                     
   MCNT = MCNT + 1                                         
   MEM = STRIP(LISTMEM.CNT)                                 
   LOC.MCNT = MEM                                           
   PDS=DASN'('MEM')'                                       
   "ALLOC DA('"PDS"') F(INDD4) SHR REUSE"                   
   "EXECIO * DISKR INDD4 (STEM MEMLOC. FINIS"               
   FINVAR.MCNT = DASN || '    ' || MEM || '    ' || MEMLOC.0
   MLOC = MLOC + MEMLOC.0                                   
END


Here MLOC gives a total count count of LOCs in the PDS...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
Search our Forums:

Back to Top