I want to remove a duplicates form a given input field using cobol program. please Any one help me out to solve this ... Thanks in Advance.

Answers were Sorted based on User's Feedback



I want to remove a duplicates form a given input field using cobol program. please Any one help me o..

Answer / meghraj hulawale

Procedure Division.
1.Open vsam file as INPUT mode.
2. Copy the records of VSAM FILE into Table or Array by using occurs clause.
3.Count no. of records in VSAM FILE.
4.By using perform statement.
e.g
perform until I < vsam-cnt
read vsam file
perform until j < no-of-records in table or vsam-cnt
if vsam-data NOT =Table-record
A. Open another Output file as OUTPUT mode.
B. Write output file.
end-if.
increase the value of j as 1.
end-perform.
increase the value I as 1.
end-perform.
Stop run.

******Note
We need to access vsam as sequential.

Is This Answer Correct ?    2 Yes 0 No

I want to remove a duplicates form a given input field using cobol program. please Any one help me o..

Answer / ak

1.copy the file into array
2.read the file entil eof
3.if file-key equals to ws-arry-key(Count)
move ws-arry-key(count) to ws-dup-rec(for duplicate values)
else continue
write ws-arry-key

Is This Answer Correct ?    0 Yes 0 No

I want to remove a duplicates form a given input field using cobol program. please Any one help me o..

Answer / naveenkumar m

As few answered for VSAM file dedup, I will explain for PS flat files,

1) Make sure your file is sorted either Ascending or descending using SORT.

2)FIRST-READ PARA
READ INPUT-FILE INTO WS-ARRAY()
UNTIL EOF
ARRAY-COUNT=ARRAY-COUNT + 1

3)PERFORM COMPARE-PARA VARYING I FROM 1 BY 1 UNTIL I < ARRAY-COUNT
IF WS-ARRAY(I)=WS-ARRAY(I+1) THEN
WRITE DUPLICATE-RECORDS
ELSE
WRITE NODUPLICATE-RECORDS
END-PERFORM

=====================================
I just given algorithm not exact code....

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More COBOL Interview Questions

How can you get the ksds file records into your cobol program?

0 Answers  


I have one ps file in which there are 3 fileds emp_no,emp_name and leave_app.this ps file information give the detail of employee which is going to apply for leave.suppose emp_no=113430,emp_name=ajay,leave_app=1 that means he is going to apply for 1 day leave.and accordingling the table in db2 will be updated means if he has that no of leave in his account then he will get dat leave and updated acc. in table(leave_balance=previous leave present in table-leave_app).Now i want to check whther the updated result is correct or not by comparing the two ps file using IEBCOMPARE or icetool so what is going to be the two ps file and how its is going to be compare.

0 Answers   Cap Gemini,


IDENTIFICATION DIVISION. PROGRAM-ID. MOVEPGM. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-I PIC 9(2). PROCEDURE DIVISION. A1000-MAIN-PARA. PERFORM PARA-X WITH TEST BEFORE UNTIL WS-I= 5 STOP RUN. PARA-X. DISPLAY "BEST2". I m getting error s722,while executing the program, seems getting in loop, can anybody tell me why

3 Answers  


can internal sort be applied to sort ksds files?

1 Answers  


What the difference is between continue and next sentence?

0 Answers  






When we code these comp,comp1,comp-2,comp-3 and comp4 values. I know the differnece.I mean when we will prefer if it is new program.Explain in detail with memory examples. Thanks in advance.

1 Answers   CTS,


What care has to be taken to force program to execute above 16 Meg line?

1 Answers  


how do you define single dimensional array and multidimensional array in your cobol?

0 Answers  


What is the Purpose of POINTER Phrase in STRING command in COBOL?

0 Answers   Winsol Solutions,


can we display comp-3 variables. if we want to display what we have to do . give me one example

6 Answers   CGI, Deloitte,


what happens if we dont close cursor in db2-cobol pgm?

6 Answers  


How will 128 be saved in s9 (3) comp-3 How will 12 be saved in s9 (2) comp

3 Answers   CTS,


Categories