Search code examples
adsmainframe

CA ADS: 3 digits in a pic 9(2) comp field


Strange thing here. During my test of an ADS dialog, numeric value 120 was moved to an index field which was defined as a PIC 9(2) COMP field.

A bit further a field with that index was referenced like this:

Move Field(index) to FIELD2.

‘Index’ was defined as PIC 9(2) COMP and before value 120 was moved to index. The dialog didn’t abended. How come? Do i have to worry about this? Whats the value of ‘index’ after the move of 120???

Thanks


Solution

  • I am presuming PIC 9(2) COMP is the same in CA ADS as in Cobol !!!

    The answer lies in

    • How PIC 9(2) COMP is implemented
    • Compiler options used

    Implementation of PIC 9(2) COMP

    A PIC 9(2) COMP will typically be allocated as either a 1 byte of 2 byte binary integer. A

    • A 1 byte binary integer can represent -128 --> 127 (or 0 --> 255 if a unsigned int is used)
    • A 2 byte binary integer can represent -32000 --> 32000 (or 0 --> 64000 if a unsigned int is used)

    So a PIC 9(2) COMP can store 120.


    Compilers

    Most (if not all) Cobol compilers have the option to check/correct Comp overflows but these options are often switched off to improve performance. I presume it is the same for CA ADS.