-1

I have a sequential file having record length of 11. I have a field in-between starting from 9th position till 11th position and is of PIC 9(03). I want to delete all the records where I have same data in above specified location. This needs to be done using JCL only. Any utility can be used but should be supporting in microfocus cobol. See the example below:

Example File:

Rob  ,d,012
Mike ,h,013
Kim  ,g,014
Bob  ,k,014
Wiz  ,t,015

In the above example I want to delete rows for Kim and Mike as it is having same value for the location i.e. 014 and final output should be:

Rob  ,d,012
Mike ,h,013
Wiz  ,t,015
James Z
  • 12,209
  • 10
  • 24
  • 44
Naman Dubey
  • 39
  • 2
  • 2
  • 5

3 Answers3

0

Try these statements in the SYSIN DD of DFSORT utility.

SORT FIELDS=COPY
OMIT COND=(9,3,ZD,EQ,014)

Microfocus use the mfsort utility which emulates all the major functions of IBM's DFSORT product.

mfsort option copy
  use input-file [record definition]
      [org organization] [key structure]
  give output-file [record definition]
      [org organization] [key structure]
  omit cond (9,3,nu,eq,014)

More details about mfsort can be found here.

Srinivasan JV
  • 705
  • 5
  • 12
  • Thanks for suggesting the code, but it looks like it will not do exactly what I want. The value at the given location will not be fixed. The value can be anything.. I just want to delete those rows where I have duplicate values at that location. The final output should be a file where I don't have more than 1 row having same value at that particular location. – Naman Dubey Jun 01 '20 at 17:48
  • You may try ```mfsort sort fields(9,3,nu,a) sum fields=none```. This will remove the duplicate values and will retain only 1 row. – Srinivasan JV Jun 01 '20 at 17:55
0

checkout nsort from ordinal. also syncsort now precisely. these are cots utilities that can drop duplicate records.

sys101
  • 19
  • 3
0

Sort by the name, and add up the count of records by name.

Use the OUTFIL command to delete the records that had more than one record:

RECORD TYPE=F,LENGTH=11
INREC FIELDS=(1,11,C'0001')  * Include a dummy field to sum up
SORT FIELDS=(9,3,BI,A)       * Sort by the "id"
SUM FIELDS=(12,4,ZD)         * Count the number of records by "id"
OUTFIL FILES=OUT,BUILD=(1,11),OMIT=(12,4,NE,C'0001')  * Get rid of duplicated records
END

This should work on DFSORT or SYNCSORT, not sure about MFSORT.

RainMoose
  • 61
  • 4