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

Compare the records from two files and write it to 3rd File


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

New User


Joined: 29 Mar 2005
Posts: 62

PostPosted: Mon Jun 20, 2005 9:46 am
Reply with quote

Hi,

plz give me the solutions for this interview questions.


i'm having two files
(this is an sequential file)having two files file-1 and file-2 and need an result which is shown in the o'p file.write the cobol program for this .plz any one give me the full syntax for this questions.

file-1 file-2 0/p

0001 0004 0002
0002 0002 0003
0003 0006
0004 0003
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 Jun 20, 2005 9:51 am
Reply with quote

You have 3 common records in both the files.....but you want two of them in output file....Is there any specific need for your output....If yes, please mention.

Or you skipped 0004 of FILE1 from output because it lies before 0002 & 0003 in FILE2....Is it like that.....Please make it clear....

Regards,

Priyesh.
Back to top
View user's profile Send private message
karthikuma

New User


Joined: 29 Mar 2005
Posts: 62

PostPosted: Mon Jun 20, 2005 9:55 am
Reply with quote

Hi,

No friend just you write an cobol program for this.i nee dan o/p as shown above.i need an algorith for this program.how to do this.

regards,
kumar
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 Jun 20, 2005 11:24 am
Reply with quote

Hi karthikuma,

Quote:
i need an algorith for this program


There should be a logic before writing any algorithm....I mean to say, you need to be clear on what basis you want to process data.....Still, If you are sure about your input & output structure....You can use below code.... It'll give you desired output....

I assumed requirement for this code as below....

Quote:
Write rec from FILE1 which are there in FILE2, but in FILE2 If they are before their predeccessor of FILE1, SKIP Them.


Code:
OPEN all the THREE Files & INITIALIZE STRUCTURE.   

PERFORM PROCESSING                 
   THRU PROC-EXIT UNTIL END-INFILE-YES.

STOP RUN.

PROCESSING
MOVE ZEROES TO COUNTER.                       
CLOSE ITEM-WSFILE.                             
READ INFILE INTO WS-IN-REC               
            AT END SET END-INFILE-YES TO TRUE 
                    GO TO P2000-EXIT           
END-READ.                                     
                                             
OPEN INPUT WSFILE.                       
SET END-WSFILE-NO TO TRUE.                     
PERFORM MATCH THRU MATCH-EXIT                 
             UNTIL END-WSFILE-YES.             
PROC-EXIT.

MATCH
READ WSFILE INTO WS-REC                   
            AT END SET END-WSFILE-YES TO TRUE     
                    GO TO MATCH-EXIT             
END-READ.                                         
                   
ADD 1 TO COUNTER.                                 
IF COUNTER <= WS-COUNTER                         
    GO TO MATCH-EXIT.                             
                                                 
IF IN-REC = WS-REC                         
   MOVE COUNTER TO WS-COUNTER                     
   MOVE IN-REC TO OUT-REC                   
   DISPLAY 'RECORD WRITTEN : ' OUT-REC         
    WRITE ITEM-OUTREC FROM WS-OUT-REC.
    MOVE SPACES TO WS-OUT-REC.       
   MOVE SPACES TO WS-WS-REC. 
   GO TO PROC-EXIT                               
   CLOSE WSFILE                             
END-IF.                                           
MATCH-EXIT.


Let me know, If any doubt on this.

Regards,

Priyesh.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Jun 23, 2005 5:41 am
Reply with quote

Come on, Karthi. You have to give this a try on your own. Show us what you've done in trying to solve it.

Getting the ans to interview ques will not make you a pgmr, but expending the effort on your own to solve problems will.

You may not solve the problem, but the effort you invest WILL make you a pgmr.

We're here to help, not to do the work for you.
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 1
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