|
Scott,
I try to have him only nibble a little at a time. Getting him to write
directly to the IFS versus using CPYTOSTMF/CPYTOIMPF will take more time.
However, now I've been informed that he had too much trouble with IFS and
he's going to ftp GEIS the DB2 file directly.
I do like your suggestion, slightly modified, and will send that off to
him.
D MyVar s 30a
D MyString s like(MyVar) inz('test')
D Nulls s like(MyString) inz(*ALLx'00')
/free
MyVar = %trimr(myString) + Nulls;
Rob Berendt
--
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety."
Benjamin Franklin
Scott Klement <klemscot@xxxxxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
08/29/2003 10:24 AM
Please respond to RPG programming on the AS400 / iSeries
To: RPG programming on the AS400 / iSeries
<rpg400-l@xxxxxxxxxxxx>
cc:
Fax to:
Subject: Re: %trimr and *loval
On Fri, 29 Aug 2003 rob@xxxxxxxxx wrote:
> Why does %Trimr put *blanks on the end?
It doesn't. If the variable is fixed-length, EVAL needs to set the
entire contents of the variable -- so it sets the remainder to blanks.
But, it's EVAL, not %trimr() that does this.
If you're using a fixed-length variable, you need to put SOMETHING in
those spaces, right? RPG has always used blanks.
> Or, better yet, is there a better way to make sure that the field ends
> in trailing nulls?
You could do this:
D MyVar s 30a
D MyString s 30a inz('test')
D Nulls s 30A inz(*ALLx'00')
/free
MyVar = %trimr(myString) + Nulls;
But, I'm at a bit of a loss... why do you want to fill it with nulls?
> (As I finished typing up this last sentence I banged off a Sametime to
> the developer suggesting a variable length field instead. I think it is
> a new file that he will be using for CPYTOSTMF or CPYTOIMPF for FTP EDI
> purposes thus he "should" be open minded...
If he's writing it to a stream file, filling it with nulls isn't any
better than filling it with blanks... the write() API will write as
many chars as your length is set to, it does not pay attention to nulls.
Instead, he should just code:
write(fd: %addr(MyString): %len(%trimr(MyString));
and skip the whole idea of translating blanks to nulls. Or better yet,
use a varying field:
D MyString s 30a varying inz('test')
/free
write(fd: %addr(MyString)+2: %len(MyString));
At the very least, this will run much faster than the business with
%trim will. Especially if you ever change MyString to be a larger
variable.
_______________________________________________
This is the RPG programming on the AS400 / 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 mailing list archive is Copyright 1997-2025 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.