IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Comp & file access doubts


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kalaignar_S
Warnings : 1

New User


Joined: 06 Jan 2006
Posts: 21

PostPosted: Mon Apr 24, 2006 10:42 am
Reply with quote

1. how to view comp values in cobol
2. I have two sequential files (transaction & master), both have a common field called emp-no.

my requirement - Read transaction file and search whether trans-emp-no is available in master file. if available then update master file with transaction data else write a new record in the master file.


Thanks
Kalaignar
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Mon Apr 24, 2006 6:36 pm
Reply with quote

Quote:
1. how to view comp values in cobol

Move them to corresponding Normal Variables and DISPLAY accordingly.

Quote:
2. I have two sequential files (transaction & master), both have a common field called emp-no.

my requirement - Read transaction file and search whether trans-emp-no is available in master file. if available then update master file with transaction data else write a new record in the master file.

So what is the problem...

Regards,
Priyesh.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Apr 27, 2006 1:02 am
Reply with quote

kalaignar_S,

This is a very simple two file compare.

Step 1. Both master and transaction file must be sorted in Emp-No order.

Step 2. Two file compare. (pseudo code)

Code:


    OPEN INPUT  MASTER-FILE
                TRANSACTION-FILE
         OUTPUT MEW-MASTER-FILE

    READ MASTER-FILE AT END MOVE HIGH-VALUES TO MASTER-EMP-NO
    READ TRANSACTION-FILE AT END MOVE HIGHT-VALUES TO TRANS-EMP-NO.

    PERFORM
      UNTIL MASTER-FILE-EOF
      AND   TRANSACTION-FILE-EOF
        IF MASTER-EMP-NO = TRANS-EMP-NO
            UPDATE MASTER-RECORD FROM TRANSACTION-RERCORD
            WRITE NEW-MASTER-RECORD FROM MASTER-RECORD
            READ MASTER-FILE AT END MOVE HIGH-VALUES TO MASTER-EMP-NO
            READ TRANSACTION-FILE AT END MOVE HIGHT-VALUES TO TRANS-EMP-NO
        ELSE
            IF MASTER-EMP-NO > TRANS-EMP-NO
                WRITE NEW-MASTER-RECORD FROM TRANSACTION-RECORD
                READ TRANSACTION-FILE AT END MOVE HIGHT-VALUES TO TRANS-EMP-NO
            ELSE
                WRITE NEW-MASTER-RECORD FROM MASTER-RECORD
                READ MASTER-FILE AT END MOVE HIGH-VALUES TO MASTER-EMP-NO
            END-IF
        END-IF
    END-PERFORM

    CLOSE MASTER-FILE
          TRANSACTION-FILE
          NEW-TRANSACTION-FILE



Dave,
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top