Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RPGILE to CSV problem with char field containing numerics

Status
Not open for further replies.

EOSLivingston

Programmer
Sep 5, 2007
3
0
0
GB
I have an RPG ILE program that creates a CSV file from a physical file on the iSeries OK . . .

BUT, the first field on the PF is a 50 character field that can sometimes contain purely numerics. So when eg '9999999999999999' is the value of the first field, it converts it to 1E+16 on the CSV. AND when you click on the field it expands it to 9999999999999990 . . . ie it replaces the last digit with a 0 !

Any ideas how I can make sure that it stays as a character value in the spreadsheet ? The other values come across OK.

Cheers.
 
Your best bet is to write a little RPG program that fills the flat file so that you can to prevent this "1E+16" and the drop in the leading zeroes and the truncting of the column, eg

Code:
/free
  outrcd = '="' + %char(Field50) + '",' + ... ;
 
Thanks, but really not sure what you mean . . .

Here is the main part of the code I use to create a row in the CSV file;

The field FL01P8 is 50A on the AS400, but when it runs through the ILE program it does what I've mentioned.

Some values in FL01P8 appear OK as they have a slash or a dot in them, it's just where all digits are numeric.

read RCAE04P8;
dow not %eof(RCAE04P8);

IfsData = %trim(FL01P8) + ','
+ %trim(FL02P8) + ','
+ %editc(FL03P8:'P') + ','
+ %trim(FL04P8) + ','
+ %editc(FL05P8:'3') + ','
+ %trim(FL06P8) + ','
+ %trim(FL07P8) + ','
+ %trim(FL08P8) + ','
+ %trim(FL09P8) + ','
+ %trim(FL10P8) + ','
+ %char(FL11P8) + ','
+ %char(FL12P8) + ','
+ %char(FL13P8) + CRLF;

callp write(fd: %addr(IfsData)+2: %len(IfsData));

read RCAE04P8;
enddo;
 
Sorry, let me clarify to my last post.

I mean to precede the numeric fields with the equal sign and encapsulate those fields with double quotes.

F.E.
Code:
    IfsData = '="' + %trim(FL01P8) + '",' + ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top