Two-dimensional variable length array in Cobol

How are you going to define a two-dimensional array of MxN in Cobol, of which M and N are of variable length?

Here's the message I get in Net Express when I try to have a variable array inside another:

COBCH0144S OCCURS DEPENDING subsidiary to OCCURS only allowed with ODOSLIDE
+3
source share
2 answers

What you are trying to determine is the "Complex Occurs Within On" (ODO) structure.

You can define a complex ODO where the table is straight, as follows:


       01  TABLE-REC.
05 M PIC S9(4) BINARY. 05 N PIC S9(4) BINARY. 05 ROWS OCCURS 10 TIMES DEPENDING ON M. 10 COLUMNS OCCURS 10 TIMES DEPENDING ON N. 20 CELL PIC X(1).

The trick is that the declaration of N cannot occur inside the variable part of the table. For example, the following declaration:


       01  TABLE-REC.
           05  M             PIC S9(4) BINARY.
           05  ROWS OCCURS 1 TO 10 TIMES DEPENDING ON M.
               10 N          PIC S9(4) BINARY
               10 COLUMNS OCCURS 1 TO 10 TIMES DEPENDING ON N.
                  20 CELL PIC X(1).

, , (.. ).

, , ODO COBOL "" . , , . , ODO . COBOL M N.

"", . :


       IDENTIFICATION DIVISION.
         PROGRAM-ID. EXODO.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       77  I                 PIC S9(4) BINARY.
       77  J                 PIC S9(4) BINARY.
       01  DIMENSIONS.
           05  M             PIC S9(4) BINARY VALUE 6.
           05  N             PIC S9(4) BINARY VALUE 7.
       01  TABLE-REC-1.
           05  ROWS OCCURS 1 TO 10 TIMES DEPENDING ON M.
               10 COLUMNS OCCURS 1 TO 10 TIMES DEPENDING ON N.
                  20 CELL PIC X(1).
       01  TABLE-REC-2.
           05  ROWS OCCURS 10 TIMES.
               10 COLUMNS OCCURS 10 TIMES.
                  20 CELL PIC X(1).
       PROCEDURE DIVISION.
           PERFORM VARYING I FROM 1 BY 1 UNTIL I > M
              PERFORM VARYING J FROM 1 BY 1 UNTIL J > N
                 MOVE 'X' TO CELL OF TABLE-REC-1 (I J)
                 MOVE 'X' TO CELL OF TABLE-REC-2 (I J)
              END-PERFORM
           END-PERFORM
           DISPLAY TABLE-REC-1
           DISPLAY TABLE-REC-2
           GOBACK
           .

:


    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXX   XXXXXXX   XXXXXXX   XXXXXXX   XXXXXXX   XXXXXXX

, ODO , 6 X 7, 10 X 10 "" OCCURS. , ( ).

, Net Express, , , , . IBM Enterprise COBOL Z/OS :

ODO LINKAGE SECTION, , . (.. N ). , - : SET ADDRESS OF ODO-DATA-STRUCTURE TO mem-address ( CICS GETMAIN CEEGTST ). - - .

( ) ODO COBOL, , .

+5

, OCCURS.. , .

+1

Source: https://habr.com/ru/post/1729936/


All Articles