PERFORM in COBOL and Types of PERFORM in COBOL.

Topictrick.com
2 min readJan 24, 2021

You’ll also learn the different variants of COBOL PERFORM statements such as perform times in COBOL, inline perform, perform varying until in COBOL, nested perform statement, etc. Let’s get started with today’s COBOL Tutorial.

COBOL PERFORM Statements are used for looping, iteration, or sequencing.

Inline PERFORM in COBOL.

The logic or functionality is included within the PERFORM and END-PERFORM statement. The specified logic is executed in a loop till the condition is satisfied. Inline PERFORM is generally used in the file reading logic.

OUT-OF-LINE PERFORM in COBOL.

Now, let’s talk about different variants of PERFORM Statements.

- Basic PERFORM in COBOL.

In a basic perform statement, you need to use the perform keyword followed by a paragraph name. The logic within that paragraph will be executed only once.

- PERFORM with Times phrase in COBOL.

In COBOL perform with times phrase, you need to use the perform keyword followed by a paragraph name and number of times you want to execute the paragraph. The logic within that paragraph will be executed n times. Refer following example.

PERFORM A000-CALC-TAX 3 Times.

- PERFORM with Thru phrase.

In COBOL perform with thru phrase execute all imperative statement/logic between starting and ending paragraphs. Refer following example.

PERFORM A000-CALC-TAX THRU A099-EXIT.

- PERFORM with Varying phrase.

In COBOL perform with the varying phrase is like perform with until phrase. But, you have an identifier to keep track of each execution. Perform with the varying phrase is used for navigating within COBOL table/array. Refer following example.

PERFORM A000-CALC-TAX THRU B000-EXIT VARYING IND-X FROM 1 BY 1 Until IND-X > 100

The execution of the PERFORM with the VARYING phrase can be easily understood from the following flow chart.

Note: When TEST BEFORE is indicated, all specified conditions are tested before the first execution and the statements to be performed are executed, if at all, only when all specified tests fail. When TEST AFTER is indicated, the statements to be performed are executed at least once, before any condition is tested. If neither the TEST BEFORE nor the TEST AFTER phrase is specified, the TEST BEFORE phrase is assumed.

PERFORM in COBOL is linked with a youtube video tutorial. Please do visit our channel and consider subscribing to our channel.

►Subscribe to Topictrick & Don’t forget to press THE BELL ICON to never miss any updates. Also, Please visit below mention the link below to stay connected with Topictrick and the Mainframe forum on -

Thank you for your support.

Originally published at https://mainframe-forum.blogspot.com.

--

--

Topictrick.com

Topictrick is a comprehensive repository of programming language tutorial and tech reviews. Also, it showcases what new in the tech industry. One place for all.