Using EXECIO makes the original requirement simpler:

/* REXX Convert PDS to sequential file                      */
/*                                                          */
/*                                                          */
/*  JCL to restore the seq file back to a PDS               */
/*  //........ JOB ...................                      */
/*  //STEP00     EXEC PGM=IEBUPDTE,PARM=NEW                 */
/*  //SYSPRINT   DD   SYSOUT=*                              */
/*  //SYSIN      DD   DISP=SHR,DSN=userid."SEQFILE".expds   */
/*  //SYSUT2     DD   DISP=SHR,DSN=your.output.pds          */
/*  REXX                                                    */
/* -------------------- REXX ** ------------------- */
/* Syntax for expds:                                */
/*    %pdstosam hlq.pdsname off                     */
/* ------------------------------------------------ */
  ARG libparm ver
  IF ver = ON THEN
      TRACE ALL
  user = USERID()
  ctr = 0
  If libparm = '' Then Do While libparm = ''
     SAY 'Library not entered '
     SAY 'Enter Library name ===>'
     Pull libparm
     End
  SAY 'Enter OUTPUT FILE qualifier '
  PULL seqfile
  temp_grc = "00"
  tot_mem  = 0
  CALL read_dir
  CALL all_utl
  DO I = 7  TO libmem.0
       MEMBER = STRIP(libmem.I)
       CALL copy_mem
  END

  CALL end_expds
/* ------------------------ */

all_utl:

  "LISTDS '"user"."SEQFILE".EXPDS'"
       IF RC = 0  THEN DO
                " DEL '"user"."SEQFILE".EXPDS'"
                      END

  " ALLOC FI(OUT) DA('"user"."SEQFILE".EXPDS') MOD CATALOG",
  " RECFM (F B) DSORG(PS) SP(200 100) CYL  ",
  " LRECL(80) BLKSIZE(8000) UNIT(3390) "
       IF RC > 0 THEN
         DO
           temp_rc   =  RC
           temp_ftc  =  "ALLOC  ERROR"
           CALL rou_rc
         END
RETURN

copy_mem:

  tot_mem = tot_mem + 1
  ctr = ctr + 1
  ROUT.0 = ctr
  ROUT.ctr = "./       ADD  LEVEL=00,SOURCE=0,NAME="MEMBER

  " ALLOC FI(TMP) DA('"libparm"("MEMBER")' ) SHR REUSE"
  "EXECIO * DISKR TMP (FINIS STEM TMP."
       IF RC > 0 THEN
         DO
           temp_rc   =  RC
           temp_ftc  =  "EXECIO ERROR ON TMP"
           CALL rou_rc
         END
  " FREE  FI(TMP)                                     "

 * DO J = 1 TO TMP.0*
*    ctr = ctr + 1*
*    ROUT.ctr = TMP.J*
*  END*
*RETURN*


read_dir:
  X = OUTTRAP("libmem.")
  "LISTDS '"libparm"' M"
       IF RC > 0 THEN
         DO
           temp_rc   =  RC
           temp_ftc  =  "LISTDS ERROR"
           CALL rou_rc
         END
  X = OUTTRAP("OFF")
       IF libmem.0 < 8 THEN
         DO
           temp_ftc = "PDS IS EMPTY"
           temp_rc  = 4
           CALL rou_rc
         END
RETURN

rou_rc:

       IF temp_rc > 0  THEN
          temp_grc = temp_rc
          SAY " > ERROR         < "
          SAY " > FUNCTION/REXX < " temp_ftc
          SAY " > RETURN CODE   < " temp_rc

  temp_rc  = 0
  temp_ftc = ""

RETURN

end_expds:

  "EXECIO * DISKW OUT (FINIS STEM ROUT."

  " FREE DATASET('"user"."SEQFILE".EXPDS')"
  SAY 'Output file written name - 'user"."SEQFILE".EXPDS"

       IF temp_grc = 0 THEN DO
             SAY "MEMBERS SUCCESSFULLY PROCESSED: "tot_mem
                            END
EXIT  temp_grc

Just add the logic in this code in the routine:

* DO J = 1 TO TMP.0*
*    ctr = ctr + 1*
*  IF POS('BLAH',TMP.J) > 0 THEN DO......*
*  END*
*    ROUT.ctr = TMP.J*
*  END*
*RETURN*

On Thu, May 28, 2020 at 11:23 AM Wayne Bickerdike <wayn...@gmail.com> wrote:

