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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Control to return to a para after execution of another para.
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 7913
Location: Bellevue, IA

PostPosted: Thu Jun 26, 2008 5:06 pm    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Thu Jun 26, 2008 9:26 pm    Post subject:
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    Post subject:
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: 7913
Location: Bellevue, IA

PostPosted: Thu Jun 26, 2008 9:32 pm    Post subject:
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    Post subject:
Reply with quote

hi all.

pls refer

http://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

Site Director


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

PostPosted: Thu Jun 26, 2008 11:57 pm    Post subject:
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.

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

http://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    Post subject:
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    Post subject: Re: Control to return to a para after execution of another p
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    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 DFHWS2LS return value divated CICS 4 Mon Nov 07, 2016 5:44 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Easytrieve - Report writing - Only 1 ... Abhi Nature CA Products 2 Wed Sep 14, 2016 11:40 am
This topic is locked: you cannot edit posts or make replies. JCL MULTIPLE STEP EXECUTION QUERY Susanta JCL & VSAM 18 Sat Jul 30, 2016 1:17 pm
No new posts output DDname JESMSGLG job during exe... italo_pm TSO/ISPF 16 Tue Jun 21, 2016 11:13 am


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