View previous topic :: View next topic
|
Author |
Message |
Krishnan85
New User
Joined: 01 Feb 2010 Posts: 2 Location: Chennai
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
any reason to reinvent the wheel ?
isn' t search for good enough for you? |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2546 Location: Silicon Valley
|
|
|
|
Based on the description so far, I do not think your main program needs to be a rexx macro. |
|
Back to top |
|
|
Krishnan85
New User
Joined: 01 Feb 2010 Posts: 2 Location: Chennai
|
|
|
|
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 |
|
|
|