Free-Form Procedure Statement

A free-form procedure-beginning statement begins with DCL-PROC, followed by the procedure name, followed by keywords, and finally a semicolon. If there is no prototype for the procedure, and *DCLCASE is specified for the procedure-name parameter of the EXTPROC keyword, then the external name of the procedure is the same as the name specified for the DCL-PROC statement, in the same case.

A free-form procedure-ending statement begins with END-PROC, optionally followed by the procedure name, and finally a semicolon. If the name is specified, it must be the same as the name specified on the procedure-beginning statement.

The only directives that are allowed within a free-form procedure statement are /IF, /ELSEIF, /ELSE, and /ENDIF.

   DCL-PROC getCustName
       /IF DEFINED(EXPORT_ALL_PROCEDURES)
               EXPORT
       /ENDIF
               ;

Examples of procedure statements

  • In the following example, the name is not specified for the END-PROC statement.
    Tip: For large procedures, where you cannot see both the DCL-PROC statement and the END-PROC statement together in your editor, you may find it useful to specify the name on the END-PROC statement.
    
       DCL-PROC cleanup;
          CLOSE *ALL;
          UNLOCK *ALL;
          deleteTempUsrspc();
       END-PROC;
    
  • In the following example, procedure getNextOrder is defined without a prototype. The procedure interface specifies EXTPROC(*DCLCASE)  2 , so the external name of the procedure is "getNextOrder", exactly as specified for the DCL-PROC statement  1 .
    Note: At run-time, you can see the external name in the joblog if the procedure has an error, or in the program stack when you display the job.
    
       DCL-PROC getNextOrder;            1 
          DCL-PI *N IND
                    EXTPROC(*DCLCASE);   2 
             order LIKEDS(order_t);
          END-PI;
    
          DCL-F orders STATIC;
    
          READ orders order;
    
          RETURN %EOF(orders);
       END-PROC getNextOrder;