Hi Kolusu, I have a slightly different twist on this request for a
different need.
Here, I will have multiple FTP directory commands' output, and want to
capture only the most recent 3 filenames in each directory. The output will
all be in one single file for further processing.
Now I know I want to capture only the EZA1701 message to extract the
directory name, and the EZA2284I messages for each file, and I want to
create output files with the command: "get dirname/filename" for only the
most recent files.
I have figured out how to change the Month value to a number and to reorder
the date to be yearmmdd, but I could not figure out how to replace the
space with a zero in the first digit of the day and I could not figure out
how to get the directory name on each file before sorting. I suppose the
space in the day value is not a problem as it would sort lower just like
zero, but I would rather it be specified accurately. Also, with the chance
that the date could be in a different column based on filesizes in the
directory, the absolute value on the column for the CHANGE won't always
work (I show that by pushing the last set to the right one column).
I hope you are not troubled with this request, and I appreciate your help.
I have attached some JCL and data with the first part of my process
(although you might change it anyway).
Thanks again!
Bill
On Mon, Apr 24, 2017 at 10:03 AM, Bill Ashton <[email protected]>
wrote:
> Kolusu, thanks for the fix - I had not noticed this problem in my test
> cases, but now believe I have a more accurate process. I appreciate your
> time and attention! Have a magnificent Monday!
>
> On Fri, Apr 21, 2017 at 5:51 PM, Sri h Kolusu <[email protected]> wrote:
>
>> Bill,
>>
>> I apologize for the oversight in parsing the dataset name. As soon as I
>> sent my earlier reply I realized that I did not cover all the scenarios
>> for the dataset name. If the HLQ is less than 6 bytes the parse would
>> grab the time which starts before the dataset name.
>>
>> for example the records in red color
>>
>> Dec 29 10:23 HOLDDATA.BIN
>> Apr 3 12:28 REPORT1.TXT
>> Nov 15 11:33 NEWDATA.BIN
>> Nov 15 11:34 a.BIN
>> Nov 15 11:35 abc.BIN
>> Nov 15 11:36 abcd.BIN
>> Nov 15 11:37 abcde.BIN
>> Nov 15 11:38 abcdef.BIN
>> Nov 15 11:39 abcdefg.BIN
>> Nov 15 11:40 abcdefgh.BIN
>>
>> So you need to change your INREC IFTHEN statements to handle these dataset
>> names. Here are the updated control cards ( Only the INREC IFTHEN
>> statments need to be changed.)
>>
>> INREC IFOUTLEN=80,
>> IFTHEN=(WHEN=(1,3,CH,EQ,C'250'),
>> PARSE=(%01=(STARTAFT=C'"',ENDBEFR=C'"',FIXLEN=50)),
>> BUILD=(C'250 ',%01)),
>>
>> IFTHEN=(WHEN=(1,3,CH,EQ,C'EZA'),
>> PARSE=(%=(ENDAT=C'.BIN'),
>> %02=(SUBPOS=12,FIXLEN=12)),
>> BUILD=(C'BIN ',%02),HIT=NEXT),
>>
>> IFTHEN=(WHEN=(1,3,CH,EQ,C'BIN'),
>> OVERLAY=(5:5,12,JFY=(SHIFT=LEFT)),HIT=NEXT),
>>
>> IFTHEN=(WHEN=(1,3,CH,EQ,C'BIN',AND,5,8,SS,EQ,C' '),
>> PARSE=(%03=(ABSPOS=5,STARTAFT=C' ',ENDAT=C'.BIN',FIXLEN=12)),
>> BUILD=(01:C'BIN ',56:%03)),
>>
>> IFTHEN=(WHEN=(1,3,CH,EQ,C'BIN',AND,5,8,SS,NE,C' '),
>> BUILD=(01:C'BIN ',56:5,12))
>>
>>
>>
>> Further if you have any questions please let me know
>>
>> Thanks,
>> Kolusu
>> DFSORT Development
>>
>>
>>
>> From: Bill Ashton <[email protected]>
>> To: [email protected]
>> Date: 04/21/2017 01:41 PM
>> Subject: Re: How to parse rows using SORT
>> Sent by: IBM Mainframe Discussion List <[email protected]>
>>
>>
>>
>> Thanks, Kolusu - that is better now! I will go and learn about HIT=NEXT,
>> as
>> I have not run into that before.
>>
>> Have a good weekend!
>>
>>
>> On Fri, Apr 21, 2017 at 4:24 PM, Sri h Kolusu <[email protected]> wrote:
>>
>> > Bill,
>> >
>> > You really don't need to complicate the control to get the desired
>> > results. I have optimized your control cards a bit which would give you
>> > the desired results
>> >
>> > //SYSIN DD *
>> > OPTION COPY
>> > INCLUDE COND=(1,003,CH,EQ,C'250',OR,
>> > 1,100,SS,EQ,C'.BIN ')
>> >
>> > INREC IFOUTLEN=80,
>> > IFTHEN=(WHEN=(1,3,CH,EQ,C'250'),
>> > PARSE=(%01=(STARTAFT=C'"',ENDBEFR=C'"',FIXLEN=50)),
>> > BUILD=(C'250 ',%01)),
>> >
>> > IFTHEN=(WHEN=(1,3,CH,EQ,C'EZA'),
>> > PARSE=(%=(ENDAT=C'.BIN'),
>> > %02=(SUBPOS=12,FIXLEN=12)),
>> > BUILD=(C'BIN ',%02),HIT=NEXT),
>> >
>> > IFTHEN=(WHEN=(1,3,CH,EQ,C'BIN'),
>> > PARSE=(%03=(STARTAFT=C' ',ENDAT=C'.BIN',FIXLEN=12)),
>> > BUILD=(01:C'BIN ',56:%03))
>> >
>> > OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'250'),PUSH=(05:5,50))
>> >
>> > OUTFIL INCLUDE=(1,3,CH,EQ,C'BIN'),
>> > BUILD=(05,75,SQZ=(SHIFT=LEFT,LEAD=C'get ',MID=C'/',
>> > TRAIL=C' //DD:LIST',LENGTH=80))
>> > //*
>> >
>> > The output from this job is
>> >
>> > get /sys01/new2017/input/TESTFL1.BIN //DD:LIST
>> > get /sys12/y2017/processed/HOLDDATA.BIN //DD:LIST
>> > get /sys12/y2017/processed/NEWDATA.BIN //DD:LIST
>> >
>> >
>> > Further if you have any questions please let me know
>> >
>> > Thanks,
>> > Sri Hari Kolusu
>> > DFSORT Development
>> > IBM Corporation
>> > Email: [email protected]
>> > Phone: 520-799-2237 Tie Line: 321-2237
>> >
>> > IBM Mainframe Discussion List <[email protected]> wrote on
>> > 04/21/2017 12:45:56 PM:
>> >
>> > > From: Bill Ashton <[email protected]>
>> > > To: [email protected]
>> > > Date: 04/21/2017 12:46 PM
>> > > Subject: Re: How to parse rows using SORT
>> > > Sent by: IBM Mainframe Discussion List <[email protected]>
>> > >
>> > > Hi Kolusu, I think I messed up my original note by trying to keep the
>> > > characters in order.
>> > >
>> > > I have attached a file that shows my JCL with input and output
>> expected.
>> > > The current run, though has a problem with the Parse for %02 and %03.
>> I
>> > > hope you can help me with this - it is probably simple.
>> > >
>> > > Thanks!
>> > > B
>> > >
>> > > On Fri, Apr 21, 2017 at 2:05 PM, Sri h Kolusu <[email protected]>
>> > wrote:
>> > >
>> > > > Bill,
>> > > >
>> > > > Why bother about the position. From the looks of it, you need to
>> pick
>> > the
>> > > > last qualifier. So go find the last byte space and then subtract 12
>> > bytes
>> > > > to get to your dataset name.
>> > > >
>> > > > something like this
>> > > >
>> > > > //STEP0100 EXEC PGM=SORT
>> > > > //SYSOUT DD SYSOUT=*
>> > > > //SORTIN DD *
>> > > >
>> >
>> EZA2284I`-RW-R--R--```1`FTPUSER``FTPUSERS```42160`SEP``2``
>> 2016`TESTFL1.BIN
>> > > >
>> > > >
>> > EZA2284I`-RW-R--R--```1`FTPUSER``FTPUSERS``442160`NOV`10`15:
>> 26`TEST2.TXT
>> > > > //SORTOUT DD SYSOUT=*
>> > > > //SYSIN DD *
>> > > > OPTION COPY
>> > > > INREC IFTHEN=(WHEN=INIT,
>> > > > PARSE=(%=(ENDBEFR=C' '),
>> > > > %01=(SUBPOS=12,FIXLEN=12)),
>> > > > BUILD=(%01)),
>> > > >
>> > > > IFTHEN=(WHEN=(1,12,SS,EQ,C'`'),
>> > > > PARSE=(%02=(STARTAFT=C'`',FIXLEN=12)),
>> > > > BUILD=(%02))
>> > > >
>> > > > OUTREC BUILD=(1,12,SQZ=(SHIFT=LEFT,LENGTH=80,
>> > > > LEAD=C' get /thisdirectory/',
>> > > > TRAIL=C' //DD:LIST'))
>> > > > //*
>> > > >
>> > > >
>> > > > The outout from this job is
>> > > >
>> > > > get /thisdirectory/TESTFL1.BIN //DD:LIST
>> > > > get /thisdirectory/TEST2.TXT //DD:LIST
>> > > >
>> > > >
>> > > > Further if you have any questions please let me know
>> > > >
>> > > >
>> > > > Thanks,
>> > > > Kolusu
>> > > > DFSORT Development
>> > > > IBM Corporation
>> > > >
>> > > >
>> > > >
>> > > > From: Bill Ashton <[email protected]>
>> > > > To: [email protected]
>> > > > Date: 04/21/2017 10:47 AM
>> > > > Subject: How to parse rows using SORT
>> > > > Sent by: IBM Mainframe Discussion List
>> > <[email protected]>
>> > > >
>> > > >
>> > > >
>> > > > Hello friends!
>> > > >
>> > > > I just ran into a problem, and am a bit confused how to correct
>> this.
>> > > >
>> > > > I am reading the output of an FTP list command, and using SORT to
>> > capture
>> > > > and format the FTP GET commands I need. This process is working fine
>> > for
>> > > > the most part, and it produces the correct commands most of the
>> time.
>> > > > However, I just noticed that the file list is different in one of my
>> > > > folders, causing me to lose the first character of the filename.
>> > > >
>> > > > I had been using this:
>> > > > PARSE=(%02=(ABSPOS=65,ENDBEFR=C'.',FIXLEN=8),
>> > > > %03=(FIXLEN=3)),
>> > > >
>> > > > but now I find that one of my folders starts the file name in pos
>> 64,
>> > and
>> > > > not 65.
>> > > >
>> > > > Is there a way to not use ABSPOS=65, but instead to say I want to
>> > start
>> > > > following a space after Col 60? In Rexx, I could say to use the 10th
>> > word,
>> > > > but I don't want to change the SORT to Rexx now, as this input is
>> > doing a
>> > > > number of different things.
>> > > >
>> > > > Here is a sample of the file listing (with ` replacing blanks to
>> keep
>> > > > spacing intact):
>> > > >
>> > > >
>> >
>> EZA2284I`-rw-r--r--```1`ftpuser``ftpusers```42160`Sep``2``
>> 2016`TESTFL1.BIN
>> > > >
>> > EZA2284I`-rw-r--r--```1`ftpuser``ftpusers``442160`Nov`10`15:
>> 26`TEST2.TXT
>> > > >
>> > > > My output from the Sort is going to say
>> > > > get /thisdirectory/TESTFL1.BIN //DD:LIST
>> > > > get /thisdirectory/TEST2.TXT //DD:LIST
>> > > >
>> > > > Thanks for your help with this troublesome question!
>> > > >
>> > > > --
>> > > > Thank you and best regards,
>> > > > *Billy Ashton*
>> > > >
>> > > >
>> ----------------------------------------------------------------------
>> > > > For IBM-MAIN subscribe / signoff / archive access instructions,
>> > > > send email to [email protected] with the message: INFO
>> IBM-MAIN
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> ----------------------------------------------------------------------
>> > > > For IBM-MAIN subscribe / signoff / archive access instructions,
>> > > > send email to [email protected] with the message: INFO
>> IBM-MAIN
>> > > >
>> > >
>> > >
>> > >
>> > > --
>> > > Thank you and best regards,
>> > > *Billy Ashton*
>> > >
>> > > ------------------------------------------------------------
>> ----------
>> > > For IBM-MAIN subscribe / signoff / archive access instructions,
>> > > send email to [email protected] with the message: INFO
>> IBM-MAIN
>> > > [attachment "SORTFILE.txt" deleted by Sri h Kolusu/Silicon Valley/IBM]
>> >
>> >
>> > ----------------------------------------------------------------------
>> > For IBM-MAIN subscribe / signoff / archive access instructions,
>> > send email to [email protected] with the message: INFO IBM-MAIN
>> >
>>
>>
>>
>> --
>> Thank you and best regards,
>> *Billy Ashton*
>>
>> ----------------------------------------------------------------------
>> For IBM-MAIN subscribe / signoff / archive access instructions,
>> send email to [email protected] with the message: INFO IBM-MAIN
>>
>>
>>
>>
>>
>>
>> ----------------------------------------------------------------------
>> For IBM-MAIN subscribe / signoff / archive access instructions,
>> send email to [email protected] with the message: INFO IBM-MAIN
>>
>
>
>
> --
> Thank you and best regards,
> *Billy Ashton*
>
--
Thank you and best regards,
*Billy Ashton*
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
//CRECMDS EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
EZA1701I >>> LIST /workdata/team1/p1
150 Opening ASCII mode data connection for /bin/ls.
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 5427 Jun 25 1998 rf1.0
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 10578 Apr 28 2004 rf11.0
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 4264 Jun 23 2005 rf11.5
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 2378 May 4 2010 rf12.0
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 2624 Feb 8 2000 rf12.21
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 282160 Mar 30 2011 rf12.6
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 11920 May 21 2015 rf14.0
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 37120 Jun 25 1998 rf4.8
226 Listing completed.
EZA1701I >>> LIST /workdata/team4/p1
150 Opening ASCII mode data connection for /bin/ls.
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 567 Jun 26 2008 rf2.2
226 Listing completed.
EZA1701I >>> LIST /workdata/team5/p1
150 Opening ASCII mode data connection for /bin/ls.
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 574 Jun 26 2008 rf2.4
226 Listing completed.
EZA1701I >>> LIST /combine/t11-12/p1
150 Opening ASCII mode data connection for /bin/ls.
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 124080 Jun 26 1998 ra1.0
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 123360 Jun 26 1998 ra1.1
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 110560 Oct 7 2005 re11.0
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 124880 Oct 10 2007 re11.1
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 138800 Jan 25 2010 re11.3
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 131120 Oct 1 2013 rf12.0
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 112720 Jun 26 1998 rb2.0
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 1321440 Jun 26 1998 rb2.8
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 1902 Jun 26 1998 rb2.9
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 183040 Jun 26 1998 rc3.0
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 137360 Jun 26 1998 rc3.1
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 110240 Jun 26 1998 rc3.2
EZA2284I -rw-r--r-- 1 ftpuser ftpusers 17520 Feb 2 2001 rc3.3
226 Listing completed.
EZA1460I Command:
EZA1736I quit
EZA1701I >>> QUIT
221 Goodbye.
//SORTOUT DD SYSOUT=*
//SYSIN DD *
*---+----1----+----2----+----3----+----4----+----5----+----6----+----7
*ZA2284I -rw-r--r-- 1 ftpuser ftpusers 10578 Apr 28 2004 rf11.0
INCLUDE COND=(1,08,CH,EQ,C'EZA2284I',OR,
1,17,CH,EQ,C'EZA1701I >>> LIST')
INREC IFOUTLEN=90,
IFTHEN=(WHEN=(1,17,CH,EQ,C'EZA1701I >>> LIST'),
PARSE=(%01=(STARTAFT=C'>>> LIST ',ENDBEFR=C' ',FIXLEN=50)),
BUILD=(C'DIR ',%01,60:C'99999999')),
IFTHEN=(WHEN=(1,8,CH,EQ,C'EZA2284I'),
BUILD=(60:59,4,
64:51,3,CHANGE=(2,
C'Jan',C'01',C'Feb',C'02',C'Mar',C'03',
C'Apr',C'04',C'May',C'05',C'Jun',C'06',
C'Jul',C'07',C'Aug',C'08',C'Sep',C'09',
C'Oct',C'10',C'Nov',C'11',C'Dec',C'12'),
66:55,2,
68:63,13))
/*
//*
//
Expected output would be
get /workdata/team1/p1/rf14.0
get /workdata/team1/p1/rf12.6
get /workdata/team1/p1/rf12.0
get /workdata/team4/p1/rf2.2
get /workdata/team4/p1/rf2.4
get /combine/t11-12/p1/rf12.0
get /combine/t11-12/p1/re11.3
get /combine/t11-12/p1/re11.1
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN