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 |
Give some advantages of REDEFINES clause?
I have two questions here. 1. How to read a flat file in reverse order? 2. How to read a VSAM KSDS file in reverse order? In both the cases we donot know the total number of records.
if we have " ibm mainframe ",in that how to remove first and last leading space eg:"ibm mainframe" like that the answer we need
What are the differences bitween cobol and cobol-2?
what is label record is standard or omitted in file description of data division?
COMP?
what happens when a copybook variables are declared using include statement ?
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.
The disposition parameter in the jcl is share ( DISP+SHR ) and the program opens file in extend mode what will happen?
I want ALL ERROR codes in VSAM
3 Answers American Express, TCS,
There is a variable with value 19446. Requirement is to convert it to 194.46. I tried it by doing divide by 100 and my receiving field data type is 9(03)v99. But the output is 194. I am not getting the decimal value. Could anyone pls let me know how to get this done?
i declare a Table as OCCURS 2000 TIMES.If the input file has more than 2000 records will the COBOL program fail?