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

Skip first 10 and last 10


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

New User


Joined: 06 Mar 2006
Posts: 35

PostPosted: Mon Apr 10, 2006 9:10 pm
Reply with quote

Hi,

I have sequential file,I want to skip first 10 lines and the last 10 lines in the file and create a new file, How can i do this. The number of lines inbetween might vary so i want to specify last 10 and the first 10 to be removed to the new output file.

Thanks,
Ganapath
Back to top
View user's profile Send private message
vidhyanarayanan

New User


Joined: 23 Dec 2005
Posts: 52

PostPosted: Tue Apr 11, 2006 12:20 pm
Reply with quote

hi GANAPATH,

use IDCAMS PRINT- SKIP ,COUNT commands......

if u kno the total no of records.......= x
do x-20 =y

skip(10)
count( y)

use repro to copy to the o/p file...

hope this ll help u

regards,
vidhya
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Tue Apr 11, 2006 12:44 pm
Reply with quote

From a SORT perspective....

If the file is in SORTED ORDER...
1. SKIPREC=10
2. COPY Descendinly.
3. SKIPREC=10.
3. COPY Ascendingly.

If the file is not in SORTED ORDER...
1. ADD a SEQ Number against each record.
2. SKIPREC=10.
3. COPY Descendingly on SEQ NUM.
4. SKIPREC=10.
5. COPY Ascendingly on SEQ NUM.


Regards,
Priyesh.
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: Tue Apr 11, 2006 7:54 pm
Reply with quote

See the "Keep the last n records" Smart DFSORT Trick at:

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

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Tue Apr 11, 2006 11:52 pm
Reply with quote

You can use this one too
I didn't test it but it would work
Code:

//STEP0001 EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//IN DD DSN=...
//TOOLIN DD *
COPY FROM(IN) TO(ICE1CNTL) USING(ICE0)
COPY FROM(IN) TO(OUTX) USING(ICE1)
/*
//OUTX DD SYSOUT=*
//ICE0CNTL DD *
  OPTION SKIPREC=10
  OUTFIL FNAMES=ICE1CNTL,OUTREC=(80X),
  TRAILER1=(' OPTION SKIPREC=10,STOPAFT=',COUNT-10=(M11,LENGTH=5)),
  REMOVECC,NODETAIL
/*
//ICE1CNTL DD DSN=&&OUT,
//            DISP=(NEW,DELETE,DELETE),
//            UNIT=SYSDA,
//            SPACE=(TRK,(1,0),RLSE)

Alain
Back to top
View user's profile Send private message
Benjamin.L

New User


Joined: 11 Apr 2006
Posts: 17
Location: DL.PRC

PostPosted: Wed Apr 12, 2006 11:41 am
Reply with quote

Hi Alain,

r u sure the code above could work? icon_question.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: Wed Apr 12, 2006 8:53 pm
Reply with quote

Quote:
Hi Alain,

r u sure the code above could work?


I tested Alain's job with DFSORT and it works fine. Why do you think it wouldn't work?
Back to top
View user's profile Send private message
GANAPATH

New User


Joined: 06 Mar 2006
Posts: 35

PostPosted: Thu Apr 13, 2006 3:23 am
Reply with quote

Hi All,

I am new to all this, I had to work around little bit to make this work, but finally it worked,I have a habit of trying all the different methods so that i learn.Thanks for all ur responses.Appreciate it

Thanks
Ganapath
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: Tue Sep 23, 2008 4:37 am
Reply with quote

You can now do this kind of thing quite easily 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) REMOVE INPUT FIRST(10) LAST(10)
/*     


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
quanzhong

New User


Joined: 12 Aug 2008
Posts: 46
Location: china

PostPosted: Wed Sep 24, 2008 11:56 am
Reply with quote

Alain,
Quote:

//ICE0CNTL DD *
OPTION SKIPREC=10
OUTFIL FNAMES=ICE1CNTL,OUTREC=(80X),
TRAILER1=(' OPTION SKIPREC=10,STOPAFT=',COUNT-10=(M11,LENGTH=5)),
REMOVECC,NODETAIL
/*

I delete following line
Quote:

OPTION SKIPREC=10

and get the same result. so what this line there for? reformat input file?
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 SKIP LOCKED DATA in UPDATE statement DB2 9
No new posts Logic to skip Maximum time-stamp and ... DB2 2
No new posts Query to skip Max time-stamp and fetc... DB2 8
No new posts Skip records depends on count DFSORT/ICETOOL 5
No new posts FTP Skip or ignore error and process ... All Other Mainframe Topics 3
Search our Forums:

Back to Top