sizecobolcicscommarea

How to set the size of the COMMAREA in a Cobol program for Kicks under VM/370CE?


I'm working on a Cobol program for Kicks under VM/370CE V1R1.2. I followed the Youtube tutorial from Moshix and Rene Ferland and it works well, but now I want my programs to communicate with each other, and to achieve this goal I need a way to set the size of the COMMAREA.

If the LINKAGE SECTION is not explicitely declared, the k2kcobcl command (which invokes the preprocessor and the compiler) generates something like this:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
       LINKAGE SECTION.
       COPY KIKEIB.
       01  KIKCOMMAREA PIC X.
       PROCEDURE DIVISION USING
              KIKEIB,
              KIKCOMMAREA.

As you can see, the COMMAREA is one byte long (PIC X), which is not enough in my case.

As stated in the Kicks documentation:

the preprocessor adds a copy for the KIKEIB copy book to the LINKAGE SECTION of your program (and creates a LINKAGE SECTION if necessary) and (like CICS) the EIB is always the first argument of the USING clause the KICKS processor adds to your program’s PROCEDURE DIVISION statement

the COMMAREA is like the EIB; it is added to the USING clause of your program by the preprocessor when you code an 01 for KIKCOMMAREA (or DFHCOMMAREA) in its LINKAGE SECTION

The second quote lets us think it is possible to declare the COMMAREA explicitely, meaning that we should be able to set a custom PICTURE like so:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
       LINKAGE SECTION.
           01 DFHCOMMAREA PIC X(8).
       PROCEDURE DIVISION. 

Unfortunately, it doesn't work with Kicks under VM/370CE V1R1.2. Indeed, declaring the COMMAREA leads to the compilation error "LINKAGE SECTION DEFINED BUT EMPTY".

I have made a few attempts to bypass this error, including the following ones.

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
       LINKAGE SECTION.
           01 DFHCOMMAREA PIC X(8).
       PROCEDURE DIVISION USING
              DFHCOMMAREA.
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
       LINKAGE SECTION.
       COPY DFHEIB.
           01 DFHCOMMAREA PIC X(8).
       PROCEDURE DIVISION USING
              DFHEIB,
              DFHCOMMAREA.
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
       LINKAGE SECTION.
       COPY DFHEIB.
           01 DFHCOMMAREA PIC X(8).
       PROCEDURE DIVISION.

The first two attempts lead to compilation errors, and the last one compiles successfully, but the preprocessor produces the following output (the preprocessor replaces "DFH" with "KIK").

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
       LINKAGE SECTION.
       COPY KIKEIB.
           01 KIKCOMMAREA PIC X(8).
       PROCEDURE DIVISION USING
              KIKEIB.

Again, the COMMAREA is not added to the USING clause, which makes it unusable.

Maybe I'm missing something. Do you know if there is any recommended way to set the size of the COMMAREA regarding Kicks under VM/370CE V1R1.2?


Solution

  • After hours of research (I actually installed Kicks under MVS/TK4-, which required rebuilding Hercules, and before that I failed to install it under MVS/TK5! Exhausting journey, lol!), I finally found that you have to declare the COMMAREA in margin A (column 8) with 2 spaces between 01 and DFHCOMMAREA!

    ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
           LINKAGE SECTION.
           01  DFHCOMMAREA PIC X(8).
           PROCEDURE DIVISION.
    

    The preprocessor is rather strict!