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
I need to compare 3 variables(dates) and do some processing based on the earliest date. There could be more then 1 date record in any of the 3 fields. What is the best way to code this?
What are the various section in data division and briefly explain them.
What is a SSRANGE and NOSSRANGE?
how we sort two input files based on a common column and giving one o/p file please send me the coding logic?
What kind of error is trapped by on size error option?
Differentiate cobol and cobol-ii. (Most of our programs are written in cobolii, so, it is good to know, how, this is different from cobol)?
What is amode(24), amode(31), rmode(24) and rmode(any) (applicable to only mvsesa enterprise server) ?
What is a report item?
What are the different rules of SORT operation?
What are 77 levels used for?
Can we change the password using ALTER? anyone tried and changed?
Differentiate between structured cobol programming and object-oriented cobol programming.
IF I mention stop run in CICS what happens?
What are literals?
Write a cobol program making use of the redefine clause.