Thursday 27 September 2012

Perform



PERFORM statement.

Program flow control is an important task while designing an application program.

In COBOL one way to control the flow of program is to use perform statement.

While performing PERFORM statements you have to write a piece of a code in a paragraph then give that paragraph name like PERFORM PARA-1. It means your executable code is in PARA-1.

Ex:
PARA-1
DISPLAY “HELLO WORLD”
DISPLAY “SUCCESSFULLY DONE”
Etc.....

How to enter into PERFORM statement loop?

You have to design your program such a way that under satisfying certain condition only you will enter into the loop for executing perform para statements.





Type 1:

SYNTAX:

PERFORM PARA-NAME N TIMES.

Here N is integer value.
This used when you have to perform a specific paragraph “N” times”.

PROGRAM:

 

OUTPUT:





TYPE 2
SYNTAX:

PERFORM PARA-1 THRU PARA-N .


                           OR

PERFORM PARA-1 THRU PARA-N  N TIMES.





PROGRAM:


OUTPUT:





How to execute complete section using perform statement?

We can execute section also using PERFORM statement.

All paragraph in that section will execute.

SYNTAX:
PERFORM SECTION-NAME OR



PERFORM SECTION –NAME N TIMES.



PROGRAM:




OUTPUT:



Type 3:

PERFORM PARA-NAME UNTIL CONDITION that will discuss later in VSAM file handling.
 





No comments:

Post a Comment