2

I was studying COBOL code and I did not understand the number at the right of the code line:

007900     03  EXAMPLE-NAME       PIC S9(17)  COMP-3.              EB813597

the first number is about position of that line in code, the second is about column's position (like how many 'tabs' you are using), the third is type of variable, but the fourth (COMP-3) and mainly the last (EB813597) I did not understand.

What does it mean?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • 1
    For `COMP-3` see https://stackoverflow.com/a/799500/9170346. The `EB813597` is treated as a comment and has no meaning in the COBOL language. – Rick Smith May 17 '18 at 20:51
  • Thanks @RickSmith – Humberto Fialho May 18 '18 at 11:51
  • I've seen a lot of rubble like this EB813597 in old code where it was used to follow changes in the code. If your shop does follow the changes another way(probably more modern source management tools like endevor), then it can be get rid of without pity. – gazzz0x2z May 21 '18 at 12:56

1 Answers1

2

Columns >= 72 are ignored. So EB813597 is ignored. It could be a change id from the last time it was changed or have some site specific meaning e.g. EB could be the initials of the person who last changed it.

Comp-3 - is the type of numeric. It is bit like using int or double in C/java. In Comp-3 (packed-decimal) 123 is stored as x'123c'. Alternatives to comp-3 include comp - normally big endian binary integer, comp-5 (like int / long in C)

007900     03  EXAMPLE-NAME       PIC S9(17)  COMP-3.              EB813597
 (a)      (b)  Field-Name         (c)  (d)    Usage (numeric type)


a - line-number ignored by the compiler
b - level-number it provides a method of grouping fields together

      01  Group.
          03 Field-1 ...
          03 Field-2 ... 

    field-1 and field-2 belong to group. it is a bit like struct in c

        struct {
            int field_1;
            int field-2;
            ...
       }
c) PIC (picture) tells us the field picture follows.
d) fields picture in this case it is a signed field with 17 decimal digits
Comp-3 - usage - how the field stored

So in summary EXAMPLE-NAME is a Signed numeric field with 17 decimal digits and it is stored as Comp-3 (packed decimal).

Bruce Martin
  • 10,358
  • 1
  • 27
  • 38
  • Nice answer @BruceMartin ! It was clear, objective, simple and answered questions perfectly. Thank you so much! – Humberto Fialho May 18 '18 at 11:46
  • 1
    also sometimes if you are using a code generator (like NETRON) it will add tags to the far right that are relevant. In NETRON, the name of frame the code was pulled from will be placed in those columns far to the right. – SaggingRufus May 22 '18 at 15:02