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

How to eliminate First and last record of a file using sort


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

New User


Joined: 22 Jan 2007
Posts: 7
Location: india

PostPosted: Fri Jan 26, 2007 3:02 pm
Reply with quote

Hi,

Could someone help me on this. I just wanted to remove the first and last record (Header and Trailer) using some method. So the output file should contain only the detail records and not the Header and Trailer

Thanks,
Deva.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 26, 2007 3:07 pm
Reply with quote

Are the header and trailer recognizable? Can you use the include/omit facility of sort to eliminate them?
Back to top
View user's profile Send private message
devabojan1

New User


Joined: 22 Jan 2007
Posts: 7
Location: india

PostPosted: Fri Jan 26, 2007 3:23 pm
Reply with quote

No the header and trailer are not recognizable. We cannot use include/omit facility here.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 26, 2007 3:26 pm
Reply with quote

How do you know that are a header and trailer, the first and last record on the file?
Which sort do you have?
What release?
Back to top
View user's profile Send private message
devabojan1

New User


Joined: 22 Jan 2007
Posts: 7
Location: india

PostPosted: Fri Jan 26, 2007 3:34 pm
Reply with quote

I know the format of the file. Previously the file didn't contain header and trailer. All are detail records. Now due to some changes we have made, a new header line and trailer line is included to the file. In another program this file should go without the header and trailer. ie. we need to strip off the first and last record and send it as it was before.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 26, 2007 3:46 pm
Reply with quote

I repeat, How do you know that are a header and trailer, the first and last record on the file?
Which sort do you have?
What release?
Back to top
View user's profile Send private message
devabojan1

New User


Joined: 22 Jan 2007
Posts: 7
Location: india

PostPosted: Fri Jan 26, 2007 3:48 pm
Reply with quote

The data in file could be something like this

01|PF40|9210|10007|20070115|03:02:00|
4500028810285056140702 00000000000Y 00000142500
40202852104500DC250701 00000000000Y 00000180100
99|0000007171850.79|0000000000000.00|00000000007999|

The first line is header and last line is trailer. The inbetween lines are detail records. I need to remove the 1st and 4th lines by some way.
Hope I have made it clear.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 26, 2007 3:54 pm
Reply with quote

First two bytes? 01 and 99 for header and trailer?
Code:
01|PF40|9210|10007|20070115|03:02:00|         
4500028810285056140702 00000000000Y 00000142500
40202852104500DC250701 00000000000Y 00000180100
99|0000007171850.79|0000000000000.00|00000000007999|

What is the significance of the vertical bars (|)?
Again, Which sort do you have?
What release?
Back to top
View user's profile Send private message
devabojan1

New User


Joined: 22 Jan 2007
Posts: 7
Location: india

PostPosted: Fri Jan 26, 2007 4:02 pm
Reply with quote

The vertical bars are just delimiters. I do not have any sort utility. Probably if someone tell me which sort or any other way that can be used that would be great.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 26, 2007 4:08 pm
Reply with quote

devabojan1 wrote:
The vertical bars are just delimiters. I do not have any sort utility. Probably if someone tell me which sort or any other way that can be used that would be great.
Just what utilities DO you have available?
Back to top
View user's profile Send private message
devabojan1

New User


Joined: 22 Jan 2007
Posts: 7
Location: india

PostPosted: Fri Jan 26, 2007 4:11 pm
Reply with quote

Just DFSORT and SORT utilities. No other utilities are available.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 26, 2007 4:28 pm
Reply with quote

Thanks, since the first two bytes don't seem to be of value, try this. An example in "Smart DFSORT Tricks" titled "Keep the last n records" uses the ENDREC in the outfil but if, instead, in the two sorts, you used the SKIPREC, you would solve your problem.
Back to top
View user's profile Send private message
devabojan1

New User


Joined: 22 Jan 2007
Posts: 7
Location: india

PostPosted: Fri Jan 26, 2007 4:42 pm
Reply with quote

The solution is found.

Simple sort with omit condition.

SORT FIELDS=COPY
OMIT COND=(3,1,CH,EQ,C'|')

Thanks William Thompson.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 26, 2007 4:57 pm
Reply with quote

devabojan1 wrote:
The solution is found.

Simple sort with omit condition.

SORT FIELDS=COPY
OMIT COND=(3,1,CH,EQ,C'|')

Thanks William Thompson.
You are very welcome. icon_biggrin.gif
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: Fri Jan 26, 2007 9:39 pm
Reply with quote

This is one of the funniest threads I've ever read here.

Quote:
No the header and trailer are not recognizable. .


Except header has 01| and trailer has 99|.

Quote:
We cannot use include/omit facility here. I do not have any sort utility.


Quote:
Just DFSORT and SORT utilities.


Hmmm ... I think DFSORT and SORT (?) qualify as sort utilities and last I looked they had include and omit.

But seriously, since you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 26, 2007 9:51 pm
Reply with quote

Frank,

You must have the patience of a saint......

Bill
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 Sep 04, 2008 11:15 pm
Reply with quote

You can now remove the header and trailer quite easily, even if they have no identifiers, using the new SUBSET operator of DFSORT's ICETOOL available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:


Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//OUT DD DSN=...  output file
//TOOLIN DD *
SUBSET FROM(IN) TO(OUT) INPUT REMOVE HEADER TRAILER
/*


For complete details on the new SUBSET function and the other new functions available with PTF UK90013, see:

Use [URL] BBCode for External Links
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top