Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 588547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:19:47+00:00 2026-05-13T15:19:47+00:00

How do you go about defining a two-dimensional MxN array in Cobol of which

  • 0

How do you go about defining a two-dimensional MxN array in Cobol of which both M and N are of variable length?

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

COBCH0144S OCCURS DEPENDING subsidiary to OCCURS only allowed with ODOSLIDE
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:19:48+00:00Added an answer on May 13, 2026 at 3:19 pm

    What you are trying to define is a “Complex Occurs Depending On” structure (complex ODO).

    You may define a Complex ODO where the table is rectaguar 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 within 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).
    

    will give you an error because the declaration implies that each row may contain a different
    number of columns (ie. not a rectangular table).

    In general, there is a lot of confusion as to what an ODO structure in COBOL
    really “buys” you. There is a common, but mistaken view, that it may
    be used to save memory
    because the size of the data structure can be dynamically sized. This is
    absolutely false when the ODO is declared under LOCAL or WORKING STORAGE.
    The COBOL compiler will allocate enough memory to accomodate
    the largest value of M and N.

    What it does “buy” you is a mechanism to physically organize data
    in memory. Look at the following program and what
    it displays:

           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
               .
    

    Displays:

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        XXXXXXX   XXXXXXX   XXXXXXX   XXXXXXX   XXXXXXX   XXXXXXX
    

    Notice the ODO version has all of the data nicely compated into
    a 6 X 7 matrix while the fixed table version retains the 10 X 10
    matrix with a bunch of “holes” in it to fill out each
    row to its maximum number of OCCURS. There are times when this
    distinction is important (most often it isn’t though).

    I see you are using Net Express, which I am not familiar with so you
    may have to fiddle around to get the next part to work. With
    IBM Enterprise COBOL for Z/OS you can do the following:

    Define an ODO in the program LINKAGE SECTION so no memory
    is allocated, it is just a record layout. Then you can
    dynamically allocate enough memory for the actual size of table
    needed (ie. M times N elements). Connect the two using
    something like: SET ADDRESS OF ODO-DATA-STRUCTURE TO mem-address
    (under CICS use GETMAIN and under batch use CEEGTST to obtain memory).
    Now you have a dynamic data structure
    that does use the minimum amount of space and will still index properly
    because of the layout propreties illustrated above.

    There are other ways of using (or not using) ODO’s in COBOL but
    these are the most common ones I am aware of.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 360k
  • Answers 360k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Since you are new to Javascript development, I'll try with… May 14, 2026 at 2:40 pm
  • Editorial Team
    Editorial Team added an answer Actually slight improvement on extraneon's answer. Define StatutCode enum first,… May 14, 2026 at 2:40 pm
  • Editorial Team
    Editorial Team added an answer Have you instantiate your dt object? May 14, 2026 at 2:40 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.