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

how to extract the member name ?


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

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Wed Feb 17, 2016 9:21 pm
Reply with quote

Hi Experts ,

I want to extract the alias name in the output from LISTDS member commands . Here is the output looks like:

Code:
UDASOLUT  ALIAS(DASOLUTN,DATAAGER)
XFAFAID  ALIAS(FILEAID)


so i want to have rexx to extract the member name so the output will become

Code:
UDASOLUT
DASOLUTN
DATAAGER
XFAFAID
FILEAID


Thanks
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Wed Feb 17, 2016 9:44 pm
Reply with quote

Combination of OUTTRAP to catch the LISTDS output and TRANSLATE to make the output lines into blank-delimited words should do it.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Thu Jul 13, 2017 1:58 am
Reply with quote

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()

/*====================================================================*/

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 Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
No new posts optim extract file - SAS DB2 2
No new posts How to copy the -1 version of a membe... TSO/ISPF 4
No new posts Searching for a member but don't know... TSO/ISPF 6
Search our Forums:

Back to Top