Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Handling WildChar '*' for MEMBER identification in PDS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 188
Location: india

PostPosted: Wed Jun 06, 2012 12:04 pm    Post subject: Handling WildChar '*' for MEMBER identification in PDS
Reply with quote

Hello People,

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)               
                                                                     
DSNAME = ("MY.PDS1.DATA("MEMB")")                   
DSNAME1 = ("MY.PDS2.DATA("MEMB")")                               
                                                                     
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'

Thank You,
Rajat
Back to top
View user's profile Send private message

prino

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Wed Jun 06, 2012 1:37 pm    Post subject:
Reply with quote

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)

?????
Code:
memb = strip(memb)
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Wed Jun 06, 2012 2:14 pm    Post subject:
Reply with quote

Code:
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)


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                               
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Thu Jun 07, 2012 2:32 pm    Post subject:
Reply with quote

Hi,

For the below rexx code i gave input like this, it worked.
Code:
TSO ZTEST1 SUSHANTH.REXX.CODE(TEST*)

rexx
Code:
/**REXX*************************
/*******************************
ARG DSN                         
"ISPEXEC VIEW DATASET('"DSN"')"


And i was just wondering, why would this be required because you can go to 3.4 and give the pds name and do like this,
Code:

Command - Enter "/" to select action       
-------------------------------------------
M        SUSHANTH.REXX.CODE(TI*)                 
***************************** End of Data S


Thanks,
Sushanth
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 188
Location: india

PostPosted: Sat Jun 09, 2012 9:15 am    Post subject:
Reply with quote

@ Pandora-Box :- Thanks for the syntax. Noted !!

@ 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 icon_smile.gif

Thank You,
Rajat
Back to top
View user's profile Send private message
Deepak KM

New User


Joined: 14 Jun 2012
Posts: 13
Location: India

PostPosted: Thu Jun 21, 2012 2:49 pm    Post subject:
Reply with quote

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..
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Thu Jun 21, 2012 4:01 pm    Post subject:
Reply with quote

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...
Back to top
View user's profile Send private message
Deepak KM

New User


Joined: 14 Jun 2012
Posts: 13
Location: India

PostPosted: Thu Jun 21, 2012 4:21 pm    Post subject:
Reply with quote

there may be other way also...
but this code stands good for the requirement, eventhough not fully... so how can it be 'useless' !!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jun 21, 2012 4:46 pm    Post subject:
Reply with quote

trying to defend the usage of POS vs LEFT and RIGHT


pos returns an integer based on the return of a compare
which is then compared

left
and
right return a char
which is then compared

is like defending
left for a block, left for a block, left for a block
vs
straight for a block

because you end-up in the same place.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Thu Jun 21, 2012 5:25 pm    Post subject:
Reply with quote

No Offense Deepak,
But it sounds like "I have 64bit machine, installing windows 7 32bit twice, would that make it 64bit Windows 7?"

(:
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Thu Jun 21, 2012 8:10 pm    Post subject:
Reply with quote

Another candidate for the "worst piece of code" contest, in the "rexx tools" category... icon_evil.gif

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
Back to top
View user's profile Send private message
Biswajit D

New User


Joined: 17 Apr 2012
Posts: 50
Location: India

PostPosted: Fri Jun 22, 2012 6:47 pm    Post subject:
Reply with quote

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...
Back to top
View user's profile Send private message
Biswajit D

New User


Joined: 17 Apr 2012
Posts: 50
Location: India

PostPosted: Fri Jun 22, 2012 7:01 pm    Post subject:
Reply with quote

oops... forgot to put ARG...
Code:
/* REXX   */                                                     
ARG SEARCHTEXT
WILDCARD='N'                                                     
IF POS('*',SEARCHTEXT) > 0 THEN DO                               
.
.
.
.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts File Stauts 92 with member of PDS sandip_mainframe COBOL Programming 4 Fri Jun 10, 2016 12:06 pm
No new posts Identification Division anandgbe COBOL Programming 2 Sat May 28, 2016 11:51 am
No new posts ON ERROR handling soundarr PL/I & Assembler 2 Wed May 11, 2016 3:37 am
No new posts Exception Handling in Native Stored P... Mariraj DB2 1 Thu Feb 25, 2016 4:08 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us