ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Skipping a level in the data division

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Skipping a level in the data division

    I saw something today I've never seen before.

    Code:
    01  aaa.
            03 bbb    pic xx.
        02  ccc.
            03   ddd    pic xxx.
            03   eee    pic xxx.
        02  fff.
            03  ggg     pic x.
            03  hhh     pic x.
    I didn't realize the compiler would allow a lower-level (bbb) before a higher one (ccc). Apparently it treats it as if the programmer had coded an 02 filler after aaa. It seems like sloppy programming to me. What do you think?

  • #2
    Re: Skipping a level in the data division

    It's a potential problem for future maintenance, but it's valid. Levels from 02 through 49 have no intrinsic meaning except when a level number is higher than the immediately preceding level number, thereby making it subordinate. As I understand it, the qualification by names is what's really important; and level numbers guide the resolution of that qualification.

    The 03-item is effectively logically at the same level as the 02-items. Perhaps there was a 02-group at one time that included that 03-item, and when it was removed, the 03-item was left by mistake. A future developer might never know the intention whether on purpose or by mistake. If on purpose, a reason comment should explain the point.

    IMO, if the indentation is accurate, the best that can be said is that it provides a visual clue.
    Tom

    There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

    Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

    Comment


    • #3
      Re: Skipping a level in the data division

      Thanks, Tom.

      Now I understand what he did. He put all the elementary items at the 03 level and used the 02 levels to group related fields, something like this:

      Code:
      01  Employee-record.
              03 Clock               pic x(5).
      	03 Name                pic x(20).
          02  Address.
              03   City              pic x(15).
              03   State-code        pic xx.
      	03   Zip-code          pic x(10).
          02  Payroll-information.
              03  Marital-status     pic x.
              03  Dependents         pic s99.
              03  Additional-federal pic s9(5)v99.
      He could have omitted the 02 levels and it wouldn't have made any difference.

      I truly learn something new every day.

      Comment

      Working...
      X