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

Problem in IF loop


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

New User


Joined: 20 Jun 2005
Posts: 86
Location: Chennai, India

PostPosted: Wed Jul 19, 2006 12:58 pm
Reply with quote

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
View user's profile Send private message
Hanfur

Active User


Joined: 21 Jun 2006
Posts: 104

PostPosted: Wed Jul 19, 2006 1:13 pm
Reply with quote

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
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Wed Jul 19, 2006 2:17 pm
Reply with quote

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
View user's profile Send private message
Bharanidharan

New User


Joined: 20 Jun 2005
Posts: 86
Location: Chennai, India

PostPosted: Wed Jul 19, 2006 2:49 pm
Reply with quote

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
View user's profile Send private message
calspach

New User


Joined: 05 May 2006
Posts: 32
Location: USA

PostPosted: Wed Jul 19, 2006 6:37 pm
Reply with quote

If you like the end- terminators, there is a also and end-read.

Just to keep things standard.
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
This topic is locked: you cannot edit posts or make replies. REXX - Do - Not able to LOOP CLIST & REXX 10
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
Search our Forums:

Back to Top