Hello Mary,

Yes, you should %trim() the filename like Raul said.. sounds like you're all set there...

Two other things you mentioned are bothering me, though. The first is this one:

wrdata = %trim(edata);
callp write(fd: %addr(wrdata): %len(%trim(wrdata)));

What is the point behind the %trim(edata) and copy into wrdata? Assuming that wrdata is a fixed-length variable, you are trimming off the blanks and then just adding them right back on again when they are assigned to wrdata. why would you do that?

Instead, consider doing this:

callp write(fd: %addr(edata): %len(%trimr(edata));

Or else, consider using a VARYING/VARCHAR field. (Actually, it's my opinion that RPGers should be using VARYING/VARCHAR for most things these days..)

The other thing is this:

iconv -f 37 -t 819 /edi/out/myfolder/edi7850.txt > /edi/out/pleatco/edi7850c.txt &&setccsid 819 /edi/out/myfolder/edi7850c.txt


Why are you doing that? You're telling it to duplicate the entire file and translate it. If you want the data in CCSID 819, why not just tell the open() API to write it in CCSID 819 in the first place? What does it gain you to write it in 37, then copy it to another file in 819?

Just change your flags like this:

flags = O_WRONLY + O_CREAT + O_TRUNC + O_CCSID + O_TEXTDATA + O_TEXT_CREAT

And your open() call like this:

fd = open(filename : flags : mode: 819: 0);


If there's an existing file in the IFS, delete it to start fresh. Now the open() API will automatically translate data to 819 when writing it, and automatically translate from 819 to the job ccsid when reading it. No need for the extra copying of the file...

-SK




On 8/25/2015 12:23 PM, Mary Lynn Riggins wrote:
Need some help with IFS stream file.

Client requires a file to be sent to them with no trailing spaces and no CRLF or EOR.


I thought the best way to accomplish this was to write to a stream file on the IFS directly from RPGLE program and then FTP stream file to client from CL program.

The program does create the stream file. I can see it using WRKLNK and can display that there is data, however when trying to FTP the file, I get the error message:


“No such path or directory: /edi/out/myfolder/edi7850.txt. The directory or a component of the path name does not exist.”

Also receive CPFA0A9 Object not found when trying to use IFS command on file. Also receive error message when trying to use QShell to convert ccsid:

iconv: 001-0023 Error found opening file /edi/out/myfolder/edi7850.txt.

However, if manually using WRKLNK green screen, I use option 7- Rename, and rename the file I can then successfully work with the file and use the QShell command and FTP the file. So, there must be something I’m missing when creating the file to begin with. If anyone can lend some insight I would appreciate it.






RPG Code to write to IFS:

**********************************************************************

* Write the IFS Ascii file directly

**********************************************************************

/free

begsr writeIFS;

flags = O_WRONLY + O_CREAT + O_TRUNC;

mode = S_IRUSR + S_IWUSR + S_IRGRP + S_IROTH + S_IWOTH;

filename = '/edi/out/myfolder/edi7850.txt';




fd = open(filename : flags : mode);

if fd < 0;

Msg = 'open() : failed for writing';

eval *Inlr = *on;

return;

endif;



// write the line of data to the IFS file

wrdata = %trim(edata);

callp write(fd: %addr(wrdata): %len(%trim(wrdata)));



//close the file

callp close(fd);

endsr;



Qshell Command used for conversion:

iconv -f 37 -t 819 /edi/out/myfolder/edi7850.txt > /edi/out/pleatco/edi7850c.txt &&setccsid 819 /edi/out/myfolder/edi7850c.txt



Thanks in advance for any help or insights.


MLR


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.