View previous topic :: View next topic
|
Author |
Message |
anonguy456
New User
Joined: 29 Jun 2021 Posts: 16 Location: India
|
|
|
|
I have attached the code below. This is a small code which will copy contents of input file INPUT01 to output file OUTPUT01. Problem is blank characters at the end of every record is getting populated with HIGH-VALUE. I am able to populate blank characters at the end of every record with HIGH-VALUE/LOW-VALUE/SPACE but not with blank character at the end of record. I have also attached the snap of input file and output file after executing the below code.
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID.
TST05.
*PROGRAM THAT WILL COPY NORMAL PROD VB FILE AND INITIALIZE
*BLANK CHARACTERS WITH HIGH VALUES
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INPUT01 ASSIGN TO CHK01.
SELECT OUTPUT01 ASSIGN TO CHK02.
*
DATA DIVISION.
FILE SECTION.
FD INPUT01
BLOCK CONTAINS 0 RECORDS
RECORD IS VARYING IN SIZE FROM 4 TO 24810
DEPENDING ON REC-LEN.
01 INPUTFILE01 PIC X(24810).
88 ENDOFINPUTFILE01 VALUE HIGH-VALUES.
01 FILLER PIC X(4).
FD OUTPUT01
RECORDING MODE IS V.
01 OUTPUTFILE01 PIC X(24810) VALUE HIGH-VALUES.
WORKING-STORAGE SECTION.
01 REC-LEN PIC 9(5) COMP.
*
PROCEDURE DIVISION.
MAINPROCEDURE.
OPEN INPUT INPUT01
OPEN OUTPUT OUTPUT01
MOVE HIGH-VALUES TO OUTPUTFILE01
READ INPUT01
AT END SET ENDOFINPUTFILE01 TO TRUE
END-READ
PERFORM WRITEPOLICIES UNTIL ENDOFINPUTFILE01
CLOSE INPUT01
CLOSE OUTPUT01
STOP RUN.
WRITEPOLICIES.
MOVE INPUTFILE01(1:REC-LEN) TO OUTPUTFILE01(1:REC-LEN)
WRITE OUTPUTFILE01
MOVE HIGH-VALUES TO OUTPUTFILE01
READ INPUT01
AT END SET ENDOFINPUTFILE01 TO TRUE
END-READ.
|
Note: RESIZE the images before posting in the Forum. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
do not post twice the same question ...
the peoplw answering here are the same answering there
and ... how many times do You have to be told not to post screenshots
when a plain TEXT cut and paste is more than enough ? |
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
Try changing this:
Code: |
MOVE INPUTFILE01(1:REC-LEN) TO OUTPUTFILE01(1:REC-LEN)
WRITE OUTPUTFILE01 |
To This:
Code: |
WRITE OUTPUTFILE01 FROM INPUTFILE01(1:REC-LEN) |
|
|
Back to top |
|
|
anonguy456
New User
Joined: 29 Jun 2021 Posts: 16 Location: India
|
|
|
|
nope i had tried this already, it fills space character. but thanks for your suggestion. |
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
How about removing the VALUE HIGH-VALUES from the 01 line.
Code: |
01 INPUTFILE01 PIC X(24810).
88 ENDOFINPUTFILE01 VALUE HIGH-VALUES.
01 FILLER PIC X(4).
FD OUTPUT01
RECORDING MODE IS V.
01 OUTPUTFILE01 PIC X(24810) VALUE HIGH-VALUES. |
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
As I anticipated from your comments on the other forum, you are doing precisely what I thought -- you are writing fixed length 24810 byte records to a variable length file. Your code needs to be something like:
Code: |
FD INPUT01
BLOCK CONTAINS 0 RECORDS
RECORD IS VARYING IN SIZE FROM 4 TO 24810
DEPENDING ON REC-LEN.
01 INPUTFILE01 PIC X(24810).
88 ENDOFINPUTFILE01 VALUE HIGH-VALUES.
01 FILLER PIC X(4).
FD OUTPUT01
RECORDING MODE IS V
RECORD IS VARYING IN SIZE FROM 4 TO 24810
DEPENDING ON OUT-LEN.
01 OUTPUTFILE01 PIC X(24810) VALUE HIGH-VALUES.
.
.
.
MOVE REC-LEN TO OUT-LEN.
WRITE OUTPUTFILE01. |
This is untested code and may require some changes to get it to run properly, but this code indicates to COBOL to write only OUT-LEN bytes to the file (unlike your code which indicates to COBOL that every record you write to OUTPUT01 will be 24810 bytes and will have HIGH-VALUES for all bytes after the last byte of the input data). |
|
Back to top |
|
|
anonguy456
New User
Joined: 29 Jun 2021 Posts: 16 Location: India
|
|
|
|
Thank You Robert, Finally it started to work the way I intended it to work |
|
Back to top |
|
|
anonguy456
New User
Joined: 29 Jun 2021 Posts: 16 Location: India
|
|
|
|
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID.
TST01.
*PROGRAM THAT WILL COPY NORMAL PROD VB FILE
*
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INPUT01 ASSIGN TO CHK01.
SELECT OUTPUT01 ASSIGN TO CHK02.
*
DATA DIVISION.
FILE SECTION.
FD INPUT01
BLOCK CONTAINS 0 RECORDS
RECORD IS VARYING IN SIZE FROM 4 TO 24810
DEPENDING ON REC-LEN.
01 INPUTFILE01 PIC X(24810).
88 ENDOFINPUTFILE01 VALUE HIGH-VALUES.
FD OUTPUT01
BLOCK CONTAINS 0 RECORDS
RECORD IS VARYING IN SIZE FROM 4 TO 24810
DEPENDING ON REC-LEN2.
01 OUTPUTFILE01 PIC X(24810).
WORKING-STORAGE SECTION.
01 REC-LEN PIC 9(5) COMP.
01 REC-LEN2 PIC 9(5) COMP.
*
PROCEDURE DIVISION.
MAINPROCEDURE.
OPEN INPUT INPUT01
OPEN OUTPUT OUTPUT01
READ INPUT01
AT END SET ENDOFINPUTFILE01 TO TRUE
END-READ
PERFORM WRITEFILE UNTIL ENDOFINPUTFILE01
CLOSE INPUT01
CLOSE OUTPUT01
STOP RUN.
WRITEFILE.
MOVE REC-LEN TO REC-LEN2
MOVE INPUTFILE01(1:REC-LEN) TO OUTPUTFILE01
WRITE OUTPUTFILE01
READ INPUT01
AT END SET ENDOFINPUTFILE01 TO TRUE
END-READ.
|
The above code works most of the times, but in some instances it does not copy all records i.e., if there are 1000 records it will copy 996 records and then at 997th row displays error message " * I/O error detected, I/O terminated * ". I need help in fixing this.
NOTE: Its not an issue related with space since at times it is able to copy files bigger than this which has got more records. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
Did you look in the JESMSGLG?
There should be System messages which provide more information.
One or more of them could be used to help you resolve your issue. |
|
Back to top |
|
|
|