Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flat File trailing blanks or spaces 1

Status
Not open for further replies.

jmanj

Programmer
May 20, 2003
298
US
How do you add trailing blanks to a flat file. I have a MF cobol program that creates a fixed length record of 300 characters. The last 60 characters is an all blank field.
I have used filler with value spaces, move spaces to the field
or move " " to the field but the created file does not contain the trailing blanks.

I know the question can be how important is it? It's just a field with nothing in it. Our client does have a purpose with it and I'm at a loss on how to deliver.

This used to work on AS400 but since we are migrating to Sun Solaris (unix) this seem to be an impossible task.

The only thing I can think of is embed the record with CR/LF characters at the end of each record but I have no idea on how to do that in micro focus cobol.

Thanks to any help.
 
What is the SELECT instruction for your flat file ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

Thanks for the quick reply. The file is only an output sequential file. I usually use working storage data before
writing to the output file and when you open the file thru notepad there is no blanks(60) at the end of each record.

I tried adding a WS-LF Pic X value spaces

at the end of the record then do a MOVE X'0A" TO WS-LF.
but it seems the compiler does not like the X'0A'.

 
Hey jmanj,

allways the first step, if I put values in a data-set is the command:

"initialize name-of-the-data-set"

All "PIC X-Fields" contain spaces
All "PIC 9-Fields" contain zeros

Regards Helmut

 
Landei,

That the very first thing I always do before using my data set. Thanks.

jmanj
 
First of all don't use single quotes. Double quotes is the standard.

What version of MF are you using? Recent versions should be able to accept X"...".

If not you can always use a binary variable redefined to PIC X.
like

01 num pic 9(4) binary.
01 numr redefines num.
05 filler pic x.
05 my_char pic x.

move 10 to num will give you X"0A" on my_char. (some compiler directives may affect this!!!).

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
The file is only an output sequential file
RECORD SEQUENTIAL or LINE SEQUENTIAL ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Frederico,

The compiler did not like the double quotes either BUT it works when I follow your advice to use binary field. However,
there is an extra blank record created. This could also explain why the program RAN as twice as before and because of the extra blank record, it also doubled the file size.

Any tips on how to correct this? Thanks Very Much!!!!!

Here's the step:

Working Storage:
01 WS-DETAIL.
02 ws-.....
02 WS-BLANKS PICTURE X(60) VALUE SPACE.
02 WS-LF PICTURE 9(4) BINARY.


Procedure:

MOVE 10 TO WS-LF.

RELEASE OUTPUT-REC FROM WS-DETAIL.

 
Please show us the FULL SELECT of the file in question.

And RELEASE is part of a sort/merge file, not a sequential file.

If you are using a RECORD SEQUENTIAL then the double line is a known issue.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Here's the select statement that I can find from the listing.

SELECT WORKOUT-FILE ASSIGN TO DISK
ORGANIZATION LINE SEQUENTIAL
STATUS WS-WORK-FILE-STATUS.



FD WRKOUT-FILE VALUE OF
FILE-ID 01 OUTPUT-REC PIC X(300).


Thanks for any help.
 
Have you trying the original code only replacing LINE SEQUENTIAL by RECORD SEQUENTIAL ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Try the following program.
It should produce a file "conv.bak" with 80 chars in each line + a 0D0A pair per line.

