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
 

 

Problem in IF loop

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Problem in IF loop
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    Post subject: Hi
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    Post subject: Re: Problem in IF loop
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    Post subject: Re: Problem in IF loop
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    Post subject:
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    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 SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm
No new posts save SAY var loop. italo_pm CLIST & REXX 3 Sun Sep 04, 2016 3:06 am


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