ROUTINE and PERFORM

You may wish to write some of your logic in a paragraph to make your program easier to understand, or to use this logic in more than one place. You can do this using PERFORM and ROUTINE.

††† PERFORM PROCESS-INPUT;

Ö

ROUTINE PROCESS-INPUT;

††† IF eibcalen = 0 THEN;

††††††† SEND Custnqry CLEAR;

††† END IF;

END ROUTINE;

 

COBOL programmers will be familiar with ROUTINE and PERFORM from COBOL as they follow similar rules to COBOLís PERFORM. Unlike COBOL, in Jazz a ROUTINE can be passed parameters by the PERFORM. However, unlike a subprogram that is invoked with CALL etc, a ROUTINE does not have any local data except for the parameters, so that a DEFINE written within a ROUTINE is known to all following statements, including those coming after END ROUTINE;

 

The PERFORM statement may be written anywhere, including within the scope of logical-control statements like IF and FOR, within another Paragraph, and so on. When executed, control is passed to the first statement following the PERFORM statement. When the Paragraph has finished executing, control is passed back to the statement following the PERFORM statement.

 

ROUTINE will be written later in the program: it must not be within IF, FOR, etc, nor within another ROUTINE.

 

A feature of Jazz is that copy books may contain both DEFINE statements and procedural code, allowing you to write a single COPY with both the data structures and the logic to perform a function. Such procedural code should be written within a ROUTINE.