to delete selected number of records in a big file useing jcl sort cards

4.2k Views Asked by At

I want to delete 501 records based on 5 character activity code from the test file with 38,792 records.

As there are 501 record I can't write a omit condition.

I need to use sort join card but my prombelem is this 5 charcter activity code is starting from 46th column for some records and 47th column for others.

So what can I do?

1

There are 1 best solutions below

0
On

The question is unclear with many details missing, but here's something which may help another searcher:

 //SYSIN DD *

  JOINKEYS F1=INA,FIELDS=(1,5,A),SORTED,NOSEQCK
  JOINKEYS F2=INB,FIELDS=(1,5,A) 

  JOIN UNPAIRED,F1 

  REFORMAT FIELDS=(F1:1,80,?) 

  OPTION COPY 

  INREC IFTHEN=(WHEN=(81,1,CH,EQ,C'B'), 
                OVERLAY=(82:SEQNUM,9,ZD)) 

  OUTFIL OMIT=(82,9,CH,LE,C'000000501', 
              AND, 
               81,1,CH,EQ,C'B') 

//JNF2CNTL DD * 
  INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'0'), 
                BUILD=(3,5)), 
        IFTHEN=(WHEN=NONE, 
                BUILD=(2,5)) 
//INA      DD * 
11111 IN 
22222 KEEP UNMATCHED 
33333 OUT 
66666 IN 
66667 KEEP UNMATCHED 
66668 KEEP UNMATCHED 
77777 OUT 
88888 SHAKE IT ALL ABOUT 
//INB      DD * 
0X11111 
0X66666 
0X88888 
133333 
799999 
877777 

This is using two input files, INA and INB.

INA is already in sequence (so specify SORTED,NOSEQCHK on the JOINKEYS for it), and is fixed-length 80-byte records.

INB is not already in sequence, because it is a mixture of different files, all are fixed-length 80-byte records.

In JNF2CNTL, only the key from the second file is extracted, as no other data is required from that file. The key is sourced from different places depending on the record-type. The file will be sorted automatically (with OPTION EQUALS set) before the JOIN itself.

The JOIN is for matches, and unmatched records from F1 (INA).

The ? in the REFORMAT statement is the "match marker" and it will be automatically set to B (both) for a match and 1 (in this case, only one is possible due to the ONLY on the JOIN statement) for an unmatched record from F1.

Of those that match, you want to ignore the first 501. So, set up a sequence number which is only incremented for the matching records.

Then on OUTFIL, OMIT= for those matched records which have a sequence less than or equal to the 501 count.

The output on SORTOUT will be all the records from the INA file, except the first 501 which matched.