View previous topic :: View next topic |
Author |
Message |
vinush2000 Beginner
Joined: 17 Jun 2005 Posts: 15 Topics: 5
|
Posted: Mon Aug 01, 2005 12:31 am Post subject: file 1 & file 2 issue (file handling in COBOL) |
|
|
Hi All,
I have 2 seq. files (PS) file 1 and file 2.
for every record in file 1 I have to scan file 2 for a match. I write the output to different files based on the match.
now, when i tried this, I get S0000 U4038 abend. I find from sysout that problem occurs when I am reading file 2 for the second record from file 1.
The file 2 has already reached 'at end' and I want to know how to reset this for every read.
Please help ( If possible, a sample code)
thanks,
vinu |
|
Back to top |
|
|
chandresha_t Beginner
Joined: 20 Jul 2005 Posts: 2 Topics: 0
|
Posted: Mon Aug 01, 2005 2:16 am Post subject: |
|
|
vinush2000,
The easiest solution will be to close and open the file 2 for each record on file 1.
Hope this helps,
Chandresha T |
|
Back to top |
|
|
vinush2000 Beginner
Joined: 17 Jun 2005 Posts: 15 Topics: 5
|
Posted: Mon Aug 01, 2005 2:20 am Post subject: |
|
|
thanks,
but, is that a coding standard to practice?
I am afraid, its not.
vinu |
|
Back to top |
|
|
hisabarish Beginner
Joined: 21 Jun 2005 Posts: 38 Topics: 11
|
Posted: Mon Aug 01, 2005 2:29 am Post subject: |
|
|
Hi ,
How it will come to _________________ Sabari
Madras |
|
Back to top |
|
|
vinush2000 Beginner
Joined: 17 Jun 2005 Posts: 15 Topics: 5
|
Posted: Mon Aug 01, 2005 3:20 am Post subject: |
|
|
Code: |
PROCEDURE DIVISION.
DISPLAY 'MAINLINE OF TRIALPRG'
OPEN INPUT TB07-FILE
LN01-FILE
OUTPUT PAPER-FILE
TAPE-FILE
CARE-FILE
CNTL-FILE
SET NOT-END-OF-FILE TO TRUE
MOVE SPACES TO HOLD-LN01-FORMAT-IND
PERFORM READ-TB07-PARA
PERFORM UNTIL END-OF-FILE
DISPLAY 'AFTER READING TB07 '
PERFORM READ-LN01-PARA
PERFORM UNTIL END-OF-LN01-FILE
DISPLAY 'INSIDE PERFORM UNTIL'
SET NOT-END-OF-LN01-FILE TO TRUE
EVALUATE HOLD-LN01-FORMAT-IND
WHEN '01'
MOVE TB07-LEC-NAME TO HOLD-LEC-NAME
WRITE PAPER-FILE-REC FROM HOLD-REC
WHEN '02'
WHEN '03'
MOVE TB07-LEC-NAME TO HOLD-LEC-NAME
WRITE TAPE-FILE-REC FROM HOLD-REC
WHEN '04'
MOVE TB07-LEC-NAME TO HOLD-LEC-NAME
WRITE CARE-FILE-REC FROM HOLD-REC
WHEN OTHER
CONTINUE
END-EVALUATE
PERFORM READ-LN01-PARA
END-PERFORM
PERFORM READ-TB07-PARA
END-PERFORM
WRITE CNTL-FILE-REC FROM CNTL-REC
CLOSE TB07-FILE
LN01-FILE
PAPER-FILE
TAPE-FILE
CARE-FILE
CNTL-FILE
STOP RUN.
READ-TB07-PARA.
IF NOT END-OF-FILE
D DISPLAY 'INSIDE TB07 READ PARA'
READ TB07-FILE
AT END
SET END-OF-FILE TO TRUE
END-READ
END-IF.
/
READ-LN01-PARA.
D DISPLAY 'NOW READING LNO1 FILE'
READ LN01-FILE
AT END
SET END-OF-LN01-FILE TO TRUE
NOT AT END
IF LN01-LEC-ID = HOLD-LEC-CODE
MOVE LN01-FORMAT-IND TO HOLD-LN01-FORMAT-IND
END-IF
END-READ. |
Thanks all, for your response. here is my code. the abend 4038 happens when the program reads the LN01 file ( thats after fetching the second record from TB07)
please help ![/code] |
|
Back to top |
|
|
hisabarish Beginner
Joined: 21 Jun 2005 Posts: 38 Topics: 11
|
Posted: Mon Aug 01, 2005 4:44 am Post subject: |
|
|
Dear vinush2000,
Really I am not understand your code. What is your goal ie., what is your exact requirement. Pls. tell me clearly. why u r coding the evaluate statement. _________________ Sabari
Madras |
|
Back to top |
|
|
vinush2000 Beginner
Joined: 17 Jun 2005 Posts: 15 Topics: 5
|
Posted: Mon Aug 01, 2005 4:48 am Post subject: |
|
|
hi, thanks for your interest
goal
------
to scan file 2 for every file 1 entry and write some o/p (blah..) based on the match found.
evaluate
---------
to write contents (blah...) into particular file based on the INDICATOR
hope its clear now,
vinu |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
vinush2000 Beginner
Joined: 17 Jun 2005 Posts: 15 Topics: 5
|
Posted: Tue Aug 02, 2005 12:14 am Post subject: thanks |
|
|
thanks, kolusu.
what I wanted was the COBOL Soln. I got much more than that.
thanks a lot,
vinu |
|
Back to top |
|
|
|
|