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 is a SSRANGE and NOSSRANGE?
Difference between cobol and cobol-ii?
) How do u handle errors in BMS macro
Have you used the sort in your project?for this type of questions any working on real time project give the eg. with real time scenario.
How many sections are there in data division in COBOL?
What are all the divisions of a COBOL program?
What rules are to be followed while using the corresponding options?
How do define dynamic array in cobol. how do you define single dimensional array and multidimensional array in your cobol?
Hi pls anybody tell me about " ANALYSIS DOCUMENT PREPARATION AND ESTIMATION OF TASK " (in real time project)."I want to update a sequential file in my project" for that purpose i need both structures i mean analysis document and estimation of task.
How to get the last record in vsam file in cluster? And how can you get the ksds file records into your cobol program?
Write the code implementing the perform … varying.
how can i see junk values in dclgen or in hostvariable of comp ?
What guidelines should be followed to write a structured cobol prgm?
There are 5 fields and 1000 records in a file. Unload it into an array. Write the syntax for declaration and how will you unload it.
In which area will you utilize 88 level items in cobol?