How to write key and record count in header using DFSORT



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

How to write key and record count in header using DFSORT

Postby salilnigam » Fri Oct 21, 2011 12:00 pm

Hi All,

I have an input file having records based on key value as mentioned in attached document.

Intiallay I will sort the Input file records based on key value.

In the next step I have to write the header record for each key value along with count of records for a perticular key.

Can someone help me out to do this using DFSORT.

Please see the details in attached document and below:

Input File:

----Key Value--
C11122233333333A1212121212AAAAA00
C11122233333333B12121211212BB0000
C11122233333333C12121212121CCC000
C11122233333333D12121212121DDDD00
C11122244444444E35353535353EE0100
C11122244444444FFF323232323FF0100
C11122244444444H1212121212DDDD100
C11122244444444AAAAAAAAAAAAAAAAAA
P11122255555555BBBBBBBBBBBBBBBBBBI
P11122255555555CCCCCCCCCCCCCCCCCCI
P11122255555555DDDDDDDDDDDDDDDDDDI
P11122266666666EEEEEEEEEEEEEEEE00D
P11122266666666EEEFFFFFFFFFFF0000D
P11122266666666GGGGGGGGGGGGGG0000D
P11122277777777HHHHHHHHHHHHHHHH00B
P11122277777777IIIIIIIIIIIIIJ0000B
P11122277777777JJJJJJJJJJJJJJJ000B
P11122277777777KKKKKKKKKKKKKK0100B
D11122288888888LLLLLLLLLLLLLL0100
D11122288888888MMMMMMMMMMMMMM0100
D11122288888888NNNNNNNNNNNNNN0000
D11122288888888OOOOOOOOOOOOOO0000
D11122288888888PPPPPPPPPPPPPP0000
D11122299999999QQQQQQQQQQQQQQ0100
D11122299999999RRRRRRRRRRRRRR0100
D11122299999999SSSSSSSSSSSSSSSS00
D11122299999999TTTTTTTTTTTTTTT100
D11122299999999UUUUUUUUUUUUUUUU00


Output File:
In output file I have to create header based on the key value and write the count also in header along with key value. i.e. C11122233333333 is key value and 000000004 is count of particular key. Output file should be as given below:

C11122233333333         000000004
C11122233333333A1212121212AAAAA00
C11122233333333B12121211212BB0000
C11122233333333C12121212121CCC000
C11122233333333D12121212121DDDD00
C11122244444444         000000004   
C11122244444444E35353535353EE0100
C11122244444444FFF323232323FF0100
C11122244444444H1212121212DDDD100
C11122244444444AAAAAAAAAAAAAAAAAA
P11122255555555         000000003
P11122255555555BBBBBBBBBBBBBBBBBBI
P11122255555555CCCCCCCCCCCCCCCCCCI
P11122255555555DDDDDDDDDDDDDDDDDDI
P11122266666666         000000003
P11122266666666EEEEEEEEEEEEEEEE00D
P11122266666666EEEFFFFFFFFFFF0000D
P11122266666666GGGGGGGGGGGGGG0000D
P11122277777777         000000004
P11122277777777HHHHHHHHHHHHHHHH00B
P11122277777777IIIIIIIIIIIIIJ0000B
P11122277777777JJJJJJJJJJJJJJJ000B
P11122277777777KKKKKKKKKKKKKK0100B
D11122288888888         000000005
D11122288888888LLLLLLLLLLLLLL0100
D11122288888888MMMMMMMMMMMMMM0100
D11122288888888NNNNNNNNNNNNNN0000
D11122288888888OOOOOOOOOOOOOO0000
D11122288888888PPPPPPPPPPPPPP0000
D11122299999999         000000005
D11122299999999QQQQQQQQQQQQQQ0100
D11122299999999RRRRRRRRRRRRRR0100
D11122299999999SSSSSSSSSSSSSSSS00
D11122299999999TTTTTTTTTTTTTTT100
D11122299999999UUUUUUUUUUUUUUUU00
You do not have the required permissions to view the files attached to this post.
salilnigam
 
Posts: 1
Joined: Fri Oct 21, 2011 9:43 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to write key and record count in header using DFSORT

Postby Frank Yaeger » Sat Oct 22, 2011 3:05 am

Here's a DFSORT job that will 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.

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,15),PUSH=(81:SEQ=8,89:ID=8))
  OUTFIL FNAMES=T1
  OUTFIL FNAMES=T2,REMOVECC,NODETAIL,
    SECTIONS=(89,8,
      TRAILER3=(1,15,50:81,8,81:C'00000000',89,8))
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&T1,DISP=(OLD,PASS)
//       DD DSN=&&T2,DISP=(OLD,PASS)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN DD *
  SORT FIELDS=(89,8,ZD,A,81,8,ZD,A)
  OUTREC BUILD=(1,80)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post