> This is the IDCAMS version:
>
> /* REXX Mainframe Week - Code                               */
> /*                                                          */
> /*  A REXX routine to convert PDS to sequential datasets    */
> /*                                                          */
>
> /* -------------------- REXX ** ------------------- */
> /* Syntax for expds:                                */
> /*    %pdstoseq hlq.pdsname off                     */
> /* ------------------------------------------------ */
>   ARG libparm ver
>   IF ver = ON THEN
>       TRACE ALL
>   user = USERID()
>   SAY 'Enter DSN qualifier '
>   PULL seqfile
>   temp_grc = "00"
>   tot_mem  = 0
>   CALL read_dir
>   CALL all_utl
>   DO I = 7  TO libmem.0
>        MEMBER = STRIP(libmem.I)
>        CALL copy_mem
>   END
>
>   CALL end_expds
> /* ------------------------ */
>
> all_utl:
>
>   "LISTDS '"user"."SEQFILE".EXPDS'"
>        IF RC = 0  THEN DO
>                 " DEL '"user"."SEQFILE".EXPDS'"
>                       END
>
>   " ALLOC FI(OUT) DA('"user"."SEQFILE".EXPDS') MOD CATALOG",
>   " RECFM (F B) DSORG(PS) SP(10 10) CYL  ",
>   " LRECL(80) BLKSIZE(8000) UNIT(3390) "
>        IF RC > 0 THEN
>          DO
>            temp_rc   =  RC
>            temp_ftc  =  "ALLOC  ERROR"
>            CALL rou_rc
>          END
> RETURN
>
> copy_mem:
>
>   tot_mem = tot_mem + 1
>   ROUT.0 = 1
>   ROUT.1 = "./       ADD  LEVEL=00,SOURCE=0,NAME="MEMBER
>   "EXECIO * DISKW OUT (FINIS STEM ROUT."
>        IF RC > 0 THEN
>          DO
>            temp_rc   =  RC
>            temp_ftc  =  "EXECIO ERROR"
>            CALL rou_rc
>          END
>
>   " REPRO INDATASET('"libparm"("MEMBER")' )  OUTFILE(OUT) "
>        IF RC > 0 THEN
>          DO
>            temp_rc   =  RC
>            temp_ftc  =  "REPRO  ERROR"
>            CALL rou_rc
>          END
> RETURN
>
> read_dir:
>   X = OUTTRAP("libmem.")
>   "LISTDS '"libparm"' M"
>        IF RC > 0 THEN
>          DO
>            temp_rc   =  RC
>            temp_ftc  =  "LISTDS ERROR"
>            CALL rou_rc
>          END
>   X = OUTTRAP("OFF")
>        IF libmem.0 < 8 THEN
>          DO
>            temp_ftc = "PDS IS EMPTY"
>            temp_rc  = 4
>            CALL rou_rc
>          END
> RETURN
>
> rou_rc:
>
>        IF temp_rc > 0  THEN
>           temp_grc = temp_rc
>           SAY " > ERROR         < "
>           SAY " > FUNCTION/REXX < " temp_ftc
>           SAY " > RETURN CODE   < " temp_rc
>
>   temp_rc  = 0
>   temp_ftc = ""
>
>   CALL end_expds
> RETURN
>
> end_expds:
>
>   " FREE DATASET('"user"."SEQFILE".EXPDS')"
>
>        IF temp_grc = 0 THEN DO
>              SAY "MEMBERS SUCCESSFULLY PROCESSED: "tot_mem
>                             END
> EXIT  temp_grc
>
> On Thu, May 28, 2020 at 11:13 AM Wayne Bickerdike <wayn...@gmail.com>
> wrote:
>
>> I have used REXX to do this. One flavour uses IDCAMS REPRO, the other
>> uses EXECIO.
>>
>> It builds the member list from a LISTDS MEMBERS.
>>
>> It adds ./ADD IEBUPDTE statements to the flat file in order to move to
>> other systems. It's a readable option compared to using XMIT on a PDS>
>>
>>
>>
>> On Thu, May 28, 2020 at 11:05 AM Lizette Koehler <stars...@mindspring.com>
>> wrote:
>>
>>> Personally I would use REXX and LM functions to read through PDS members
>>> and
>>> action them.
>>>
>>> I did that when I needed to update all Members in a PDS to insert some
>>> additional control cards
>>>
>>> REXX with ISPF LM (Library Management) functions work very well for this.
>>>
>>> Lizette
>>>
>>>
>>> -----Original Message-----
>>> From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On
>>> Behalf Of
>>> Sri h Kolusu
>>> Sent: Wednesday, May 27, 2020 3:08 PM
>>> To: IBM-MAIN@LISTSERV.UA.EDU
>>> Subject: Re: Sort extracting values in PDS members
>>>
>>> ITschak,
>>>
>>> I already responded to this topic. Not sure where it went, but I did
>>> respond
>>> before your email. You can use IEPTPCH to flatten the PDS to a sequential
>>> file. If you use STOPAFT=5 then it will only print the 5 lines of the
>>> PDS.
>>> So don't have to use SUPERC
>>>
>>> Thanks,
>>>  Kolusu
>>> DFSORT Development
>>> IBM Corporation
>>>
>>> IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> wrote on
>>> 05/27/2020 02:50:28 PM:
>>>
>>> > From: ITschak Mugzach <imugz...@gmail.com>
>>> > To: IBM-MAIN@LISTSERV.UA.EDU
>>> > Date: 05/27/2020 02:51 PM
>>> > Subject: [EXTERNAL] Re: Sort extracting values in PDS members Sent by:
>>> > IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU>
>>> >
>>> > I would start with creating a single file using a ISRSUPC (it works
>>> outside
>>> > of ISPF, try opt 3.14 background option to generate the JCL) searching
>>> for
>>> > the two keywords you are looking for.
>>> >
>>> > ITschak
>>> > ITschak Mugzach
>>> > *|** IronSphere Platform* *|* *Information Security Continuous
>>> > Monitoring for z/OS, x/Linux & IBM I **| z/VM comming son  *
>>> >
>>> >
>>> >
>>> >
>>> > On Wed, May 27, 2020 at 11:41 PM Billy Ashton <bill00ash...@gmail.com>
>>> > wrote:
>>> >
>>> > > Hi again! This group has been so helpful - especially Kolusu - and I
>>> > > have one more question as I learn how to use SORT more creatively.
>>> > >
>>> > > I have a bunch of PDS files where I have to read through each member
>>> and
>>> > > create some control cards based on the content in the member (due to
>>> the
>>> > > nature of these files, the request needs to be vague). So here are
>>> > > the
>>> > > questions:
>>> > > 1. Is there a way to automatically read all members of a PDS? If
>>> > > not, I can generate the individual file names with member in a
>>> > > separate process.
>>> > > 2. When I read each member, I will be looking for KEYWORD(value) -
>>> > > the keyword will be either "KEYWORD1" or "LONGKEYWORD2" and will be
>>> > > within the first 5 lines of the member, at which point I stop
>>> > > reading (some of the members have 25000 lines!), and the Keyword
>>> > > could be anywhere on
>>> the
>>> > > line, in column 1 or with a space delimiter. Keyword can be 8 or 12
>>> > > characters long, and Value can be 2 to 8 characters.
>>> > > 3. I then need to create a string of -ADD- Value.Keyword.Dyyyymmdd
>>> > > (Today's date) that I will use in my further processing.
>>> > >
>>> > > Note that I could write a program to manage this, but am trying to
>>> > > keep the processing in a control member rather than a program, as
>>> > > utility programs seem to get lost around here.
>>> > >
>>> > > Since I can't show you the real input, here is some contrived data:
>>> > >
>>> > > Member1:
>>> > > KEYWORD1(val) Otherkw(val) Otherkey2(anothervalue)
>>> > > Line2
>>> > > Line3
>>> > > etc.
>>> > >
>>> > > Member 2:
>>> > > Line 1
>>> > > Line 2
>>> > > Otherkw(val) Otherkw2(val) LONGKEYWORD2(longvalu) Otherkw3(val) etc.
>>> > >
>>> > > Member 3:
>>> > > Line 1
>>> > > Otherkw1(withitslongvalue) LONGKEYWORD2(valu) Line 3 etc.
>>> > >
>>> > > Member 4:
>>> > > Line 1
>>> > > Line 2
>>> > > Line 3
>>> > > Line4
>>> > > KW(val) Anotherkw(anditsvalue) Alongkeywordhere(withalongvalue)
>>> > > KEYWORD1(va)
>>> > > etc.
>>> > >
>>> > > This would create the output (either in a single MOD file, or
>>> > > separate files I can put together myself:
>>> > > VAL.KEYWORD1.D20200527
>>> > > LONGVALU.LONGKEYWORD2.D20200527
>>> > > VALU.LONGKEYWORD2.D20200527
>>> > > VA.KEYWORD1.D20200527
>>> > >
>>> > > Can something like this be done in a DFSORT step? If not, I can
>>> > > write the various utilities myself in Rexx and/or COBOL, so you
>>> > > don't need to suggest that.
>>> > >
>>> > > Thanks for your help once more!
>>> > > Billy
>>> > >
>>> > > --------------------------------------------------------------------
>>> > > -- For IBM-MAIN subscribe / signoff / archive access instructions,
>>> > > send email to lists...@listserv.ua.edu with the message: INFO
>>> > > IBM-MAIN
>>> > >
>>> >
>>> > ----------------------------------------------------------------------
>>> > For IBM-MAIN subscribe / signoff / archive access instructions, send
>>> > email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>>> >
>>>
>>> ----------------------------------------------------------------------
>>> For IBM-MAIN subscribe / signoff / archive access instructions, send
>>> email
>>> to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>>>
>>> ----------------------------------------------------------------------
>>> For IBM-MAIN subscribe / signoff / archive access instructions,
>>> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>>>
>>
>>
>> --
>> Wayne V. Bickerdike
>>
>>
>
> --
> Wayne V. Bickerdike
>
>

-- 
Wayne V. Bickerdike

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to