I have a File that has duplicate records. I need only those records that occur more than
thrice.?
Answer Posted / nsingh
DEFINE A TABLE
01 TABLE.
05 TABLE-A OCCURS 500 TIMES
INDEXED BY IDX
10 TEXT PIC X(100)
10 COUNT PIC9(4).
01 W-REC PIC X(100).
01 W-OUT PIC X(100).
01 SUB S9(4) COMP VALUE 0
PROCEDURE DIVISION.
INITIALIZE TABLE-A
READ-PARA.
READ F1 IN W-REC
AT END
SET IDX TO 1
PERFORM VARING SUB FROM 1 BY 1 UNTIL SUB > 500
IF COUNT(IDX) > 3
WRITE W-OUT FROM TEXT(IDX)
ELSE
SET IDX UP BY 1
END-IF
END-PERFORM
STOPRUN
NOT AT-END
CONTINUE
END-READ
SEARCH TABLE-A
AT END
PERFORM TABLE-ENTRY
WHEN W-REC = TEXT(IDX)
ADD +1 TO COUNT
END-SEARCH
GO TO READ-PARA
TABLE-ENTRY.
SET IDX TO 1
PERFORM VARYING SUB FROM 1 BY 1
UNTIL SUB > 500
IF TEXT (IDX) = SPACES
MOVE 1 TO COUNT (IDX)
MOVE W-REC TO TEXT (IDX)
ELSE
SET IDX UP BY 1
END-IF
END-PERFORM
| Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
HOw can I get the negative sign while deduct high value from low value
what is the difference between COBOL2 AND COBOL390?
Difference between array and sub-script ?
What are the different rules for performing sort operation?
State the various causes of s0c1, s0c5 and s0c7.
What is the difference between PIC 9.99 and 9v99 in COBOL?
What is the use of intialize verb?
write a cobol logic. i have file that has 10 records .1 record go to first output file and second record goes to 2 output and etc
What is the utilization of copybook in cobol? Could we utilize a similar copybook?
What is difference between static and dynamic call in cobol?
i need a small 3d program using inline and outline.
What is inspect in cobol ?
How to get the last record in vsam file in cluster? And how can you get the ksds file records into cobol program?
Can we redefine the field of x(200) to less than 200?
Explain how to differentiate call by context by comparing it to other calls?