Sort needed to omit the first few bytes of a record in file



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

Sort needed to omit the first few bytes of a record in file

Postby Laksh » Mon Jan 07, 2008 4:02 pm

Hi

My input file has the seven bytes as the sort tag. I need a sort that would give me two output files - One with unique records with the first seven bytes and the count of such records. The second should be the same as my input file with the first seven bytes removed. Is it possible to write such a Sort?

My input file:

ABCDEFG jkhfjdkhmhgjldhglkdgh
ACDFGRE ljglkrgjrklgjrklgjrklgjkl
BFGRSFF dgdgdkglrgmlgmlglgklkl
ABCDEFG jfkfjkjlmhnfdjknfhssjs
ASDFREG jklejf agfwdhdsbndmfj
ACDFGRE hwitbbcvmznhyurhwin

My output files should be:
Output 1:
ABCDEFG 2
ACDFGRE 2
BFGRSFF 1
ASDFREG 1

Output 2:
jkhfjdkhmhgjldhglkdgh
ljglkrgjrklgjrklgjrklgjkl
dgdgdkglrgmlgmlglgklkl
jfkfjkjlmhnfdjknfhssjs
jklejf agfwdhdsbndmfj
hwitbbcvmznhyurhwin

Thanks in advance,
Laksh
Laksh
 
Posts: 3
Joined: Mon Jan 07, 2008 3:43 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Sort needed to omit the first few bytes of a record in file

Postby Frank Yaeger » Mon Jan 07, 2008 10:19 pm

This is a bit complicated because you want OUT1 and OUT2 in their original order rather than in sorted order (at least that's what your example output shows). But here's a DFSORT/ICETOOL 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=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD *
ABCDEFG jkhfjdkhmhgjldhglkdgh
ACDFGRE ljglkrgjrklgjrklgjrklgjkl
BFGRSFF dgdgdkglrgmlgmlglgklkl
ABCDEFG jfkfjkjlmhnfdjknfhssjs
ASDFREG jklejf agfwdhdsbndmfj
ACDFGRE hwitbbcvmznhyurhwin
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT1 DD DSN=...  output file1 (FB/80)
//OUT2 DD DSN=...  output file2 (FB/73)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
SORT FROM(T1) TO(T2) USING(CTL2)
SORT FROM(T2) TO(OUT1) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD)
  OUTFIL FNAMES=OUT2,BUILD=(8,73)
  OUTFIL FNAMES=T1
/*
//CTL2CNTL DD *
  OPTION EQUALS
  SORT FIELDS=(1,7,CH,A,81,8,ZD,D)
  OUTFIL FNAMES=T2,REMOVECC,NODETAIL,
    SECTIONS=(1,7,
      TRAILER3=(1,7,9:COUNT=(EDIT=(IIIIT)),81:81,8))
/*
//CTL3CNTL DD *
  SORT FIELDS=(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

Re: Sort needed to omit the first few bytes of a record in file

Postby Laksh » Tue Jan 08, 2008 12:32 pm

Thanks Frank.
Laksh
 
Posts: 3
Joined: Mon Jan 07, 2008 3:43 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post