View previous topic :: View next topic |
Author |
Message |
sheelu Beginner
Joined: 07 Apr 2014 Posts: 26 Topics: 6
|
Posted: Tue May 06, 2014 10:00 am Post subject: Count no:of occurrences of a string within a PDS |
|
|
Hi
I have written the following code to calculate the no:of occurrences of a string within A PDS.
Code: |
SAY 'ENTER STRING'
PULL STR
INPUT=XXXXXX.XXXXX.PDS (PDS NAME)
COUNT=0
X=OUTTRAP(BUF.)
ADDRESS TSO "LISTDS('"INPUT"') MEMBERS"
X=OUTTRAP("OFF")
DO I=7 TO BUF.0
BUF.I=STRIP(BUF.I)
ADDRESS TSO "ALLOC F(XX) DSN('"INPUT"("BUF.I")') SHR REU"
"EXECIO * DISKR XX (FINIS STEM NEWVAR.")
DO I=1 TO NEWVAR.0
IF POS(STR,NEWVAR.I) <> 0
THEN COUNT = COUNT +1
ELSE
NOP
END
END
END
SAY COUNT
EXIT
|
On executing the code,the count value is printed but it is equal to the no:of occurrences of the string in the first member of the PDS and thereafter the error message "invalid data set name XXXX(PDS name)" is printed..
Can you please tell me how to achieve the count value equal to the total value of all occurrences of the string in the PDS?? |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue May 06, 2014 12:13 pm Post subject: |
|
|
sheelu,
Code: |
/* REXX */
SAY 'ENTER STRING TO SEARCH '
PULL STR
MAC = 'PDSRCH'
PDS = "'Your.pds.to.be.searched'"
TOT_COUNT = 0
ADDRESS ISPEXEC "VPUT (STR) SHARED"
SAY 'SEARCHING THE PDS : ' PDS
SAY 'STRING TO BE SEARCHED : ' STR
X = OUTTRAP("LIBMEM.")
ADDRESS TSO "LISTDS "PDS" M"
X = OUTTRAP("OFF")
PDS = STRIP(PDS,"B","'")
DO I = 7 TO LIBMEM.0
LIBMEM.I = STRIP(LIBMEM.I)
ADDRESS ISPEXEC "VIEW DATASET ('"PDS"("LIBMEM.I")') MACRO ("MAC")"
ADDRESS ISPEXEC "VGET (ZISPFRC) SHARED"
TOT_COUNT = TOT_COUNT + ZISPFRC
END
SAY 'TOTAL COUNT IS : ' TOT_COUNT
EXIT
|
The macro PDSRCH used to search
Code: |
/* REXX */
ADDRESS ISPEXEC "VGET (STR) SHARED"
ADDRESS ISREDIT "MACRO PROCESS"
ADDRESS ISREDIT "SEEK ALL '" || STR || "'"
ADDRESS ISREDIT "(ZISPFRC) = SEEK_COUNTS"
ADDRESS ISPEXEC "VPUT (ZISPFRC)"
ADDRESS ISREDIT "END"
EXIT |
_________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
sheelu Beginner
Joined: 07 Apr 2014 Posts: 26 Topics: 6
|
Posted: Wed May 07, 2014 12:56 am Post subject: |
|
|
Thanks Kolusu
I tried the code but on execution of the code,I am getting the error-
"command PDSRCH" not found!! |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed May 07, 2014 11:23 am Post subject: |
|
|
sheelu wrote: | Thanks Kolusu
I tried the code but on execution of the code,I am getting the error-
"command PDSRCH" not found!! |
Sheelu,
Did you save the second macro as PDSRCH ?
Follow these steps.
1. Save the 1st REXX exec as "STRSRCH"
2. Save the 2nd REXX exec as "PDSRCH"
3. Issue the command TSO STRSRCH which will give you the desired results. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
|
|