View previous topic :: View next topic |
Author |
Message |
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Mon Oct 05, 2009 10:24 am Post subject: Using LMDLIST on multiple masks |
|
|
I am running into something starnge when executing a REXX program and am hoping someone can tell me how to resolve this.
I have a REXX command which will except multiple dataset masks
(i.e. A111111.G*, Z222222.G*). I am trying to return all the datasets with those masks using LMDLIST.
I build an array which holds the masks and then I use a DO statement to loop thru the masks.
With in the DO statement I have the following:
Code: |
DO J = 1 to I
"LMDINIT LISTID(LMD) LEVEL("DSNAME.J")
Do Forever
"LMDLIST LISTID("LMD") OPTION(LIST) DATASET(DSET)"
IF RC > 0 then Leave
END
"LMDFREE LISTID("LMD")"
END
|
When I run this, I get different LISTIDs for each dataset mask
(This is OK).
When the A111111.G* occurs before the Z222222.G* in the array, I get the correct results. When the Z222222.G* occurs before the A111111.G* in the array, the datasets with the Z222222.G* mask are returned, but when the LMDLIST is executed for the A111111.G* mask, a return code of 8 is returned which kicks me out of the loop and doesn't return any datasets for that mask (even though there are datasets with that pattern).
Does anyone have a solution (other than sorting the datasets alphabetically) to this? Why does this happen? |
|
Back to top |
|
 |
expat Intermediate

Joined: 01 Mar 2007 Posts: 475 Topics: 9 Location: Welsh Wales
|
Posted: Tue Oct 06, 2009 1:53 am Post subject: |
|
|
You could presort the HLQ's Code: |
IF DSNAME.0 > 1 THEN
DO I1 = 1 TO DSNAME.0-1
DO I2 = I1+1 TO DSNAME.0
IF DSNAME.I1 > DSNAME.I2 THEN
DO
FIL = DSNAME.I1; DSNAME.I1 = DSNAME.I2; DSNAME.I2 = FIL
END
END
END
|
However, this is a grossly inefficient method of sorting large numbers of variables in a stem. For larger numbers please use the external SORT product. _________________ If it's true that we are here to help others,
then what exactly are the others here for ? |
|
Back to top |
|
 |
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Tue Oct 06, 2009 7:06 am Post subject: |
|
|
Thanks for the reply. However that is exactly why I don't want to sort if I don't have to. I could have a large number of data masks sent to me.
I am wondering why the LMDLIST works the way it does. I would think that every time the LMDLIST command is executed using a dataset mask that it would work independently of the last LMDLIST command.
Why would the LMDLIST not return values for a dataset mask just because of the order it was executed? |
|
Back to top |
|
 |
expat Intermediate

Joined: 01 Mar 2007 Posts: 475 Topics: 9 Location: Welsh Wales
|
Posted: Wed Oct 07, 2009 1:42 am Post subject: |
|
|
Try using this - I've added one line to reset the DSET variable before each iteration. It worked OK when I tested it.
Myself, I would use SYS1.SAMPLIB(IGGCSIRX) rather than this if there may be large numbers of requests to process. Code: |
DO J = 1 to I
DSET = ''
"LMDINIT LISTID(LMD) LEVEL("DSNAME.J")
Do Forever
"LMDLIST LISTID("LMD") OPTION(LIST) DATASET(DSET)"
IF RC > 0 then Leave
END
"LMDFREE LISTID("LMD")"
END
|
_________________ If it's true that we are here to help others,
then what exactly are the others here for ? |
|
Back to top |
|
 |
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Wed Oct 07, 2009 8:28 am Post subject: |
|
|
It worked! Great (and simple) solution!
You had mentioned the name of another program which I could use and I found it, but am not sure that this will fit my needs.
I am trying to write a program that will return all sequential files and PDS dataset/members given a list of masks. Once I have those captured, I will execute an edit macro on each one of these.
This is for doing mass changes when you have both sequential datasets and PDS members and you don't want to have to type out the full name of each dataset.
Thanks again for your input. Great solution! |
|
Back to top |
|
 |
|
|