Page 1 of 1

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

PostPosted: Mon Jan 07, 2008 4:02 pm
by Laksh
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

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

PostPosted: Mon Jan 07, 2008 10:19 pm
by Frank Yaeger
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)
/*

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

PostPosted: Tue Jan 08, 2008 12:32 pm
by Laksh
Thanks Frank.