Merge up to four records to one new record



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

Merge up to four records to one new record

Postby puffes » Wed Mar 12, 2014 1:13 am

Hi,
I hope someone can help me with my dilemma. I have a sequential file that is fixed blocked and lrecl=34.
In position 1-15 you find the key. In position 16-19 there is year and position 20-34 is a numeric fieldvalue.
Here's the layout of the file
1122334455AA01 2010000000000011100
1122334455AA01 2011000000000222200
1122334455AA01 2012000000000333300
1122334455AA01 2013000000000044400
1234567890BB02 2010000000000055500
1234567890BB02 2012000000000666600

What I want is that for all unique keys (containing max 4 records in the file) take the value in the record from position 20-34 and put it in a new output record with the condition that if value in position 16-19 should land in:
Value in pos 16-19 Output file position
2010 16-30
2011 32-46
2012 48-62
2013 64-78

So the output file (lrecl=79,recfm=fb) should look like this if you use the six records in the input file above:
1122334455AA01 000000000011100 000000000222200 000000000333300 000000000044400
1234567890BB02 000000000055500 000000000666600

Is it possible to accomplish this?

Kind regards,
Mike
puffes
 
Posts: 5
Joined: Wed Mar 12, 2014 12:46 am
Has thanked: 0 time
Been thanked: 0 time

Re: Merge up to four records to one new record

Postby skolusu » Wed Mar 12, 2014 3:41 am

Assuming that the data is already sorted on the key and year, the following DFSORT JCL will give you the desired results


//STEP0100 EXEC PGM=ICETOOL                           
//TOOLMSG  DD SYSOUT=*                                 
//DFSMSG   DD SYSOUT=*                                 
//IN       DD DISP=SHR,DSN=Your Input FB 34 Byte file 
//OUT      DD SYSOUT=*                                 
//TOOLIN   DD *                                       
 SPLICE FROM(IN) TO(OUT) ON(1,15,CH) WITHANY     -
 WITH(32,15) WITH(48,15) WITH(64,15) USING(CTL1)       
//*                                                   
//CTL1CNTL DD *                                       
  OPTION COPY                                         
  INREC IFOUTLEN=79,IFTHEN=(WHEN=INIT,                 
  BUILD=(1,15,81:20,15,X,SEQNUM,1,ZD,RESTART=(1,15))),
  IFTHEN=(WHEN=(97,1,ZD,EQ,1),OVERLAY=(16:81,15)),     
  IFTHEN=(WHEN=(97,1,ZD,EQ,2),OVERLAY=(32:81,15)),     
  IFTHEN=(WHEN=(97,1,ZD,EQ,3),OVERLAY=(48:81,15)),     
  IFTHEN=(WHEN=(97,1,ZD,EQ,4),OVERLAY=(64:81,15))     
//*
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