In your structured program, you control the flow of the program with loops and decisions that are controlled by conditional statements.
For looping (repeating the same code), use one of the forms of the PERFORM statement. You can use the PERFORM statement to control the looping with a definite number or with a decision. PERFORM statements can be in-line or out-of-line. Use the PERFORM statement to execute a paragraph and then implicitly return control to the next executable statement. In effect, the PERFORM statement is a way of specifying a closed subroutine that you can enter from many different parts of the program.
Coding a Loop to Be Executed a Definite Number of Times
Use the PERFORM ... TIMES statement to execute a paragraph a specified number of times:
When the control reaches the PERFORM statement, the code for the paragraph 010-PROCESS-ONE-MONTH is executed 12 times before control is transferred to the INSPECT statement. Conditional Looping
Use the PERFORM . . . UNTIL statement to execute a paragraph until a condition you specify is satisfied. You can use either of the following forms:
In the following example, the implicit TEST BEFORE phrase provides a 'DO-WHILE' structure.
When control reaches the PERFORM statement, the condition (MONTH EQUAL DECEMBER) is tested. If it is satisfied, control is transferred to the INSPECT statement. If it is not satisfied, 010-PROCESS-ONE-MONTH is executed, and the condition is tested again. This cycle continues until the condition tests as true. (To make your program easier to read, you may want to code the WITH TEST BEFORE clause.) Use the PERFORM ... WITH TEST AFTER . . . UNTIL if you want to execute the paragraph at least once and then test before any subsequent execution. This is equivalent to the "do-until" structure. Looping through a Table
Use the PERFORM statement to control a loop through a table. You can use either of the following forms:
For example, use PERFORM . . . VARYING to initialize the table. In this form, a variable is increased or decreased and tested until a condition is satisfied. Executing a Group of Paragraphs or Sections
In structured programming, the paragraph you execute is usually a single paragraph. However, you can execute a group of paragraphs, a single section, or a group of sections using the PERFORM . . . THRU statement.
When you use PERFORM . . . THRU, use a paragraph-EXIT statement to clearly indicate the end point for the series of paragraphs.
IBM Mainframe Related Interview Questions
|IBM Lotus Notes Interview Questions||IBM-CICS Interview Questions|
|COBOL Interview Questions||Linux Interview Questions|
|IBM-JCL Interview Questions||IBM Mainframe Interview Questions|
|IBM AIX Interview Questions||IBM WAS Administration Interview Questions|
|IBM Lotus Domino Interview Questions||IBM Integration Bus Interview Questions|
|Mainframe DB2 Interview Questions||Unix Production Support Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.