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
How to read a member from PDS
-
- Posts: 18
- Joined: Wed Mar 26, 2008 1:04 pm
- Skillset: JCL,COBOL,DB2,CICS
- Referer: From www.google.com
- MrSpock
- Global moderator
- Posts: 809
- Joined: Wed Jun 06, 2007 9:37 pm
- Skillset: REXX, JCL, DFSORT, Syncsort, Axway MFT, Connect:Direct, FTP, SFTP
- Referer: ibmmainframes.com
- Location: Raleigh NC USA
- Contact:
Re: How to read a member from PDS
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.
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.
-
- Posts: 18
- Joined: Wed Mar 26, 2008 1:04 pm
- Skillset: JCL,COBOL,DB2,CICS
- Referer: From www.google.com
Re: How to read a member from PDS
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,
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,
- dick scherrer
- Global moderator
- Posts: 6268
- Joined: Sat Jun 09, 2007 8:58 am
Re: How to read a member from PDS
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.
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.
d.sch.
- MrSpock
- Global moderator
- Posts: 809
- Joined: Wed Jun 06, 2007 9:37 pm
- Skillset: REXX, JCL, DFSORT, Syncsort, Axway MFT, Connect:Direct, FTP, SFTP
- Referer: ibmmainframes.com
- Location: Raleigh NC USA
- Contact:
Re: How to read a member from PDS
Of course, I have to ask why write a program that does what an existing utility IPOUPDTE already does.
- MrSpock
- Global moderator
- Posts: 809
- Joined: Wed Jun 06, 2007 9:37 pm
- Skillset: REXX, JCL, DFSORT, Syncsort, Axway MFT, Connect:Direct, FTP, SFTP
- Referer: ibmmainframes.com
- Location: Raleigh NC USA
- Contact:
Re: How to read a member from PDS
Here's a job that you could use as an example:
The code for MYREXX:
Just keep in mind that it's not really necessary to use REXX here, since this could be done using existing system utilities.
Code: Select all
//*
//* 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:
Code: Select all
/* 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.
- dick scherrer
- Global moderator
- Posts: 6268
- Joined: Sat Jun 09, 2007 8:58 am
Re: How to read a member from PDS
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
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
-
- Posts: 1
- Joined: Fri Jul 24, 2009 9:07 pm
- Skillset: MVS, ZOS, ISPF, REXX, CLIST, UNIX
- Referer: On the web
Re: How to read a member from PDS
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
/*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
-
- Posts: 136
- Joined: Mon Sep 21, 2015 1:39 pm
- Skillset: VSAM,CICS,JCL,COBOL
- Referer: INTERENT
Re: How to read a member from PDS
Hi e06trsp,
How can I pass my PDS to this rexx?
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
-
- Global moderator
- Posts: 3006
- Joined: Fri Apr 18, 2008 11:25 pm
- Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
- Referer: www.ibmmainframes.com
Re: How to read a member from PDS
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
topic locked
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
Code: Select all
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
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
-
- Similar Topics
- Replies
- Views
- Last post
-
- 6
- 6440
-
by Mainframe_Dev
View the latest post
Mon Jan 30, 2023 1:06 am
-
- 7
- 5252
-
by sergeyken
View the latest post
Fri Nov 13, 2020 1:24 am
-
- 3
- 7938
-
by socker_dad
View the latest post
Thu Jan 28, 2021 4:13 am
-
-
FTP dataset member with Arabic letters
by Mahmoud Anwer » Sat May 29, 2021 6:37 pm » in Simulators & Emulators - 1
- 3788
-
by enrico-sorichetti
View the latest post
Sat May 29, 2021 11:57 pm
-
-
-
transferring file from pc to mainframe pds member
by valeca » Wed Sep 28, 2022 3:42 am » in TSO & ISPF - 5
- 3390
-
by Pedro
View the latest post
Thu Sep 29, 2022 12:11 am
-