I wanted to write blank fields as there in input file as it is, but after using cobol WRITE i am only able to add only HIGH-VALUE/LOW-VALUE/SPACE. Is there any way I can write to output file with blank places wherever blank is present.
images deleted !
regarding COBOL WRITE verb (VB File Handling)
-
- Posts: 4
- Joined: Wed Jan 27, 2021 9:23 pm
- Skillset: beginner
- Referer: through search
-
- Global moderator
- Posts: 3720
- Joined: Sat Dec 19, 2009 8:32 pm
- Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
- Referer: other forum
- Location: Dubuque, Iowa, USA
Re: regarding COBOL WRITE verb (VB File Handling)
I think you misunderstand what you posted. The blanks at the end of the input data indicate that the record ends after 15 bytes. Your output data set can replicate this behavior by setting the record length to 15 bytes before executing the WRITE statement. If your record length is longer than 15 bytes, you will have data in the remaining bytes -- spaces, HIGH VALUES, LOW VALUES, or whatever you put into the record before writing it. You do NOT write "blank spaces" -- you set the record length and the "blank spaces" will show up automatically as they indicate there is no record data in those bytes.I wanted to write blank fields as there in input file as it is, but after using cobol WRITE i am only able to add only HIGH-VALUE/LOW-VALUE/SPACE. Is there any way I can write to output file with blank places wherever blank is present.
-
- Posts: 4
- Joined: Wed Jan 27, 2021 9:23 pm
- Skillset: beginner
- Referer: through search
Re: regarding COBOL WRITE verb (VB File Handling)
Actually the records in the file are of variable length. The lrecl of the record is 24,814. And all the records length vary from 4 to 24,810. There is no fixed length record. For better clarity i am rephrasing the question i had posted: "I wanted to write blank character as it is there in input file, but after using cobol WRITE i am able to add only HIGH-VALUE/LOW-VALUE/SPACE. Is there any way I can write to output file with blank character wherever blank character is present"
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: regarding COBOL WRITE verb (VB File Handling)
anonguy456 wrote:Actually the records in the file are of variable length. The lrecl of the record is 24,814. And all the records length vary from 4 to 24,810. There is no fixed length record. For better clarity i am rephrasing the question i had posted: "I wanted to write blank character as it is there in input file, but after using cobol WRITE i am able to add only HIGH-VALUE/LOW-VALUE/SPACE. Is there any way I can write to output file with blank character wherever blank character is present"
In a normally designed program, the standard zOS + COBOL internals take care in full of all this thingies.
The best way would be if you presented here some pieces of your COBOL code, used JCL, and input/output data. Otherwise it's very hard to understand your specific non-standard terminology.
IMPORTANT!!!
Learn how to use code tags to insert your pieces of code into your post text.
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Global moderator
- Posts: 3720
- Joined: Sat Dec 19, 2009 8:32 pm
- Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
- Referer: other forum
- Location: Dubuque, Iowa, USA
Re: regarding COBOL WRITE verb (VB File Handling)
You have completely ignored what I posted.Actually the records in the file are of variable length. The lrecl of the record is 24,814. And all the records length vary from 4 to 24,810. There is no fixed length record. For better clarity i am rephrasing the question i had posted: "I wanted to write blank character as it is there in input file, but after using cobol WRITE i am able to add only HIGH-VALUE/LOW-VALUE/SPACE. Is there any way I can write to output file with blank character wherever blank character is present"
Let's start from the beginning. There is NO SUCH THING AS A BLANK CHARACTER! To repeat, you cannot write blank characters to your output file (sic) because blank characters do not exist, period. On the mainframe, the EBCDIC collating sequence is generally used, and it contains 256 characters from X'00 (also known as LOW-VALUES) to X'FF' (also known as HIGH-VALUES). Every byte of every record you write will be one of those 256 characters -- and not a one of them is a blank character.
When using ISPF to display a data set (it's not a file), and the data set is variable length, ISPF leaves the line blank once it reaches the end of that particular record. This is a convention ISPF uses so you will know where the record ends since there is no end-of-line indicator the way there is for UNIX / LINUX / Windows systems. If your program is properly coded, it will set the output record length BEFORE writing the record, and if you then use ISPF to look at that output data set you will see that no characters are displayed after the end of the record. If your program is not properly coded, it is entirely possible that you will output every record as the maximum length allowed.
-
- Posts: 4
- Joined: Wed Jan 27, 2021 9:23 pm
- Skillset: beginner
- Referer: through search
Re: regarding COBOL WRITE verb (VB File Handling)
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.
Code: Select all
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.
-
- Global moderator
- Posts: 3720
- Joined: Sat Dec 19, 2009 8:32 pm
- Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
- Referer: other forum
- Location: Dubuque, Iowa, USA
Re: regarding COBOL WRITE verb (VB File Handling)
See my comments on the other forum. This topic is locked as a duplicate.
-
- Similar Topics
- Replies
- Views
- Last post
-
-
File Handling 3 input files and 1 output file by using EZT
by pavan426 » Thu Sep 09, 2021 12:17 am » in CA-Easytrieve - 0
- 4414
-
by pavan426
View the latest post
Thu Sep 09, 2021 12:17 am
-
-
-
Array processing and Table handling with packed decimal
by rogerstrycova » Tue Oct 26, 2021 3:55 pm » in IBM Cobol - 2
- 1700
-
by Robert Sample
View the latest post
Wed Oct 27, 2021 1:12 am
-
-
- 3
- 2655
-
by sergeyken
View the latest post
Sat Nov 16, 2024 11:05 pm
-
-
COBOL SORT - How to sort entire file first & sort by Key
by k_ekam » Thu Dec 01, 2022 12:58 pm » in IBM Cobol - 3
- 1540
-
by Robert Sample
View the latest post
Wed Dec 07, 2022 7:32 am
-
-
-
EZIOE004 Logical I/O error on file occurred reading VB file
by savitha_y » Mon Feb 15, 2021 7:54 pm » in CA-Easytrieve - 3
- 4954
-
by savitha_y
View the latest post
Wed Feb 17, 2021 5:02 am
-