Monday 28 July 2014

PERFORM in COBOL | Types of PERFORM in COBOL | Basic PERFORM Statements | PERFORM With Times | PERFORM with Varying | PERFORM Examples.

COBOL PERFORM Statement
PERFORM Statement in COBOL.


COBOL PERFORM statement is generally used to implement loops in the COBOL program. In this session, you'll learn the basics of the COBOL PERFORM statement in COBOL. 

You'll also learn the different variants of COBOL PERFORM statements (i.e. How many different types of performs are there in COBOL?) 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.  

Agenda.
  • Introduction.
  • COBOL PERFORM Statement.
  • COBOL PERFORM Statement Variants.
  • COBOL PERFORM Statement Examples. 
  • Conclusion

Introduction.

COBOL is a procedural language and one of the oldest language which is still in use. COBOL is generally used in large-scale enterprise applications such as banking, health-care, aviation industry, etc. 

In general, COBOL program logic is group into different paragraphs or sections. COBOL PERFORM statement controls the flow and executes the logic specified in these paragraphs.

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

Let's discuss the PERFORM statement and its variants in detail. 

COBOL PERFORM Statement.

As you know, that perform statement control the flow and execution of logic specified in paragraphs or sections. These are generally used for looping, iteration, or sequencing in COBOL programs. COBOL PERFORM verb is similar to DO...WHILE or FOR...loops of other programming languages such as VB, JAVA, or Python.  

In simple terms, the COBOL PERFORM statement is used to transfer control implicitly or explicitly with in the paragraph, section, or procedure. 

PERFORM statements in COBOL are broadly divided into two categories. These categories are further subdivided into different variants. Let's look at each category one by one.  
  • INLINE PERFORM Statement.
  • OUT-OF-LINE PERFORM Statement. 

TYPE OF COBOL PERFORM STATEMENTS, COBOL Tutorial
COBOL PERFORM Types.


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. 

The logic or functionality is included in different paragraphs or sections and the branch is set up by using PERFORM statements. Out-of-line PERFORM is generally used when logic within different paragraphs or sections is executed based on certain conditions.
 
Now, let's talk about different variants of PERFORM Statements.  

how many different types of performs are there in COBOL?

In COBOL, COBOL PERFORM statement has the following different types:

  • PERFORM .....   Paragraph name. 
  • PERFORM .....  Times phrase.
  • PERFORM .....  Thru phrase.
  • PERFORM .....  Until phrase.
  • PERFORM .....  Varying phrase. 


- 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. Refer following example. 


          ► PERFORM A000-CALC-TAX.

- 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 the 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 B000-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

COBOL PERFORM
PERFORM with the Varying Example

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

                          
                                        COBOL PERFORM with the Varying Phrase.


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.

Youtube: PERFORM in COBOL Tutorial.

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


Conclusion. 

In this session, you learn the basics of the COBOL PERFORM Statement. PERFORM statement in COBOL is used to implement loops, sequences, or iteration in COBOL programs. You also learned the different variants of PERFORM Statements such as PERFORM with times, PERFORM with Until phrase, Perform with Varying Phrase, etc. 

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

► Youtube
► Facebook 
► Reddit

Thank you for your support. 
Mainframe Forum™

 

No comments:

Post a Comment

New In-feed ads