regarding COBOL WRITE verb (VB File Handling)



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

regarding COBOL WRITE verb (VB File Handling)

Postby anonguy456 » Mon Jun 28, 2021 5:57 pm

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 !
anonguy456
 
Posts: 4
Joined: Wed Jan 27, 2021 9:23 pm
Has thanked: 0 time
Been thanked: 0 time

Re: regarding COBOL WRITE verb (VB File Handling)

Postby Robert Sample » Mon Jun 28, 2021 8:56 pm

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.
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.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: regarding COBOL WRITE verb (VB File Handling)

Postby anonguy456 » Mon Jun 28, 2021 9:17 pm

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"
anonguy456
 
Posts: 4
Joined: Wed Jan 27, 2021 9:23 pm
Has thanked: 0 time
Been thanked: 0 time

Re: regarding COBOL WRITE verb (VB File Handling)

Postby sergeyken » Mon Jun 28, 2021 11:34 pm

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.
User avatar
sergeyken
 
Posts: 438
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 7 times
Been thanked: 40 times

Re: regarding COBOL WRITE verb (VB File Handling)

Postby Robert Sample » Tue Jun 29, 2021 4:26 am

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"
You have completely ignored what I posted.

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.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: regarding COBOL WRITE verb (VB File Handling)

Postby anonguy456 » Tue Jun 29, 2021 2:26 pm

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.

       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.
 
anonguy456
 
Posts: 4
Joined: Wed Jan 27, 2021 9:23 pm
Has thanked: 0 time
Been thanked: 0 time

Re: regarding COBOL WRITE verb (VB File Handling)

Postby Robert Sample » Tue Jun 29, 2021 11:33 pm

See my comments on the other forum. This topic is locked as a duplicate.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post