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
 

 

Is scope terminators are mandatory in a cobol program

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

New User


Joined: 11 Apr 2005
Posts: 12

PostPosted: Mon Jul 17, 2006 10:36 am    Post subject: Is scope terminators are mandatory in a cobol program
Reply with quote

is explicit scope terminators are mandatory in a cobol program ?
if not , then why we specify them in the cobol programs ?
i tried them without specifying END-EVALUATE,END-PERFORM.it was worked fine. my question is why we specify them without any need.

and one more question is what is meant by top-down approach.
can any one give a brief explanation on that
Back to top
View user's profile Send private message

Rupa.P.V
Warnings : 1

New User


Joined: 04 Jul 2006
Posts: 30

PostPosted: Mon Jul 17, 2006 12:22 pm    Post subject: Re: Is scope terminators are mandatory in a cobol program
Reply with quote

Its not mandatory...but depending on the requirement u may have to use the scope terminators....

For example if u have many conditions and u want to end the innermost if condition alone then if u give Period all the if conditios will be ended there itself..

Eg:;
IF (FILE-NSPNLIST-END NOT = 'Y')
PERFORM 4100-SEARCH-CWIPCRLT THRU 4100-EXIT
IF (WS-CWIPCRLT-FOUND = 'Y')
PERFORM 4200-SEARCH-FSSCOMM THRU 4200-EXIT
IF (WS-FSSCOMM-FOUND = 'Y')
PERFORM 4300-CALC-NETQTY THRU 4300-EXIT
END-IF
END-IF
END-IF
. . . . . . . . . . . . . . . .

Here if u put period after PERFORM 4300-CALC-NETQTY THRU 4300-EXIT all the if conditions will ended there itself.
Here if u want to close all the if conditions u can just use period.
But if u have any else statements for any of the IF conditions above in that case
scope terminators will useful....


Hope i am clear to u....
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Mon Jul 17, 2006 12:35 pm    Post subject: Re: Is scope terminators are mandatory in a cobol program
Reply with quote

pushpalatha wrote:
i tried them without specifying END-EVALUATE,END-PERFORM.it was worked fine.



END-EVALUATE,END-PERFORM, END-SEARCH, END-IF are ment for better readability. They don't indicate any specific instruction.

Scope Terminators are not mandetory. When the compilor encounters certain COBOL KEYWORDS like IF, MOVE, PERFORM.........., it automatically terminates the scope of the present statement.

~Vamsi
Back to top
View user's profile Send private message
Hanfur

Active User


Joined: 21 Jun 2006
Posts: 104

PostPosted: Mon Jul 17, 2006 1:19 pm    Post subject: Hi
Reply with quote

This simply esnures improved readbility of code and would be easy in maintaing..

-Han.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Jul 18, 2006 3:45 am    Post subject: Re: Is scope terminators are mandatory in a cobol program
Reply with quote

There is more to scope terminators that just readability. Although it does greatly help with that, and it is a requirement in all the coding I review.

Take an example

Code:

    IF VARIABLE-A = CONDITION-A
    THEN
        IF VARIABLE-B = CONDITION-B
        THEN
            MOVE CONSTANT-C TO VARIABLE-A
        END-IF
        ADD 1           TO VARIABLE-A
        MOVE VARIABLE-A TO VARIABLE-D
    ELSE
        MOVE CONSTANT-D TO VARIABLE-D
    END-IF.


This is a very simple example, but without the scope terminators, you cannot build an IF statement like this.

Dave
Back to top
View user's profile Send private message
calspach

New User


Joined: 05 May 2006
Posts: 32
Location: USA

PostPosted: Wed Jul 19, 2006 6:43 pm    Post subject:
Reply with quote

Exactly. You might be able to get away with just coding .'s when you need to terminate most of the time, but the good old end-if, end-read, end-perform can really come in handy sometimes too. And, I would like to note that the readability issue should be reason enough, even if you can prove to me that you can do it without an end-if, it would certainly be easier to read with it.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Jul 20, 2006 1:07 am    Post subject: Re: Is scope terminators are mandatory in a cobol program
Reply with quote

As for you TOP-DOWN question, see this Previous Post
If you still have questions, please come back

Dave
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 XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm
No new posts pre-compiler for program in an HFS Pedro DB2 0 Fri Jun 23, 2017 11:13 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm


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