Skip to main content

I am having issues creating an variable length records for a file I am exporting out of my program.

My issue is that the Carriage Return and the Line feed are not showing up in the correct spot in the record.

When I would make this file in RM COBOL - It allowed me to use an Line Sequential File layout, and records that had spaces at the end (that are supposed to be there) were NOT truncated.

Now, using the same exact code with Visual COBOL, the records that have spaces at the end of the record, the Carriage Return\\Line feed is being placed at the end of the last character in the record (the way Line sequential files are SUPPOSED to work)

I've changed my file layout to be Record Sequential, but now i'm getting Garbage at the front of every record.

How do I make this file work?? I've tried EVERYTHING!

I am having issues creating an variable length records for a file I am exporting out of my program.

My issue is that the Carriage Return and the Line feed are not showing up in the correct spot in the record.

When I would make this file in RM COBOL - It allowed me to use an Line Sequential File layout, and records that had spaces at the end (that are supposed to be there) were NOT truncated.

Now, using the same exact code with Visual COBOL, the records that have spaces at the end of the record, the Carriage Return\\Line feed is being placed at the end of the last character in the record (the way Line sequential files are SUPPOSED to work)

I've changed my file layout to be Record Sequential, but now i'm getting Garbage at the front of every record.

How do I make this file work?? I've tried EVERYTHING!

This should help

How to create a Line Sequential file without truncating trailing spaces - Micro Focus Community - 1739481<>



This should help

How to create a Line Sequential file without truncating trailing spaces - Micro Focus Community - 1739481<>


: Thanks - but that is for Net Express - which I am not using.

 


: Thanks - but that is for Net Express - which I am not using.

 

Did you try it? If you had you'd see it worked. It works for Net Express, Visual Cobol, Enterprise Developer...

I am having issues creating an variable length records for a file I am exporting out of my program.

My issue is that the Carriage Return and the Line feed are not showing up in the correct spot in the record.

When I would make this file in RM COBOL - It allowed me to use an Line Sequential File layout, and records that had spaces at the end (that are supposed to be there) were NOT truncated.

Now, using the same exact code with Visual COBOL, the records that have spaces at the end of the record, the Carriage Return\\Line feed is being placed at the end of the last character in the record (the way Line sequential files are SUPPOSED to work)

I've changed my file layout to be Record Sequential, but now i'm getting Garbage at the front of every record.

How do I make this file work?? I've tried EVERYTHING!

The garbage at the front of the record is probably the record length. Try converting it from a binary to a display number.


Did you try it? If you had you'd see it worked. It works for Net Express, Visual Cobol, Enterprise Developer...

  -

Yes, I tried it, and it is not working.  Could it be because I am using DB Connectors?


The garbage at the front of the record is probably the record length. Try converting it from a binary to a display number.

You used the term Variable Length record and Line Sequential record and they are different. The solution I proposed will pad out the record with spaces for the full length of the record as opposed to writing that CRLF after the last character.



As for garbage at the frnt of a record, it is as mentioned probably the record length which typically you would not see or need to deal with in your Cobol program



  -

Yes, I tried it, and it is not working.  Could it be because I am using DB Connectors?

Not sure if you mentioned Visual Studio or Eclispe



Not sure if you mentioned Visual Studio or Eclispe


I am using Visual Studio.
What I don't understand WHY when I use RM\\COBOL, it let me create a Variable Length Line Sequential file, - and it doesn't truncate the trailing spaces in a record. Visual COBOL on the other hand is working the way Line sequential files are supposed to..

As for the Record Length, I would need that because my records are variable length. I've never used a Record Sequential file before - but that is what I found on Google...

Do you have another way I can create a file with variable length records that have a CR-LF at the end of each line?


I am using Visual Studio.
What I don't understand WHY when I use RM\\COBOL, it let me create a Variable Length Line Sequential file, - and it doesn't truncate the trailing spaces in a record. Visual COBOL on the other hand is working the way Line sequential files are supposed to..

As for the Record Length, I would need that because my records are variable length. I've never used a Record Sequential file before - but that is what I found on Google...

Do you have another way I can create a file with variable length records that have a CR-LF at the end of each line?

if you don't want 0D0A at end from your lines, use only sequential!!!

select sqlcontrol-file assign to sqlcontrol-filename
organization is sequential
access mode is sequential
file status is sqlcontrol-file-status.


You used the term Variable Length record and Line Sequential record and they are different. The solution I proposed will pad out the record with spaces for the full length of the record as opposed to writing that CRLF after the last character.



As for garbage at the frnt of a record, it is as mentioned probably the record length which typically you would not see or need to deal with in your Cobol program


You can see the field by redifining the record a PIC S9(04) comp occurs x then set the subscript backwards, does not work with index.


if you don't want 0D0A at end from your lines, use only sequential!!!

select sqlcontrol-file assign to sqlcontrol-filename
organization is sequential
access mode is sequential
file status is sqlcontrol-file-status.

 

I  NEED the CR-LF at the end of my records. 

I'm trying to create an export file that another company needs for input - and they require a CR-LF at the end of each lin

 


 

I  NEED the CR-LF at the end of my records. 

I'm trying to create an export file that another company needs for input - and they require a CR-LF at the end of each lin

 

OK, if you need 0D0A at end from your lines, the use line sequential!!!

select sqlcontrol-file assign to sqlcontrol-filename
organization is line sequential
access mode is sequential
file status is sqlcontrol-file-status.

this works fine


I am using Visual Studio.
What I don't understand WHY when I use RM\\COBOL, it let me create a Variable Length Line Sequential file, - and it doesn't truncate the trailing spaces in a record. Visual COBOL on the other hand is working the way Line sequential files are supposed to..

As for the Record Length, I would need that because my records are variable length. I've never used a Record Sequential file before - but that is what I found on Google...

Do you have another way I can create a file with variable length records that have a CR-LF at the end of each line?

You need to specify this as a LINE SEQUENTIAL FILE in order for it to delimit the records with a CRLF (X"0D0A")  pair and for there to not be additional control characters at the beginning of the records. Record sequential files do not delimit the records with the X"0D0A" characters.

The default is to truncate the trailing spaces. In order to change this behavior so that trailing spaces are left intact you must perform the following:

1. Create an extfh.cfg file with an entry like the following:

[XFH-DEFAULT]
STRIPSPACE=OFF

and then set the environment variable EXTFH to the location of the extfh.cfg file.
SET EXTFH=c:\\myconfig\\extfh.cfg

 


OK, if you need 0D0A at end from your lines, the use line sequential!!!

select sqlcontrol-file assign to sqlcontrol-filename
organization is line sequential
access mode is sequential
file status is sqlcontrol-file-status.

this works fine

a other possibility is to use $set for the select
$no rm
select sqlcontrol.....
......
$rm
when the effect is depending on the rm directive!

You need to specify this as a LINE SEQUENTIAL FILE in order for it to delimit the records with a CRLF (X"0D0A")  pair and for there to not be additional control characters at the beginning of the records. Record sequential files do not delimit the records with the X"0D0A" characters.

The default is to truncate the trailing spaces. In order to change this behavior so that trailing spaces are left intact you must perform the following:

1. Create an extfh.cfg file with an entry like the following:

[XFH-DEFAULT]
STRIPSPACE=OFF

and then set the environment variable EXTFH to the location of the extfh.cfg file.
SET EXTFH=c:\\myconfig\\extfh.cfg

 

Chris, are you sure that extfh.cfg is solving this problem?
i am not conform!