I am trying to get my head around in one issue in which I want to seek you advise\possible solution for my below problem.
I have coded a REXX (GETME) which allows the user to search for a MEMBER in a PDS and if the MEMBER is not found in the PDS the it displays the proper message.
Everything was going perfect as i expected until when someone tried the below :-
Code:
TSO GETME PDS*
It caused the below error :-
Code:
IKJ56709I INVALID DATA SET NAME, 'MY.PDS1.DATA(PDS*)'
INVALID DATASET NAME, 'MY.PDS1.DATA(PDS*)'
IKJ56709I INVALID DATA SET NAME, 'MY.PDS2.DATA(PDS*)'
INVALID DATASET NAME, 'MY.PDS2.DATA(PDS*)'
MEMBER PDS* NOT FOUND
Below is my GETME REXX :-
Code:
PARSE ARG LINEDATA
"ISPEXEC CONTROL ERRORS RETURN"
MEMB = SUBSTR(LINEDATA,1,8) /* GET MEMBER NAME */
IF MEMB = ' ' then
DO
say 'MENTION THE NAME OF THE JOB/UTILITY YOU WANT TO SEARCH'
exit
END
IF SUBSTR(MEMB,8,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,7)
IF SUBSTR(MEMB,7,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,6)
IF SUBSTR(MEMB,6,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,5)
IF SUBSTR(MEMB,5,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,4)
IF SUBSTR(MEMB,4,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,3)
IF SUBSTR(MEMB,3,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,2)
IF SUBSTR(MEMB,2,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,1)
x = SYSDSN("'"DSNAME"'")
y = SYSDSN("'"DSNAME1"'")
IF (y ¬= 'OK' & x ¬= 'OK') THEN
DO
SAY 'MEMBER' MEMB 'NOT FOUND'
EXIT
END
IF (x = 'OK' & y = 'OK') THEN
DO
"ISPEXEC VIEW DATASET('"DSNAME"')"
"ISPEXEC VIEW DATASET('"DSNAME1"')"
EXIT
END
IF (x = 'OK' & y ¬= 'OK') THEN
DO
"ISPEXEC VIEW DATASET('"DSNAME"')"
EXIT
END
IF (y = 'OK' & x ¬= 'OK') THEN
DO
"ISPEXEC VIEW DATASET('"DSNAME1"')"
EXIT
END
The issue is that the below statements :-
Code:
x = SYSDSN("'"DSNAME"'")
y = SYSDSN("'"DSNAME1"'")
are not able to handle wildcard Char '*' .
Is there a possible way to check this? In ideal senario if the member PDS* is present in any of the PDS then it should display all the members in the corresponding PDS othewise should say 'Member not found'
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
Use the ISPF LM* services. (And RTFM/STFW if you don't know what they are!)
Code:
IF SUBSTR(MEMB,8,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,7)
IF SUBSTR(MEMB,7,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,6)
IF SUBSTR(MEMB,6,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,5)
IF SUBSTR(MEMB,5,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,4)
IF SUBSTR(MEMB,4,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,3)
IF SUBSTR(MEMB,3,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,2)
IF SUBSTR(MEMB,2,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,1)
IF MEMB = ' ' then
DO
say 'MENTION THE NAME OF THE JOB/UTILITY YOU WANT TO SEARCH'
exit
END
IF SUBSTR(MEMB,8,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,7)
IF SUBSTR(MEMB,7,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,6)
IF SUBSTR(MEMB,6,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,5)
IF SUBSTR(MEMB,5,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,4)
IF SUBSTR(MEMB,4,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,3)
IF SUBSTR(MEMB,3,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,2)
IF SUBSTR(MEMB,2,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,1)
can be replaced by
Code:
MEMB = STRIP(SUBSTR(LINEDATA,1,8)) /* GET MEMBER NAME */
IF MEMB = ' ' then
DO
say 'MENTION THE NAME OF THE JOB/UTILITY YOU WANT TO SEARCH'
exit
END
@ sushanth bobby :- Viewing the data is not a problem, it will execute as what you mentioned in your post. So for eg. if there is a MEM i.e. MEM1* which is not present in the PDS i.e. MY.PDS.TEST then i will end up getting a empty member MEM1* opened in MY.PDS.TEST because its not present. I don't want that. I first want my REXX to check if MEM1* is present in the PDS MY.PDS.TEST and if it is present then display all the members staring with MEM1* in the PDS else display "MEMBER NOT FOUND".
Why I need it ?
There are 20 datasets which I want to make a member search and client don't want to remeber all the datasets names and then srch for the member he want to srch. He want it to be in REXX and there could be some other enhancement to this requirement which need to be in REXX and so i am doing it
IF POS('*',INP1) = 1 THEN /* WILD CARD IN FIRST POS */
DO
.....
.....
END
IF POS('*',INP1,LEN1) = LEN1 THEN /* WILD CARD IN LAST POS */
DO
.....
.....
END
And, yea.. this handles only wildcard in first & last pos.. as I was too lazy to write a code for wild card char in mid, I dint spend time on that.. ;)
if you are able to, you are welcome to share the code !
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
Deepak KM wrote:
may be this will help you
Code:
LEN1 = LENGTH(INPUT)
IF POS('*',INP1) = 1 THEN /* WILD CARD IN FIRST POS */
DO
.....
.....
END
IF POS('*',INP1,LEN1) = LEN1 THEN /* WILD CARD IN LAST POS */
DO
.....
.....
END
And, yea.. this handles only wildcard in first & last pos.. as I was too lazy to write a code for wild card char in mid, I dint spend time on that.. ;)
if you are able to, you are welcome to share the code !
good luck..
Look daddy, I have added a useless post to this thread, to show that I am left and right clueless about REXX...
Another candidate for the "worst piece of code" contest, in the "rexx tools" category...
Code:
PARSE ARG LINEDATA
MEMB = SUBSTR(LINEDATA,1,8) /* GET MEMBER NAME */
IF SUBSTR(MEMB,8,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,7)
IF SUBSTR(MEMB,7,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,6)
IF SUBSTR(MEMB,6,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,5)
IF SUBSTR(MEMB,5,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,4)
IF SUBSTR(MEMB,4,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,3)
IF SUBSTR(MEMB,3,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,2)
IF SUBSTR(MEMB,2,1) = ' ' THEN MEMB = SUBSTR(MEMB,1,1)
Replaced by one line:
Code:
PARSE ARG MEMB . /* it's not dirt on your screen, it is a period */
Deepak KM wrote:
And, yea.. this handles only wildcard in first & last pos.. as I was too lazy to write a code for wild card char in mind, I didnt spend time on that.. ;)
Why do you think "wildcard in first & last pos" is important ?
Why not just be super lazy and write:
Code:
IF POS('*',MEMB) \= 0 THEN /* WILD CARD ANYWHERE */
DO
.....
.....
END
If i understood TS requirement... the below rexx might help...(i am guessing that your wild card search would be in general XXXX* coz most of the time we know what is the starting few characters of member name.. if not, few modification would be needed)...
Code:
/* REXX */
WILDCARD='N'
IF POS('*',SEARCHTEXT) > 0 THEN DO
WILDCARD='Y'
SEARCHTEXT=SUBSTR(SEARCHTEXT,1,POS('*',SEARCHTEXT)-1)
LEN=LENGTH(SEARCHTEXT)
SAY 'LISTING MEMBERS MATCHING YOUR SEARCH:'
END
PDS1 = "XX.X.XXXXX.PDS1"
PDS2 = "XX.X.XXXXX.PDS2"
X = OUTTRAP('M1.')
"LISTDS '"PDS1"' MEMBERS"
X = OUTTRAP('OFF')
X = OUTTRAP('M2.')
"LISTDS '"PDS2"' MEMBERS"
X = OUTTRAP('OFF')
DO N = 7 TO M1.0
PARSE VAR M1.N MEMBER
MEMBER=STRIP(MEMBER)
IF WILDCARD='N' THEN DO
DSNAME = (PDS1"("MEMBER")")
IF SYSDSN("'"DSNAME"'")='OK' & MEMBER=SEARCHTEXT THEN DO
ADDRESS ISPEXEC "VIEW DATASET('"DSNAME"')"
"ISREDIT RES"
END
END
IF WILDCARD='Y' THEN DO
IF POS(SEARCHTEXT,MEMBER)=1 THEN DO
SAY MEMBER
END
END
END
DO N = 7 TO M2.0
PARSE VAR M2.N MEMBER
MEMBER=STRIP(MEMBER)
DSNAME1 = (PDS2"("MEMBER")")
IF WILDCARD='N' THEN DO
IF SYSDSN("'"DSNAME1"'")='OK' & MEMBER=SEARCHTEXT THEN DO
ADDRESS ISPEXEC "VIEW DATASET('"DSNAME1"')"
"ISREDIT RES"
END
END
IF WILDCARD='Y' THEN DO
IF POS(SEARCHTEXT,MEMBER)=1 THEN DO
SAY MEMBER
END
END
END
EXIT 0
might nt be the most optimized one.. but should serve purpose...