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
 

 

How and when to use keyword "SECTION"?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
ankit.jain

New User


Joined: 02 Jul 2009
Posts: 14
Location: Mumbai

PostPosted: Thu Jul 02, 2009 11:19 am    Post subject: How and when to use keyword "SECTION"?
Reply with quote

Hi,

In my code, I observed weird program flow when I added the keyword “SECTION” to a paragraph. Consider the following code as an example:

100-PROCESS SECTION.
<steps>
GO TO 100-EXIT.
100-ERROR.
<steps>
100-EXIT.
EXIT.

200-PROCESS SECTION.
<steps>
200-EXIT.
EXIT.

300-PROCESS SECTION.
<steps>
300-EXIT.
EXIT.

In this code, the keyword “SECTION” is not used in 100-ERROR. In this case, when the control reaches GO TO 100-EXIT, it executes the 100-EXIT and returns to the next line from where 100-PROCESS section was called.

But when I added the keyword “SECTION” after 100-ERROR (so it will appear as 100-ERROR SECTION), the flow of the program changed. In this case, when the control reaches GO TO 100-EXIT, it executes the 100-EXIT, but after that it executes 200-PROCESS section, then 300-PROCESS section and so on.

Is this correct and why does it happen?

Thanks in advance,
Ankit Jain
Back to top
View user's profile Send private message

Binop B

Active User


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

PostPosted: Thu Jul 02, 2009 12:27 pm    Post subject:
Reply with quote

Hi Ankit,

Its been sometime since i have come across SECTION concept. I will tell what i remember.

SECTIONs can be considered to logical parititions within a DIVISION. In your case here SECTION is supposed to be logical divisions to your PROCEDURE division.

Now I hope u know the general difference between GOTO and PERFORM. The general idea is when we do a PERFORM statement to call a paragraph it executes the same and control returns back. When we do a GOTO para it executes the same para but continues the execution with the next paragraph in line.

When a PERFORM to a section is done ( in this case 100-PROCESS ), if i remember correctly, the whole SECTION is executed. In the example given above, you have basically given a GOTO within the SECTION. As far as the initial PERFORM is concerned the control is still within the SECTION hence after executing 100-EXIT it returns back to the statment after the PERFORM 100-PROCESS statement. Please note that if there were other paragraphs after 100-EXIT ( before the next SECTION ) it would execute those paragraphs also and then only return back to the initial PERFORM statment.

In the second case you have mentioned when you are doing a GOTO to a completely new SECTION, the initial PERFORM looses its flow as it has come out of the expected flow and hence the initial PERFORM is terminated. Hence after executing the 100-EXIT SECTION it continues on with the next paragraph.

Hope i have been of help.
Back to top
View user's profile Send private message
ankit.jain

New User


Joined: 02 Jul 2009
Posts: 14
Location: Mumbai

PostPosted: Thu Jul 02, 2009 1:53 pm    Post subject: Reply to: How and when to use keyword "SECTION"?
Reply with quote

Thanks a lot Binop, your explanation is really helpful and I appreciate the way you explained it.
Back to top
View user's profile Send private message
Binop B

Active User


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

PostPosted: Thu Jul 02, 2009 1:57 pm    Post subject:
Reply with quote

Nice to hear that... icon_biggrin.gif
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Jul 02, 2009 4:45 pm    Post subject: Reply to: How and when to use keyword "SECTION"?
Reply with quote

Procedure Division "SECTIONS" have been steadily falling out of favor, except when they are mandated, such as COBOL INPUT and OUTPUT SORT PROCEDURE SECTIONS. However, USING and GIVING t/w the FASTSRT compile option instead, seems to be more of the rule.

When compiling a program which uses SECTIONS and specifying the OPT compiler option, you'll find that the generated Load Module tends to be slightly larger than a program without SECTIONS, excluding the SORT PROCEDURE SECTIONS as outlined above.

FWIW, INPUT and OUTPUT SORT PROCEDURE SECTIONS are akin to E15 and E35 Sort Exits, respectively.

Regards,
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 Jul 02, 2009 8:22 pm    Post subject:
Reply with quote

Hello,

Quote:
However, USING and GIVING t/w the FASTSRT compile option instead, seems to be more of the rule.
Lots of code specifies using/giving - with or without fastsrt. This is usually because the people who implemented these did not understand input/output procedure or they had an extract process a sort and an output process and combined them into one set of code so they would not be required to document 3 steps or they were just plain lazy.

All of the timing tests i've seen or conducted show that input/out procedure performs better than using/giving. One reason is that using/giving requires at least 2 complete extra passes of all of the data.

FASTSRT can help the performance of code with using/giving but it does nothing for input/output procedure (at least not that i've seen).
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Jul 02, 2009 8:32 pm    Post subject: Reply to: How and when to use keyword "SECTION"?
Reply with quote

Thanks Dick. I had thought just the opposite in regards to performance as IBM touts USING/GIVING as a faster way to perform sorts in COBOL.

Yes and that's a true statement that FASTSRT has no effect on INPUT and OUTPUT Procedures.

Heaven forbid, but do you think they've not been entirely forthcoming regarding USING/GIVING? icon_rolleyes.gif

Never would have thunk it.... icon_eek.gif

Regards,
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Thu Jul 02, 2009 8:49 pm    Post subject:
Reply with quote

IBM touting something that increases the need for hardware? Who woulda thunk it? icon_biggrin.gif
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 Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am
No new posts Include/omit with "ALL" pa... mgl DFSORT/ICETOOL 6 Wed Jun 14, 2017 2:31 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts RC 20 for Address ISPEXEC "ISRED... pkmurali CLIST & REXX 3 Sun Apr 16, 2017 11:30 pm
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am


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