MainframeMaster

COBOL Tutorial

COBOL BINARY-CHAR

The BINARY-CHAR data type in COBOL represents a specialized numeric format designed for seamless interoperability with C programming language applications, specifically matching the size and characteristics of C's char data type.

Understanding BINARY-CHAR

BINARY-CHAR matches the C language's 'char' data type, typically 8 bits (1 byte). This ensures perfect data compatibility when interfacing with C functions.

Key Characteristics:

  • Single byte storage (8 bits)
  • Range: 0-255 (unsigned) or -128 to 127 (signed)
  • Perfect C char compatibility
  • Ideal for status codes and flags
cobol
1
2
3
4
5
6
7
8
9
DATA DIVISION. WORKING-STORAGE SECTION. 01 STATUS-FLAGS. 05 ERROR-CODE USAGE BINARY-CHAR. 05 OPERATION-MODE USAGE BINARY-CHAR. PROCEDURE DIVISION. MOVE 0 TO ERROR-CODE. CALL "c_function" USING BY VALUE ERROR-CODE.