IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Removing header and footer from input file using DFSORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prafull

New User


Joined: 08 Dec 2006
Posts: 48

PostPosted: Wed Feb 28, 2007 7:27 pm
Reply with quote

hi
can we remove first N lines or last N lines from a Input file using DFSORT?
Back to top
View user's profile Send private message
IQofaGerbil

Active User


Joined: 05 May 2006
Posts: 183
Location: Scotland

PostPosted: Wed Feb 28, 2007 8:47 pm
Reply with quote

yes
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Feb 28, 2007 9:17 pm
Reply with quote

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
View user's profile Send private message
prafull

New User


Joined: 08 Dec 2006
Posts: 48

PostPosted: Thu Mar 01, 2007 11:05 am
Reply with quote

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
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Thu Mar 01, 2007 11:37 am
Reply with quote

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
View user's profile Send private message
prafull

New User


Joined: 08 Dec 2006
Posts: 48

PostPosted: Thu Mar 01, 2007 1:54 pm
Reply with quote

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
View user's profile Send private message
IQofaGerbil

Active User


Joined: 05 May 2006
Posts: 183
Location: Scotland

PostPosted: Thu Mar 01, 2007 5:49 pm
Reply with quote

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
View user's profile Send private message
prafull

New User


Joined: 08 Dec 2006
Posts: 48

PostPosted: Thu Mar 01, 2007 6:58 pm
Reply with quote

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
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 183
Location: hyderabad

PostPosted: Thu Mar 01, 2007 8:32 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 01, 2007 10:06 pm
Reply with quote

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
View user's profile Send private message
prafull

New User


Joined: 08 Dec 2006
Posts: 48

PostPosted: Fri Mar 02, 2007 2:33 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top