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

Error in evaluate statement with Next sentence


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

New User


Joined: 15 Aug 2005
Posts: 62

PostPosted: Tue Feb 14, 2006 2:43 pm
Reply with quote

Hi All,


can u please help me out ... i am getting error in the following evaluate statement on NEXT SENTENCE ..

EVALUATE TRUE

WHEN SQLCODE = 00

NEXT SENTENCE

WHEN OTHER

<do error routine?>

END-EVALAUTE.



thanks in advance
Balaji
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Tue Feb 14, 2006 2:48 pm
Reply with quote

It would be helpfull if you can give us the exact error message. Thanks. :-)

O.
Back to top
View user's profile Send private message
sbalajibe

New User


Joined: 15 Aug 2005
Posts: 62

PostPosted: Tue Feb 14, 2006 2:49 pm
Reply with quote

Hi Ofer71 ,
i am getting error like

?The "NEXT SENTENCE" phrase was invalid in this context


thanks
Balaji
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Tue Feb 14, 2006 4:14 pm
Reply with quote

As far as I know (and I'm not a COBOL expert) - The NEXT SENTENCE clause is part of the SEARCH and IF statements only.

O.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Tue Feb 14, 2006 10:30 pm
Reply with quote

Code "CONTINUE" in place of "NEXT SENTENCE"... that will solve your problem...

Regards,

Priyesh.
Back to top
View user's profile Send private message
lordholnapult
Currently Banned

New User


Joined: 01 Feb 2006
Posts: 5
Location: Italy

PostPosted: Sun Feb 19, 2006 7:04 am
Reply with quote

I think NEXT SENTENCE was a cobol '86 code version of the CONTINUE code command, created in COBOL 2.
or am I Wrong ?

icon_wink.gif
Back to top
View user's profile Send private message
cevelavl

New User


Joined: 20 Feb 2006
Posts: 4

PostPosted: Mon Feb 20, 2006 4:36 pm
Reply with quote

1) Clause NEXT SENTENCE is valid only in IF and SEARCH statements.
2) Non-conditional statement CONTINUE from ANSI Cobol 85 is possible everywhere.
3) So it can be in EVALUATE statement and in other conditional statements inclusive IF and SEARCH too.
Back to top
View user's profile Send private message
DARAPRADEEP

New User


Joined: 13 Apr 2005
Posts: 7

PostPosted: Tue Feb 21, 2006 10:05 am
Reply with quote

hi,
you can code like this

EVALUATE TRUE

WHEN SQLCODE not = 00

<do error routine?>
WHEN OTHER

CONTINUE

END-EVALUATE.

I think if the condetions are one or two use IF is better.

thanks,
pradeep.
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Tue Feb 21, 2006 11:36 am
Reply with quote

Hi frnds,

Let me add this point to your discussion.

CONTINUE is a replacement of NEXT SENTENCE in COBOL-II. As older one NEXT SENTENCE doesn?t understands key worlds like END-IF, END-SEARCH, END-STRING, etc which are used to terminate a sentence. In Cobol-I only way to terminate a sentence was '.' .

Now coming to why EVALUATE doesn?t supports NEXT SENTENCE? Reason is -- the EVALUATE statement was introduced with COBOL-II.

Using NEXT SENTENCE in place of CONTINUE can be dangerous if you are using COBOL-II.

I have not tried explaining everything...but I hope it will help you guys.

Correction's always welcome.
Back to top
View user's profile Send private message
small_world

New User


Joined: 22 Jul 2005
Posts: 24
Location: pune

PostPosted: Tue Feb 21, 2006 12:36 pm
Reply with quote

COBOL II introduced the CONTINUE verb, which means "do nothing."
But wait a minute -- isn't that what NEXT SENTENCE means?

No, not quite. NEXT SENTENCE is actually an unconditional branch to whatever follows the next period. In effect, it is a restricted form of GO TO.

Consider the following fragment:

[ warning: bad code ahead ]

IF NOT INPUT-EOF
IF INPUT-REC-TYPE = '55'
PERFORM 2100-PROCESS-WTN
ELSE
NEXT SENTENCE
END-IF
ADD +1 TO INPUT-COUNT.


Quick, now: when INPUT-REC-TYPE is '00', what happens to INPUT-COUNT? Answer: nothing. NEXT SENTENCE branches around the ADD statement.
If you're used to thinking of NEXT SENTENCE as "do nothing," this result may come as a surprise. Before COBOL II, we not only didn't have CONTINUE, we also didn't have END-IF, or any of its kindred. The kind of situation shown above didn't arise.

With COBOL II and its successors, however, these situations can arise. Our old reflexes are no longer reliable.

Conclusions
Do not code NEXT SENTENCE. Ever.
If you really mean "do nothing," code CONTINUE.

If you really mean "branch to the next sentence," code a GO TO, or otherwise rearrange the code. If you insist on a GO TO, code it explicitly -- don't disguise it.

icon_wink.gif
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 Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Getting Error while trying to establi... DB2 3
Search our Forums:

Back to Top