Mike,
Isn't %size(buffer) always 256? Maybe use the Varying keyword on the buffer definition:
D buffer S 256A varying
Paul
Principal Programmer Analyst
IT Supply Chain/Replenishment
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Mike Wills
Sent: Friday, January 07, 2011 4:41 PM
To: RPG programming on the IBM i / System i
Subject: Weird problem creating IFS file
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
As an Amazon Associate we earn from qualifying purchases.