View previous topic :: View next topic
|
Author |
Message |
rameyshkanthan v
New User
Joined: 15 Nov 2013 Posts: 10 Location: India
|
|
|
|
Hi All,
I want to list the members of a PDS which are in particular pattern(like member* we use in 3.4 search ).
PDS name -> ramesh.pds.dt12
member -> MEMBERA, MEMBERB, MEMBERC
I tried using the ISPF function LMMLIST,but got RC4. If I give MEMBERA in pattern then i get RC0.
Code: |
dsn = ramesh.pds.dt12
memid = 'MEMBER?'
/*****Begin main *******/
'ISPEXEC LMINIT DATAID(dataid)
DATASET('''dsn''')
ENQ(SHRW)'
'ISPEXEC LMOPEN DATAID('dataid')'
do forever
'ISPEXEC LMMLIST DATAID('dataid') OPTION(LIST) MEMBER('memlist')
STATS(NO) pattern('memid')'
if rc <> 0 then leave
say 'MEMBER LIST:' memlist
end
'ISPEXEC LMCLOSE DATAID('dataid')'
'ISPEXEC LMFREE DATAID('dataid')'
|
Thanks in advance |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Change MEMBER? to MEMBER* |
|
Back to top |
|
|
rameyshkanthan v
New User
Joined: 15 Nov 2013 Posts: 10 Location: India
|
|
|
|
Thank you, Its working now
Actually I want to scan a PDS and search member names with pattern MEMBER* ..
If only MEMBERA & MEMBERB are found in the PDS, then i need to return MEMBERC.
Same applies till MEMBERZ.
I thought LMMLIST will help me to do this, but now lost somewhere..
Can anybody give me an idea on this |
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
I have done this slightly different.
The pattern is done once outside of the loop. This creates the list.
The say statement is at the top of the loop.
Subsequent LMMLIST and rc check are at the bottom of the loop.
Code: |
dsn = ramesh.pds.dt12
memid = 'MEMBER*'
/*****Begin main *******/
'ISPEXEC LMINIT DATAID(dataid)
DATASET('''dsn''')
ENQ(SHRW)'
'ISPEXEC LMOPEN DATAID('dataid')'
'ISPEXEC LMMLIST DATAID('dataid') OPTION(LIST) MEMBER('memlist')
STATS(NO) pattern('memid')'
if rc <> 0 then do
Say 'No matches found'
exit
end
do forever
say 'MEMBER LIST:' memlist
'ISPEXEC LMMLIST DATAID('dataid') OPTION(LIST) MEMBER('memlist')
STATS(NO)'
if rc <> 0 then leave
end
'ISPEXEC LMMLIST DATAID('dataid') OPTION(FREE)'
'ISPEXEC LMCLOSE DATAID('dataid')'
'ISPEXEC LMFREE DATAID('dataid')' |
|
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
How do you expect to return MEMBERC if the only members are A & B? |
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
After I read Nic's response.....
I mis-interpeted your question (silly me).
I thought you were not getting MEMBERC when it was actually there.
You want to know what the next MEMBER* will be?
Try this:
Code: |
Alphabet = 'ABCDEFGHIJKLMOPQRSTUVWXYZ'
Last_letter = right(memlist,1)
t1 = pos(last_letter,Alphabet)
t1 = t1 + 1
new_letter = substr(Alphabet,t1,1)
new_member = 'MEMBER'||new_letter |
If you have numbers, add them to your Alphabet. |
|
Back to top |
|
|
rameyshkanthan v
New User
Joined: 15 Nov 2013 Posts: 10 Location: India
|
|
|
|
@daveporcelan - Thanks a lot, code works fine |
|
Back to top |
|
|
|