3. Embedded QUEL for COBOL : Precompiling, Compiling, and Linking an EQUEL Program : Coding Requirements for Writing EQUEL Programs : Embedding Statements In IF and PERFORM Blocks
 
Share this page                  
Embedding Statements In IF and PERFORM Blocks
The preprocessor can produce several COBOL statements for a single EQUEL statement. In most circumstances, you can simply nest the statements in the scope of a COBOL IF or PERFORM statement.
There are some EQUEL statements for which the preprocessor generates COBOL paragraphs and paragraph names. These statements are:
retrieve
display
formdata
unloadtable
submenu
These statements cannot be nested in the scope of a COBOL IF or PERFORM statement because of the paragraph names the preprocessor generates for them.
Another consequence of these generated paragraphs is that they can terminate the scope of a local COBOL paragraph, thus modifying the intended flow of control. For example, a paragraph generated by the preprocessor in a source paragraph can cause the program to return prematurely to the statement following the PERFORM statement that called the source paragraph. To ensure that control does not return prematurely, you must use the THROUGH clause in the PERFORM statement.
The following example demonstrates the use of PERFORM-THROUGH and an EXIT paragraph to force correct control flow:
UNIX:
DATA DIVISION.
WORKING-STORAGE SECTION.

##  01    ENAME         PIC X(20).
##  DECLARE

    PROCEDURE DIVISION.
    BEGIN.

*  Initialization of program

*  Note the THROUGH clause to ensure correct control
*  flow.
     PERFORM UNLOAD-TAB THROUGH END-UNLOAD.

* User code

    UNLOAD-TAB.
* This paragraph includes a paragraph generated by the
* preprocessor

##   UNLOADTABLE Empform Employee (ENAME = Lastname) 
##   {
##       APPEND TO person (name = ENAME)
##   }

* This paragraph-name and EXIT statement causes control
* to pass back to the caller's scope
     END-UNLOAD.
        EXIT.  

VMS:
* This paragraph-name causes control to pass back to 
* the callers scope
END-UNLOAD.
USER-PARAGRAPH.
*Program continues