MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sorting the data in between the header and trailer records

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
bprasanna
Beginner


Joined: 05 Sep 2003
Posts: 119
Topics: 33
Location: Hyderabad

PostPosted: Tue Aug 24, 2004 8:04 am    Post subject: Sorting the data in between the header and trailer records Reply with quote

Hi,
I need to do the following using sort(SYNCSORT) .I am having a flat file of length 80 and the data is like below.

HR08/20/2004
061
081
062
082
071
TR00090000290000000
HR08/19/2004
061
081
062
082
071
091
TR00090000290000000

I need to sort the detail records on the ascending order basis so that they will be in sorted order.

I need the output like below.

HR08/20/2004
061
062
071
081
082
TR00090000290000000
HR08/19/2004
061
062
071
081
082
091
TR00090000290000000

Now when there is only one header and one trailer I am able to sort the data.I found a similar post here but it has been dealt with only one header and trailer.How I can do this one if more than 1 header and triler were there in the input file.I am not sure how many headers and trailers will come on each day.Actually this is needed for our production support.

Thanks in advance..
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Aug 25, 2004 3:47 pm    Post subject: Reply with quote

Bprassana,

I can't think of a way to sort the records in between multiple headers and trailers with the available traditional features of sort.

So I used easytrieve to populate the number at the end of each record , so that all the detail records can be identified as a group.

Code:

//STEP0100 EXEC PGM=EZTPA00                   
//STEPLIB  DD DSN=EASYTREV.LOADLIB, 
//            DISP=SHR                         
//SYSPRINT DD SYSOUT=*                         
//SYSSNAP  DD SYSOUT=*                         
//INFILE   DD *                               
HR08/20/2004                                   
061                                           
081                                           
062                                           
082                                           
071                                           
TR00090000290000000                           
HR08/19/2004                                   
061                                           
081                                           
062                                           
082                                           
071                                           
091                                           
TR00090000290000000         
//OUTFILE  DD DSN=USERID.TEMP.FILE,           
//            DISP=(NEW,CATLG,DELETE),         
//            UNIT=SYSDA,                       
//            SPACE=(CYL,(X,Y),RLSE),           
//            DCB=(LRECL=88,RECFM=FB,BLKSIZE=0)       
//SYSIN    DD *                                 
  FILE INFILE                                   
       IN-REC             01 80  A             
       TYP                01 02  A             
                                               
  FILE OUTFILE FB (0  0)                       
       OUT-REC            01 80  A             
       O-SEQ              81 08  N 0           
                                               
  W-SEQNUM       W 08 N 0                       

  JOB INPUT INFILE                             
                                               
      OUT-REC    = IN-REC                       

      CASE TYP                                 
           WHEN 'HR'                           
                W-SEQNUM     = W-SEQNUM + 1     
           WHEN 'TR'                           
                W-SEQNUM     = W-SEQNUM + 1     
      END-CASE                                 

      O-SEQ                  = W-SEQNUM         
      PUT OUTFILE                               
//*
//STEP0200 EXEC PGM=SORT           
//SYSOUT   DD SYSOUT=*             
//SORTIN   DD DSN=USERID.TEMP.FILE,
//            DISP=SHR   
//SORTOUT DD DSN=YOUR OUTPUT SORTED FILE,           
//            DISP=(NEW,CATLG,DELETE),         
//            UNIT=SYSDA,                       
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *
  SORT FIELDS=(81,8,CH,A,     $ SORT ON SEQNUM
               01,3,CH,A)     $ SORT ON KEY     
  OUTREC FIELDS=(01,80)       $ STRIP THE SEQNUM
//*               


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bprasanna
Beginner


Joined: 05 Sep 2003
Posts: 119
Topics: 33
Location: Hyderabad

PostPosted: Thu Aug 26, 2004 1:11 pm    Post subject: Reply with quote

Hi Kolusu,
Thank you very much,it worked fine ..

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


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Sat Aug 28, 2004 12:10 am    Post subject: Reply with quote

Frank,

May I have your opinion about this : do you have an idea if it is feasible with dfsort ?
Yes or no is enough for me. If it is no, I could test something on monday. Smile

Alain
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sat Aug 28, 2004 10:16 am    Post subject: Reply with quote

Alain,

It's irrelevent since bprasanna asked for a Syncsort solution.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Alain Benveniste
Beginner


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Sat Aug 28, 2004 12:54 pm    Post subject: Reply with quote

Frank,

I'm agree.
During a search for a potential Dfsort solution and for my personal curiosity, I found an old thread (1 month ago) from an other forum with the a similar need. If I find something I will post it down there.

Alain
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group