In a CA Easytrieve Program, how do I correctly code the value assigned to a BINARY field when passing to a COBOL program?

Document ID : KB000016199
Last Modified Date : 14/02/2018
Show Technical Document Details
Question:

In the CA Easytrieve program, the field passed to COBOL is defined as a type 'U', which is an unsigned packed decimal field. The value 20 is stored as x'00000020'. In the COBOL pgm, you declared it as PIC S9(8) COMP, which is a 4 byte integer. Integer value of x'00000020' is 32. 

How can I get the correct value assigned to a BINARY field when passing to a COBOL program?

Answer:

In the CA Easytrieve Program, you should declare it as type 'I'.

Please Note:
Type 'I' is an integer in new function mode.
In compatibility mode, a 4 byte binary value has type: 4 B
The 4 B type is valid in new function mode as well.