PERFORM will be useful when you want to execute a set of statements in multiple places of the program. Write all the statements in one paragraph and invoke it using PERFORM wherever needed. Once the paragraph is executed, the control comes back to next statement following the PERFORM.
1.SIMPLE PERFORM. PERFORM PARA-1. DISPLAY PARA-1 executed STOP RUN. PARA-1. Statement1 Statement2. It executes all the instructions coded in PARA-1 and then transfers the control to the next instruction in sequence.
2.INLINE PERFORM. When sets of statements are used only in one place then we can group all of them within PERFORM END-PERFORM structure. This is called INLINE PERFORM. This is equal to DO..END structure of other languages. PERFORM ADD A TO B MULTIPLE B BY C DISPLAY VALUE OF A+B*C C END-PERFORM
3. PERFORM PARA-1 THRU PARA-N. All the paragraphs between PARA-1 and PARA-N are executed once.
4. PERFORM PARA-1 THRU PARA-N UNTIL condition(s). The identifiers used in the UNTIL condition(s) must be altered within the paragraph(s) being performed; otherwise the paragraphs will be performed indefinitely. If the condition in the UNTIL clause is met at first time of execution, then named paragraph(s) will not be executed at all.
5. PERFORM PARA-1 THRU PARA-N N TIMES. N can be literal defined as numeric item in working storage or hard coded constant.
6. PERFORM PARA-1 THRU PARA-N VARYING identifier1 FROM identifier 2 BY identifier3 UNTIL condition(s) Initialize identifier1 with identifier2 and test the condition(s). If the condition is false execute the statements in PARA-1 thru PARA-N and increment identifier1 BY identifier3 and check the condition(s) again. If the condition is again false, repeat this process till the condition is satisfied.
7.PERFORM PARA-1 WITH TEST BEFORE/AFTER UNTIL condition(s). With TEST BEFORE, Condition is checked first and if it found false, then PARA-1 is executed and this is the default. (Functions like DO- WHILE) With TEST AFTER, PARA-1 is executed once and then the condition is checked. (Functions like DO-UNTIL)