COBOL Perform Times

COBOL Perform Through COBOL Perform Until

Advertisements


PERFORM TIMES is mainly used to execute the set/block of statements or paragraph/section in repetitively with number of times specified.

PERFORM TIMES requires to execute repetitively up to certain number of times without any specific condition.

PERFORM TIMES was INLINED and OUTLINED.


Syntax:



Inline PerformOutline perform
PERFORM {N} TIMES
       Statements
END-PERFORM.
PERFORM {Paragraph/Section} 
       [THROUGH/THRU] {N} TIMES
       [{paragraph/section}].

The PERFORM TIMES is most dangerous because it will execute the Block of statements without checking any condition.

The PERFORM TIMES will blindly execute the block that many times mentioned in PERFORM.

INLINE PERFORM TIMES mainly used to perform a set of statements/ block of statements that executed in between the PERFORM and END-PERFORM by using the number in TIMES.

OUTLINE PERFORM mainly used to perform set of statements/ block of statements coded in separate section or separate paragraph provided with PERFORM Statement.


Example:


Calculating the percentage of the student using PERFORM.

The below examples describes how the above example can be coded in below different ways.

  1. INLINE PERFORM TIMES
  2. OUTLINE PERFORM TIMES
  3. INLINE PERFROM TIMES THROUGH

Practical Example - Inline PERFORM TIMES:

Code:



Jcl:



Output:



Practical Example - Outline PERFROM TIMES:

Code:



Jcl:



Output:



Practical Example - Outline PEFROM TIMES THROUGH:

Code:



Jcl:



Output:



COBOL Perform Through COBOL Perform Until

Advertisements