Ask the Expert

Pros and cons of SECTIONs

I'd like to know the pros and cons of using SECTION in a COBOL program.

Requires Free Membership to View

You do not say what type of SECTION, so I will assume using SECTION as a type of procedure name in the PROCEDURE DIVISION of a COBOL program. There are also SECTIONs in the DATA DIVISION, so let me know if I guessed wrong.

Interesting question! I do not know any pros or cons for using SECTIONs as procedure names in the PROCEDURE DIVISION of your COBOL program, as opposed to using paragraph names to name your procedures. I can explain the difference; maybe that would help you? If not, ask again!

There are several reasons for using paragraphs or sections to name parts of your program. One is documentation; the other is to allow execution via PERFORM statements (or INPUT and OUTPUT PROCEDURE phrases of the SORT statement). With SECTIONs, you could execute several paragraphs contained in the section or execute individual paragraphs. I guess that would be a PRO, unless you don't want that. :-) Example:

MAIN Section.
* Perform all of the code and paragraphs in SubSect 
Perform SubSect.
* Perform only paragraphs Para1 in SubSect 
Perform Para1.

SubSect Section.
Para1.
Stuff1. . . 
Para2.
Stuff2. . .
Para3.
Stuff3. . .
EndSect Section.
GoBack

This was first published in March 2005

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: