Highlighted
Absent Member.
Absent Member.
1826 views

Sequential file I/O - 'strange' Output result

Jump to solution

I was a COBOL-programmer between 1989 and 1995
Started with MF COBOL / Eclipse a few days ago

Got strange behaviour and can not find any explanation in the manuals/website

Just some test program to get the COBOL-feeling again ...

Input is ASCII TXT file on MS-Windows 8.1 = 13 chars + CR/LF = 15

Output of first line is 13 chars + CR/LF = 15
following records are 5 spaces + 13 chars + CR/LF = 20

First line of output is correct data (13 chars) but record length = 15, not 20 as supposed to be by the record description outfile-record   (part A and B)

Why ?

Best regards,

J.M. Lietaer

Input is  (data + CR/LF = 15 chars)

test line 001
test line 002
test line 003
test line 004
test line 005
+ CR/LF

Output is  (data + CR/LF = 20 chars)

test line 001
     test line 002
     test line 003
     test line 004
     test line 005
+ 5 spaces and CR/LF

COBOL -program is ...

******************************************************************

IDENTIFICATION DIVISION.

PROGRAM-ID. HELLO as "hello".
AUTHOR. J M Lietaer.
DATE-WRITTEN. 19 AUG 2014 / 20 AUG 2014.

******************************************************************

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

INPUT-OUTPUT SECTION.

FILE-CONTROL.
SELECT infile
ASSIGN 'c:\data\cobol\workspace\hello\file.in'
ORGANIZATION SEQUENTIAL.
SELECT outfile
ASSIGN 'c:\data\cobol\workspace\hello\file.out'
ORGANIZATION SEQUENTIAL.

******************************************************************

DATA DIVISION.

FILE SECTION.
fd infile.
01 infile-record pic x(15).
fd outfile.
01 outfile-record.
03 outfile-record-A pic x(15).
03 outfile-record-B pic x(5).

WORKING-STORAGE SECTION.
01 vInput pic x(16).
01 _CMD PIC X(3).
88 _CMD_END VALUE 'END'.
01 _FS PIC 9 value 0.
88 _EOF VALUE 1.

******************************************************************

PROCEDURE DIVISION.

******************************************************************
* MAIN PROGRAM FLOW
******************************************************************

MPF.
perform para_start.
perform para_loop until _CMD_END.
perform para_stop.

para_start.
display "Hello !" at 1108.

para_loop.
perform para_input.

if _CMD = 'IO'
perform para_io
end-if.

para_stop.
display spaces upon crt.
display "* * * E N D O F P R O G R A M * * *"
at 1217
foreground-color is 12.
display " " at 2520.

stop run.

******************************************************************
* SUBROUTINES
******************************************************************

para_input.
move spaces to vinput.
display 'Input : ' at 0205.
accept vInput at 0220
background-color is 2
foreground-color is 10.
move function upper-case(vinput) to _CMD.
display _CMD at 0420.

para_io.
open input infile.
open output outfile.
perform para_io_readwrite until _EOF.
close infile outfile.

para_io_readwrite.

read infile
at end move 1 to _FS.

move infile-record to outfile-record-a.
move spaces to outfile-record-B.

if not _EOF write outfile-record.

* end program hello.

******************************************************************

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: Sequential file I/O - 'strange' Output result

Jump to solution

I made a new version after verifying via Google and MF documentation

Seems that some default values for LINE SEQUENTIAL / RECORD SEQUENTIAL ... differ depending on docs

Please feel free to make suggestions ...

View solution in original post

Tags (1)
0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.

RE: Sequential file I/O - 'strange' Output result

Jump to solution

I made a new version after verifying via Google and MF documentation

Seems that some default values for LINE SEQUENTIAL / RECORD SEQUENTIAL ... differ depending on docs

Please feel free to make suggestions ...

View solution in original post

Tags (1)
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.