GO TO statement without a procedure name following it



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

GO TO statement without a procedure name following it

Postby ramkumar1992sp » Thu Aug 04, 2016 12:29 am

Hello,

I'm in the process of converting some old OS VS COBOL programs to Enterprise COBOL and I found the below 'GO TO' statement without a procedure name following it.

Can someone please let me know where the control passed when the below GO TO is executed ?


 090-BRANCH-STATEMENT.      
     GO TO.                  
 


I also found some ALTER statements when I looked for 060-BRANCH-STATEMENT.


640-ANY-XXX-XXXXX.                                            
    IF XXX-XXXX1 EQUAL TO '1'   OR                              
       XXX-XXXX2 EQUAL TO '1'                                    
           ALTER 090-BRANCH-STATEMENT TO 645-CHECK-XXXX-XXXXX
          GO TO 1700-CHECK-FOR-XXX-XXXXX.                      
 


I was able to get some resources online about the ALTER statement but I'm still not very clear about it.

Can someone please help me understand the above statements?

Thanks,
Ram Kumar
ramkumar1992sp
 
Posts: 44
Joined: Sat Jul 23, 2016 8:52 am
Has thanked: 25 times
Been thanked: 0 time

Re: GO TO statement without a procedure name following it

 

Re: GO TO statement without a procedure name following it

Postby Robert Sample » Thu Aug 04, 2016 12:47 am

The GO TO statement is referred to as an altered GO TO. What is happening is that the ALTER statement sets the location for the GO TO statement in the paragraph. Yes, this is changing the GO TO during program execution. It causes great difficulty in maintenance since the paragraph can be executed three different times during one execution of the program and results in three different locations continuing the code after the paragraph name. I personally have only encountered ALTER / GO TO logic once in my career, and the person who was requested to maintain the program wound up rewriting it without the ALTER / GO TO logic as it took him several weeks of running tests to figure out how the program worked.

These users thanked the author Robert Sample for the post:
ramkumar1992sp (Thu Aug 04, 2016 1:31 am)
Robert Sample
Global moderator
 
Posts: 3162
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 192 times

Re: GO TO statement without a procedure name following it

Postby ramkumar1992sp » Thu Aug 04, 2016 1:42 am

Thanks Robert.
So this what I think its doing based on your answer and what I read here.Please correct me if I got it wrong.
http://www.ibm.com/support/knowledgecen ... 395348.htm

The ALTER command sets the paragraph to be called when 090-BRANCH-STATEMENT Para is called.There is an another area in my program where this ALTER command was used on 090-BRANCH-STATEMENT

 ALTER 090-BRANCH-STATEMENT TO 600-DETERMINE-XXXX-XXXX
 


and then there was this

    GO TO 090-BRANCH-STATEMENT.
 


Now to rewrite this,I'm thinking of setting flags to true in both the places and then based on the flags using an EVALUATE in the 090-BRANCH-STATEMENT ,I would call either of those 2 procedures.

I will let you know how that goes.


Thanks,
Ram Kumar
ramkumar1992sp
 
Posts: 44
Joined: Sat Jul 23, 2016 8:52 am
Has thanked: 25 times
Been thanked: 0 time

Re: GO TO statement without a procedure name following it

Postby ramkumar1992sp » Thu Aug 04, 2016 1:49 am

Not flags,I would move some value to a variable and then evaluate that variable to make that call

Thanks,
Ram Kumar
ramkumar1992sp
 
Posts: 44
Joined: Sat Jul 23, 2016 8:52 am
Has thanked: 25 times
Been thanked: 0 time

Re: GO TO statement without a procedure name following it

Postby Robert Sample » Thu Aug 04, 2016 2:01 am

EVALUATE is a good replacement for ALTER. However, this statement
The ALTER command sets the paragraph to be called when 090-BRANCH-STATEMENT Para is called
is not accurate. When control reaches 090-BRANH-STATEMENT -- be it from a PERFORM or a GO TO or even just falling through from the previous statement -- then the next statement to be executed will be the first statement in the paragraph currently active in the ALTER. If no ALTER statement has been executed for 090-BRANCH-STATEMENT, then the altered GO TO works as a CONTINUE statement and the next statement executed depends on how control reached 090-BRANCH-STATEMENT.

These users thanked the author Robert Sample for the post:
ramkumar1992sp (Thu Aug 04, 2016 2:16 am)
Robert Sample
Global moderator
 
Posts: 3162
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 192 times

Re: GO TO statement without a procedure name following it

Postby ramkumar1992sp » Thu Aug 04, 2016 2:20 am

Thanks Robert..
ramkumar1992sp
 
Posts: 44
Joined: Sat Jul 23, 2016 8:52 am
Has thanked: 25 times
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post