Hi,
We have the exact same data.bin file including binary data on an HP-UX machine and a RedHat Linux machine.
- HP-UX(big-endian):
smppru@bayyana:/cralm/simep/prue/Arquitectura/testreadbindata> od -x data.bin | head -1 | nl
1 0000000 0fcc 0000 00bc 0000 f1f6 f4f4 8030 0198
- Linux RedHat(little-endian):
int-cob-d-01u:/cralm/simep/prue/apps/testreadbindata>od -x data.bin | head -1 | nl
1 0000000 cc0f 0000 bc00 0000 f6f1 f4f4 3080 9801
I have created a Cobol program that retrieves two of these binary data in COMP-5 variables and displays them on the screen, thus being able to verify that the binary data is interpreted differently on the HP-UX(big-endian) and Linux(little-endian) platforms.
The code of the executed program is exactly the same on both the HP-UX and Linux platforms:
1 IDENTIFICATION DIVISION.
2 PROGRAM-ID. testreadbindata.
3
4 ENVIRONMENT DIVISION.
5 CONFIGURATION SECTION.
6 SOURCE-COMPUTER. UNIX.
7 OBJECT-COMPUTER. UNIX.
8
9 SPECIAL-NAMES.
10 DECIMAL-POINT IS COMMA.
11
12 INPUT-OUTPUT SECTION.
13
14 FILE-CONTROL.
15 SELECT EPRLVORSE ASSIGN TO "./data.bin".
16
17 DATA DIVISION.
18 FILE SECTION.
19
20 FD EPRLVORSE
21 BLOCK CONTAINS 4096 CHARACTERS.
22
23 01 REG-EPRLVORSE.
24 05 W4096X-EPRLVORSE PIC X(4096).
25
26 WORKING-STORAGE SECTION.
27
28 01 RREG-ENTRADA PIC X(4096).
29 01 REG-ENTRADA REDEFINES RREG-ENTRADA.
30 05 W4P-VLIENT PIC 9(4) COMP-5.
31 05 W4P-FILLER1 PIC 9(4) COMP-5.
32 05 W4P-VLISUB PIC 9(4) COMP-5.
33 05 W4P-FILLER2 PIC 9(4) COMP-5.
34 05 W4088X-RESTO PIC X(4088).
35
36 01 W1X-VLI-AUX PIC X(1).
37
38 01 W4P-VLI-AUX PIC 9(4) COMP-5.
39 01 FILLER-VLI REDEFINES W4P-VLI-AUX.
40 05 W1X-VLIA-1 PIC X(1).
41 05 W1X-VLIA-2 PIC X(1).
42
43 01 W4X-VLI-ACT.
44 05 W4P-VLI-WRK PIC 9(4) COMP-5.
45 05 W4P-FILLER3 PIC 9(4) COMP-5.
46
47 01 W1X-FIN PIC X VALUE '0'.
48 88 FIN-EPRLVORSE VALUE 'F'.
49
50 01 K1XF PIC X VALUE 'F'.
51
52 PROCEDURE DIVISION.
53
54 OPEN INPUT EPRLVORSE.
55
56 READ EPRLVORSE INTO REG-ENTRADA
57 AT END MOVE K1XF TO W1X-FIN
58 NOT AT END
59 DISPLAY 'testreadbindata::W4P-VLIENT: [' W4P-VLIENT '].'.
60 DISPLAY 'testreadbindata::W4P-VLISUB: [' W4P-VLISUB '].'.
61 CLOSE EPRLVORSE.
62 STOP RUN.
The outputs of the testreadbindata program on both platforms are different::
• HP-UX:
smppru@bayyana:/cralm/simep/prue/Arquitectura/testreadbindata> testreadbindata
testreadbindata::W4P-VLIENT: [04044] - 0000 1111 1100 1100(binary) - 0FCC(hex) -> BIG ENDIAN
testreadbindata::W4P-VLISUB: [00188] - 0000 0000 1011 1100(binary) - 00BC(hex) -> BIG ENDIAN
• Linux:
int-cob-d-01u:/cralm/simep/prue/apps/testreadbindata>testreadbindata
testreadbindata::W4P-VLIENT: [52239] - 1100 1100 0000 1111(binary) - CC0F(hex) -> LITTLE ENDIAN
testreadbindata::W4P-VLISUB: [48128] – 1011 1100 0000 0000(binary) - BC00(hex) -> LITTLE ENDIAN
How should we proceed so that the data retrieved by the testreadbindata program on the Linux RedHat platform from the binary file in COMP-5 variables are exactly the same as those retrieved by the testreadbindata program on the HP-UX platform?
Thanks a lot.
Regards.
<------------------------------------------------------------------------------------------------------------------------------>
Platform information:
• HP-UX:
smppru@bayyana:/opt/microfocus/cobol/etc> cat cobver
ServerExpress cobol v5.1.00
PRN=RXCAQ/AAP:9p.k5.51.07
PTI=WrapPack 6
PTI=ES
smppru@bayyana:/opt/microfocus/cobol/etc> uname -a
HP-UX bayyana B.11.31 U ia64 0804249662 unlimited-user license
• Linux:
int-cob-d-01u:/cralm/simep/prue/uxna/bdon>cat $COBDIR/etc/cobver
Visual cobol v7.0.0
PRN=K1CRH/AAK:Ao.U4.13.04
PTI=32/64 bit
PTI=Micro Focus COBOL Server 7.0 - Patch Update 08
PTI=Patch Update 08
PTI=pkg_303630
PTI=MFInstaller
int-cob-d-01u:/cralm/simep/prue/uxna/bdon>cat /etc/os-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.9 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.9"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.9 (Maipo)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.9:GA:server"
HOME_URL="">https://www.redhat.com/"
BUG_REPORT_URL="">bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION=7.9
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="7.9"




