Monday, 28 July 2014

COBOL TIMES phrase PERFORM | COBOL PERFORM with TIMES phrase Example [COBOL PERFORM ]

COBOL PERFORM Statement, COBOL PERFORM TIMES Phrase

COBOL PERFORM with TIMES Phrase.


Welcome back to today's session on "COBOL PERFORM Statement". In this session, you'll get a summary of the COBOL PERFORM Statement and the types of PERFORM in COBOL. But, we will deep dive into the COBOL TIMES Phrase PERFORM statement and how you can use them in your COBOL programs. Let's get started with the question What are COBOL PERFORM Statements? 

COBOL PERFORM Phrase Times - Agenda. 

  • What is COBOL PERFORM Statements?
  • Types of PERFORM in COBOL.
  • PERFORM TIMES Phrase in COBOL.
  • COBOL PERFORM with TIMES Phrase syntax.
  • COBOL PERFORM 
  • Conclusion.  


What is COBOL PERFORM Statements?

In most, programming languages you use the "DO WHILE LOOP" statement to implement looping. However, COBOL is an English-like language, and to implement looping you have to use COBOL PERFORM statement. 

PERFORM statement in COBOL is used to transfer control internally to one or more paragraphs/sections. The control will return to the next executable statement after performing the specified paragraphs/sections.

Types of PERFORM in COBOL?

In general, the COBOL PERFORM statement is divided into two categories and has four different formats. These categories are further subdivided into different variants. Let's look at each category one by one. Let's discuss each category briefly:

  • An Out-of-line PERFORM statement: The logic or functionality is included in different paragraphs or sections and the branch is set up by using PERFORM statements.

  • An in-line PERFORM statement: The logic or functionality is included within the PERFORM and END-PERFORM statement.



As mention earlier, the COBOL PERFORM statement has the following different types:

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


COBOL PERFORM TIMES Phrase (COBOL TIMES phrase PERFORM).

PERFORM... TIMES phrase in COBOL is used to execute the specific paragraph/section for the number of times specified into PERFORM statement. 

                                                                    OR 

In general, the COBOL PERFORM TIMES phrase statement tells the computer to execute a sequence of steps, a fixed number of times. 

Note: The logic within that paragraph will be executed n times. Refer following example.

          ► PERFORM A000-CALC-TAX 4 Times.

COBOL  PERFORM with TIMES phrase Syntax.  

COBOL PERFORM with TIMES phrase is simple from an understanding and implementation perspective. You simply need to use the perform keyword followed by paragraph/section name and the number of times you want to execute the logic. Refer to the following example:

   PERFORM [procedure-name]
          {identifier | literal} TIMES
           [statement-1 ...]
   [END-PERFORM].

#1. COBOL PERFORM with TIMES Phrase Example.

In the following example, the B100-DISP-PARA business logic will be executed only 1 time. Refer to the following program snapshot for details program structure. 

*
 PROCEDURE DIVISION.
 A000-MAIN-PARA. 
     PERFORM B100-DISP-PARA 1 TIMES.
*   


COBOL PERFORM Statement, COBOL PERFORM with TIMES phrase

COBOL PERFORM TIMES Phrase.

#2. COBOL PERFORM THRU with TIMES Phrase Example.

In the following example, the B100-DISP-PARA THRU B200-PRNT-NME business logic will be executed only 1 time. 

*
 C000-MAIN-PARA. 
     PERFORM B100-DISP-PARA 
        THRU B200-PRNT-NME   1 TIMES.
*   

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 with TIMES phrase. 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™

Created with Artisteer

No comments:

Post a Comment