Sort Detail records with Header & Trailer



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

Sort Detail records with Header & Trailer

Postby purva » Fri Feb 17, 2012 2:23 pm

Hi,

I have one sequential file (LRECL=80) with the below record structure:

HH -------> Header Record
AS,Empid1,H,N,current date,22:00,06:00-----> Detail record
JR,W,22:00,05:00,D008,S9518 ------> All JR records are part of the AS record.
JR,L1,05:00,05:30,D008,S9518
JR,W,05:30,06:00,D008,S9518
AS,Empid2,H,N,Previous date,22:00,06:00-----> Detail record
JR,W,22:00,05:00,D008,S9518 ------> All JR records are part of the AS record.
JR,L1,05:00,05:30,D008,S9518
JR,W,05:30,06:00,D008,S9518
TT ----------> Trailer record

The requirement is to sort the only AS records in detail record in ascending order by Empid & current date.
The file is currently having records in random order.
Emp id position is position is AS record is 5, length 7
Date filed position 13, length 8.

The output file should have the header & trailer as it is. And the format should be like the existing file but only in ascending order of AS record.



Appreciate your help!

Thanks,
Purva
purva
 
Posts: 9
Joined: Thu Feb 16, 2012 11:34 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sort Detail records with Header & Trailer

Postby skolusu » Fri Feb 17, 2012 10:27 pm

purva,

Use the following DFSORT JCL
//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
HH -------> HEADER RECORD                                           
AS, EMPID02,20120216,22:00,06:00-----> DETAIL RECORD               
JR,W,22:00,05:00,D008,S9518                                         
JR,L1,05:00,05:30,D008,S9518                                       
JR,W,05:30,06:00,D008,S9518                                         
AS, EMPID02,20120215,22:00,06:00-----> DETAIL RECORD               
JR,W,22:00,05:00,D008,S9518                                         
JR,L1,05:00,05:30,D008,S9518                                       
JR,W,05:30,06:00,D008,S9518                                         
TT ----------> TRAILER RECORD                                       
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1')),                       
  IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'AS'),PUSH=(82:5,7,13,8)),   
  IFTHEN=(WHEN=(1,2,CH,EQ,C'HH'),OVERLAY=(81:C'0')),               
  IFTHEN=(WHEN=(1,2,CH,EQ,C'TT'),OVERLAY=(81:C'2'))                 
  SORT FIELDS=(81,16,CH,A),EQUALS                                   
  OUTREC BUILD=(1,80)                                               
//*
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


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post