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
What are the pertinent COBOL commands?
System Testing for Mainframe Developers What is System Testing? integration testing ? what's the procedure ..
input 1 input2 ouput1 output2 output 3 1 re 300 1 re 200 1 re 300 3 rc 500 1 re 200 2 rr 400 1 re 300 2 rr 400 1 rc 400 3 rc 500 1 rc 400 2 rr 700 2 rr 700 5 tt 900 5 tt 900 2 inputs r in flat file and output 1 is matched records,ouptput2 is unmatched of input1,output3 is unmatched of input2! how vl u get the output files using sequential order and to check with each and every records! let me know the procedure division ?
What is a report item?
how do you define single dimensional array and multidimensional array in your cobol?
What are the various section in data division and briefly explain them.
How can you get the ksds file records into your cobol program?
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 rules are to be followed while using the corresponding options?
What is a scope terminator give example?
Write down the divisions of cobol program?
Explain about different table spaces.
How to traceback if I am getting SOC7 or SOC4 abend? List down the steps
Explain how will you differentiate between an internal and an external sort, the pros and cons, internal sort syntax etc
What is the difference between structured cobol programming and object alternativelyiented cobol?