Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Replace a string in all members of a PDS
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Replace a string in all members of a PDS
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    Post subject:
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

Site Director


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

PostPosted: Wed Jul 11, 2007 5:02 am    Post subject:
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    Post subject: Re: Replace a string in all members of a PDS
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

Moderator Team Head


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

PostPosted: Wed Jul 11, 2007 8:20 am    Post subject: Re: Replace a string in all members of a PDS
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    Post subject: Re: Replace a string in all members of a PDS
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

Moderator Team Head


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

PostPosted: Mon Jul 16, 2007 9:40 pm    Post subject: Re: Replace a string in all members of a PDS
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Re: Replace a string in all members of a PDS
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    Post subject:
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
This topic is locked: you cannot edit posts or make replies. Sort card to replace text using cross... Susanta SYNCSORT 32 Tue Sep 13, 2016 4:17 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us