Rule Definition
Because a statically called program is link-edited into the same load module as the calling program, a static call is faster than a dynamic call. A static call is the preferred method if your application does not require the services of the dynamic call.
Remediation
If a subprogram is dynamically called multiple times, then replace the dynamic calls by static calls as much as possible.
Violation Code Sample
IDENTIFICATION DIVISION.
PROGRAM-ID. PROG01.
*----------
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
DECIMAL-POINT IS COMMA.
*----------
DATA DIVISION.
WORKING-STORAGE SECTION.
01 SPGM PIC X(8) VALUE "SUBPGM01".
01 RET-DAT PIC 9(4) VALUE 0.
*----------
LINKAGE SECTION.
01 PARAM.
05 PARAM-F1 PIC X(10).
05 PARAM-F2 PIC 99.
05 PARAM-F3 PIC 9(3).
*----------
PROCEDURE DIVISION
MAIN-PARAGRAPH.
PERFORM PAR-1.
PERFORM PAR-2.
PERFORM PAR-3.
PERFORM PAR-4.
PERFORM PAR-5.
STOP RUN.
PAR-1.
MOVE "NAME" TO PARAM-F1
MOVE 50 TO PARAM-F2.
CALL SPGM USING PARAM.
ADD PARAM-F3 TO RET-DAT.
PAR-2.
MOVE "GRADE" TO PARAM-F1
MOVE 10 TO PARAM-F2.
CALL SPGM USING PARAM.
ADD PARAM-F3 TO RET-DAT.
MOVE "QRY" TO PARAM-F1
MOVE 11 TO PARAM-F2.
CALL SPGM USING PARAM.
PAR-3.
MOVE "DEPT" TO PARAM-F1
MOVE 30 TO PARAM-F2.
CALL SPGM USING PARAM.
ADD PARAM-F3 TO RET-DAT.
MOVE "QRY" TO PARAM-F1
MOVE 31 TO PARAM-F2.
CALL SPGM USING PARAM.
PAR-4.
MOVE SPACES TO PARAM-F1
MOVE 99 TO PARAM-F2.
CALL SPGM USING PARAM.
ADD PARAM-F3 TO RET-DAT.
CANCEL SPGM.
PAR-5.
DISPLAY "RET=" RET-DATA.
MOVE 0 TO PARAM-F2.
Fixed Code Sample
IDENTIFICATION DIVISION.
PROGRAM-ID. PROG01.
*----------
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
DECIMAL-POINT IS COMMA.
*----------
DATA DIVISION.
WORKING-STORAGE SECTION.
01 SPGM PIC X(8) VALUE "SUBPGM01".
01 RET-DAT PIC 9(4) VALUE 0.
*----------
LINKAGE SECTION.
01 PARAM.
05 PARAM-F1 PIC X(10).
05 PARAM-F2 PIC 99.
05 PARAM-F3 PIC 9(3).
*----------
PROCEDURE DIVISION
MAIN-PARAGRAPH.
PERFORM PAR-1.
PERFORM PAR-2.
PERFORM PAR-3.
PERFORM PAR-4.
PERFORM PAR-5.
STOP RUN.
PAR-1.
MOVE "NAME" TO PARAM-F1
MOVE 50 TO PARAM-F2.
CALL "SUBPGM01" USING PARAM.
ADD PARAM-F3 TO RET-DAT.
PAR-2.
MOVE "GRADE" TO PARAM-F1
MOVE 10 TO PARAM-F2.
CALL "SUBPGM01" USING PARAM.
ADD PARAM-F3 TO RET-DAT.
MOVE "QRY" TO PARAM-F1
MOVE 11 TO PARAM-F2.
CALL SPGM USING PARAM.
PAR-3.
MOVE "DEPT" TO PARAM-F1
MOVE 30 TO PARAM-F2.
CALL "SUBPGM01" USING PARAM.
ADD PARAM-F3 TO RET-DAT.
MOVE "QRY" TO PARAM-F1
MOVE 31 TO PARAM-F2.
CALL SPGM USING PARAM.
PAR-4.
MOVE SPACES TO PARAM-F1
MOVE 99 TO PARAM-F2.
CALL "SUBPGM01" USING PARAM.
ADD PARAM-F3 TO RET-DAT.
PAR-5.
DISPLAY "RET=" RET-DATA.
MOVE 0 TO PARAM-F2.
Reference
IBM Enterprise Cobol - Programming Guide
Related Technologies
Technical Criterion
Efficiency - Memory, Network and Disk Space Management
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.