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
 

 

Am getting Error in IF Statement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
arunmozhicholan

New User


Joined: 07 Feb 2007
Posts: 27
Location: chennai

PostPosted: Tue Apr 03, 2012 4:06 pm    Post subject: Am getting Error in IF Statement
Reply with quote

Code:
If ((S-DATE1   =  WS-START-DATE1         AND         
     WS-S-TIME <  WS-START-TIME(IDX))    OR           
    (S-DATE1   =  WS-END-DATE1           AND         
     WS-S-TIME >  WS-END-TIME(IDX))      OR           
    (S-DATE1   <  WS-START-DATE1         OR           
     S-DATE1   >  WS-END-DATE1)          OR           
    (S-DATE1   >  WS-START-DATE1         AND         
     S-DATE1  <> WS-END-DATE1)           OR           
    (S-DATE1  <> WS-START-DATE1         AND           
     S-DATE1   <  WS-END-DATE1))             


A literal or an expression was expected following a relational operator, but '>' was found , th if statement was discarded.

Please help me to get this done
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Apr 03, 2012 4:18 pm    Post subject: Re: Am getting Error in IF Statement
Reply with quote

Please use the Code tags.

Where did you find "<>" in the Enterprise Cobol manual?
Back to top
View user's profile Send private message
arunmozhicholan

New User


Joined: 07 Feb 2007
Posts: 27
Location: chennai

PostPosted: Tue Apr 03, 2012 4:40 pm    Post subject: Reply to: Am getting Error in IF Statement
Reply with quote

Need to use not equal to ...?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Apr 03, 2012 5:03 pm    Post subject: Reply to: Am getting Error in IF Statement
Reply with quote

Well, yes.

You have yourself an unreadable IF as well. You need to do some work to improve it.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Tue Apr 03, 2012 5:22 pm    Post subject:
Reply with quote

Are there no other COBOL programs at your company to review?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Apr 03, 2012 6:04 pm    Post subject: Reply to: Am getting Error in IF Statement
Reply with quote

Years ago, when I did code review, I would hand this back to you and have you redo it.

There were times that in order to understand similar code, I'd have to generate the Assembler expansion, which occasionally ended in multiple right parenthesis. icon_eek.gif

You need to think of the next person who may need to do maintenance on this spaghetti salad. icon_rolleyes.gif

What about EVALUATE or nested IF's?

Software Engineer's shouldn't be writing crap like this....
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Apr 03, 2012 6:51 pm    Post subject:
Reply with quote

Code:
.
.
.
S-DATE1 <> WS-END-DATE1) OR
.
That's not how you use "NOT EQUAL TO" in COBOL. For COBOL it's
Code:
IF A NOT EQUAL B THEN
.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Apr 03, 2012 6:52 pm    Post subject: Reply to: Am getting Error in IF Statement
Reply with quote

Code:
           IF (
                (
                    ( S-DATE1   EQUAL TO  WS-START-DATE1 )
                AND ( WS-S-TIME LESS THAN WS-START-TIME ( IDX ) )
                )
           OR   (
                    ( S-DATE1   EQUAL TO     WS-END-DATE1 )
                AND ( WS-S-TIME GREATER THAN WS-END-TIME ( IDX ) )
                )
           OR   (
                    ( S-DATE1   LESS THAN    WS-START-DATE1 )
                OR  ( S-DATE1   GREATER THAN WS-END-DATE1 )
                )
           OR   (
                    ( S-DATE1   GREATER THAN WS-START-DATE1 )
                AND ( S-DATE1   NOT EQUAL TO WS-END-DATE1 )
                )
           OR   (
                     ( S-DATE1  NOT EQUAL TO WS-START-DATE1 )
                AND  ( S-DATE1  LESS THAN    WS-END-DATE1 )
                )
              )


Even after "tarting it up" it is still very clumsy. Take some of Mr Bill's good advice.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Apr 03, 2012 7:00 pm    Post subject:
Reply with quote

Kept the thread open longer than anticiapted and missed the excellent suggestion from Bill O'Boyle. Read his post and try to implement.
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Tue Apr 03, 2012 7:00 pm    Post subject:
Reply with quote

Been coding several decades. My weakest skill is working with date checking statements just like this one. I think they cause more confusion than any other type of condition checking.

I will spend two hours breaking them into nested IFs or Evaluate statements. usually when I'm done, I find that there is a much smaller way to do it. It's like factoring a large equation, then letting things cancel out.
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 S922 Error yuvan ABENDS & Debugging 3 Fri Dec 02, 2016 6:58 pm
No new posts Invoke Webservice Fails with DFHPI100... divated CICS 2 Thu Nov 24, 2016 5:57 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts Error during restore rename archanamuthukrishnan All Other Mainframe Topics 2 Fri Oct 14, 2016 3:30 pm
No new posts Error IEC161I 052(009,XXXRS00)-084 wh... amitc23 JCL & VSAM 10 Wed Oct 12, 2016 5:00 pm


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