View previous topic :: View next topic
|
Author |
Message |
prafull
New User
Joined: 08 Dec 2006 Posts: 48
|
|
|
|
hi
can we remove first N lines or last N lines from a Input file using DFSORT? |
|
Back to top |
|
|
IQofaGerbil
Active User
Joined: 05 May 2006 Posts: 183 Location: Scotland
|
|
|
|
yes |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
prafull,
You need to provide more information about exactly what you want to do. What is n? Please show an example of the records in your input file and what you expect for the output records. Also, what is the RECFM and LRECL of the input file? |
|
Back to top |
|
|
prafull
New User
Joined: 08 Dec 2006 Posts: 48
|
|
|
|
Frank ,
my input file is like :
1 XYZ comapny
2 File from : ABC source
3 00010008950
4 00020007950
5 00030006950
6 00040008550
7 00050078950
8
9 Total: 0041350
out of these 9 lines I want my SORTOUT file should remove first 2 lines and last 2 lines..
is it possible? how is important..
IQofaGerbil , please justify your 'yes'
Thank you |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Prafull,
You cna use following sort card
Code: |
//SYSIN DD *
OPTION SKIPREC=2
SORT FIELDS=COPY
OUTFIL FILES=1,ENDREC=5
/* |
Here i am assuming that u know the number of record in i/p file .
Hope it will be helpful |
|
Back to top |
|
|
prafull
New User
Joined: 08 Dec 2006 Posts: 48
|
|
|
|
Thanks Ekta!
SKIPREC=2 will remove header but I never know the number of records so removing footers is the only problem left.
Does DFSORT has any OPTION to skip records from bottom ?
Frank, expecting clues from you.
Anyway,Thanks much all. |
|
Back to top |
|
|
IQofaGerbil
Active User
Joined: 05 May 2006 Posts: 183 Location: Scotland
|
|
|
|
remove the first two lines as Guptae as shown
To remove the last two;
if your file is sorted in sequence then reverse that sequence and repeat the removal of the first two lines, then sort back in original order
if your file is not in sort order then use Frank's method to reverse it
ibmmainframes.com/viewtopic.php?t=10862&highlight=reverse
then remove the first two lines, then undo the revese
although I'm sure that Frank will come up with a super efficient way of doing it in one pass!
Another way?
if the second last line is the only one with spaces then omit it
eg
OMIT COND=(p,l,CH,EQ,C' ')
and
if the last line is the only one with characters = 'total', omit it also
OMIT COND=(p,l,CH,EQ,C'Total') |
|
Back to top |
|
|
prafull
New User
Joined: 08 Dec 2006 Posts: 48
|
|
|
|
Thanks IQofaGerbil.
The approach to remove footer (reverse the file and remove first 2 lines again) seems good.
I was using,the other way you have shown. But in my input file there can be changes in header and footer records each time.So I should not use INCLUDE/OMIT COND. |
|
Back to top |
|
|
sril.krishy
Active User
Joined: 30 Jul 2005 Posts: 183 Location: hyderabad
|
|
|
|
Hi,
I think by creating the dynamic control cards and using the count operator,you can delete the first 2 and last 2 records.
Thanks
Krishy |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
prafull,
Here's a DFSORT/ICETOOL job that will do what you asked for:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//CTL2CNTL DD DSN=&&C2,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
COPY FROM(IN) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=CTL2CNTL,REMOVECC,NODETAIL,
BUILD=(80X),
TRAILER1=(' OPTION SKIPREC=2,STOPAFT=',
COUNT-4=(M11,LENGTH=8),80:X)
/*
|
|
|
Back to top |
|
|
prafull
New User
Joined: 08 Dec 2006 Posts: 48
|
|
|
|
yes Frank Yaeger ,
As expected , gr8 way to finish the problem!
We are lucky to have you here.
Thank you.
sril.krishy thank you 2. |
|
Back to top |
|
|
|