× 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.



I agree with Lim. The spaces are AFTER your eof (which is really eol) which
makes them appear to be BEFORE the next line's data since it is a stream of
bytes. Do not attempt to write more data than you actually have in the
buffer!

Stu


On Fri, Jan 7, 2011 at 15:55, Lim Hock-Chai
<Lim.Hock-Chai@xxxxxxxxxxxxxxx>wrote:

That is probably because you are using %size(buffer), which will always
give you a value of 256, as the buffer size to write.

Try change buffer variable to be a varying length field and change write
statement to be like below:
write(fd:%addr(buffer)+2:%len(buffer)

"Mike Wills" <mike@xxxxxxxxxxxxxx> wrote in message
news:<mailman.22509.1294436679.2702.rpg400-l@xxxxxxxxxxxx>...
I am using Scott's documentation to create IFS files. I finally have
something working, however after the first row each line has over 150
characters of extra spaces before the data. What makes it stranger is
that
there isn't any consistency on how many spaces there are.

Here is a snipit of the file:
"Transaction Date","Account Desc.","Transaction
Desc","Account","Debit","Credit"


08/01/2010,"SERV CHG-SODA SALES","Ribfest-F&B Wk1
sales
J","622-49862-345130",.00,152.95


08/01/2010,"SERV CHG-CAN SODA SALES","Ribfest-F&B Wk1
sales
J","622-49862-345138",.00,9357.38

The code I use to create this is as follows:

D eof C const(x'0d25')

P WriteCsv B
D WriteCsv PI

D buffer S 256A

/free

buffer = %trim(%char(pTranDate:*usa)) + ',"' + %trim(pAcctDesc)
+
'","' + %trim(pTranDesc) + '","' + %trim(pAcct) + '",'
+
%trim(%editc(pDbAmt:'L')) + ',' +
%trim(%editc(pCrAmt:'L')) + eof;

if (write(fd:%addr(buffer):%size(buffer)) < %size(buffer));
abEnd = *on;
return;
endif;

return;

/end-free
P WriteCsv E

In debug, the spaces are not there. Any ideas?

--
Mike Wills
http://mikewills.me
--
This is the RPG programming on the IBM i / System i (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 ...

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.