This REXX code is to count the record in the PDS in Mainframe, just copy paste it into the pds and execute it
/*Rexx
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Runs ICETOOL
to count records */
/* */
/* */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* get dataset
name
*/
/*_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/*
*/
TRACE o
X =
MSG("Off")
arg count_dsn
if
length(search_dsn)=0 then do
say "Dataset name required"
say "Enter dataset name or press enter
to quit"
pull count_dsn
if length(count_dsn)=0 then exit
end
count_dsn =
strip(count_dsn,b,"'")
/*
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* check dsorg of
dataset and determine type of record count */
/* to
perform.
*/
/*_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/* */
x =
LISTDSI("'"count_dsn"'" directory smsinfo)
Select
When SYSDSORG =
PO Then
Do
Say "Sorry, this function does not work
for libraries"
Exit 4
End
When SYSUNIT ^=
3390 Then
Do
Say "Sorry, this function only works
for files on disk"
Exit 4
End
When SYSDSORG =
VS Then Call VCount
OTHERWISE
Call DCount
Exit Return_Code
/*
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
*/
/*_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/* */
DCOUNT:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Count DD */
/*_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _*/
/* */
"FREE da('"count_dsn"')"
"ALLOC
File(countdd) da('"count_dsn"') shr"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Toolin */
/*_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _*/
/* */
toolin = 'ttlu.BASE.cntl(icecount)'
"FREE
FILE(TOOLIN)"
"FREE da('"TOOLIN"')"
"ALLOC F(toolIN) da('"TOOLIN"')"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Toolmsg */
/*_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _*/
/* */
tmsgdsn =
'TTLU.']]SYSVAR("SYSUID")]]'.toolmsg'
"FREE
FILE(TOOLMSG)"
"FREE da('"TMSGDSN"')"
"DELETE
'"tmsgdsn"'"
"ALLOC
F(toolmsg) DA('"tmsgdsn"')
NEW CYLINDERS CATALOG SPACE(1,1)
UNIT(SYSDA)
BLKSIZE(0) RECFM(F,B,A) LRECL(133)"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* DFSMsg */
/*_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _*/
/* */
dmsgdsn =
'TTLU.']]SYSVAR("SYSUID")]]'.dfsmsg'
"FREE
FILE(DFSMSG)"
"FREE da('"DMSGDSN"')"
"DELETE
'"dMsgdsn"'"
"ALLOC
F(dfsmsg) DA('"dMsgdsn"')
NEW CYLINDERS CATALOG SPACE(1,1)
UNIT(SYSDA)
BLKSIZE(0) RECFM(F,B,A) LRECL(133)"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Run */
/*_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _*/
/* */
/*
"ICETOOL" */
ADDRESS LINKMVS
ICETOOL
Retcd = RC
If Retcd ^= 0 Then
Say 'Return code is ' RC
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Free
datasets */
/*_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _*/
/* */
Address TSO
"FREE FILE(toolin)"
"FREE FILE(toolmsg)"
"FREE FILE(dfsmsg)"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Dig out the
record count from */
/* the Toolmsg
file */
/*_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _*/
/* */
"FREE FILE(INDD)"
"ALLOC FILE(INDD)
DA('"tmsgdsn"') SHR",
eof = 'no' /* initialize
end-of-file */
hit_count=0
x t_count=0
"EXECIO *
DISKR Indd (STEM Irec." /* READ A LINE */
DO x = 1 TO
Irec.0
/* Say 'Checking line ' Irec.x */
If substr(Irec.x,2,22) = 'ICE628I 0
RECORD COUNT' Then
Do
Count = substr(Irec.x,27,15)
If count = 000000000000000 Then
Count = 0
Else
Count = strip(substr(Irec.x,27,15),l,'0')
Say 'The Record
Count for dataset ' Count_dsn ' = ' count
"FREE FILE(indd)"
"FREE FILE(toolin)"
"FREE FILE(toolmsg)"
"FREE FILE(dfsmsg)"
"FREE FILE(Countdd)"
Exit
End
End
End
"FREE FILE(indd)"
"FREE FILE(toolin)"
"FREE FILE(toolmsg)"
"FREE FILE(dfsmsg)"
"FREE FILE(Countdd)"
Return
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* VCOUNT */
/*
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
VCount:
X =
OUTTRAP(Irec.)
ADDRESS TSO
"LISTC ENT('"Count_DSN"')
ALL"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Analyze
outtrap & extract the */
/* relevant
parameters */
/*_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _*/
/* */
DO x = 1 TO
Irec.0
/* Say "Rec
number is " x */
/* Say
"Record being checked is " Irec.x
*/
If substr(Irec.x,8,9) = 'REC-TOTAL' Then
Do
Count
= strip(substr(Irec.x,17,15),l,'-')
Say 'The Record Count for dataset '
Count_dsn ' = ' count
Exit 0
End
End
Return
No comments:
Post a Comment