Copy Stream File

55 pts.
Tags:
DDS
iSeries
Stream files
Hello, I have a stream file that I have copied to the iSeries. I would now like to copy this file to a physical file defined using DDS as a file with one field of 1024. The records in the stream file are delimited with a tilde, not a CR, LF, or any combination of these. Any suggestions how to copy this file? Any options I try seem to insist the records are delimited by the pre-mentioned. Thank you.

Answer Wiki

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

You might try:

QSH CMD(‘tr ”~” ”\n” < /inputfile.txt > /outputfile.txt’)

This command will translate all ~ characters in /inputfile.txt to line feeds while copying the data from inputfile.txt to /outputfile.txt. The various CPY commands you have been trying should then be able to handle the file. If /outputfile.txt does not already exist, this command will create it with a default CCSID appropriate for your job (which may or may not be what you want). If you want the CCSID to be the same as that used for /inputfile.txt you will want to create /outputfile.txt in advance.

Alternatively, you could also write directly to the physical file if you move from DDS and simply go with program described. This could be done with:

CRTPF SOMELIB/MYFILE RCDLEN(1024)
QSH CMD(‘tr ”~” ”\n” < /inputfile.txt > /qsys.lib/somelib.lib/myfile.file/myfile.mbr’)

Hope this helps,
Bruce Vining

Discuss This Question: 9  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
  • Doddski
    Hi Bruce, Thank you very much. This works great. The physcial file I am traing to copy to actually has only a single field of length 1024. I am still puzzled that it is necessary to do this as I would have thought the iseries would have been able to cope with delimiters in a string file other than carriage returns. The tilde is part of American EDI HIPAA standards. Anyway, thanks again. I've been surfing for a few days now trying to find a solution. Kathleen
    55 pointsBadges:
    report
  • Cwc
    "I am still puzzled that it is necessary to do this as I would have thought the iseries would have been able to cope with delimiters in a string file other than carriage returns" Yes, the System i/iSeries can handle it (note: I'm not an IBM spokesperson and don't even play one on TV). CPYFRMIMPF, Copy From Import File, is the answer (along with its counterpart, CPYTOIMPF). These commands are quite versatile, and I can nearly always achieve what I need using them. They can also copy files between the IFS. In the RCDDLM parameter, you can specify *CR, *LF, *CRLF, *LFCR, or any specific character. So, you should be able to specify the tilde to make that work. You may also want to check the CPYFRMSTMF, Copy From Stream File, and CPYTOSTMF, Copy To Stream File, commands, although I have not used these as often, since the import file commands usually get it done for me.
    4,290 pointsBadges:
    report
  • Doddski
    I have tried both commands and have found no combination that works. When I use CPYFRMIMPF with anything other than the *CR, *LF, or combination I get the error message below. It is a stream file I am trying to copy and this message does say I need to use *CR, *CRLF, *LF, LFCR. The copy did not complete for reason code 11. 11 - The RCDDLM parameter for a stream file can only be *CR, *CRLF, *LF, or *LFCR and for a data base file the RCDDLM parameter can be *EOR or a valid value.
    55 pointsBadges:
    report
  • Doddski
    No more suggestions?
    55 pointsBadges:
    report
  • bvining
    Perhaps I misunderstood this discussion sequence. Your first response was "This works great." and I assumed your second response "I have tried both commands..." was in response to Cwc puzzlement and not that you still had a problem. Isn't the translate solution converting your tildes to line feeds? Bruce
    6,430 pointsBadges:
    report
  • Doddski
    Hi, Yes the translation solution does work and I am using it. But as I said in my second posting, I am surprised that it is necessary as I thought the iSeries would have a native command. Cwc said that yes the iseries does, cpyfrmimpf or cpyfrmstmf. My reply that I have tried both of these commands was in response to Cwc and neither of these work as per the error message. I too thought it should be as simple as Cwc said, but it doesn't appear to be. Having said that it is not like your (Bruce) solution is highly complicated, I am just interested if there is another solution. The translation one is up and running. But if there is another solution I am interested. Someone else has also told me the cpyfrmimpf and cpyfrmstmf commands should work but that error message is quite explicit.
    55 pointsBadges:
    report
  • bvining
    I am not aware of any solution to this other than using the translate function or writing your own application to provide the tilde support. Both the error message and the help text for CPYFRMIMPF are pretty specific: " If the FROMFILE parameter is specified, valid values are *EOR or a character value. If the FROMSTMF parameter is specified, valid values are *CR, *CRLF, *LF, *LFCR or *ALL." Your input is a stream file, so the use of a character value such as the tilde is not supported by the command (at least not through V5R4). I'm sure there is some reason for why EDI implemented a standard based on the tilde rather than the more conventional values of CR, CRLF, LF, and/or LFCR; but I certainly don't have a clue as to what that reason might be. Bruce Vining http://www.brucevining.com/
    6,430 pointsBadges:
    report
  • Doddski
    Thanks again Bruce. I guess I just wanted reassurance that I wasn't missing something. One guess for the tilde would be that you can actually see it, i.e. in the documentation, although I suppose they could have said the tilde was representing a CR. Or maybe it doesn't matter to machines other than the iSeries. It isn't a small sector that requires this, but the entire healthcare industry in the US:
    55 pointsBadges:
    report
  • bvining
    Most machines I'm aware of (certainly more than the AS/400, iSeries, System i, etc) would expect the conventional *CR, *LF, *CRLF, and/or *LFCR delimiter. I suspect that there are applications on those other systems though that also directly support the EDI formatting. Such EDI applications also exist on the System i (or at least I've seen advertising to suggest that -- I've never used one). In our case we're trying to use a general purpose i5/OS command rather than an EDI aware command. I will say though that allowing a delimiter character to be specified with a stream file (like how is done with a database file) would seem like a very reasonable enhancement to the system. IBM provides this link to allow users to make such requests. I would certainly encourage you to use it :-) Bruce Vining http://www.brucevining.com/
    6,430 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