How to read a member from PDS



IBM's Command List programming language & Restructured Extended Executor

How to read a member from PDS

Postby Chaitnya » Wed May 21, 2008 4:36 pm

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
Chaitnya
 
Posts: 18
Joined: Wed Mar 26, 2008 1:04 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to read a member from PDS

Postby MrSpock » Wed May 21, 2008 7:12 pm

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.
User avatar
MrSpock
Global moderator
 
Posts: 807
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Re: How to read a member from PDS

Postby Chaitnya » Sat May 24, 2008 7:17 am

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,
Chaitnya
 
Posts: 18
Joined: Wed Mar 26, 2008 1:04 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to read a member from PDS

Postby dick scherrer » Sat May 24, 2008 8:14 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: How to read a member from PDS

Postby MrSpock » Sat May 24, 2008 9:30 am

Of course, I have to ask why write a program that does what an existing utility IPOUPDTE already does.
User avatar
MrSpock
Global moderator
 
Posts: 807
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Re: How to read a member from PDS

Postby MrSpock » Mon May 26, 2008 12:16 am

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.
User avatar
MrSpock
Global moderator
 
Posts: 807
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Re: How to read a member from PDS

Postby dick scherrer » Mon May 26, 2008 2:25 am

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
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: How to read a member from PDS

Postby e06trsp » Fri Jul 24, 2009 9:17 pm

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
e06trsp
 
Posts: 1
Joined: Fri Jul 24, 2009 9:07 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to read a member from PDS

Postby arya_starc » Tue Jan 24, 2017 6:58 pm

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
arya_starc
 
Posts: 136
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 5 times
Been thanked: 0 time

Re: How to read a member from PDS

Postby enrico-sorichetti » Tue Jan 24, 2017 7:10 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post