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

Replace a string in all members of a PDS


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Jatin saraf

New User


Joined: 30 Mar 2007
Posts: 22
Location: United States of america

PostPosted: Wed Jul 11, 2007 3:14 am
Reply with quote

Hi,

I have a PDS with 100 members. I need to replace a string with another string in all the 100 members. The original string is the same in all the 100 members. Please let me know how this can be achieved other than manually doing it.
Back to top
View user's profile Send private message
Jatin saraf

New User


Joined: 30 Mar 2007
Posts: 22
Location: United States of america

PostPosted: Wed Jul 11, 2007 3:43 am
Reply with quote

Hi,

I dont have FILEAID/File Manager/Insync at my place.
Please let me know if any more info is required.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jul 11, 2007 5:02 am
Reply with quote

Hello,

I'm not aware of any "straight" tso/ispf command that will do this. As you mentioned, several add-ons provide this.

Have you talked with your system support people? They may have something that will do what you need. It is worth a chat to save doing it by hand. . . .
Back to top
View user's profile Send private message
Aryang4u

New User


Joined: 21 Feb 2006
Posts: 8
Location: Los Angels, CA

PostPosted: Wed Jul 11, 2007 5:07 am
Reply with quote

We have utility named PDSMAN check if its there in your system.
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Wed Jul 11, 2007 8:20 am
Reply with quote

Might want to look at this previous topic.
Back to top
View user's profile Send private message
Jatin saraf

New User


Joined: 30 Mar 2007
Posts: 22
Location: United States of america

PostPosted: Mon Jul 16, 2007 9:35 pm
Reply with quote

I have spoken to the DBA at my place. There is no such utility that is supported here. Can anybody give me a REXX code/any other code that would help in replacing a given string with another in all the members of a PDS.

Thanks,
Jatin
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Mon Jul 16, 2007 9:40 pm
Reply with quote

Jatin saraf wrote:
There is no such utility that is supported here.


What utility/function are you missing? REXX? IPSF? TSO? IPOUPDTE?
Back to top
View user's profile Send private message
Jatin saraf

New User


Joined: 30 Mar 2007
Posts: 22
Location: United States of america

PostPosted: Mon Jul 16, 2007 11:43 pm
Reply with quote

Hi,

Sorry for not mentioning that. I was talking about Fileaid/File manager/Insync which are not supported here.
Back to top
View user's profile Send private message
Jatin saraf

New User


Joined: 30 Mar 2007
Posts: 22
Location: United States of america

PostPosted: Tue Jul 17, 2007 1:02 am
Reply with quote

Does anybody know any way of doing this apart from the utilities mentioned in my above post?Please help.
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Tue Jul 17, 2007 3:40 am
Reply with quote

Here are 2 Rexx when used together they will do the job.

Code:
/* REXX RXPDS000 routine uses 2 parameters: pds name & subroutine name */
/* The subroutine is called for each member of the pds - passing     */
/* the pds and member names to perform the subroutine function       */
                                                                       
/* Example to list all members of a pds:                             */
/* RXPDS000 XXX.PROD.DB2.SQLLIB RXPDSL00                             */
                                                                       
Parse Upper Arg fromdsn func rest                                     
Say fromdsn ' ' func                                                   
 If 0<>listdsi("'"fromdsn"'") then                                     
  Do                                                                       
     Say 'Data set 'fromdsn' not allocated'                             
     Exit                                                               
   End                                                                 
 If 'PO'<>substr(sysdsorg,1,2) then                                     
   Do                                                                   
     Say 'Data set 'fromdsn' is not a pds'                             
     Exit                                                               
   End                                                                 
"ALLOC F(AREAD) DS('"fromdsn"') SHR REUSE DSORG(PS) LRECL(256) RECFM(F B)"
'EXECIO * DISKR AREAD ( FINIS STEM DIRS.'                               
'FREE F(AREAD)'                                                         
Do blocknum = 1 to dirs.0                                               
  block=dirs.blocknum                                                   
  Parse Var dirs.blocknum bl 3 block                                   
  block=substr(block,1,c2d(bl)-2)                                       
  Do While block<>''                                                   
    Parse Var block mbrname 9 ttr 12 c 13 block                         
    c=c2d(bitand(c,'1f'x))                                             
    If mbrname='FFFFFFFFFFFFFFFF'x then                                       
        Leave blocknum                   
    mbrname=strip(mbrname)             
    func fromdsn mbrname rest           
    If RC <> 0 then Exit(RC)           
    block=delstr(block,1,c*2)           
  End                                   
  If RC <> 0 then                       
    Do                                 
      Say "RC passed from function: " RC
    End                                 
