Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Tue Feb 04, 2003 11:17 am Post subject:
Try this
[code:1:9c6b8a3a91]
/* REXX */
/********************************************************************/
/* */
/* NAME: IGGCSIRX */
/*DESCRIPTION: THIS REXX EXEC IS USED TO CALL THE CATALOG */
/* SEARCH INTERFACE. */
/* INPUT: FILTER KEY */
/* OUTPUT: DATA SETS NAMES AND VOLUMES */
/* */
SAY 'ENTER FILTER KEY' /* ASK FOR FILTER KEY */
PULL KEY /* GET FILTER KEY */
/********************************************************************/
/* */
/* INITIALIZE THE PARM LIST */
/* */
/********************************************************************/
MODRSNRC = SUBSTR(' ',1,4) /* CLEAR MODULE/RETURN/REASON */
CSIFILTK = SUBSTR(KEY,1,44) /* MOVE FILTER KEY INTO LIST */
CSICATNM = SUBSTR(' ',1,44) /* CLEAR CATALOG NAME */
CSIRESNM = SUBSTR(' ',1,44) /* CLEAR RESUME NAME */
CSIDTYPS = SUBSTR(' ',1,16) /* CLEAR ENTRY TYPES */
CSICLDI = SUBSTR('Y',1,1) /* INDICATE DATA AND INDEX */
CSIRESUM = SUBSTR(' ',1,1) /* CLEAR RESUME FLAG */
CSIS1CAT = SUBSTR(' ',1,1) /* INDICATE SEARCH > 1 CATALOGS*/
CSIRESRV = SUBSTR(' ',1,1) /* CLEAR RESERVE CHARACTER */
CSINUMEN = '0001'X /* INIT NUMBER OF FIELDS */
CSIFLD1 = SUBSTR('VOLSER',1,8) /* INIT FIELD 1 FOR VOLSERS */
/********************************************************************/
/********************************************************************/
/* */
/* BUILD THE SELECTION CRITERIA FIELDS PART OF PARAMETER LIST */
/* */
/********************************************************************/
CSIOPTS = CSICLDI || CSIRESUM || CSIS1CAT || CSIRESRV
CSIFIELD = CSIFILTK || CSICATNM || CSIRESNM || CSIDTYPS || CSIOPTS
CSIFIELD = CSIFIELD || CSINUMEN || CSIFLD1
/********************************************************************/
/* */
/* INITIALIZE AND BUILD WORK ARE OUTPUT PART OF PARAMETER LIST */
/* */
/********************************************************************/
WORKLEN = 64000 /*@01C*/
DWORK = '0000FA00'X || COPIES('00'X,WORKLEN-4) /*@01C*/
/********************************************************************/
/* */
/* INITIALIZE WORK VARIABLES */
/* */
/********************************************************************/
RESUME = 'Y'
PREVNAME = '' /* NO PREVIOUS NAME @01A*/
CATNAMET = SUBSTR(' ',1,44)
DNAMET = SUBSTR(' ',1,44)
/********************************************************************/
/* */
/* SET UP LOOP FOR RESUME (IF A RESUME IS NCESSARY) */
/* */
/********************************************************************/
DO WHILE RESUME = 'Y'
RESUME = SUBSTR(CSIFIELD,150,1) /* GET RESUME FLAG FOR NEXT LOOP */
USEDLEN = C2D(SUBSTR(DWORK,9,4)) /* GET AMOUNT OF WORK AREA USED */
POS1=15 /* STARTING POSITION */
/********************************************************************/
/* */
/* PROCESS DATA RETURNED IN WORK AREA */
/* */
/********************************************************************/
DO WHILE POS1 < USEDLEN /* DO UNTIL ALL DATA IS PROCESSED*/
IF SUBSTR(DWORK,POS1+1,1) = '0' /* IF CATALOG, PRINT CATALOG HEAD*/
THEN DO
CATNAME=SUBSTR(DWORK,POS1+2,44)
IF CATNAME
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Wed Feb 05, 2003 1:18 am Post subject:
Akshaj, If I'm not wrong, all u want is to capture the list of datasets which start with the qualifier "abc.def.*". U can do this very easily.
The following Command will list all the datasets which start with the name/qualifier ABC.XYZ
Make sure not to use '*' in the name. U can get the name from the user with a '*' and then before using the following command, strip of the '.*' or '*' from the name. No Embedded * also are allowed.
COUNT = 1
DO WHILE COUNT <= NAMELIST.0
SAY STRIP(NAMELIST.COUNT)
COUNT = COUNT + 5
END
In the output of the above code, every 5th element will be the actual Dataset name. The other 4 rows will show the details of the datasets such as DSORG, VOLUME, ... This is the reason I'm incrementing the counter by 5. If u wish to see all the details increment the counter by 1.
The above code does not list any Datasets with the name exactly matching 'ABC.XYZ'. If u want that to be listed then u need to manually check for that as shown below.
Code:
IF SYSDSN(DIRECTORY) = 'OK' THEN
DO
SAY DIRECTORY
END
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
Posted: Wed Feb 05, 2003 2:56 am Post subject:
I never knew about the LEVEL parm on LISTDS but I tried it and it has a couple of serious drawbacks. It causes the data sets to be recalled if they are migrated. So that can take a very long time if the files are on tape. It also is subject to the TSO prefix in the profile so your example will not work if the profile has a prefix (unless that is what you intended). Finally, it looks like it probably updates the last referenced date, so it may mess up your backup or data set expiration procedures. You'd be better off using something that just goes against the catalog only and not the VTOC ( so use SVC 26, CSI, LMDLIST, LISTCAT, etc).
Personally, I don't like solutions that trap TSO command output because they are dependent on listing formats and those change occasionally. Invoking commands also can have unwanted side effects (like the ones listed above). I'd rather use documented programming interfaces such as APIs (as in IGGCSIRX) or chasing control blocks if those control blocks are gaurenteed by IBM to be stable from release to release. You have complete control over the input, output and side effects that way, and they will almost always perform orders of magnitude better.
I outtrap the LISTA dsn MEMBERS because LM services are so slow in REXX. Can't fault them in a compiled program, lightning quick... _________________ Dave Crayford
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum