View previous topic :: View next topic
|
Author |
Message |
Bharanidharan
New User
Joined: 20 Jun 2005 Posts: 86 Location: Chennai, India
|
|
|
|
I have an issue with the following piece of code inside IF loop.
Code: |
SELECT RIP-INPUT
ASSIGN TO RIPIN
FILE STATUS IS RIP-STATUS.
05 RIP-STATUS PIC 9(02).
88 END-OF-RIP VALUE 10.
88 IO-ERROR VALUE 30.
88 OPEN-ERROR VALUE 92.
IF RECORD-FLAG1 IS EQUAL TO '1'
READ RIP-INPUT AT END SET END-OF-RIP TO TRUE
IF END-OF-RIP
GO TO S5000-EXIT
END-IF
GO TO S5000-BUILD-REC
END-IF.
|
After READ takes place, "IF END-OF-RIP" comparison is not performed; control goes to the statement after the outer END-IF. I discovered this by inserting DISPLAYs before and after READ.
But the following code, which is not bounded within any IF loops, works:
Code: |
READ RIP-INPUT AT END SET END-OF-RIP TO TRUE.
IF END-OF-RIP
GO TO S5000-EXIT
END-IF.
|
I guess there is some problem in executing AT END because I am overwriting the RIP-STATUS, which is also the file status for the input file, but I am not sure.
Can anyone explain this phenomenon? |
|
Back to top |
|
|
Hanfur
Active User
Joined: 21 Jun 2006 Posts: 104
|
|
|
|
Bharani,
In second code frag a period follows the READ statement where in the first doesnt have.
Try putting a Period just after to READ in the first code.
-Han |
|
Back to top |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
hi,
Keeping a period at the end of the READ in the first code may not help.
It eventually terminates the scope of the If condition and gives an compilation errors.
Bharani,
What exactly the logic should be in the condition??
Is it as..
IF RECORD-FLAG1 IS EQUAL TO '1'
READ RIP-INPUT
AT END
SET END-OF-RIP TO TRUE
END-READ
IF END-OF-RIP
GO TO S5000-EXIT
END-IF
GO TO S5000-BUILD-REC
END-IF.
Here the exact flow...when the cond IF END-OF-RIP is not clear.
~Vamsi |
|
Back to top |
|
|
Bharanidharan
New User
Joined: 20 Jun 2005 Posts: 86 Location: Chennai, India
|
|
|
|
You are amazing. Thanks so much for the quick reponses. This is exactly what I want. I didn't know how to terminate READ explicitly. I am not a flamboyant COBOL programmer, since I work in assembler all the time.
Thanks again. |
|
Back to top |
|
|
calspach
New User
Joined: 05 May 2006 Posts: 32 Location: USA
|
|
|
|
If you like the end- terminators, there is a also and end-read.
Just to keep things standard. |
|
Back to top |
|
|
|