COBOL: Nested PERFORM VARYING

I have written an interesting topic. In Cobol, the most popular COBOL statement is “PERFORM VARYING”. The Nested perform means perform within the perform.

When data is needed in two dimensional array format, the we need nested perform varying.

Ex:

PERFORM 200-MAJOR-RTN VARYING CTR1 FROM 1 BY 1 UNTIL CTR1 > 10     
PERFORM 300-CALC-RTN VARYING CTR2 FROM 1 BY 1 UNTIL CTR2 > 20

You can find very intersting things in this book-Buy Today . First inner loop will execute and later Outer loop will execute.

Alternative way is, in simple Perform:

PERFORM CTR1 FROM 1 BY 1 UNTIL CTR1 > 10
AFTER CTR2 FROM 1 BY 1 UNTIL CTR2 > 20
....
....
END-PERFORM

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.