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
 

 

Terminate from the perform loop

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

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Thu Nov 15, 2007 4:12 pm    Post subject: Terminate from the perform loop
Reply with quote

Hello

I need to perform a loop varying ws-sub by 1 to 1 until a condition is met
like for example

PERFORM VARYING WS-SUB FROM 1 BY 1 UNTIL
WS-SUB > PMFC-A-OCCURS

if a(ws-sub) = b then

<some statements>
(statement to break the loop)
end-if
end-perform

(some statments)

I want to come out of perform once my if condition is true and need not continue until ws-sub > PMFC-A-OCCURS

Is there any BREAK statement and using Exit may come out of paragraph

What statement should i use to break perform?
Back to top
View user's profile Send private message

VinayCM

New User


Joined: 06 Nov 2007
Posts: 36
Location: Bengaluru

PostPosted: Thu Nov 15, 2007 4:40 pm    Post subject:
Reply with quote

I think EXIT statement may work.... Otherwise you can use GO TO (Next Para Name) inside IF loop.
Back to top
View user's profile Send private message
murmohk1

Senior Member


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

PostPosted: Thu Nov 15, 2007 4:43 pm    Post subject:
Reply with quote

Deepa & Vinay,

Quote:
Otherwise you can use GO TO (Next Para Name)


Check your shop standards before GOTO is used.
Back to top
View user's profile Send private message
VinayCM

New User


Joined: 06 Nov 2007
Posts: 36
Location: Bengaluru

PostPosted: Thu Nov 15, 2007 4:51 pm    Post subject:
Reply with quote

Murali,
It's true that using GOTO is not a standard way of programming but is there any other ways. If there a way please suggest for my future use.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Thu Nov 15, 2007 4:55 pm    Post subject:
Reply with quote

perform until .....
or ....
or ....
or ....
do something
set an or conditition true
end-perform


do not use go to's in a perform loop, very poor programming practice as well as difficult to debug.
Back to top
View user's profile Send private message
Varun Singh

New User


Joined: 01 Aug 2007
Posts: 25
Location: Delhi

PostPosted: Thu Nov 15, 2007 4:55 pm    Post subject: Reply to: Terminate from the perform loop
Reply with quote

Hey ,

U can make it simple
by using
compute ws-sub = pmfc-a-occurs + 1

Though I have never used break
and I suppose COBOL does not have any verb 'BREAK'

Though it has a verb 'CONTINUE'

icon_biggrin.gif
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Thu Nov 15, 2007 5:37 pm    Post subject:
Reply with quote

Hi Deepa.m,

Use below code

Code:
if a(ws-sub) = b then

<some statements>
(statement to break the loop)

WS-SUB = WS-SUB + PMFC-A-OCCURS
end-if
end-perform

(some statments)


Since WS-B will have high value it will come out of that loop
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Thu Nov 15, 2007 6:12 pm    Post subject:
Reply with quote

Hi There,

u can also use NEXT SENTENCE for this


Code:
PERFORM VARYING WS-SUB FROM 1 BY 1 UNTIL
WS-SUB > PMFC-A-OCCURS

IF a(ws-sub) = b then
   ..
   NEXT SENTENCE
END-IF
END-PERFORM.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Thu Nov 15, 2007 6:21 pm    Post subject: Reply to: Terminate from the perform loop
Reply with quote

Hi,

Code the following code.

In IF condition, code the following line.

WS-SUB = PMFC-A-OCCURS +1

KSK
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 130
Location: Guntur

PostPosted: Thu Nov 15, 2007 6:35 pm    Post subject:
Reply with quote

Hi ksk


Quote:

WS-SUB = PMFC-A-OCCURS [/code]+1


no need to add 1 to PMFC-A-OCCURS

Since we are adding it in perform
this is enough
Code:

WS-SUB = PMFC-A-OCCURS


Before it checks again for the condition it will add 1 to WS-SUB since its a loop.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Thu Nov 15, 2007 6:44 pm    Post subject:
Reply with quote

HI Bala Krishna,

Did you read the question properly.

I KNOW WS-SUB would be incremented since it is in perform.

OS wants to come out of the loop forcibly, so she has to add this condition to come out when IF condition becomes true.
Back to top
View user's profile Send private message
Deepa.m
Warnings : 1

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Mon Nov 19, 2007 12:36 pm    Post subject:
Reply with quote

Thnks for the reply.

ws-sub = pmfc-a-occurs + 1 is one solution that strikes everyone but I am looking for some statements that could acheive this force complete perform other than nomal exit through until condition.

I cant use GOTO or EXIT as it may come out of paragrqaph without executing the statements below end-perform in teh same paragraph


So I think "Next Sentence" is good solution but my period "." comes in end-if. Inside which the perform is coded.

So i will go with ws-sub = pmfc-a-occurs


Thanks Guys.
Back to top
View user's profile Send private message
murmohk1

Senior Member


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

PostPosted: Mon Nov 19, 2007 1:28 pm    Post subject:
Reply with quote

Deepa,

Quote:
So I think "Next Sentence" is good solution but my period "." comes in end-if.

If you are providing '.' inside perform, doesn't the loop terminate there? Could you post your PERFORM loop.
Back to top
View user's profile Send private message
Deepa.m
Warnings : 1

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Mon Nov 19, 2007 2:32 pm    Post subject:
Reply with quote

para1.

if not eof

some sentences

PERFORM VARYING WS-SUB FROM 1 BY 1 UNTIL
WS-SUB > PMFC-A-OCCURS

if a(ws-sub) = b then

<some statements>
(statement to break the loop)
else

<some sentences>
end-if
end-perform
<some sentences>

end-if.

<some sentences>

para-1-exit.
exit.

this is my actual para flow. I need to pass the control to bold part once
a(ws-sub) = b is true

thanks,
Deepa.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Tue Nov 20, 2007 10:37 am    Post subject:
Reply with quote

Hi Deepa,

If you feel some solution strikes you or you know some possible solution, better post that striking solution while you are posting the question. Others won't waste their time to type and to give the solution. Everybody has their own work to do.

KSK
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 DB2 - TERMINATE utility vasanthz DB2 5 Mon May 15, 2017 11:49 pm
No new posts save SAY var loop. italo_pm CLIST & REXX 3 Sun Sep 04, 2016 3:06 am
No new posts How to perform Digest Access Authenti... vasanthz All Other Mainframe Topics 0 Tue Mar 15, 2016 4:47 pm
No new posts print out the correct info in LOOP? jackzhang75 CLIST & REXX 7 Wed Dec 23, 2015 10:39 pm
No new posts Using different values for Skeleton d... venksiv CLIST & REXX 8 Thu Sep 03, 2015 5:28 pm


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