End                                     
Exit(RC)                               

Code:
/*Rexx routine RXPDSU00 to Update (change) members of a pds fromval toval */
/*called from RXPDS000 for all or RXPDS001 for selected members    */
                                                                     
/*Example: RXPDS000 XXX9XXX.A.A RXPDSU00 CLASS=D CLASS=C           */
/*         change all members of XXX9XXX.A.A                       */
/*         change all values of CLASS=D to CLASS=C                 */
                                                                     
/*Example: RXPDS001 XXX9XXX.A.A RXPDSU00 XXX17 CLASS=D CLASS=C     */
/*         change all members of XXX9XXX.A.A starting with XXX17   */
/*         change all values of CLASS=D to CLASS=C                 */
                                                                     
/* Author: Douglas Wilder */                                           
                                                                     
Parse Upper Arg dsname name oldval newval rest                       
                                                                     
  SAY "'"dsname'('name")'"                                           
    /* READ/WRITE USING ARRAY */                                     
     FROM_NAME = "'"DSNAME"("NAME")'"                               
    /* READ/WRITE USING ARRAY */                                       
     FROM_NAME = "'"DSNAME"("NAME")'"                                   
    "ALLOCATE DDNAME(INFILE) SHR DSNAME(" FROM_NAME ")"                 
                                                                       
    "EXECIO * DISKR INFILE (STEM RECD. FINIS"                           
    HOW_MANY = RECD.0                                                   
                                                                       
    do c = 1 to how_many                                               
        strt = pos(oldval,recd.c)                                       
        do while strt > 0                                               
          say                                                           
          say recd.c                                                   
          ln = left(recd.c,strt-1)||newval||substr(recd.c,strt+length(oldval))
          recd.c = ln                                                   
          say recd.c                                                   
          strt = pos(oldval,recd.c)                                     
        end                                                             
    end c                                                               
                                                                       
    "EXECIO " HOW_MANY " DISKW INFILE (STEM RECD. FINIS"
                                                         
    "FREE DDNAME(INFILE)"                               
Exit                                                     


Example: RXPDS000 XXX9XXX.A.A RXPDSU00 CLASS=D CLASS=C
For ech member in PDS XXX9XXX.A.A Rexx RXPDS000 will call Rexx RXPDSU00 Passing it the PDS, member, CLASS=D, and CLASS=C.
Rexx RXPDU000 replace all occurances of CLASS=D with CLASS=C in that member of the PDS.
Back to top
View user's profile Send private message
Help-Me-Out

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Tue Jul 17, 2007 11:15 am
Reply with quote

Douglas Wilder wrote:
Here are 2 Rexx when used together they will do the job.

Code:
/* REXX RXPDS000 routine uses 2 parameters: pds name & subroutine name */
/* The subroutine is called for each member of the pds - passing     */
/* the pds and member names to perform the subroutine function       */
                                                                       
/* Example to list all members of a pds:                             */
/* RXPDS000 XXX.PROD.DB2.SQLLIB RXPDSL00                             */
                                                                       
Parse Upper Arg fromdsn func rest                                     
Say fromdsn ' ' func                                                   
 If 0<>listdsi("'"fromdsn"'") then                                     
  Do                                                                       
     Say 'Data set 'fromdsn' not allocated'                             
     Exit                                                               
   End                                                                 
 If 'PO'<>substr(sysdsorg,1,2) then                                     
   Do                                                                   
     Say 'Data set 'fromdsn' is not a pds'                             
     Exit                                                               
   End                                                                 
"ALLOC F(AREAD) DS('"fromdsn"') SHR REUSE DSORG(PS) LRECL(256) RECFM(F B)"
'EXECIO * DISKR AREAD ( FINIS STEM DIRS.'                               
'FREE F(AREAD)'                                                         
Do blocknum = 1 to dirs.0                                               
  block=dirs.blocknum                                                   
  Parse Var dirs.blocknum bl 3 block                                   
  block=substr(block,1,c2d(bl)-2)                                       
  Do While block<>''                                                   
    Parse Var block mbrname 9 ttr 12 c 13 block                         
    c=c2d(bitand(c,'1f'x))                                             
    If mbrname='FFFFFFFFFFFFFFFF'x then                                       
        Leave blocknum                   
    mbrname=strip(mbrname)             
    func fromdsn mbrname rest           
    If RC <> 0 then Exit(RC)           
    block=delstr(block,1,c*2)           
  End                                   
  If RC <> 0 then                       
    Do                                 
      Say "RC passed from function: " RC
    End                                 
