List data sets

Scenario 1

With ZOAU, you can list all data sets that start with ${prefix}, showing details for the data sets with any of the following ways:

  • Issuing a shell command:

    • Option 1:
    dls -us "${prefix}.*"
    
    • Option 2:
    echo " LISTCAT LVL(${prefix}) ALL" | mvscmdauth --pgm=IDCAMS --sysprint=* --amsdump=dummy --sysin=stdin | awk '/0NONVSAM/ { print }'
    

  • Calling an API in Python programs:

    print(datasets.listing("%s.*" % HLQ, verbose=True))
    

Without ZOAU, to achieve the same purpose, you need to write the following JCL statements:

//*
//* List all the datasets that start with
//* to @@HLQ.ZOASAMP
//*
//DLS      EXEC PGM=IDCAMS 
//SYSPRINT DD SYSOUT=*
//AMSDUMP  DD DUMMY
//SYSIN    DD *
  LISTCAT LVL(@@HLQ@@.ZOASAMP) ALL
/*

Scenario 2

Use the dls shell command with option -V to list all the data sets in volume “RES480” that match the pattern “SYS1.M*”:

dls -l -V RES480 SYS1.M*

The output is as follows:

SYS1.MACLIB                                  PO  FB      80 RES480
SYS1.MIGLIB                                  PO  U        0 RES480
SYS1.MODGEN                                  PO  FB      80 RES480
SYS1.MSGCHS                                  PO  VB     259 RES480
SYS1.MSGDEU                                  PO  VB     259 RES480
SYS1.MSGENP                                  PO  VB     259 RES480
SYS1.MSGENU                                  PO  VB     259 RES480
SYS1.MSGJPN                                  PO  VB     259 RES480

Scenario 3

Use the dls shell command with options -l and -a to list the PDS members and members aliases of the data set SYS1.MIGLIB:

dls -l -a SYS1.MIGLIB

The output is as follows:

SYS1.MIGLIB                                  PO  U        0 RES480
ADYEXT
ADYGETSM
ADYHDFMT
AHLFCGTF
AHLFVEC  ALIAS(AHLFFP)
AHLTWINT
AIZBLKR
AMAPDUPL ALIAS(MTFTPS)
AMAPDUPT
AMASPZAP ALIAS(IMASPZAP)
AMATERSE ALIAS(GIMUNPCK TRSMAIN)

If you use wildcards in the data set name, the output is organized by data set. For example, use the following command to list the PDS members and members aliases of all the datasets that match the pattern SYS1.M*:

dls -l -a SYS1.M*       

The output is as follows:

SYS1.MACLIB                                  PO  FB      80 RES480
ABEND
ACBVS

SYS1.MIGLIB                                  PO  U        0 RES480
ADYEXT
IXLC2LBF ALIAS(IXLCTLBF)
IXLF1RTR ALIAS(IXLFMCBF IXLFMRTR IXLFMSTR)

SYS1.MODGEN                                  PO  FB      80 RES480
ADROAB
ADRRAB
ADRRBLKB

SYS1.MSGJPN                                  PO  VB     259 RES480
ADFSMRJP
ADYDAEJP ALIAS(GIMUNPCK TRSMAIN)