COBOL Data Types

Data Types in COBOL

Data Types – Denoted by PICTURE (PIC) clause.

PIC clause provides the data type along with a length

1) Numeric – 0 to 9, maximum length is 18. Denoted by 9

2) Alphabet – A to Z, a to z or Space, maximum length is 255. It denotes ‘A’

3) Alphanumeric – Combination of numeric and alphabet. Denoted by ‘X’

These are 3 main data types in Cobol. We can use Numeric data types with other data types(picture clause) as well

We will cover all these in detail here –

Numeric and other data types we use with numeric data types 

a) 9 –> Numeric – 0-9. Maximum length is 18. This holds actual memory space. Example PIC 9(2)

b) S –> Sign data type – It links a sign to a number. If this is present, the number is signed number. If this is not present, the number is an unsigned number.

c) + sign -> Plus sign. Used to print (+) as sign

d) – Sign –> Minus sign. Used to print (-) as sign

e)  V –> Implied Decimal. Does not hold any memory space. Because it is not used to display but it is useful for computation.

     Example: PIC 9(4)V99   –

  If the Value of this variable is defined as 123456, then it is like 1234.56 but it will not be displayed like 1234.56. If we use this in computation, the value will be 1234.56 and this will take part in computation

f). (Dot)–> Actual decimal point. Used for display, not for calculation or an arithmetic operation

     Example: PIC 9(4).99.

If the value is 123456, then it will display as 1234.56 but we can’t use this for computation

g)  Z –> Used to suppress only the leading Zeros with blanks. Does not do anything with non-zero

     Example: PIC ZZ99.99,

if we pass the value to this variable 0012.34 then it will display like bb12.34

h)  Comma –> To insert a comma into the data item at a particular position

i)   $ -> Dollar symbol – To insert a dollar sign at the first position. we normally use this for currency

Tutorials for all brains!