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

What is the difference between Structured COBOL Programming and Object Oriented COBOL programming?

662


How to get the last record in vsam file in cluster? And how can you get the ksds file records into cobol program?

687


Our issue is there seems to be a disconnect, or no link, between our SELECT statement and our SD. We had SELECT SORT-FILE and SELECT SORT-FILE ASSIGN TO SORTWRK. ASSIGN TO SORTWRK1 SORTWRK2 SORTWRK3 SORTWRK4. with SD SORT_FILE RECORD CONTAINS 7833 CHARACTERS. In either case, at run time, the system ignored our SORTWRK# DD statements and allocated 16 sort works with the SORTWK## naming convention. Any ideas why the system does not recognize the connection? We do not even need the SORTWRK DD statements. Thanks

2312


In COBOL programming, what is PERFORM? What is VARYING?

659


What is length is cobol?

633






How arrays can be defined in COBOL?

649


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

656


How to get the last record in vsam file in cluster? And how can you get the ksds file records into your cobol program?

635


how do you reference the esds vsam file formats from cobol programs

616


Explain how you can characterize tables in cobol?

627


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

692


Why is it necessary that file needs to be opened in I-O mode for REWRITE?

725


how do you reference the printer file formats from cobol programs

639


Write a program that uses move corresponding.

658


what happens if parmparameter passes zero bytes to the program

1648