Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Removing header and footer from input file using DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Removing header and footer from input file using DFSORT
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    Post subject: Re: removing header and footer from input file using DFSORT
Reply with quote

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

DFSORT Moderator


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

PostPosted: Wed Feb 28, 2007 9:17 pm    Post subject:
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    Post subject:
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: 1187
Location: Bangalore,India

PostPosted: Thu Mar 01, 2007 11:37 am    Post subject:
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    Post subject:
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    Post subject: Re: removing header and footer from input file using DFSORT
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

http://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    Post subject:
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    Post subject: Re: Removing header and footer from input file using DFSORT
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 Moderator


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

PostPosted: Thu Mar 01, 2007 10:06 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us