Reputation: 45
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?
Upvotes: 2
Views: 163
Reputation: 10543
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).
Upvotes: 2