How to replace the GOTO statement in COBOL without changing
the structure of program. e.g. consider following code...
I.D.
E.D.
D.D.
P.D.
compute C = A + B.
GOTO para 100-display.
compute D = C - D.
GOTO 200-display.
some other logic......
........
GOTO 300-para.
......
......
GOTO 400-para.
Now I want to replacce all GOTO statements without
changing the structure and otput of program.
Answers were Sorted based on User's Feedback
Answer / muttaiah
My Opinion is we won't be able to change GOTO with Perform
here. why because if we use perform instead of goto like
this..
compute C = A + B.
Perform para 100-display.
compute D = C - D.
Perform 200-display.
what will happen means once c value is calculated. It wil
execute 100-display para once it completes. It will
calcualte d value. which is not the case in goto. Once C
value is calculated the control is passed to 100-display
para. The control will never return and cal D value.
what say!!
Correct me if i'm wrong please
| Is This Answer Correct ? | 10 Yes | 0 No |
Answer / suraj borge
Using evaluate statement
take the value of para in a variable then evaluate it for ex.
evaluate xyz
when 100 perform para-100
when 200 perform para-200
..
.
.
.
.
like that we can replace the goto statement .
| Is This Answer Correct ? | 8 Yes | 2 No |
Answer / krishnan a
Instead of GOTO we can use PERFORM noneed to go EVALUATE
also
compute C = A + B.
PERFORM 100-display.
compute D = C - D.
PERFORM 200-display.
some other logic......
........
PERFORM 300-para.
......
......
PERFORM 400-para.
| Is This Answer Correct ? | 8 Yes | 5 No |
Answer / vani
is there any exit statement for the goto para
if it's so,it can be replaced with perform statement
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / ganesh
but if there is no any condition to check for in evaluate
statement. how can we replace it using evaluate.
won't it change the structure of program if we use evaluate
statement.
| Is This Answer Correct ? | 1 Yes | 0 No |
Why there is no questions in this column?
What is the different between index and subscript?
In a program, variables are used but no DB2 involved in it. Can you call it as host variables??
In COBOL "BEFORE" advancing is there or not ?
How many times the loop runs here 01 a pic 9(2) value 10. perform para1 a times stop run. para1: move 20 to a.
how to check whether the open command of a sequential file is successful? or not?
how to crack cts interview apps? NOVEMBER 21 2010
What is comp-1 and comp-2?
How many variables can be declared in w-s section.?
If I want to increase the Limit in GDG. What should I do?
Can we call a CICS program from a batch program or viceversa?If so, how?
I have the file which is having the extension no as records. sample file will look like below. 2310 3410 3256 4350 3781 5408 I need to replace the record which is starting with 3 to 5 (i.e) 3410 to 5410. How can we do it through cobol and cobol-db2 program? I need the possible logic?