I have the requirement to compare the two files and pick up
the matching records.
File 1. file2

23 32
32 13
34 15
35 36
36 35
43

Get the matching records from this 2 files to out file. how
you will do this in cobol program?

Answer Posted / bala

FILE SECTION.
FD OLD-MASTER
LABEL RECORDS ARE STANDARD.
01 OLD-MASTER-REC.
05 M-ACCT-NO PIC X(5).
05 AMOUNT-DUE PIC 9(4)V99.
05 PIC X(89).
FD TRANS-FILE
LABEL RECORDS ARE STANDARD.
01 TRANS-REC.
05 T-ACCT-NO PIC X(5).
05 AMT-TRANS-IN-CURRENT-PER PIC 9(4)V99.
05 PIC X(89).
FD NEW-MASTER
LABEL RECORDS ARE STANDARD.
01 NEW-MASTER-REC.
05 ACCT-NO-OUT PIC X(5).
05 AMOUNT-DUE-OUT PIC 9(4)V99.
05 PIC X(89).
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
100-MAIN-MODULE.
PERFORM 800-INITIALIZATION-RTN.
PERFORM 600-READ-MASTER.
PERFORM 700-READ-TRANS.
PERFORM 200-COMP-RTN
UNTIL M-ACCT-NO = HIGH-VALUES
AND
T-ACCT-NO = HIGH-VALUES
PERFORM 900-END-OF-JOB-RTN.
STOP RUN.
200-COMP-RTN.
EVALUATE TRUE
WHEN T-ACCT-NO = M-ACCT-NO
PERFORM 300-REGULAR-UPDATE
WHEN T-ACCT-NO < M-ACCT-NO
PERFORM 400-NEW-ACCOUNT
WHEN OTHER
PERFORM 500-NO-UPDATE
END-EVALUATE.
300-REGULAR-UPDATE.
MOVE OLD-MASTER-REC TO NEW-MASTER-REC
COMPUTE AMOUNT-DUE-OUT = AMT-TRANS-IN-CURRENT-PER
+ AMOUNT-DUE
WRITE NEW-MASTER-REC
PERFORM 600-READ-MASTER
PERFORM 700-READ-TRANS.
400-NEW-ACCOUNT.
MOVE SPACES TO NEW-MASTER-REC.
MOVE T-ACCT-NO TO ACCT-NO-OUT.
MOVE AMT-TRANS-IN-CURRENT-PER TO AMOUNT-DUE-OUT.
WRITE NEW-MASTER-REC.
PERFORM 700-READ-TRANS.
500-NO-UPDATE.
WRITE NEW-MASTER-REC FROM OLD-MASTER-REC.
PERFORM 600-READ-MASTER.
600-READ-MASTER.
READ OLD-MASTER
AT END
MOVE HIGH-VALUES TO M-ACCT-NO
END-READ.
700-READ-TRANS.
READ TRANS-FILE
AT END
MOVE HIGH-VALUES TO T-ACCT-NO
END-READ.
800-INITIALIZATION-RTN.
OPEN INPUT OLD-MASTER
TRANS-FILE.
OPEN OUTPUT NEW-MASTER.
900-END-OF-JOB-RTN.
CLOSE OLD-MASTER
TRANS-FILE
NEW-MASTER.

Hope this is useful.

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we change the password using ALTER? anyone tried and changed?

1542


What is the difference between comp and comp-3?

694


Why do we code s9 (4) comp. Inspite of knowing comp-3 will occupy less space?

706


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?

1228


Differentiate between structured cobol programming and object-oriented cobol programming.

663






In which area will you utilize 88 level items in cobol?

716


System Testing for Mainframe Developers What is System Testing? integration testing ? what's the procedure ..

1586


how do you reference the rrds file formats from cobol programs

792


How can we find that module can be called – whether DYNAMICALLY or STATICALLY?

708


Write the code implementing the perform … varying.

639


i have 10 names in an array and my name is one of them also array is not in sorted order i need to display my name using index how will i do this

992


Which division and paragraphs are mandatory for a COBOL program?

707


if we display var1 then what will b displayed in below condition. 77 var1 pic s9(2) value -10. 77 var1 pic s9(2) value -11. " " " -12. " " " -13. -14 ... ... -19.

5673


Write a program to enter and display the names of students in a class using the occurs clause.

647


I have program P1 which calls file F1 which has 100 records and following structure 001 .................. 002 .................. 003 .................. 098 .................... 099 ................... 100 .................... Now I want to read these files and write these records in file F2 in following manner. 001 ...... 051 ..... 002 ...... 052 ..... 003 ...... 053 ..... .......... ....... .......... ....... .......... ....... 048 ........ 098 ...... 049 .......... 099 ....... 050 .... 100 ......

10577