Mainframe Forum: A comprehensive repository for programming tutorials and technology news. Got a minute? Click upon those blue words to start learning in Cobol, DB2, CICS, JCL, CA7, APIs, DevOps, Agile, JAVA, SORT, Excel macro, python, and mainframe tools.
PERFORM in COBOL or BASIC PERFORM statement in COBOL is primarily used to implements loops in the COBOL programs. In this session, you'll learn the basics of the BASIC PERFORM statement in COBOL.
You'll also learn how to use PERFORM Statement in COBOL programs with the help of an example. Let's get started with today's COBOL Basic PERFORM tutorial.
Agenda.
Introduction.
PERFORM in COBOL.
COBOL PERFORM Statement Variants.
COBOL BASIC PERFORM Statement.
COBOL BASIC PERFORM Syntax
COBOL BASIC PERFORM Examples.
Conclusion
Introduction.
COBOL is a procedural language and it's one of the oldest programming language which is still in use. COBOL is primarily used in large-scale enterprise applications such as banking, healthcare, the aviation industry, etc.
In general, COBOL program logic is group into different paragraphs or sections. COBOL PERFORM statement executes the logic specified in these paragraphs. In nutshell, PERFORM in COBOL is used to control the program flow.
COBOL PERFORM Statements are used for looping, iteration, or sequencing.
PERFORM in COBOL.
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 within 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.
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:
The basic PERFORM statement in COBOL is one of the simplistic variants of the COBOL PERFORM statements. The procedures (i.e. paragraph/sections) referenced in the basic PERFORM statement are executed once and then the control passes to the next executable statement following the PERFORM statement.
It is important to note that a COBOL PERFORM statement must not cause itself to be executed. Such a recursive PERFORM statement can cause unpredictable results.
Now, let's focus on the syntax of BASIC PERFORM Statements.
COBOL BASIC PERFORM Syntax.
The following syntax is the syntax of the basic PERFORM Statement.
COBOL PERFORM Statment Syntax.
COBOL PERFORM Example.
In the following example, B000-OPEN-FILES and C000-CALC-TAX para will be executed one after the other if there is no program failure. Also, the control will move from one statement to the next executable statement mentioned in the paragraph.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
*
PROCEDURE DIVISION.
A000-MAIN-LOGIC.
PERFORM B000-OPEN-FILES.
PERFORM C000-CALC-TAX.
STOP RUN.
*
B000-OPEN-FILES.
...
...
...
C000-CALC-TAX.
...
...
...
COBOL PERFORM THRU Example.
In the following example, B100-INIT-PARA and B100-EXIT para will be executed one after the other if there is no program failure. Also, the control will move from one statement to the next executable statement mentioned in the paragraph.
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 BASIC 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 -
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 COBOLTIMES 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 TIMES Phrase.
#2. COBOL PERFORM THRU with TIMES Phrase Example.
In the following example, the B100-DISP-PARATHRU B200-PRNT-NME business logic will be executed only 1 time.
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 -
Enable GingerCannot connect to Ginger Check your internet connection or reload the browserDisable in this text fieldRephraseRephrase current sentenceEdit in Ginger×Enable GingerCannot connect to Ginger Check your internet connection or reload the browserDisable in this text fieldRephraseRephrase current sentenceEdit in Ginger×