Block comment Uncomment COBOL Statements:

 

Comment/Un comment Multiple lines in COBOL code

This tool can come handy if you have to do a lot of commenting and un commenting in a COBOL module. Doing it manually is not my way so here's another freebie for all you guys hungry for mainframe tools.

To use this clist you need to copy the code in a PDS allocated to Sysproc and then issue a "command line command" CCOM with parameters ON/OFF for commenting/un commenting respectively, and issue a "line command"

V- Single line command

Vn - n is the number of lines to be commented/uncommented

VV- It is a block command, the lines between a block will be commented / un commented.

/**********************************************************************
/* TITLE      : CCOM
/*-------------------------------------------------------------------
/* FUNCTION   : TO BLOCK COMMENT OR UNCOMMENT COBOL STATEMENTS
/*-------------------------------------------------------------------
/* AUTHOR     : mainframewizard.com
/*-------------------------------------------------------------------
/* DESCRIPTION: THIS CLIST COMMENTS OR UNCOMMENTS THE DESIRED NUMBER
/*            : OF COBOL STATEMENTS.
/*            :
/*            :
/*-------------------------------------------------------------------
/* HOW TO RUN : COPY THIS MEMBER TO THE PDS ALLOCATED TO SYSPROC. OPEN
/*            : THE COBOL PROGRAM YOU WISH TO COMMENT OR UNCOMMENT.
/*            : TYPE 'CCOM' WITH PARMETER ON/OFF FOR COMMENTING AND
/*            : UNCOMMENTING RESPECTIVELY ON THE COMMAND LINE AND GIVE
/*            : ANY OF THE COMMANDS V,VN,VV AT THE LINE COMMAND AREA
/*            : WHERE V IS A SINGLE LINE COMMAND, N IS THE NUMBER TO BE
/*            : GIVEN TO COMMENT N NUMBER OF LINES, VV IS BLOCK COMMAND
/*            : YOU CAN USE THIS AS ANY OTHER LINE COMMAND LIKE C,R,M
/*-------------------------------------------------------------------
/**********************************************************************
ISREDIT MACRO (PARM1) NOPROCESS
ISPEXEC CONTROL ERRORS RETURN
ISREDIT PROCESS RANGE V
IF &LASTCC >= 16 THEN EXIT CODE(&LASTCC)
  ISREDIT (CMD) = RANGE_CMD
ISREDIT FIND 'IDENTIFICATION DIVISION' ALL
/**********************************************************************
/********* VALIDATING THAT IT IS A COBOL PROGRAM BEFORE RUNNING*********
/**********************************************************************
IF &LASTCC NE 0 THEN +
DO
SET &ZEDSMSG = &STR(NOT VALID COBOL)
ISPEXEC SETMSG MSG(ISRZ001)
GOTO ENDCLIST
END
/**********************************************************************
/*STORING FIRST AND LAST LINE NUMBERS
/**********************************************************************
ISREDIT (FIRST) = LINENUM .ZFRANGE
ISREDIT (LAST) = LINENUM .ZLRANGE
/**********************************************************************
/*GETTING TOTAL NO OF LINES
/**********************************************************************
SET TOT_LINES=&LAST - &FIRST + 1
 IF &STR(&CMD) =  THEN +
   DO
    SET &ZEDSMSG = &STR(LINE COMMAND 'V' PENDING)
    ISPEXEC SETMSG MSG(ISRZ001)
    EXIT CODE(12)
   END
 IF &STR(&CMD) = &STR(V) THEN +
   DO
    ISREDIT X  '*' 7 .ZFRANGE .ZLRANGE ALL
    ISREDIT (EXLN,EXCNT) = EXCLUDE_COUNTS
     IF &PARM1=ON | &PARM1= THEN +
       DO
        IF &EXCNT=&TOT_LINES THEN +
          DO
           SET &ZEDSMSG = &STR(LINES UNCOMMENTED)
           ISPEXEC SETMSG MSG(ISRZ001)
           ISREDIT C '*' ' ' 7 .ZFRANGE .ZLRANGE ALL
           ISREDIT RESET
           ISREDIT LOCATE .ZFRANGE
           EXIT CODE(1)
          END
        SET &ROWNO=&FIRST
          DO WHILE &ROWNO<&EVAL(&LAST+1)
                /*WRITE LINENUM-- &ROWNO RC--&ERR
                ISREDIT LINE &EVAL(&ROWNO) = LINE + <7 '*'>
            SET ROWNO= &EVAL(&ROWNO +1)
          END
           SET &ZEDSMSG = &STR(LINES COMMENTED)
           ISPEXEC SETMSG MSG(ISRZ001)
       END
     IF &PARM1=OFF THEN +
       ISREDIT C '*' ' ' 7 .ZFRANGE .ZLRANGE ALL
       ISREDIT RESET
       ISREDIT LOCATE .ZFRANGE
   END
EXIT CODE(1)
END
ENDCLIST: +
ISREDIT LOCATE .ZFRANGE
ISREDIT RESET
EXIT CODE(1)
END

 

CLIST on similar lines to comment/uncomment JCL and SQL to follow soon.....

 

Please provide your feedback/suggestions regarding this tutorial on contact form. Tutorials related to COBOL, JCL, DB2 etc are also present on the Website for mainframe developers. Mainframe jobs can be posted on our mainframe jobs forum.