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

Control to return to a para after execution of another para.


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

New User


Joined: 26 Jun 2008
Posts: 8
Location: Hyderabad

PostPosted: Thu Jun 26, 2008 1:15 pm
Reply with quote

Hi, Please look at the code snippets below.

Code 1:

Para1 section.
perform para2 until count>10.

Para2 section.
move ws-data to ws-load(count)
add 1 to count.

Para3.

Code 2:

Para1 section.
perform para2 until count>10.

Para2.
move ws-data to ws-load(count)
add 1 to count.

Para3.

Code 3:

Para1.
perform para2 until count>10.

Para2.
move ws-data to s-load(count)
add 1 to count.

Para3.

For code 1 and code 2 the control is not returning to para 1 after executing para 2. It would just increment the count by 1 for the first time and then execute para 3. Only for code 3 would the control return to para 1. But i was under the impression that the control would return to para 1 even when a para is defined as a section. Please correct me if iamb wrong.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jun 26, 2008 2:48 pm
Reply with quote

Whenever a section is PERFORMed COBOL will generate its own (hidden) EXIT instruction when the next section-name is encountered....

If a section-name in your source file has the word SECTION missing, COBOL will treat it as a continuation of the preceding section ... here para 3 does not have a section verb with it ..so cobol will treat it to be a continuation to para2 section ....
Back to top
View user's profile Send private message
nirmal arthur

New User


Joined: 26 Jun 2008
Posts: 8
Location: Hyderabad

PostPosted: Thu Jun 26, 2008 3:00 pm
Reply with quote

Thanks ashimer. But in code 2 also the control wasn't returning to para 1 after executing para 2. Here para 2 is not defined as a section. Can you tell me why this was happening?
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jun 26, 2008 3:03 pm
Reply with quote

in code 2 para 2 will be considered as continuation to para 1 as para 2 is not mentioned as a section and it executes para 2 followed by para 3 ....
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jun 26, 2008 3:04 pm
Reply with quote

try specifying EXIT for each section ...

para1 section.
....
...
exit para1.

para2.

....
....
Back to top
View user's profile Send private message
nirmal arthur

New User


Joined: 26 Jun 2008
Posts: 8
Location: Hyderabad

PostPosted: Thu Jun 26, 2008 3:04 pm
Reply with quote

Yeah but there is a perform in para 1 and the control was going to para 2. So the control wont come back to para 1 since it is defined as a section??
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Jun 26, 2008 5:06 pm
Reply with quote

How can you tell it's not returning to para1? And if the code is specified as you have it, how do you prevent the program from doing the perform, returning to para1, and then falling through into para2 again?
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jun 26, 2008 5:09 pm
Reply with quote

Use exit for each section ..it will work ..or else dont define any para ..define all as sections....
Back to top
View user's profile Send private message
nirmal arthur

New User


Joined: 26 Jun 2008
Posts: 8
Location: Hyderabad

PostPosted: Thu Jun 26, 2008 5:15 pm
Reply with quote

Hi Robert,

I had put it through intertest and thus i know that the control is not returning to para 1.
You are right. The code will come to para 2 once para 1 is done. I know this is a bad code according to the standards. But im not looking for a solution. I already have the code up and working as per the requirement. Thing is i want to know the reason.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jun 26, 2008 9:26 pm
Reply with quote

Hello,

Quote:
Thing is i want to know the reason


Probably not the answer you want, but the reason is that the code is functioning exactly as it was written. . . and as it is supposed to according to the rules of cobol. . .

If you use the "IBM Manuals" link at the top of the page, there is much more info in the COBOL documentation. If you find something in the manual(s) that is not clear, post it here and we may be able to help clarify.
Back to top
View user's profile Send private message
nirmal arthur

New User


Joined: 26 Jun 2008
Posts: 8
Location: Hyderabad

PostPosted: Thu Jun 26, 2008 9:29 pm
Reply with quote

Thanks dick. I did look up in the manuals for 'section' and 'para' but nothing was said about when the control would return and when it wouldn't. If only you would give me the right link....
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Jun 26, 2008 9:32 pm
Reply with quote

Did you follow the test through a few iterations? Perform control works by jumping to the paragraph, executing, then jumping back to the calling PERFORM to do the UNTIL logic check. Then if the logic says to perform again (UNTIL not satisfied), the jump to the paragraph occurs again. This repeats until the UNTIL clause is satisfied.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jun 26, 2008 9:50 pm
Reply with quote

hi all.

pls refer

publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/evfeb4ls124.htm
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jun 26, 2008 11:57 pm
Reply with quote

Hello,

See if these help. . . Spending only a few minutes will often not find what you want - it may take a while to get to what you are looking for. . . One value of using the manuals to do research "long-hand" is that you become exposed to information you would not see when someone simply points to a page. . . What you are doing is basically for learning, so there should be no urgency to get an answer terribly quickly.

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/igy3lr10/6.2.27.1

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/igy3lr10/1.8
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jun 27, 2008 5:07 am
Reply with quote

what is the value of count at the begining of the start of code 2?????????do you ever initialize count????
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jun 27, 2008 5:16 am
Reply with quote

In code 1 para2 is a section so when you perform para2 that includes para2 and para3 since para3 is part of para2 section.

In code 2 and code 3 para2 is paragraph so when you perform para2 that is all that gets performed.
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 Return codes-Normal & Abnormal te... JCL & VSAM 7
No new posts Capturing Job Execution Information All Other Mainframe Topics 3
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
This topic is locked: you cannot edit posts or make replies. Programa para Realiza Operaciones sob... JCL & VSAM 3
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
Search our Forums:

Back to Top