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

Extract VSAM file attributes from Rexx


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

New User


Joined: 08 May 2008
Posts: 15
Location: Bangalore

PostPosted: Wed May 20, 2009 4:56 pm
Reply with quote

Hi All,

I want to get the attributes(space-units, space-allocated, space-used) from a VSAM file using REXX. I can do for flat files/PDS using LISTDSI but LISTDSI wil not support VSAM files.

Can anyone help me on this?

It would be great if i see any solution to this.

Thanks in advance
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed May 20, 2009 5:21 pm
Reply with quote

This is an old REXX for extracting some VSAM information using CSI. If you want to add more fields then you will have to refer to the manual below for field names and also change the code accordingly.

Click HERE to see the manual for using CSI. Appendix C.

You may also want to investigate DCOLLECT records as a source of information instead.

This was created for batch execution with CATIN DD * supplying the VSAM clusters to be interrogated. It Accepts full * ** % and %% filtering capabilities for CATIN.

Good luck ......................

Code:

/* REXX ** RETURNS VSAM INFO, HARBA, HURBA, PHYRECSZ, RECS/TRK       */
NUMERIC DIGITS(30)
 "EXECIO * DISKR CATIN ( STEM CAT. FINIS"
 DO KCNT = 1 TO CAT.0
 KEY = SUBSTR(CAT.KCNT,1,44)
MODRSNRC = SUBSTR(' ',1,4)
CSIFILTK = SUBSTR(KEY,1,44)
CSICATNM = SUBSTR(' ',1,44)
CSIRESNM = SUBSTR(' ',1,44)
CSIDTYPS = 'C               '
CSICLDI  = SUBSTR('Y',1,1)
CSIRESUM = SUBSTR(' ',1,1)
CSIS1CAT = SUBSTR(' ',1,1)
CSIRESRV = SUBSTR(' ',1,1)
CSINUMEN = '0005'X
CSIFLD1  = 'VOLSER  '
CSIFLD2  = 'HARBADS '
CSIFLD3  = 'HURBADS '
CSIFLD4  = 'PHYBLKSZ'
CSIFLD5  = 'NOBLKTRK'
CSIOPTS  = CSICLDI || CSIRESUM || CSIS1CAT || CSIRESRV
CSIFIELD = CSIFILTK || CSICATNM || CSIRESNM || CSIDTYPS || CSIOPTS
CSIFIELD = CSIFIELD || CSINUMEN || CSIFLD1 || CSIFLD2 || CSIFLD3
CSIFIELD = CSIFIELD || CSIFLD4 || CSIFLD5
WORKLEN = 65536
DWORK = '00001000'X || COPIES('00'X,WORKLEN-4)
RESUME = 'Y'
CATNAMET = SUBSTR(' ',1,44)
DNAMET = SUBSTR(' ',1,44)
DO WHILE RESUME = 'Y'
 ADDRESS LINKPGM 'IGGCSI00  MODRSNRC  CSIFIELD  DWORK'
 RESUME = SUBSTR(CSIFIELD,150,1)
 USEDLEN = C2D(SUBSTR(DWORK,9,4))
 POS1=15
 DO WHILE POS1 < USEDLEN
   IF SUBSTR(DWORK,POS1+1,1) = '0'
    THEN DO
         CATNAME=SUBSTR(DWORK,POS1+2,44)
         IF CATNAME ^= CATNAMET THEN
          DO
           SAY 'CATALOG ' CATNAME
           SAY ' '
           CATNAMET = CATNAME
          END
         POS1 = POS1 + 50
         END
   DNAME = SUBSTR(DWORK,POS1+2,44)  /* GET ENTRY NAME                */
   IF SUBSTR(DWORK,POS1+1,1) = 'C' THEN DTYPE = 'CLUSTER '
   ELSE IF SUBSTR(DWORK,POS1+1,1) = 'D' THEN DTYPE = 'DATA    '
   ELSE IF SUBSTR(DWORK,POS1+1,1) = 'I' THEN DTYPE = 'INDEX   '
   ELSE IF SUBSTR(DWORK,POS1+1,1) = 'A' THEN DTYPE = 'NONVSAM '
   ELSE IF SUBSTR(DWORK,POS1+1,1) = 'H' THEN DTYPE = 'GDS     '
   ELSE IF SUBSTR(DWORK,POS1+1,1) = 'B' THEN DTYPE = 'GDG     '
   ELSE IF SUBSTR(DWORK,POS1+1,1) = 'R' THEN DTYPE = 'PATH    '
   ELSE IF SUBSTR(DWORK,POS1+1,1) = 'G' THEN DTYPE = 'AIX     '
   ELSE IF SUBSTR(DWORK,POS1+1,1) = 'X' THEN DTYPE = 'ALIAS   '
   ELSE IF SUBSTR(DWORK,POS1+1,1) = 'U' THEN DTYPE = 'UCAT    '
   ELSE DTYPE = '        '
    POS1 = POS1 + 46
    NUMVOL = C2D(SUBSTR(DWORK,POS1+4,2))/6
    POS2 = POS1+14
    DO I=1 TO 3
      VOLSER.I = SUBSTR(' ',1,6)
    END
    DO I = 1 TO NUMVOL
      VOLSER.I = SUBSTR(DWORK,POS2,6)
      POS2 = POS2 + 6
    END
    DSHARBA  = X2D(C2X(SUBSTR(DWORK,POS2,4)))
    DSHARBA  = RIGHT(DSHARBA,15)
    POS2 = POS2 + 4
    DSHURBA  = X2D(C2X(SUBSTR(DWORK,POS2,4)))
    DSHURBA  = RIGHT(DSHURBA,15)
    POS2 = POS2 + 4
    DSBLKSZ  = X2D(C2X(SUBSTR(DWORK,POS2,4)))
    DSBLKSZ  = RIGHT(DSBLKSZ,6)
    POS2 = POS2 + 4
    IF NUMVOL > 1 THEN DO
       DO J = 2 TO NUMVOL
          POS2 = POS2 + 4
       END
    END
    BLKTRK   = X2D(C2X(SUBSTR(DWORK,POS2,2)))
    BLKTRK   = RIGHT(BLKTRK,6)
    IF DNAMET ^= DNAME THEN
    DO
     IF DTYPE = 'DATA    ' THEN DO
     SAY DTYPE DNAME VOLSER.1 VOLSER.2 DSHARBA DSHURBA DSBLKSZ BLKTRK
     END
     IF DTYPE = 'INDEX   ' THEN DO
     SAY DTYPE DNAME VOLSER.1 VOLSER.2 DSHARBA DSHURBA DSBLKSZ BLKTRK
     END
     DNAMET=DNAME
    END
    POS1 = POS1 + C2D(SUBSTR(DWORK,POS1,2))
  END
END
END
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed May 20, 2009 5:31 pm
Reply with quote

Code:
X = OUTTRAP("Lst.")                                  /*1*/
Address TSO "LISTCAT ENTRIES(your.vsam.file) ALL"    /*2*/
X = OUTTRAP("OFF")                                   /*3*/

Do I = 1 To Lst.0
   Say Lst.I                                         /*4*/
End


  1. The 1st OUTTRAP tells REXX to store the output in the stem var instead of displaying it on the console.
  2. the LISTCAT command.
  3. Stop trapping output
  4. You will have to check each line for the attributes you need.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed May 20, 2009 5:41 pm
Reply with quote

Looks like I have been using CSI for too long, and had completely forgotten about the IDCAMS approach.

Nice one Marso icon_lol.gif
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 FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Running REXX through JOB CLIST & REXX 13
Search our Forums:

Back to Top