Page 1 of 1

How to read a member from PDS

PostPosted: Wed May 21, 2008 4:36 pm
by Chaitnya
Hi,

Can any one tell me if I have a PDS name and I want to read members from it without knowing the member name in prior and I want to change perticular string say word 'ABC' to 'XYZ' from all members. how is it possible

Thanks

Re: How to read a member from PDS

PostPosted: Wed May 21, 2008 7:12 pm
by MrSpock
Wow, this topic is going to be hard to answer, since the content is rather vague, and there are a lot of possibilities to consider.

So, you have a PDS and you want to read the members. To do this, you're going to have to generate a member list so you can write a loop to process the members as desired. If you refer to this website you'll see an example of how to read the PDS directory blocks directly using native REXX. In TSO/E, the LISTDS command will create a member list. Using ISPF Services, the LMMLIST Service will do the same.

If you then want to read each member one-by-one, in TSO/E you'll have to first ALLOCATE the PDS with the member:

ALLOCATE DD(MYPDS) DA('PDS(MEMBER)') SHR REUSE

and then you can read the DD as needed. In other environments, if TSO ALLOCATE won't work, then it may be possible to use the BPXWDYN Dynamic Allocation utility instead.

In ISPF, you have the option of using the LMGET Service instead.

The other part of your post mentions that you want to change text from one string to another. Without knowing more about your requirements, I can only suggest that you look into the possibility of editing the member and changing the string globally, with a pseudo-command like 'CHANGE ABC to XYX ALL' . This would give you the flexibility of dealing with unqeual-length and/or mixed-case strings. Again, edits can be done with the TSO/E EDIT command, or with the ISPF EDIT Service combined with an ISPF EDIT Macro. Otherwise, in CLIST or REXX you can use standard text-processing functions like SUBSTR. In REXX you have more functions like PARSE, LEFT, OVERLAY, POS, RIGHT, SUBSTR, WORDPOS et al.

Re: How to read a member from PDS

PostPosted: Sat May 24, 2008 7:17 am
by Chaitnya
Thanks MrSpock.

However still I have question. My requirement is to search a string say 'ABC' in a PDS and replace it by 'XYZ'. I am trying to write the program in rexx so could any one help me out.

Thanks in Advance,

Re: How to read a member from PDS

PostPosted: Sat May 24, 2008 8:14 am
by dick scherrer
Hello,

You need to re-read the last para posted by MrSpock and read the material provided in those links. That explains what you need to code.

When you have something coded and if there are questions post the problem code and the question(s) here.

Re: How to read a member from PDS

PostPosted: Sat May 24, 2008 9:30 am
by MrSpock
Of course, I have to ask why write a program that does what an existing utility IPOUPDTE already does.

Re: How to read a member from PDS

PostPosted: Mon May 26, 2008 12:16 am
by MrSpock
Here's a job that you could use as an example:


//*                                                          
//* STEP1 RUN IEBPTPCH TO PUNCH THE PDS TO A PS DATASET      
//*                                                          
//STEP1    EXEC PGM=IEBPTPCH                                  
//SYSPRINT DD   SYSOUT=*                                      
//SYSUT1   DD   DISP=SHR,DSN=&SYSUID..PDS                    
//SYSUT2   DD   DSN=&&T1,DISP=(,PASS),UNIT=VIO,              
//         SPACE=(TRK,(1,1),RLSE)                            
//SYSIN    DD   *                                            
  PUNCH TYPORG=PO                                            
/*                                                            
//*                                                          
//* STEP2 RUN SORT TO CONVERT THE DATASET TO IEBUPDTE FORMAT  
//*                                                          
//STEP2    EXEC PGM=SORT                                      
//SORTIN   DD   DSN=&&T1,DISP=(OLD,DELETE)                    
//SORTOUT  DD   DSN=&&T2,DISP=(,PASS),UNIT=VIO,              
//         SPACE=(TRK,(1,1),RLSE),RECFM=FB                    
//SYSOUT   DD   SYSOUT=*                                      
//SYSIN    DD   *                                            
  OPTION COPY                                                
  OUTREC IFTHEN=(WHEN=(2,11,CH,EQ,C'MEMBER NAME'),            
    BUILD=(1:C'./',10:C'ADD NAME=',15,8)),                    
         IFTHEN=(WHEN=(2,11,CH,NE,C'MEMBER NAME'),            
    BUILD=(1:2,80))                                          
/*                                                            
//*                                                          
//* STEP3 RUN REXX EXEC TO FIND AND CHANGE STRING VALUES      
//*                                                          
//STEP3    EXEC PGM=IKJEFT01,PARM='%MYREXX'                  
//SYSPROC  DD   DISP=SHR,DSN=&SYSUID..REXX                    
//SYSTSPRT DD   SYSOUT=*                                      
//SYSTSIN  DD   DUMMY                                        
//SYSUT1   DD   DSN=&&T2,DISP=(OLD,DELETE)                    
//SYSUT2   DD   DSN=&&T3,DISP=(,PASS),UNIT=VIO,              
//         SPACE=(TRK,(1,1),RLSE)                            
//*                                                          
//* STEP4 RUN IEBUPDTE PROGRAM TO UPDATE THE PDS              
//*                                                          
//STEP4    EXEC PGM=IEBUPDTE,PARM='NEW'                      
//SYSPRINT DD   SYSOUT=*                                      
//SYSUT2   DD   DSN=&SYSUID..PDS,DISP=SHR                    
//SYSIN    DD   DSN=&&T3,DISP=(OLD,DELETE)                    
 


The code for MYREXX:


/* REXX */                                        
eof = 0                                            
Do Until eof                                      
  "EXECIO 1 DISKR sysut1"                          
  If rc <> 0 Then eof = 1                          
  Else                                            
    Do                                            
      Pull rec                                    
      offset = Pos("ABC",rec)                      
      If offset > 0 Then                          
        Do                                        
          rec = Overlay("XYZ",rec,offset,3)        
        End                                        
      Push rec                                    
      "EXECIO 1 DISKW sysut2"                      
    End                                            