End                                     
Exit(RC)                               

Code:
/*Rexx routine RXPDSU00 to Update (change) members of a pds fromval toval */
/*called from RXPDS000 for all or RXPDS001 for selected members    */
                                                                     
/*Example: RXPDS000 XXX9XXX.A.A RXPDSU00 CLASS=D CLASS=C           */
/*         change all members of XXX9XXX.A.A                       */
/*         change all values of CLASS=D to CLASS=C                 */
                                                                     
/*Example: RXPDS001 XXX9XXX.A.A RXPDSU00 XXX17 CLASS=D CLASS=C     */
/*         change all members of XXX9XXX.A.A starting with XXX17   */
/*         change all values of CLASS=D to CLASS=C                 */
                                                                     
/* Author: Douglas Wilder */                                           
                                                                     
Parse Upper Arg dsname name oldval newval rest                       
                                                                     
  SAY "'"dsname'('name")'"                                           
    /* READ/WRITE USING ARRAY */                                     
     FROM_NAME = "'"DSNAME"("NAME")'"                               
    /* READ/WRITE USING ARRAY */                                       
     FROM_NAME = "'"DSNAME"("NAME")'"                                   
    "ALLOCATE DDNAME(INFILE) SHR DSNAME(" FROM_NAME ")"                 
                                                                       
    "EXECIO * DISKR INFILE (STEM RECD. FINIS"                           
    HOW_MANY = RECD.0                                                   
                                                                       
    do c = 1 to how_many                                               
        strt = pos(oldval,recd.c)                                       
        do while strt > 0                                               
          say                                                           
          say recd.c                                                   
          ln = left(recd.c,strt-1)||newval||substr(recd.c,strt+length(oldval))
          recd.c = ln                                                   
          say recd.c                                                   
          strt = pos(oldval,recd.c)                                     
        end                                                             
    end c                                                               
                                                                       
    "EXECIO " HOW_MANY " DISKW INFILE (STEM RECD. FINIS"
                                                         
    "FREE DDNAME(INFILE)"                               
Exit                                                     


Example: RXPDS000 XXX9XXX.A.A RXPDSU00 CLASS=D CLASS=C
For ech member in PDS XXX9XXX.A.A Rexx RXPDS000 will call Rexx RXPDSU00 Passing it the PDS, member, CLASS=D, and CLASS=C.
Rexx RXPDU000 replace all occurances of CLASS=D with CLASS=C in that member of the PDS.



This is quite interesting question.

Can we write this in the JCL itself without REXX code? I mean to say purely in JCL using ISPF commands.
Back to top
View user's profile Send private message
Jatin saraf

New User


Joined: 30 Mar 2007
Posts: 22
Location: United States of america

PostPosted: Tue Jul 17, 2007 9:03 pm
Reply with quote

Hi Douglas,

Thanks a lot for both the REXX codes. I am trying to run the 2nd part of the REXX code which replaces all the occurences of a string with another string in a given member. I have copied the REXX code in a member of a PDS and trying to execute it but it shows the following error:
4 +++ SAY "'"DSNAME'('HNTU099.JCL.SAMPLE(BINDPACK)")'"
IRX0043I Error running REPLSTRG, line 4: Routine not found

Here the REXX code is present in the member REPLSTRG and the string needs to be replaced in HNTU099.JCL.SAMPLE(BINDPACK).
Can you tell me the reason for the error and the solution too. Thanks.
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Tue Jul 17, 2007 9:25 pm
Reply with quote

I do not generally use the second REXX without the first. But it works for me. Did you try it as follows?
TSO RXPDSU00 ISC9013.A.A ISC1700 CLASS=c CLASS=d
Note: Do not put quotes around the pds name.
Note: The first REXX can be used for anything you need to do to all members of a PDS. That is why I keep the 2 separate.
Back to top
View user's profile Send private message
Jatin saraf

New User


Joined: 30 Mar 2007
Posts: 22
Location: United States of america

PostPosted: Tue Jul 17, 2007 10:07 pm
Reply with quote

Hi douglas,

Did not get that. Guess you are asking me to execute the subroutine TXPDSUOO but teh above code does not have any reference to that. It is mentioned only in the comments.
Currently I have copied the following code in a member of a pds and trying to run it by typing EXEC in front of the member name:

Parse Upper Arg dsname name oldval newval rest

