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 see junk values in dclgen or in hostvariable of comp ?
i need a small 3d program using inline and outline.
How to remove 2 duplicate records and copy only one using job control language?
What is comp-1 and comp-2?
I have a program with an Array of 5000 occurences which is being passed from 5 sub levels to the front end screen. Thess 5 programs using each 5*2 = 10 different arrays with size as 5000. This is causing the transaction to utilize more storage consupmtion. I am looking to reduce the storage consumption. As part of that initially i thought Dynamic array may solve my problem. After viewing the comments given i see its same as normal array. IS there any other way we can resolve this issue?
Differentiate between structured cobol programming and object-oriented cobol programming.
How can we find that module can be called – whether DYNAMICALLY or STATICALLY?
Are you comfortable in cobol or jcl?
Which mode is used to operate the sequential file?
Explain how you can characterize tables in cobol?
How to change size of Initial number of records to *NOMAX for ALL PF files from perticular library, how can I do that
What is rmode(24)
How many sections are there in data division in COBOL?
2 input fles: 2 flat files, with different number of records. both are having unique key for each record and already sorted in ascending order . match these files using unique key and in output only matching key value has to be written. please procide cobol logic
Whats the difference between search & search ALL?