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

Sorting after few records


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

New User


Joined: 23 Feb 2006
Posts: 12

PostPosted: Wed Mar 05, 2008 4:18 pm
Reply with quote

Hi,

Would like to know how to start sorting after a few records.

Regards,
Mythili.
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Wed Mar 05, 2008 4:41 pm
Reply with quote

Mythili,

Please, post an example.

Alain Benveniste
Back to top
View user's profile Send private message
Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Wed Mar 05, 2008 4:45 pm
Reply with quote

Your reqt is not clear.
Check SKIP rec or START record position to see if it meets your reqt.
Back to top
View user's profile Send private message
mythili.m

New User


Joined: 23 Feb 2006
Posts: 12

PostPosted: Wed Mar 05, 2008 5:04 pm
Reply with quote

It's like this. I have say 1000 records, but I want to start sorting in between, say from 14 rec... . The output file should contain all the records without skipping any of the initial records(first 13) and the sorted ones.

Hope I'm clear.

Mythili.
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 Mar 05, 2008 10:42 pm
Reply with quote

You mean you want to keep the first 13 records in place and sort the rest?

If so, then you can use a DFSORT job like this. I assumed your input file has RECFM and LRECL=80 and your sort field is a character field in positions 21-28. Change as appropriate:

Code:

//S1  EXEC  PGM=ICEMAN                                             
//SYSOUT    DD  SYSOUT=*                                           
//SORTIN DD DSN=...  input file (FB/80)                               
//SORTOUT DD DSN=... output file (FB/80)                           
//SYSIN    DD    *                                                 
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:9C'9',89:SEQNUM,8,ZD)),       
        IFTHEN=(WHEN=(89,8,ZD,LE,+13),OVERLAY=(81:SEQNUM,8,ZD))     
  SORT FIELDS=(81,8,ZD,A,11,8,CH,A)                                 
  OUTREC BUILD=(1,80)                           
/*                   
Back to top
View user's profile Send private message
skkp2006

New User


Joined: 14 Jul 2006
Posts: 93
Location: Chennai,India

PostPosted: Thu Mar 06, 2008 11:54 am
Reply with quote

Is it possible with DFSORT to sort only a few records in between? Say i have the following records from the input file and i want to sort only the records from the 4th record till the 6th record.

Code:
1111111111
9999999990
2323232332
4564564576
0088765765
1213534645
6666666666
9999999999
5555555555



and the expected output is

Code:
1111111111
9999999990
2323232332
0088765765
1213534645
4564564576
6666666666
9999999999
5555555555


How should i proceed ??
Back to top
View user's profile Send private message
mythili.m

New User


Joined: 23 Feb 2006
Posts: 12

PostPosted: Thu Mar 06, 2008 2:43 pm
Reply with quote

Thank You so much Frank.
I got the desired result but, could not completely understand the sort portion...though I tried searching in DFSORT material....
Would be helpful if i could know it.

Thanks again.

Mythili.
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 06, 2008 9:56 pm
Reply with quote

Quote:
I got the desired result but, could not completely understand the sort portion...though I tried searching in DFSORT material....
Would be helpful if i could know it.


Code:

  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:9C'9',89:SEQNUM,8,ZD)),       
        IFTHEN=(WHEN=(89,8,ZD,LE,+13),OVERLAY=(81:SEQNUM,8,ZD))     


The INREC statement changes the records to the following:

Code:

|data|00000001|00000001|
...
|data|00000013|00000013|
|data|99999999|00000014|
|data|99999999|00000015|
...


Notice that records 1-13 have a unique first sequence number whereas records 14-n all have 99999999 as the first sequence number. The second sequence number is just used by the second IFTHEN clause to tell us when we get to record 13.

Code:

  SORT FIELDS=(81,8,ZD,A,11,8,CH,A)     


The SORT statements sorts on the first sequence number and then on the actual key. Since we have a sequence number of 1-13 for the first 13 records, they will stay in that sequence. Since we have a sequence number of 99999999 for the rest of the records they will be sorted by the key.

Code:

  OUTREC BUILD=(1,80)       


The OUTREC statement just removes the sequence numbers.

I hope this helps.
Back to top
View user's profile Send private message
mythili.m

New User


Joined: 23 Feb 2006
Posts: 12

PostPosted: Fri Mar 07, 2008 10:21 am
Reply with quote

Thank You for the explanation, Frank.


Mythili.
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 Mar 07, 2008 10:48 pm
Reply with quote

skkp2006,

You can use a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1  EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD *
SNUM,+4     Starting number
ENUM,+6     Ending number
/*
//SORTIN DD *
1111111111
9999999990
2323232332
4564564576
0088765765
1213534645
6666666666
9999999999
5555555555
/*
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(81,8,ZD,GE,SNUM,AND,81,8,ZD,LE,ENUM),
          OVERLAY=(81:SNUM,TO=ZD,LENGTH=8))
  SORT FIELDS=(81,8,ZD,A,1,10,CH,A)
  OUTREC BUILD=(1,80)
/*
Back to top
View user's profile Send private message
skkp2006

New User


Joined: 14 Jul 2006
Posts: 93
Location: Chennai,India

PostPosted: Mon Mar 10, 2008 12:18 pm
Reply with quote

Thanks a lot Frank...I got the desired result...and the logic is something brilliant icon_idea.gif

Regards,
Syam
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 Aug 12, 2008 4:47 am
Reply with quote

With z/OS DFSORT V1R5 PTF UK90013 (July, 2008), you can now use the new DATASORT operator of DFSORT's ICETOOL to easily keep headers, trailers or headers and trailers in place while you sort the data records between them. For complete details on DATASORT, 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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
Search our Forums:

Back to Top