How to sort groups of records based NOT on the header



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

How to sort groups of records based NOT on the header

Postby Irene Ioujanina » Fri Feb 03, 2012 8:50 pm

Hi,

May I please ask again...
Is it possible to sort groups of records when the sort key is always in the second record pos 10thru14 (and this record is identified as KEY in the first 3 positions). For instance:
HDR 043434
KEY 10001
R01 lllll
R01 KKSDKSKD
HDR 0101010
KEY 10000
R03

Each record has 'record identifier' in the first 3 positions. Each group starts from 'HDR', then goes 'KEY', then can go any number of any different record types(except HDR and KEY). The group of record ends when the next 'HDR' comes, or EOF. The order of records withing each group should not change. The record length let's say 80B.
The result I need :
HDR 0101010
KEY 10000
R03
HDR 043434
KEY 10001
R01 lllll
R01 KKSDKSKD

Thank you so much in advance,
Irene Ioujanina
 
Posts: 27
Joined: Thu Feb 21, 2008 6:42 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to sort groups of records based NOT on the header

 

Re: How to sort groups of records based NOT on the header

Postby Akatsukami » Fri Feb 03, 2012 9:34 pm

See if Gerry's first sort step is of use to you. Otherwise, you could concatenate all the records in one group, sort those concatenated records, and split them up again, although I daresay that you'd rather avoid that.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: How to sort groups of records based NOT on the header

Postby skolusu » Fri Feb 03, 2012 10:03 pm

Irene Ioujanina,

The following DFSORT JCL will give you the desired results.

//STEP0100 EXEC PGM=SORT 
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=Your input FB 808 File,DISP=SHR
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),               
          PUSH=(809:1,808),RECORDS=2),                             
  IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(1617:ID=8)),   
  IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'KEY'),PUSH=(1625:5,5))
  SORT FIELDS=(1625,5,CH,A),EQUALS                                 
                                                                   
  OUTFIL IFOUTLEN=808,OMIT=(1,3,CH,EQ,C'HDR'),                     
  IFTHEN=(WHEN=(1,3,CH,EQ,C'KEY'),BUILD=(809,808,/,1,808))         
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: How to sort groups of records based NOT on the header

Postby Irene Ioujanina » Fri Feb 03, 2012 10:38 pm

Thank you so much!
Irene Ioujanina
 
Posts: 27
Joined: Thu Feb 21, 2008 6:42 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post