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
 

 

Coding Synatx check in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Coding Synatx check in COBOL
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: 1439
Location: Bangalore,India

PostPosted: Mon Sep 24, 2007 2:58 pm    Post subject:
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: 1439
Location: Bangalore,India

PostPosted: Mon Sep 24, 2007 3:00 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Mon Sep 24, 2007 6:05 pm    Post subject:
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    Post subject:
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: 1439
Location: Bangalore,India

PostPosted: Tue Sep 25, 2007 12:17 pm    Post subject:
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: 171
Location: Bangalore

PostPosted: Wed Sep 26, 2007 12:17 pm    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Wed Sep 26, 2007 2:11 pm    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


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