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

What if SECTION keyword not used


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

New User


Joined: 03 Jun 2008
Posts: 30
Location: India

PostPosted: Fri Aug 14, 2009 5:02 pm
Reply with quote

While defining a new paragraph in cobol, what are the consequences if SECTION keyword is not used in paragraph name ?

Thanks
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: Fri Aug 14, 2009 5:20 pm
Reply with quote

A SECTION can contain more than one paragraph. Doing a PERFORM of a SECTION means multiple paragraphs may be executed. Having SECTION names in the PROCEDURE DIVISION is not required.

Way back when a mainframe could have as little as 64K of memory (when I was in school, we ran a 360-30 with 3 partitions with 32K, 20K, and 12K), the SECTION names were numbered and these SECTION numbers were used to define the overlay structure of the program. This allowed swapping of pieces of the program not currently in use out to auxiliary storage so larger programs than would physically fit in memory could be executed. This practice has been obsolete for quite some time since mainframes have more memory these days.
Back to top
View user's profile Send private message
rulerofera

New User


Joined: 03 Jun 2008
Posts: 30
Location: India

PostPosted: Fri Aug 14, 2009 6:25 pm
Reply with quote

Thank You, Robert. That is certainly very well explained.

Just one more thing, though you have already answered, but I was thinking in terms of code fall through. What I mean by this is, if I have a call as PERFORM PARA1 and then PARA1 is followed by PARA2 without any EXIT lines in between and no SECTION keywords, will the control at end of PARA1 fall through the code in PARA2, because EXIT line is not there (in sense usually we have call as PERFORM 100-P1 thru 100-EXIT).

And will the functionality be same in both COBOL and COBOLII compiled programs.

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

Global Moderator


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

PostPosted: Fri Aug 14, 2009 6:31 pm
Reply with quote

you will find that an exit statement does not do anything.

you perform a para or a sect, execution stops at the next para or section name. If the performing a para, the paragraph with the exit statement is just another paragraph so rookies can 'GO TO' instead of modular coding to avoid 'GO TOs'.
Back to top
View user's profile Send private message
rulerofera

New User


Joined: 03 Jun 2008
Posts: 30
Location: India

PostPosted: Fri Aug 14, 2009 6:47 pm
Reply with quote

Right, Dick.

I tried all the possibilities which I raised earlier. Findings are - code do not fall through, compiled with both COBOL and COBOII program types.
What I did is, I included a para PAR2 immediatley after PARA1 and call only to PARA1. COBOLII compiled with RC = 4 and eleminated uncalled paragraphs. While, COBOL compiled with RC =0 but the control do not fall through PARA2, it executed only PARA1 and finished.

So which means, the only reason to have SECTION keyword is to denote the start of some paragraph; an identifier kind of thing - original purpose lost in history.

Thank You!! - Robert and Dick.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Aug 14, 2009 7:07 pm
Reply with quote

Quote:
the only reason to have SECTION keyword is to denote the start of some paragraph


rulerofera,

you can perform a section - which will execute all paragraphs in that section. (sort of like perform para thru para.)
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri Aug 14, 2009 7:16 pm
Reply with quote

Some shops insist on SECTIONS only, some PARAGRAPHS only. It's unwise to have both in the same program.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Aug 14, 2009 8:48 pm
Reply with quote

Quote:
It's unwise to have both in the same program

as i indicated in my earlier post, without the para names in the sections,
they can't write their GO TO's.
Back to top
View user's profile Send private message
rulerofera

New User


Joined: 03 Jun 2008
Posts: 30
Location: India

PostPosted: Fri Aug 14, 2009 9:35 pm
Reply with quote

So it is like, if one uses Go To to call a PARA and if the following para do not have SECTION keyword, then I think the control at end of PARA1 is bound to fall through PARA2
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 Aug 14, 2009 10:10 pm
Reply with quote

You don't call a paragraph or a section. Section is a COBOL reserved word. When you perform a section you perform from the start of the SECTION upto and including the last statement of the last paragraph before the next section then control returns to the statement after the perform. If you perform a paragraph control returns to the next statement after the perform at the end of the paragraph you are performing.

GO TO and PERFORM are completely different.

Just consider a SECTION as a collection of paragraphs.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Mon Aug 17, 2009 1:17 pm
Reply with quote

Hi rulerofera,

You could probably have a look into this topic which was discussed some time back.
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 COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts FD Section to Create FB or Vb File Dy... COBOL Programming 1
No new posts Sections: need one appearance of cer... DFSORT/ICETOOL 4
No new posts Missing SECTION break DFSORT/ICETOOL 9
Search our Forums:

Back to Top