End of file and the CPYTOSTMF

25 pts.
Tags:
AS/400
ASCII File
CPYTOSTMF
CRLF
I am using the CPYTOSTMF command to create an ASCII file with fixed record length. Is there any way to prevent the CRLF after the last record in the file?

Answer Wiki

Thanks. We'll let you know when a new response is added.

No – all records including the last record will have the same record termination code.
You can change it for all records.
Phil

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    Is there any way to prevent the CRLF after the last record in the file? Only the last line? Or do you mean every line in the file? Tom
    125,585 pointsBadges:
    report
  • Rsh
    Tom, Only aftert the last line.
    25 pointsBadges:
    report
  • TomLiotta
    IMO, the only correct answer is not to put any *CRLF into the file at the end when you first write it. First, it doesn't make much sense to have both fixed-length lines and *CRLFs in the file. When all lines are fixed-length, there is no point to having *CRLFs. But removing only the last *CRLF is bizarre. I've never run into such a requirement. I've never done it, but I suppose the programming necessary to remove a trailing *CRLF would require issuing open() as O-RDWR, then lseek() to SEEK_END with offset of -2, then write() two bytes of nulls. Alternatively, you could do a normal open() for reading this file and a second open() for writing a copy. You'd still want to lseek() to SEEK_END to get the actual offset into the file. Then you could read() and write() bytes until you reached those last two bytes. At that point, close() the files and delete the original copy. Regardless, it seems far easier just not to write the trailing *CRLF when you create the file. It might be possible to work up some Qshell or PASE script to get it done. If I can find a way to do that, I'll post it. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    No, not with CPYTOSTMF. But you may be able to remove it later as Tom describes. Perhaps the focus should be with the process that uses this program. Phil
    49,570 pointsBadges:
    report
  • philpl1jb
    oh...not program ... that uses this file.
    49,570 pointsBadges:
    report
  • TomLiotta
    ...not with CPYTOSTMF. Yes, CPYTOSTMF is a generic tool that provides generic solutions. To do it correctly means not to use CPYTOSTMF (nor CPYTOIMPF.) Write the programming yourself to put the data into the streamfile. That way you get exactly the results you want. I.e., don't put a *CRLF at the end of the file if you don't want one there. Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following