Taking your suggestions, this is my latest version of the program. (Boss doesn’t want two programs, so I’m assuming an external sort wouldn’t be an option for me.)
01 VENDOR VIEW OF VENDOR
02 VENDOR-NUM(A13)
02 REDEFINE VENDOR-NUM
03 FILLER 1X
03 #TIN(A9)
02 NAME(A31)
02 DTUSED-2K(D)
02 VNDR-ENTR-IND(A1)
*
01 #HOLD (999)
02 #HOLD-NAME(A31)
02 #HOLD-TIN(A9)
02 VENDOR-NUM(A13)
02 NAME(A31)
02 DTUSED-2K(D)
02 VNDR-ENTR-IND(A1)
*
01 #NAME(A31)
*
01 #I(N3)
01 #N(N3)
END-DEFINE
*
READ MULTI-FETCH 10 DVSF01 PHYSICAL
MOVE VENDOR.NAME TO #NAME
EXAMINE #NAME FOR ' ' DELETE
EXAMINE #NAME FOR ',' DELETE
EXAMINE #NAME FOR '.' DELETE
END-ALL
AND
SORT BY #NAME VENDOR.VENDOR-NUM USING VENDOR.NAME #TIN
VENDOR.VNDR-ENTR-IND VENDOR.DTUSED-2K
*
AT TOP OF PAGE (1)
WRITE (1)
'DUPLICATE NAMES ON VENDOR FILE'
121T 'PAGE' *PAGE-NUMBER (1) //
'VENDOR NUMBER' 27T 'VENDOR NAME' 65T 'VENDOR ENTER INDICATOR'
104T 'LAST DATE USED' /
'-'(16) 26T '-'(31) 63T '-'(26) 104T '-'(15) //
END-TOPPAGE
*
IF #NAME NE #HOLD-NAME(1)
IF #I > 1
FOR #N 1 #I
WRITE (1) #HOLD.VENDOR-NUM(#N) 26T #HOLD.NAME(#N) 74T
#HOLD.VNDR-ENTR-IND(#N) 106T
#HOLD.DTUSED-2K(#N)(EM=MM/DD/YYYY) /
END-FOR
SKIP (1) 1
END-IF
RESET #HOLD(*)
MOVE #NAME TO #HOLD-NAME(1)
MOVE #TIN TO #HOLD-TIN(1)
MOVE VENDOR.VENDOR-NUM TO #HOLD.VENDOR-NUM(1)
MOVE VENDOR.NAME TO #HOLD.NAME(1)
MOVE VENDOR.VNDR-ENTR-IND TO #HOLD.VNDR-ENTR-IND(1)
MOVE VENDOR.DTUSED-2K TO #HOLD.DTUSED-2K(1)
MOVE 1 TO #I
ESCAPE TOP
END-IF
IF #TIN = #HOLD-TIN(1) OR (#I >= 1 AND #TIN = #HOLD-TIN(#I))
ESCAPE TOP
END-IF
ADD 1 TO #I
MOVE #NAME TO #HOLD-NAME(#I)
MOVE #TIN TO #HOLD-TIN(#I)
MOVE VENDOR.VENDOR-NUM TO #HOLD.VENDOR-NUM(#I)
MOVE VENDOR.NAME TO #HOLD.NAME(#I)
MOVE VENDOR.VNDR-ENTR-IND TO #HOLD.VNDR-ENTR-IND(#I)
MOVE VENDOR.DTUSED-2K TO #HOLD.DTUSED-2K(#I)
*
END-SORT
END