SAY "'"dsname'('name")'"
/* READ/WRITE USING ARRAY */
FROM_NAME = "'"DSNAME"("NAME")'"
/* READ/WRITE USING ARRAY */
FROM_NAME = "'"DSNAME"("NAME")'"
"ALLOCATE DDNAME(INFILE) SHR DSNAME(" FROM_NAME ")"

"EXECIO * DISKR INFILE (STEM RECD. FINIS"
HOW_MANY = RECD.0

do c = 1 to how_many
strt = pos(oldval,recd.c)
do while strt > 0
say
say recd.c
ln = left(recd.c,strt-1)||newval||substr(recd.c,strt+length(oldval))
recd.c = ln
say recd.c
strt = pos(oldval,recd.c)
end
end c

"EXECIO " HOW_MANY " DISKW INFILE (STEM RECD. FINIS"

"FREE DDNAME(INFILE)"
Exit

So where do i have to mention the subroutine RXPDSU00?also is there any set up required to execute a REXX program. Sorry to mention but this is the 1st time am working on a REXX program. I read the manuals and understood how to allocate the PDS containing REXX code to SYSPROC and have done that.
Back to top
View user's profile Send private message
Jatin saraf

New User


Joined: 30 Mar 2007
Posts: 22
Location: United States of america

PostPosted: Tue Jul 17, 2007 10:10 pm
Reply with quote

Also i have hard coded the values of 'old val', 'new val', FROM_NAME in the above code that I am trying to execute.
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Wed Jul 18, 2007 12:32 am
Reply with quote

RXPDSU00 is the member name of this REXX in my REXX.EXEC PDS. Just substitute your member name for that one when you enter the command.
Is the first line of your REXX a comment with the word REXX in it? If not add this.
If you just type EXEC in front of the member name in the PDS directory list did you put in the parameters needed by this REXX?
If I were you I would put it back like it was and try to execute it from the command line.

From an ISPF command prompt type:
TSO REPLSTRG HNTU099.JCL.SAMPLE BINDPACK from to

Since you modified it I would need to see how you are executing it and exactly what the first few line of the REXX are now, in order to debug it.
Back to top
View user's profile Send private message
Jatin saraf

New User


Joined: 30 Mar 2007
Posts: 22
Location: United States of america

PostPosted: Wed Jul 18, 2007 1:06 am
Reply with quote

Hi,

I am using the following code which is present at
HNTU099.JCL(REPLSTRG):

/* REXX */
/*THIS REXX CODE REPLACES A GIVEN STRING WITH ANOTHER STRING IN*/
/*A MEMBER OF A PDS*/
/*DSNAME = 'HNTU099.JCL.SAMPLE(BINDPACK)'*/
PARSE UPPER ARG DSNAME NAME HNTU ABCD REST
SAY "'"DSNAME'('HNTU099.JCL.SAMPLE(BINDPACK)")'"
/*READ/WRITE USING ARRAY*/
FROM_NAME = "'"DSNAME"("HNTU099.JCL.SAMPLE(BINDPACK)")'"
"ALLOCATE DDNAME(INFILE) SHR DSNAME(" HNTU099.JCL.SAMPLE(BINDPACK)")"
"EXECIO * DISKR INFILE (STEM RECD. FINIS"
HOW_MANY = RECD.0
DO C = 1 TO HOW_MANY
STRT = POS(HNTU,RECD.C)
DO WHILE STRT > 0
SAY
SAY RECD.C
LN = LEFT(RECD.C,STRT-1)||ABCD||SUBSTR(RECD.C,STRT+LENGTH(HNTU))
RECD.C=LN
SAY RECD.C
STRT=POS(HNTU,RECD.C)
END
END C
"EXECIO " HOW_MANY " DISKW INFILE (STEM RECD. FINIS"
"FREE DDNAME(INFILE)"
EXIT
As you can see, I am trying to replace the string 'HNTU' with 'ABCD' in HNTU099.JCL.SAMPLE(BINDPACK)'. I have allocated the PDS HNTU099.JCL to SYSEXEC. I also tried the following on ISPF command prompt:
TSO REPLSTRG HNTU099.JCL.SAMPLE(BINDPACK) HNTU ABCD

It failed giving the same error :-
6 +++ SAY "'"DSNAME'('HNTU099.JCL.SAMPLE(BINDPACK)")'"
IRX0043I Error running REPLSTRG, line 6: Routine not found
Back to top
View user's profile Send private message
Jatin saraf

New User


