IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Dynamically searching a string within all PDS members


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Krishnan85

New User


Joined: 01 Feb 2010
Posts: 2
Location: Chennai

PostPosted: Mon Feb 01, 2010 6:51 pm
Reply with quote

Hi. I am a new to REXX and just trying to learn it.

With the limited knowledge I have in REXX functions, I have written the following segment to search all the members of a PDS for a string.

The string I want to search is in variable 'TYP'. In my case TYP = 'ABC'.

'MEM1' is the current member in the PDS.

Right now the PDS name and string to search are static, but moving forward, I'll be making it dynamic.

My purpose is solved but I want to search for the string passed in TYP dynamically as against a static find I have used in the code attached. I have currently made use of 'FIND ALL' command in my code to accomplish my purpose.

Main ISPF Edit Macro
Code:

"ISREDIT MACRO"                                                         
"ISPEXEC LMINIT DATAID(DSNM) DATASET('X.Y.Z') ENQ(SHR)"
"ISPEXEC LMOPEN DATAID(&DSNM) OPTION(INPUT)"                                                                               
MEM=''                                                                 
DO FOREVER                                                             
  "ISPEXEC LMMLIST DATAID(&DSNM) OPTION(LIST) MEMBER(MEM) STATS(YES)"   
  IF RC <> 0 THEN LEAVE                                                 
  TYP = 'ABC'                                                           
  ADDRESS ISPEXEC                                                       
  MEM1 = STRIP(MEM)                                                     
  'VPUT (MEM1,TYP)' SHARED                                             
  "EDIT DATAID("DSNM") MEMBER("MEM1") MACRO(SCH1)"                     
END                                                                     
"ISPEXEC LMMLIST DATAID(&DSNM) OPTION(FREE)"                           
"ISPEXEC LMCLOSE DATAID(&DSNM)"                                         
EXIT                                                                   

ISPF Edit Macro SCH1 :
Code:

"ISREDIT MACRO PROCESS"       
ADDRESS ISPEXEC 'VGET (MEM1)'
ADDRESS ISPEXEC 'VGET (TYP)' 
MEM1=STRIP(MEM1)             
TYP=STRIP(TYP)               
"ISREDIT FIND ALL 'ABC' "     
IF RC = 0 THEN               
DO                           
   SAY MEM1       
END                           
"ISREDIT CANCEL"             
RETURN 

Please let me know if more details are needed.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Mon Feb 01, 2010 7:06 pm
Reply with quote

any reason to reinvent the wheel ?
isn' t search for good enough for you?
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Mon Feb 01, 2010 7:31 pm
Reply with quote

Krishnan, you're close. You can pass parameters to the ISPF Edit Macro, so the VPUT/VGET services aren't really needed. A few changes and your code should work:

1. Change for the calling program:
Code:

"EDIT DATAID("DSNM") MEMBER("MEM1") MACRO(SCH1)" 


to
Code:

"EDIT DATAID("DSNM") MEMBER("MEM1") MACRO(SCH1) PARM(TYP)" 


2. Change your macro:
Code:

"ISREDIT MACRO PROCESS"       
ADDRESS ISPEXEC 'VGET (MEM1)'
ADDRESS ISPEXEC 'VGET (TYP)' 
MEM1=STRIP(MEM1)             
TYP=STRIP(TYP)               
"ISREDIT FIND ALL 'ABC' "     
IF RC = 0 THEN               
DO                           
   SAY MEM1       
END                           
"ISREDIT CANCEL"             
RETURN


to:
Code:

"ISREDIT MACRO (TYP)"
"ISREDIT (MEM1) = MEMBER"
TYP = STRIP(TYP)               
"ISREDIT FIND ALL '"TYP"'"
IF RC = 0 THEN               
DO                           
   SAY MEM1       
END                           
"ISREDIT CANCEL"             
RETURN
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Tue Feb 02, 2010 2:03 am
Reply with quote

Based on the description so far, I do not think your main program needs to be a rexx macro.
Back to top
View user's profile Send private message
Krishnan85

New User


Joined: 01 Feb 2010
Posts: 2
Location: Chennai

PostPosted: Tue Feb 02, 2010 4:42 pm
Reply with quote

Superk,

Thanks a lot for your help. I tried incorporating the 'FIND ALL' instruction alone and it worked. Later, I also tried all the other changes and then realised that I can do it without VGET and VPUT.

I also have another query.

The following instruction passes one parameter,ie, TYP to the called program.
"EDIT DATAID("DSNM") MEMBER("MEM1") MACRO(MEMB2) PARM(TYP)"

Is there a similar way for me to pass two or more parameters? Else, do I have to go back to VPUT and VGET? Currently my need is to pass two strings, say TYP1 and TYP2, from the calling macro to the called macro.

Hope some one resolves this query as well.

Thanks in advance once again.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Dynamically pass table name to a sele... DB2 2
No new posts file manager is doing string conversion IBM Tools 3
Search our Forums:

Back to Top