How to convert a COBOL file with comp-3

ADegeneffe Posted messages 2 Status Member -  
KX Posted messages 19031 Status Moderator -
Hello.
I have a COBOL file (on Windows) from an old BS2000 system with fields declared in COMP-3 format.
On Windows, this file is partially unreadable where there are COMP-3 fields.
How can I make it fully readable?
Thank you in advance.

3 answers

  1. KX Posted messages 19031 Status Moderator 3 020
     
    The COMP-3 is a fixed-point format with one digit per quartet (the last one reserved for the sign, C or D).
    To make the data readable, it should be converted, for example, to hexadecimal:

    Examples in PIC S9(5)V99:

    +123 : 00 12 30 0C -456 : 00 45 60 0D 7.89 : 00 00 78 9C

    --
    Trust does not exclude control.
    0
  2. ADegeneffe Posted messages 2 Status Member
     
    I completely agree that they should be converted.
    Does a tool exist that allows me to convert the file containing formats X, 9, and comp-3?
    0
  3. KX Posted messages 19031 Status Moderator 3 020
     
    "The file contains X, 9, and comp-3 formats"
    Not exactly, the file only contains bytes, it's your Cobol program that interprets the data as this or that, and sometimes we can even have Xs at the same time as 9s, when using REDEFINES for example. Thus, the byte series "45 6D" can represent the values -4.56, -45.6, -456, or "Em" depending on whether we have a PIC S9V99 COMP-3, PIC S9(2)V9 COMP-3, PIC S9(3) COMP-3, or PIC X(2) in ASCII.

    In fact, a file is never really readable other than by the COBOL file itself, that's why hexadecimal display is an intermediate solution, as it allows data to be readable without interpreting it, which would be a risky exercise...

    Note: you say you can read the PIC X part under Windows, this means that the COBOL implementation uses ASCII characters, however, this is not the rule, IBM systems, for example, use EBCDIC, therefore the PIC X would also be unreadable, except in hexadecimal where their interpretation would be immediate.
    --
    Trust does not exclude control
    0