View previous topic :: View next topic
|
Author |
Message |
karthikuma
New User
Joined: 29 Mar 2005 Posts: 62
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
karthikuma
New User
Joined: 29 Mar 2005 Posts: 62
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
|