Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Overlapping PERFORM...THRU...EXIT

Overlapping PERFORM...THRU...EXIT

Problem:

My program appears to be losing its ability to perform thru exit. It falls to the next para instead of returning to the location where it was performed from. .

Resolution:

This customer's program presumably has some mainframe heritage, and was coded in such a way as to rely on implementation-specific behaviour that the mainframe gives. 

Fortunately we can emulate this behavior using the checker directive PERFORM-TYPE(OSVS).

It specifies the behavior of return jumps from nested PERFORM statements.

PERFORM-TYPE"OSVS" provides compatibility with the mainframe behavior of OS/VS COBOL and DOS/VS COBOL.

The following program demonstrates having an inner PERFORM (paragraph TESTER) fall into a new SECTION instead of returning to the controlling SECTION: 

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PROGRAM1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  COUNTER           PIC 9       VALUE 0.
       01  SUB               PIC 9.

       PROCEDURE DIVISION.
       MAIN SECTION.
       BEGIN.
           PERFORM PROCESS
           DISPLAY "NORMAL TERMINATION"
           STOP RUN.
     
       PROCESS SECTION.
           DISPLAY "STARTING PROCESS SECTION".

       PROCESS-LOOP.
           PERFORM TESTER VARYING SUB FROM 1 BY 1 UNTIL SUB >= 10
           GO TO PROCESS-EXIT.     
       TESTER.
           IF (COUNTER = 6) 
               GO TO PROCESS-EXIT
           ELSE 
               ADD 1 TO COUNTER
           END-IF.
       PROCESS-EXIT.
           EXIT.
     
       FALL-THROUGH SECTION.
       ALERT.
           DISPLAY "*** FALL THROUGH CODE ***"
           STOP RUN.
       END PROGRAM PROGRAM1.


The program falls through when compiled using cob -vug Program1.cbl 
[support@rhsupv2 100500]$ cobrun Program1
STARTING PROCESS SECTION
*** FALL THROUGH CODE ***

The program succeeds when compiled using cob -vug demo.cbl  -C'PERFORM-TYPE(OSVS)'
[support@rhsupv2 100500]$ cobrun Program1
STARTING PROCESS SECTION
NORMAL TERMINATION

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2014-12-16 13:56
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.