× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello Brad.  I'm not Scott, but I'll chime in.

As of V5R4, the keyword *DATA was added to %addr().  So, you use %add(myVaryingField : *data). 

Previously, you'd use %addr(myVaryingField) + 2.  *DATA knows if the size bytes are 2 or 4.  I don't recall when the large field capability requiring 4 bytes was introduced.


Roger Harman
COMMON Certified Application Developer – ILE RPG on IBM i on Power
OCEAN User Group
 
 


Date: Wed, 26 Aug 2015 16:32:53 -0500
Subject: Re: Writing and FTP'ing IFS Stream File
From: bvstone@xxxxxxxxx
To: rpg400-l@xxxxxxxxxxxx

Scott,

Forgive me if this has been covered, it's been a while... but using
%addr(varying_field)... doesn't that cause issues with the length in the
first 2/4 bytes of the field?

I was actually looking for this today as I know it's been discussed and
couldn't find a definitive answer.

On Wed, Aug 26, 2015 at 2:55 PM, Scott Klement
wrote:

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

--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



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.