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
 

 

How to use REXX to rename list of VSAM or OSAM file ?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Wed Jun 03, 2015 11:25 pm    Post subject: How to use REXX to rename list of VSAM or OSAM file ?
Reply with quote

Hi experts,

I want to wirte the rexx to rename list of VSAM and OSAM file in batch . But i got two questions regarding to this .

1. How to use rexx to find all the VSAM or OSAM data set in the system?
for example how to get list of all the data set begining with #IMSS1.**
Code:
#IMSS1                   
#IMSS1.GC.GCACPCD1       
#IMSS1.GC.GCACPCD1.DATA 
#IMSS1.GC.GCACPCD3       
#IMSS1.GC.GCACPCD3.DATA 
#IMSS1.GC.GCACPCD5       
#IMSS1.GC.GCACPCD5.DATA 
#IMSS1.GC.GCACPCD7       
#IMSS1.GC.GCACPCD7.DATA 
#IMSS1.GC.GCACPCD9       
#IMSS1.GC.GCACPCD9.DATA 
#IMSS1.GC.GCACPCX1       
#IMSS1.GC.GCACPCX1.DATA 
#IMSS1.GC.GCACPCX1.INDEX 
and so on

2. After step 1, How to rename it , i know for pds using rename but what the command for VSAM and OSAM ?

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

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1717
Location: UK

PostPosted: Thu Jun 04, 2015 10:04 pm    Post subject:
Reply with quote

Have you referred to the AMS manual? Do you know about LISTCAT? Do you know how to use IDCAMS to rename datasets?
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Thu Jun 04, 2015 10:24 pm    Post subject:
Reply with quote

Hi,

Thanks for your answer, i figured out ,it works.
Here is the code:

Code:
/* rexx */                                 
  THEPDS = "' #IMSS1'"         /* data set want to change */
  X = OUTTRAP('ML.')                         
  "LISTCAT LEVEL("THEPDS")"                 
  X = OUTTRAP('OFF')                         
  A=0                                       
  MEMBER.=0                                 
  DO N = 1 TO ML.0                           
    PARSE VAR ML.N MEMBER.N                 
   IF SUBSTR(MEMBER.N,1,7)='NONVSAM'|,       
      SUBSTR(MEMBER.N,1,5)='INDEX'|,         
      SUBSTR(MEMBER.N,1,7)='CLUSTER'|,       
      SUBSTR(MEMBER.N,1,4)='DATA'   THEN DO 
     OUTPUT.N=SUBSTR(MEMBER.N,17,50)         
     A=A+1                                   
     OUTPUT.A=STRIP(OUTPUT.N)               
   END                                       
end                                                                   
DO I= 1 to A                                                           
OLDNAME=' #IMSS1'       /* old data set name */                                                 
TMPTXT1= ' #IMSS2'        /* new data set name  change to any name you want*/                                             
NEWSTR.I =OUTPUT.I                                                     
DO WHILE POS(oldname,NEWSTR.I) > 0                                     
   NEWSTR.I = SUBSTR(NEWSTR.I, 1 , POS(oldname,NEWSTR.I)-1) ||,         
   TMPTXT1 || SUBSTR(NEWSTR.I, POS(oldname,NEWSTR.I) + LENGTH(oldname))
END                                                                     
"ALTER '"OUTPUT.I"'",                                                   
     "NEWNAME('"NEWSTR.I"')"                                           
END                                                           
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1717
Location: UK

PostPosted: Fri Jun 05, 2015 3:23 pm    Post subject:
Reply with quote

Great. Now all you have to do is to amend the program so that it takes THEPDS (need a better name!) as an argument that can be specified on the command line.
Back to top
View user's profile Send private message
Pete Wilson

Active User


Joined: 31 Dec 2009
Posts: 437
Location: London

PostPosted: Wed Jul 15, 2015 9:13 pm    Post subject:
Reply with quote

You also need to cater for any 'associations' the VSAM files you're renaming....i.e. any that have AlX's or PATH's related to them. In the LISTCAT you need to include the CDILVL parameter (ZOS1.13 and up) if using masking to be certain of identifying them. Or use something like DFDSS DUMP with SPHERE and PARM='TYPRUN=NORUN' on the exec