End                                                
"EXECIO 0 DISKR sysut1 (FINIS"                    
"EXECIO 0 DISKW sysut2 (FINIS"                    
Exit 0                                            
 


Just keep in mind that it's not really necessary to use REXX here, since this could be done using existing system utilities.

Re: How to read a member from PDS

PostPosted: Mon May 26, 2008 2:25 am
by dick scherrer
And before doing anything - make a backup of your pds.

Actually, i'd recommend working from a copy until the process is debugged and ready to run for real - then make a backup and run the process before anything else is done to the dataset.

d

Re: How to read a member from PDS

PostPosted: Fri Jul 24, 2009 9:17 pm
by e06trsp
This is the way I do It:
/*REXX*/

PARSE ARG LIB MACRO
LIB = STRIP(LIB,B,"'")
ADDRESS ISPEXEC
"LMINIT DATAID(LIBDID) DATASET("LIB") ENQ(SHR)"
"LMOPEN DATAID("LIBDID") OPTION(INPUT)"
MEMBER = ''
"LMMLIST DATAID("LIBDID") OPTION(LIST) STATS(YES) MEMBER(MEMBER)"
/*------------------------------------------------------------------*/
/* */
/*------------------------------------------------------------------*/
DO WHILE ( RC = 0 )
MEMBER = STRIP(MEMBER)
"EDIT DATASET('"LIB"("MEMBER")') MACRO("MACRO")"
"LMMLIST DATAID("LIBDID") OPTION(LIST) STATS(YES) MEMBER(MEMBER)"
END
/*------------------------------------------------------------------*/
/* FREE AND CLOSE LIB LIBRARY DIRECTORY */
/*------------------------------------------------------------------*/
"LMMLIST DATAID("LIBDID") OPTION(FREE)"
"LMCLOSE DATAID("LIBDID")"
"LMFREE DATAID("LIBDID")"
EXIT


Where MACRO contains:

/*REXX*/
ADDRESS ISREDIT
"MACRO PROCESS"
"CHANGE 'ABC' 'EFG' ALL"
"SAVE"
"END"
"MEND"
EXIT

Re: How to read a member from PDS

PostPosted: Tue Jan 24, 2017 6:58 pm
by arya_starc
Hi e06trsp,

How can I pass my PDS to this rexx?


e06trsp wrote:This is the way I do It:
/*REXX*/

PARSE ARG LIB MACRO
LIB = STRIP(LIB,B,"'")
ADDRESS ISPEXEC
"LMINIT DATAID(LIBDID) DATASET("LIB") ENQ(SHR)"
"LMOPEN DATAID("LIBDID") OPTION(INPUT)"
MEMBER = ''
"LMMLIST DATAID("LIBDID") OPTION(LIST) STATS(YES) MEMBER(MEMBER)"
/*------------------------------------------------------------------*/
/* */
/*------------------------------------------------------------------*/
DO WHILE ( RC = 0 )
MEMBER = STRIP(MEMBER)
"EDIT DATASET('"LIB"("MEMBER")') MACRO("MACRO")"
"LMMLIST DATAID("LIBDID") OPTION(LIST) STATS(YES) MEMBER(MEMBER)"
END
/*------------------------------------------------------------------*/
/* FREE AND CLOSE LIB LIBRARY DIRECTORY */
/*------------------------------------------------------------------*/
"LMMLIST DATAID("LIBDID") OPTION(FREE)"
"LMCLOSE DATAID("LIBDID")"
"LMFREE DATAID("LIBDID")"
EXIT


Where MACRO contains:

/*REXX*/
ADDRESS ISREDIT
"MACRO PROCESS"
"CHANGE 'ABC' 'EFG' ALL"
"SAVE"
"END"
"MEND"
EXIT

Re: How to read a member from PDS

PostPosted: Tue Jan 24, 2017 7:10 pm
by enrico-sorichetti
Mr. e06trsp was seen for the last time here on 2009
the chances that he will be back to reply are pretty slim

also, resurrecting an 8 years old topic is pretty useless
if You have a question start a new topic

anyway your question was already replied by the rexx statement
PARSE ARG LIB MACRO


topic locked