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
 

 

Sorting after few records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sorting after few records
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    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Mar 05, 2008 10:42 pm    Post subject:
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    Post subject: Reply to: Sorting after few records
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    Post subject:
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 Moderator


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

PostPosted: Thu Mar 06, 2008 9:56 pm    Post subject:
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    Post subject:
Reply with quote

Thank You for the explanation, Frank.


Mythili.
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: Fri Mar 07, 2008 10:48 pm    Post subject:
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    Post subject: Reply to: Sorting after few records
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 Moderator


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

PostPosted: Tue Aug 12, 2008 4:47 am    Post subject:
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:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


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