And for NONVSAM you have to deal with any ALIASes that may be pointing to the file being renamed (usually PDS's, but strictly).

Also consider that by renaming the datasets in place they may effectively be outside the expected storage pool for those names. Sometimes a DFDSS COPY with RENAMEU is better as it renames and moves the files to the correct pool based on DFSMS routines.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Thu Jul 16, 2015 7:17 pm    Post subject:
Reply with quote

Because you made the effort to write your own code and post it here, I will make an effort too. icon_smile.gif

A few remarks about your code:
1. in both loops you use stem variables when not necessary, it just makes the code more complicated.
2. in the 2nd loop, the OLDNAME starts with a space, but you stored the name with STRIP, so there will be no hits.
3. You should assign OLDNAME and TMPTXT1 before the loop, not inside.
4. Use indentation.
5. Add documentation.

Code:
/* --------------------------------------- Make list of files */
ThePDS = '#IMSS1'         
X = OutTrap('ML.')       
"LISTCAT LEVEL('"ThePDS"')"
X = OutTrap('OFF')       

/* ----------------------------- Keep only relevant filenames */
A = 0                                                       
OldList. = ''                                               
Do N = 1 To ML.0                                             
   Parse Var ML.N Type . Name .                             
   If WordPos(Type,'NONVSAM INDEX DATA CLUSTER') > 0 Then Do
      A = A + 1                                             
      OldList.A = Name                                       
   End                                                       
End                                                         

/* --------------------------------------------- Rename files */
OldStr = '#IMSS1'
NewStr = '#IMSS2'
Do I = 1 To A                                         
   NewFile = OldList.I                               
   Do Forever                                         
      S = Pos(OldStr,NewFile)                         
      If S = 0 Then Leave                             
      NewFile = SubStr(NewFile,1,S-1) || NewStr || , 
         SubStr(NewFile,S+Length(OldStr))             
   End                                               
   say 'ALTER from 'OldList.I 'to' NewFile           
End
Of course, you don't have to write like this, that's just how I like to do it
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Thu Jul 16, 2015 7:49 pm    Post subject:
Reply with quote

Hi Marso,

Thanks for your code. I like it.

one thing is i think you missed the actual code to do the rename.

I added it in your code .
Code:
/* REXX ---------------------------------- MAKE LIST OF FILES */ 
THEPDS = 'TTAT.TSP.TU14.CHANGED'                                 
X = OUTTRAP('ML.')                                               
"LISTCAT LEVEL('"THEPDS"')"                                       
X = OUTTRAP('OFF')                                               
/* ----------------------------- KEEP ONLY RELEVANT FILENAMES */ 
A = 0                                                             
OLDLIST. = ''                                                     
DO N = 1 TO ML.0                                                 
   PARSE VAR ML.N TYPE . NAME .                                   
   IF WORDPOS(TYPE,'NONVSAM INDEX DATA CLUSTER') > 0 THEN DO     
      A = A + 1                                                   
      OLDLIST.A = NAME                                           
   END                                                           
END                                                               
/* --------------------------------------------- RENAME FILES */ 
OLDSTR = 'CHANGED'             
NEWSTR = 'HAO'                                     
DO I = 1 TO A                                       
   NEWFILE = OLDLIST.I                             
   DO FOREVER                                       
      S = POS(OLDSTR,NEWFILE)                       
      IF S = 0 THEN LEAVE                           
      NEWFILE = SUBSTR(NEWFILE,1,S-1) || NEWSTR || ,
         SUBSTR(NEWFILE,S+LENGTH(OLDSTR))           
   END                                             
  [b] "ALTER '"OLDLIST.I"'",                           
        "NEWNAME('"NEWFILE"')" [/b]                     
   SAY 'ALTER FROM 'OLDLIST.I 'TO' NEWFILE         
END           
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Jul 16, 2015 8:04 pm    Post subject: Reply to: How to use REXX to rename list of VSAM or OSAM file ?
Reply with quote

nope he did not miss it icon_evil.gif

it used a say <the command that would be executed>

it is a pretty normal thing to do when testing ...

You say what You are going to do before doing it until the tests show that everything is right
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Jul 16, 2015 8:23 pm    Post subject: Reply to: How to use REXX to rename list of VSAM or OSAM file ?
Reply with quote

a coding alternative with a bit of lateral thinking

Code:

OldHLQ = "#IMSS1"
NewHLQ = "#IMSS2"

lst.1 = "#IMSS1.DS1"
lst.2 = "#IMSS1.DS1.DATA"
lst.3 = "#IMSS1.DS2"
lst.4 = "#IMSS1.DS2.DATA"
lst.5 = "#IMSS1.DS3"
lst.0 = 5

do  l = 1 to lst.0
    interpret "parse var lst."l "with '"OldHLQ".' tail"
    NewNAME = NewHLQ"."tail
    say left("OldNAME("lst.l")",44) "NewNAME("NewNAME")"
end
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Thu Jul 16, 2015 9:08 pm    Post subject:
Reply with quote

Hi enrico,

I am not very familar with " interpret " insturction , what does it do ?

Thanks
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2019
Location: Silicon Valley

PostPosted: Thu Jul 16, 2015 9:13 pm    Post subject: Reply to: How to use REXX to rename list of VSAM or OSAM file ?
Reply with quote

re: "what does REXX INTERPRET do?"
See here click here
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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