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 -
No comments:
Post a Comment