Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
how to extract the member name ?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 115
Location: windsor

PostPosted: Wed Feb 17, 2016 9:21 pm    Post subject: how to extract the member name ?
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 User


Joined: 01 Sep 2015
Posts: 161
Location: Switzerland

PostPosted: Wed Feb 17, 2016 9:44 pm    Post subject:
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

Active User


Joined: 29 Apr 2008
Posts: 170
Location: Maryland

PostPosted: Thu Jul 13, 2017 1:58 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Copying a ps to member of a existing PDS Deepika Chikyala JCL & VSAM 10 Tue Sep 05, 2017 11:44 am
No new posts Extract Data till prev hour balaji81_k DB2 16 Fri Aug 25, 2017 9:25 pm
No new posts What is the Extract Function in JCL dharmaraok JCL & VSAM 3 Wed Jun 14, 2017 9:12 am
No new posts member list compare jzhardy TSO/ISPF 6 Fri May 12, 2017 3:18 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us