Page 1 of 1

Finding missing sequential number

PostPosted: Tue Dec 20, 2011 10:00 pm
by profondo
I have an input file where each record - excluding the header and trailer - is numbered sequentially but doesn't necessarily start from 1. The file varies in size daily. The header and trailer both contain the count range for this list - "HEADER," followed by the 5-byte start range, followed by the 5-byte end range. There are rare times when a record or 2 is missing from the file. I need to find the numbers in the range that are missing. In the following example, the range is from 00015 to 00022. Record numbers 15, 18 and 22 are missing.

Input file:
HEADER0001500022
00016
00017
00019
00020
00021
TRAILR0001500022

Output:
00015
00018
00022

Is this possible with ICETOOL?

Re: Finding missing sequential number

PostPosted: Tue Dec 20, 2011 11:16 pm
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for:


//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD DSN=...  input file
//IN2 DD *
00015
00016
00017
00018
00019
00020
00021
00022
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(1,5,A),SORTED
  JOINKEYS F2=IN2,FIELDS=(1,5,A),SORTED
  JOIN UNPAIRED,F2,ONLY
  OPTION COPY
/*
//JNF1CNTL DD *
  OMIT COND=(1,1,SS,EQ,C'HT')
/*

Re: Finding missing sequential number

PostPosted: Wed Dec 21, 2011 1:14 am
by profondo
Thanks, Frank.

Regarding your IN2 file: is there any way to have DFSORT create this file of sequential numbers? My begin/end ranges change from day to day but they are contained in the header and trailer of IN1.

When first presented with the initial task, my biggest issue when trying to find a solution was figuring out a way for ICETOOL to create this file you laid out and then I was thinking of merging the file with IN1 and using SELECT to eliminate the dupes.

Re: Finding missing sequential number

PostPosted: Wed Dec 21, 2011 4:08 am
by Frank Yaeger
You could have saved us both some time by giving your complete requirement in your first post.

At any rate, you can use a DFSORT/ICETOOL job like the following for your new requirement:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=...  input file
//CTL2CNTL DD DSN=&&C2,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file
//TOOLIN DD *
COPY FROM(IN1) USING(CTL1)
COPY FROM(IN1) USING(CTL2)
COPY JKFROM USING(CTL3)
/*
//CTL1CNTL DD *
  OPTION STOPAFT=1
  OUTFIL FNAMES=CTL2CNTL,BUILD=(C' OPTION STOPAFT=1',80:X,/,
   C' OUTFIL FNAMES=T2,REPEAT=',
    (12,5,ZD,SUB,7,5,ZD),ADD,+1,TO=ZD,LENGTH=5,
   C',BUILD=(SEQNUM,5,ZD,START=',
    7,5,C')')
/*
//CTL3CNTL DD *
  JOINKEYS F1=IN1,FIELDS=(1,5,A),SORTED
  JOINKEYS F2=T2,FIELDS=(1,5,A),SORTED
  JOIN UNPAIRED,F2,ONLY
  OPTION COPY
  OUTFIL FNAMES=OUT
/*
//JNF1CNTL DD *
  OMIT COND=(1,1,SS,EQ,C'HT')
/*

Re: Finding missing sequential number

PostPosted: Fri Dec 30, 2011 1:43 am
by profondo
Thanks again, Frank. I keep forgetting how powerful building control cards on the fly can be...