Sections inside Procedure division.



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Sections inside Procedure division.

Postby gokulNmf » Wed May 08, 2013 8:10 pm

Hi All,

We have some old Cobol programs; we are changing a part of logic in it for another purpose. These programs have sections instead of Paras inside Procedure division. we are planning to change them to para instead of sections.

These programs call sub programs which also have sections instead of Paras inside Procedure division.

My query is; if we change it in main program and leave sub program untouched; will it affect the execution?
Cheers,
Gokul
User avatar
gokulNmf
 
Posts: 114
Joined: Sat Mar 28, 2009 6:41 pm
Location: India
Has thanked: 0 time
Been thanked: 0 time

Re: Sections inside Procedure division.

 

Re: Sections inside Procedure division.

Postby Akatsukami » Wed May 08, 2013 8:16 pm

No.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Sections inside Procedure division.

Postby BillyBoyo » Wed May 08, 2013 9:13 pm

No.

Since you are going to change them in your main program, do you know the difference between a SECTION and a paragraph?

Perhaps show an example of what there is, including the PERFORM of it, and then show your replacement code. If you just change a SECTION to a paragraph you may not get what you want.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Sections inside Procedure division.

Postby gokulNmf » Wed May 08, 2013 11:40 pm

Billy,

My understanding is;
On hierarchy Sections come above Paras, So When you perform a Section all the paras and other statements inside the section will execute until, a EXIT or next Section comes.
Cheers,
Gokul
User avatar
gokulNmf
 
Posts: 114
Joined: Sat Mar 28, 2009 6:41 pm
Location: India
Has thanked: 0 time
Been thanked: 0 time

Re: Sections inside Procedure division.

Postby dick scherrer » Thu May 09, 2013 12:12 am

Hello,

Suggest you post the info BB requested . . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Sections inside Procedure division.

Postby BillyBoyo » Thu May 09, 2013 2:20 pm

Gokul,

"until EXIT or next Section comes".

Not really. EXIT does nothing.

    MOVE 1 TO A-FIELD
    PERFORM A-PARA
    DISPLAY A-FIELD
    GOBACK
    .

A-PARA.
    EXIT
    EXIT
    EXIT
    EXIT
    EXIT
    EXIT
    MOVE ZERO TO A-FIELD
    .


In changing from the use of SECTIONs just for the sake of it, you run the danger of wasting time and getting something different.

If the SECTIONs contain paragraphs, you're going to have to change to PERFORM ... THRU ... which is an ugly, inflexible, way to do it, and which is prone to several types of error.

Once a program is compiled, it is irrelevant whether there are SECTIONs or paragraphs in it. By that time it is just "object code", with Assembler versions of "go to" of various types.

The example of what you are proposing changing it to is useful to be able to highlight potential problems in making the change, which is set against none/very little benefit.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Sections inside Procedure division.

Postby Robert Sample » Thu May 09, 2013 2:37 pm

SECTIONS in the PROCEDURE DIVISION were, in the early days of COBOL, used to help with overlaying code. Sections with the same priority number were kept together in the same segment so when code was swapped in and out of memory there would be less chance of memory reference errors. This is no longer part of Enterprise COBOL, but not knowing this could impact someone attempting to remove sections from a program. And gokulNmf, your understanding of sections is fatally flawed -- from the Language Reference manual 6.1.4:
A section ends immediately before the next section header, or at the end of the procedure division, or, in the declaratives portion, at the keywords END DECLARATIVES.

Segments
A segment consists of all sections in a program that have the same priority-number. Priority-number determines whether a section is stored in a fixed segment or an independent segment at run time.

Segments with a priority-number of 0 through 49 are fixed segments. Segments with a priority-number of 50 through 99 are independent segments.

The type of segment (fixed or independent) controls the segmentation feature.

In fixed segments, procedures are always in last-used state. In independent segments, procedures are in initial state each time the segment receives control from a segment with a different priority-number, except when the transfer of control results from the execution of a GOBACK or EXIT PROGRAM statement. Restrictions on the use of ALTER, SORT, and MERGE statements in independent segments are described under those statements.

Enterprise COBOL does not support the overlay feature of the Standard COBOL 85 segmentation module.
So the EXIT has nothing to do with the end of a SECTION; I've seen plenty of errors caused by code dropping through an exit paragraph because there was an improperly coded PERFORM statement.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post