sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2018 Location: USA
|
|
|
|
Just accidentally faced this unfinished topic.
In my archives I found similar REXX code I created ages ago.
More or less flexible... But can be customized if desired.
Is it needed yet?
Code: |
/***** REXX ***********************************************************/
/* */
/* Function: */
/* Check member list of partitioned dataset */
/* */
/* Call: */
/* "NEWSTACK" */
/* MemList.0 = $PDSLIST( dataset_name {, ListType } ) */
/* If MemList.0 >= 0 Then */
/* Do iMember = 1 to MemList.0 */
/* Pull MemList.iMember */
/* End iMember */
/* Else Do */
/* --- handle possible errors --- */
/* End */
/* "DELSTACK" */
/* */
/* Parameters: */
/* dataset_name input DSNAME for the library */
/* ListType optional list type */
/* 'M' member names except aliases (default) */
/* 'A' aliases names only */
/* 'F' full list of members and aliases */
/* */
/* Return code: */
/* RC = -4 error in DSNInfo function; details in the stack */
/* RC = -3 error in ListDS function; details in the stack */
/* RC = -2 dataset not found */
/* RC = -1 dataset is not PDS */
/* RC = 0 no members in PDS */
/* RC > 0 the number of members found; the names in the stack */
/* */
/* Stack output: */
/* - after RC = -4 */
/* Error code from DSNInfo function */
/* Error message from DSNInfo function */
/* - after RC = -3 */
/* Error code from ListDS function */
/* - after RC > 0 */
/* list of library members */
/* */
/**********************************************************************/
$PDSLIST:
Arg InDSNAME, ListType .
If ListType = '' ,
| 1 <> Length( ListType ) ,
| 0 <> Verify( ListType, 'MAF' ) Then
ListType = 'M'
parse value DSNInfo( "'"InDSNAME"'", , 'F' ) ,
with rc info
Result = (rc + 0)
If Result = 8 Then
Return -2
Else If Result <> 0 Then
Do
Parse var info,
DSN Reason Message
Queue Reason
Queue message
Return -4
End
/* Normal case here, when RC = 0 */
Parse var info,
DSN,
volser,
unit,
dsorg, /* dataset organization */
recfm,
lrecl,
blksize,
keylen,
rkp,
created,
expires,
referenced,
password,
updated,
racfpro,
managed,
ddname,
status,
ndisp,
cdisp,
units,
alloc,
used,
extents,
primary,
secondary,
blkstrk,
trkscyl,
cylsvol,
adirblks,
udirblks,
members, /* total members */
dsntype,
storclass,
mgmtclass,
dataclass
If Substr( dsorg, 1, 2 ) <> 'PO' Then
Return -1
If members = 0 Then
Return 0
xc = outtrap('ML.')
"LISTDS '"InDSNAME"' MEMBERS"
If RC <> 0 Then
Do
Queue RC
Return -3
End
xc = outtrap('OFF')
Do il = 1 to ML.0
If ML.il = '--MEMBERS--' Then
Leave il
End il
MLines = (ML.0 - il)
Do il = (il + 1) to ML.0
Select
/* consider possible formats of ListDS output lines:
' member '
' member ALIAS(alias1) '
' member ALIAS(alias1,alias2,...,aliasN) '
' member ALIAS(alias1,alias2,...,aliasL, '
' aliasM,..........,aliasX, '
' aliasY,..........,aliasZ) '
' aliasZ) '
*/
When Words( ML.il ) > 1 Then
Do /* ' member ALIAS(alias1,alias2,alias3,...) ' */
If ListType <> 'A' Then /* extract real member when needed */
Queue Word( ML.il, 1 )
If ListType <> 'M' Then /* extract all aliases when needed */
Do
Parse value ML.il,
with . 'ALIAS(' Aliases ')' . /* extract from keyword */
Aliases = Translate( Aliases, ' ', ',' ) /* erase commas */
Do iA = 1 to Words(Aliases)
Queue Word( Aliases, iA )
End iA
End
End
When Substr( ML.il, 1, 3 ) = ' ' Then
Do /* ' alias1,alias2,alias3,...) ' */
If ListType <> 'M' Then /* extract all aliases when needed */
Do
Parse value ML.il,
with Aliases ')' . /* extract from keyword */
Aliases = Translate( Aliases, ' ', ',' ) /* erase commas */
Do iA = 1 to Words(Aliases)
Queue Word( Aliases, iA )
End iA
End
End
Otherwise /* ' member ' */
If ListType <> 'A' Then /* extract real member when needed */
Queue strip(ML.il)
End /* Select */
End il
Return Queued()
/*====================================================================*/
|
|
|