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

Coding Synatx check in COBOL


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

New User


Joined: 26 Apr 2007
Posts: 12
Location: Mysore

PostPosted: Mon Sep 24, 2007 2:47 pm
Reply with quote

Hi,
Is it possible to exit the evaluate when the XYZ(D) = ABC(D) and avoid performing the loop until LIMIT.


Code:

PROGRAM

EVALUATE x

WHEN 1
           PERFORM D VARIYING FROM 1 BY 1 UNTIL D > LIMIT
              IF XYZ(D) = ABC(D)
                   MOVE 'Y'      TO   WS-VAR
             
              END-IF
WHEN OTHER
            MOVE 'N'      TO WS-VAR



END-EVALUATE



GOBACK.



 



CONTINUE and NEXT SENTENCE will not work as i am moving values within IF statement. If I insert EXIT command it wiil go to infinite Loop. I am working on COBOL II version.Is there anyway i can exit the perform without using the Flag as below.

Code:



 PERFORM D VARIYING FROM 1 BY 1 UNTIL D > LIMIT or FLAG
              IF XYZ(D) = ABC(D)
                   MOVE 'Y'      TO   WS-VAR
                    MOVE 'YES'   TO FLAG
              END-IF
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Mon Sep 24, 2007 2:58 pm
Reply with quote

Praveen,

After MOVE statement, why dont you recalculate the var 'D' (say LIMIT+1).
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Mon Sep 24, 2007 3:00 pm
Reply with quote

Praveen,

In addition to my prev post,

.......... when you dont need variable 'D' (original) value down the program.
Back to top
View user's profile Send private message
saptagiri kintali

New User


Joined: 21 Sep 2007
Posts: 20
Location: chennai

PostPosted: Mon Sep 24, 2007 3:26 pm
Reply with quote

and u can move '0' to limit if D contains only positive values, by this way also u can make exit
Back to top
View user's profile Send private message
saptagiri kintali

New User


Joined: 21 Sep 2007
Posts: 20
Location: chennai

PostPosted: Mon Sep 24, 2007 3:27 pm
Reply with quote

........and the best way is move low values to limit.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Mon Sep 24, 2007 3:35 pm
Reply with quote

Please check with the following code for your requirement. It is using WS-VAR to exit from the EVALUATE when the XYZ(D) = ABC(D) and avoid performing the loop until LIMIT.
Code:
EVALUATE X
 WHEN 1
  PERFORM VARIYING D FROM 1 BY 1 UNTIL D > LIMIT OR WS-VAR = 'Y'
   IF XYZ(D) = ABC(D)
    MOVE 'Y' TO WS-VAR
   END-IF
 WHEN OTHER
  MOVE 'N' TO WS-VAR
END-EVALUATE
GOBACK.
Back to top
View user's profile Send private message
blpraveen123
Currently Banned

New User


Joined: 26 Apr 2007
Posts: 12
Location: Mysore

PostPosted: Mon Sep 24, 2007 5:33 pm
Reply with quote

Hi,
I thank you all for approaching the question to answer, But i put the code in the wrong way
please see the code below.

Code:

working_Storage section

01 list
     05 filler                   pic x(10) value 'A AAAAAAAA'
     05 filler                   pic x(10) value 'B BBBBBBBB'
     ....
     ....
     05 filler                   pic x(10) value 'Z ZZZZZZZZ'

01 Group-rec      redfines list
     05 xyx occures  26 times
         10  letter           pic  x.
         10  filler           pic  x.
         10  ENV            pic x(8). 


EVALUATE X
 WHEN 1
  PERFORM VARIYING D FROM 1 BY 1 UNTIL D > LIMIT
   IF XYZ(D) = ABC(D)
    MOVE XYZ(D) (1:1) TO WS-VAR
   END-IF
 WHEN OTHER
  MOVE 'N' TO WS-VAR
END-EVALUATE
GOBACK.



Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Sep 24, 2007 6:05 pm
Reply with quote

Would not something like this work?
Code:

EVALUATE X
 WHEN 1
  PERFORM VARYING D FROM 1 BY 1 UNTIL D > LIMIT
                                or XYZ(D) = ABC(D)
  end-perform
 WHEN OTHER
  MOVE 'N' TO WS-VAR
END-EVALUATE
IF XYZ(D) = ABC(D)
    MOVE XYZ(D) (1:1) TO WS-VAR
END-IF
GOBACK.
Back to top
View user's profile Send private message
blpraveen123
Currently Banned

New User


Joined: 26 Apr 2007
Posts: 12
Location: Mysore

PostPosted: Tue Sep 25, 2007 9:09 am
Reply with quote

Hi,

Thanks
I want to know why it give Compilation error when i inserted NEXT statement after move wthin in the If para. Is that the NEXT statement to be used to indicate perform nothing when IF condition is TRUE.


Code:

EVALUATE X
 WHEN 1
  PERFORM VARIYING D FROM 1 BY 1 UNTIL D > LIMIT
   IF XYZ(D) = ABC(D)
    MOVE XYZ(D) (1:1) TO WS-VAR
     NEXT SENTENCE
   END-IF
 WHEN OTHER
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Sep 25, 2007 12:17 pm
Reply with quote

Praveen,

Please post spool messages (compiliation messages).
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Wed Sep 26, 2007 12:17 pm
Reply with quote

I think NEXT SENTENCE
Should be used as a single statement.

If <Condition> then
{Statement-1
Next Sentence}
Else
{Statement-2
Next Sentence}
end-if

That's why you are getting compile error.

Correct me if i am wrong
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Sep 26, 2007 2:11 pm
Reply with quote

blpraveen123 wrote:
I want to know why it give Compilation error
I don't know, since you have not provided the error....
But I can tell that your coding style sucks...for example, why turn a simple IF into such a mess and where is the END-PERFORM?
Quote:
Code:

EVALUATE X
 WHEN 1
  PERFORM VARIYING D FROM 1 BY 1 UNTIL D > LIMIT
   IF XYZ(D) = ABC(D)
    MOVE XYZ(D) (1:1) TO WS-VAR
     NEXT SENTENCE
   END-IF
 WHEN OTHER
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top