Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Compare the records from two files and write it to 3rd File
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: 1452
Location: Chicago, IL

PostPosted: Mon Jun 20, 2005 9:51 am    Post subject: Re: vscobol 11
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    Post subject: Re: vscobol 11
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: 1452
Location: Chicago, IL

PostPosted: Mon Jun 20, 2005 11:24 am    Post subject: Re: vscobol 11
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 4 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us