Code:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. DEMO.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.

            SELECT MAPA ASSIGN TO DISK
                       "CC.CBL"
                   ORGANIZATION LINE SEQUENTIAL.
            SELECT MAPA1 ASSIGN TO DISK
                       "CONV.BAK"
                   ORGANIZATION SEQUENTIAL.

       DATA DIVISION.
       FILE SECTION.

       FD MAPA    LABEL RECORD OMITTED.
       01 LINHA   PIC X(80).
       FD MAPA1   LABEL RECORD OMITTED.
       01 LINHA1  PIC X(80).

       WORKING-STORAGE SECTION.
       01  WS-1 PIC XX.
       PROCEDURE DIVISION.
       INIC.
           PERFORM Z10-OPEN-FILES.
           MOVE "00" to WS-1
           PERFORM UNTIL WS-1 NOT = "00"
              MOVE SPACES TO LINHA
              READ MAPA NEXT
                AT END
                   MOVE "01" TO WS-1
               NOT AT END
                   MOVE SPACES TO LINHA1
                   MOVE LINHA TO LINHA1
                   WRITE LINHA1 BEFORE 1
              END-READ
           END-PERFORM.

       FIM.
           PERFORM Z20-CLOSE-FILES.
           GOBACK.
       Z10-OPEN-FILES.
           OPEN INPUT  MAPA.
           OPEN OUTPUT MAPA1.
       Z20-CLOSE-FILES.
           CLOSE MAPA.
           CLOSE MAPA1.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
GUYS,

I forgot to mentioned that the application I'm working on has a tools for entering cobol statement which unfortunately allow us only to enter PROCEDURE statements and WORKING STORAGE data definitions. There is a GUI to define work files(flat files, csv etc), print report formatting and screen design aids. When we compile a defined program, the tool will create all other Cobol sections and other sections necessary to connect to pre defined files then proceeds to compiling it. It is therefore very difficult for me to change data file definitions as this is controlled by the toolset. The select statement came from the listing of the compiled program.

As you can see I can only supply some part of the PROCEDURE division and WORKING STORAGE section and the rest is supplied by the toolset.

Thanks for all your help.

jmanj
 
That does not prevent you from trying my program.

If it works then it is a question of adjusting the tools you use to produce a certain type of SELECT and WRITES for a particular definition type.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
another possible trick, define the output file as a printer file, give it a file name instead of a printer name, and code your output statement as "write out-record before advancing 1 lines".
 
PHV is right. The line-sequential parameter causes the trailing spaces to be supressed (replaced with CR/LF).

PHV gets the star!
 
GUYS,

As I mentioned before, we are at the mercy of this toolset. There's no way of changing the file types or creating an environment or data division. Anyway I tried replacing LF with CR and the file seems to be ok. I view the file with notepad and it seems there are 2 spaces extra which could account for the CR character. I will need my client to verify the record length if including the extra space will work for them or if their programs will distinguish between a space and CR char.

Thanks everybody .....

jmanj
 
This is similar to Frederico's solution but may fit in better with your limitations.

Note that a line sequential file can (and does) have a longer record length than you specify. If you wanted a record length of 40 it would not matter if you specified 80 as the read ends with CRLF.

Code:
       IDENTIFICATION DIVISION.
       PROGRAM-ID.    FAKELSEQ.
       AUTHOR.        CLIVE CUMMINS.
       INSTALLATION.  [URL unfurl="true"]www.tubularity.com[/URL]
       DATE-WRITTEN.  JUN 20,1996.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT FAKELSEQ-FILE ASSIGN TO FAKELSEQ-FILE-ID
                  FILE STATUS  IS FAKELSEQ-RETURN-CODE
                  ACCESS MODE  IS SEQUENTIAL
                  ORGANIZATION IS LINE SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD  FAKELSEQ-FILE.
       01  FAKELSEQ-RECORD            PIC X(42).
       WORKING-STORAGE SECTION.
       01  FAKELSEQ-RECORD-WORK.
           05  RECORD-WORK            PIC X(40).
           05  HEX-0A                 PIC X(01) VALUE X'0A'.
           05  HEX-0D                 PIC X(01) VALUE X'0D'.
       01  FAKELSEQ-FILE-WORK.
           05  FAKELSEQ-FILE-ID       PIC X(12)  VALUE "FAKELSEQ.TXT".
           05  FAKELSEQ-RETURN-CODE   PIC X(02).
       PROCEDURE DIVISION.
           OPEN OUTPUT FAKELSEQ-FILE.
           MOVE 'test' TO RECORD-WORK.
           WRITE FAKELSEQ-RECORD FROM FAKELSEQ-RECORD-WORK.
           CLOSE FAKELSEQ-FILE.
           GOBACK.


Clive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top