Highlighted
Absent Member.
Absent Member.
2254 views

Configuration Variable - STRIP_TRAILING_SPACES

[Migrated content. Thread originally posted on 12 July 2011]

I can't seem to write line sequential file with 94 character with WITHOUT stripping the trailing spaces.
I have set the STRIP_TRAILING_SPACES to 0;
I've tried using BLOCK CONTAINS 94 CHARACTERS in FD section
I've tried RECORD IS VARYING IN SIZE FROM 1 TO 94 CHARACTERS
DEPENDING ON 94-CHAR-VARIABLE in FD section.

Using AcuCobol 8.01.
FYI, Wring a NACHA file for Direct Deposit transfer, and bank wants every record to be exactly 94 character without losing the trailing spaces.

Thanks for help in advance.

0 Likes
9 Replies
Highlighted
Micro Focus Contributor
Micro Focus Contributor

RE: Configuration Variable - STRIP_TRAILING_SPACES

Hello,

Could you sent me the SELECT, the FD of your file ?
On which OS are you using ACUCOBOL-GT ?

Roch Rolland
Ingénieur Micro Focus
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Configuration Variable - STRIP_TRAILING_SPACES

Hi Roch,
Thanks for responding.
Here is my select and fd:
SELECT NACHA-FILE ASSIGN TO NACHA-FILE-NAME
ORGANIZATION IS LINE SEQUENTIAL
FILE STATUS IS NACHA-STATUS.

FD NACHA-FILE
VALUE OF FILE-ID IS NACHA-FILE-NAME
* block contains 94 characters
* RECORD IS VARYING IN SIZE FROM 1 TO 94 CHARACTERS
* DEPENDING ON 94-CHAR-VARIABLE
LABEL RECORDS ARE STANDARD.
01 NACHA-RECORD PIC X(94).

We are using Windows xp, Windows 2xxx Server & W7.



0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Configuration Variable - STRIP_TRAILING_SPACES

RECORD IS VARYING IN SIZE FROM 1 TO 94 CHARACTERS
will make a variable length
RECORD Contains 94 CHARACTERS
will make a fixed length
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Configuration Variable - STRIP_TRAILING_SPACES

I've tried "Record Contains 94 characters".
It still stripped out the trailing spaces.
I have SET ENVIRONMENT "STRIP_TRAILING_SPACES" TO 0 in the program before opening the file for output.

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

RE: Configuration Variable - STRIP_TRAILING_SPACES

I compiled and ran this program and it did not strip the trailing spaces:
       PROGRAM-ID.  lineseq.
       FILE-CONTROL.
           select lineseq
                  assign to "lineseq.txt"
                  organization is line sequential
                  file status is fs.
       FILE SECTION.
       fd lineseq.
       01 lineseq-rec pic x(15).
       WORKING-STORAGE SECTION.
       01 fs pic xx.
       PROCEDURE DIVISION.
       MAIN.
           open output lineseq.
           move "test data      " to lineseq-rec.
           write lineseq-rec.
           close lineseq.
           stop run.


Note that if any of the file's WRITE statements include the AFTER phrase the file is seen as a PRINT file and the trailing spaces will always be stripped.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Configuration Variable - STRIP_TRAILING_SPACES

Enclosed is my test program.
i do have a work around which is to shell out to a vb program, but i rather not do that if i can handle this within the cobol program.


IDENTIFICATION DIVISION.
PROGRAM-ID.  testTrailingSpaces.

DATE-COMPILED.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.

FILE-CONTROL.

    select test-file assign to test-file-name
                ORGANIZATION IS LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
fd test-file
    COPY 'Q:VALUE.FD'. test-file-name
    record contains 94 characters
*    RECORD IS VARYING IN SIZE FROM 1 TO 94 CHARACTERS
*        DEPENDING ON 94-CHAR-VARIABLE
    LABEL RECORDS ARE STANDARD.
01 test-record                        pic x(80).

WORKING-STORAGE SECTION.
01 94-CHAR-VARIABLE    pic 9(6) value 80.
01 padd-char        pic x value "9".
01 test-file-name    pic x(100).
/*-----------------------------------------------------------
PROCEDURE DIVISION.
100-MAIN.

    perform 600-test-strip-trailing-spaces.
    
    stop run.

600-test-strip-trailing-spaces.

    SET ENVIRONMENT "STRIP_TRAILING_SPACES" TO 0.
    move 'nacha.txt' to test-file-name.

    open output test-file.
    
    move "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234" to test-record.
    write test-record before advancing 1 line.
    move "this is second line                                                                           " to test-record.
    write test-record before advancing 1 line.
    move "this is third line " to test-record.
    write test-record before advancing 1 line.

    close test-file.
        
0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

RE: Configuration Variable - STRIP_TRAILING_SPACES

You have the BEFORE phrase on the WRITE statements, which causes the same behavior as AFTER. The file is seen as a print file and the trailing spaces will always be stripped. The BEFORE phrase is really not necessary for a line sequential file. Try removing the BEFORE phrase.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Configuration Variable - STRIP_TRAILING_SPACES

Problem solved! Thanks DougP!
It has to do with "before advancing 1 line" in "Write test-record before advancing 1 line".

I've used "before advancing 1 line" because it used to insert a crlf before the first line when i didn't have the "before advancing" line.

This may sound confusing but not having any "before advancing" in any WRITE line as in DougP example, the output looks correct without the initial crlf in the first line; however, if i have a "before advancing" in any of the WRITE line, the system inserts a crlf in the first line???

i just like to know why the system is differentiating the two?

Thanks again.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Configuration Variable - STRIP_TRAILING_SPACES

DougP, you are too quick!!!
Thanks!!!
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.