Joined: 30 Mar 2007
Posts: 22
Location: United States of america

PostPosted: Wed Jul 18, 2007 2:07 am
Reply with quote

Hi,

I have found the solution. The problem was with the quotes on the pds name. We should put only single quotes for the pds name.:-)Probably that is installation specific.
Thanks a lot for all the help. The final code that worked was:

/* REXX */
/*READ/WRITE USING ARRAY*/
"ALLOC F(INFILE) SHR DS('HNTU099.JCL.SAMPLE(BINDPACK)')"
"EXECIO * DISKR INFILE (STEM RECD. FINIS"
HOW_MANY = RECD.0
DO C = 1 TO HOW_MANY
STRT = POS(HNTU,RECD.C)
DO WHILE STRT > 0
SAY
SAY RECD.C
LN = LEFT(RECD.C,STRT-1)||ABCD||SUBSTR(RECD.C,STRT+LENGTH(HNTU))
RECD.C=LN
SAY RECD.C
STRT=POS(HNTU,RECD.C)
END
END C

This changed all the occurences of HNTU with ABCD in the member
HNTU099.JCL.SAMPLE(BINDPACK).
Back to top
View user's profile Send private message
sakthi_ksv

New User


Joined: 20 Jul 2006
Posts: 48
Location: Chennai

PostPosted: Wed Jul 18, 2007 1:03 pm
Reply with quote

Hi,
This Rexx code simply displays the changed results. May I know how the changed results can be written into another member of PDS or the same member itself. anything is ok for me. ie in the above example I want to write the changed results in HNTU099.JCL.SAMPLE(BINDPACK) itself. How to do that.

Sakthi.
Back to top
View user's profile Send private message
Jatin saraf

New User


Joined: 30 Mar 2007
Posts: 22
Location: United States of america

PostPosted: Wed Jul 18, 2007 9:03 pm
Reply with quote

Hi Sakthi,

The above code also changes the values in HNTU099.JCL.SAMPLE(BINDPACK) itself. The display is given only for understanding. Just try it out.
Back to top
View user's profile Send private message
sakthi_ksv

New User


Joined: 20 Jul 2006
Posts: 48
Location: Chennai

PostPosted: Thu Jul 19, 2007 12:28 pm
Reply with quote

Hi Jatin,

I tried before posting my question. But it just displays but it is not writing into that member. Also another query I have is, does anyone has rexx code to search a string in all the members of a PDS. if the string is found it should display as 'found' in the prompt column. doest anyone has code or idea to do that.

Thanks in advance,
Sakthi
Back to top
View user's profile Send private message
kavisuresh

New User


Joined: 22 May 2007
Posts: 7
Location: chennai

PostPosted: Thu Jul 19, 2007 1:09 pm
Reply with quote

Hi,

Create the below rexx tool in the same format and place inside a pds and execute using "tso exec 'PDS(member)'",this is used to allocate a private PDS,

"EXECUTIL SEARCHDD(yes)" /* to ensure that SYSEXEC is available*/
"ALLOC FILE(SYSEXEC) DATASET(rexx.exec) shr reuse"
IF RC = 0 then
SAY 'Allocation to SYSEXEC completed.'
ELSE
SAY 'Allocation to SYSEXEC failed.'
/*"call lmac.load(lmac)" */

Note:
PDS name should be "userid.rexx.exec" and the rexx tool should be inside "SYSEXEC" member inside the pds


After allocating the personal PDS,proceed with the below ISPF EDIT macro
create another member inside the same pds with the edit macro.dont submit this member
/**********EDIT MACRO*******/
ADDRESS ISREDIT MACRO
ADDRESS ISREDIT RESET EXCLUDED
ADDRESS ISREDIT EXCLUDE ALL 'K' 1
ADDRESS ISREDIT FIND ALL 'K' 1
ADDRESS ISREDIT CHANGE ALL 'K' 1 'D' 1
EXIT


After preparing the above edit macro place all the 100 members which requires the changes inside the same PDS and place alone the edit macro
member on the command prompt and hit an enter which will do the changes and save the same ,follow the same for other members,
Hope the above will help you which will be very simple instead of doing the same manually

Regards,
Kavitha
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts list pds members name starting with xyz CLIST & REXX 11
No new posts Conditional replace values in output ... DFSORT/ICETOOL 3
No new posts Need to find a specific STRING COBOL Programming 11
No new posts String has hex character need to conv... COBOL Programming 3
No new posts SORT - To repeat a string in same col... SYNCSORT 3
Search our Forums:

Back to Top