|
This is quite interesting Scott. Will this actually put the '\t' on the IFS text file? Is there a way to read back the text file with tab as well? What is CRLF in the example? Is this carriage return? Can we also use the new line this way? What is the Hex value for that? Thanks for the example, Sudha Sudha Ramanujan SunGard Futures Systems sramanujan@xxxxxxxxxxxxxxxxxx (312) 577 6179 (312) 577 6101 - Fax -----Original Message----- From: Scott Klement [mailto:rpg400-l@xxxxxxxxxxxxxxxx] Sent: Friday, December 17, 2004 2:08 PM To: RPG programming on the AS400 / iSeries Subject: Re: Tab delimited data in a file On Fri, 17 Dec 2004, Joubert, Robert wrote: > I have been asked to create a "Tab Delimited" file for download. > Can this be done in (any flavor of) RPG? If so - how???? It can be done in ILE RPG using the IFS APIs, or using the ILE runtime. (two ways!) The way I like to do it is to create a large VARYING field in the RPG program, and concatenate all of the fields together. Use the %char() BIF to convert numeric fields to character fields so they can be concatenated. For example (this is V5R2 code): H DFTACTGRP(*NO) FITMMAST IF E DISK /copy ifsio_h D fd s 10I 0 D IfsData s 32767A varying D TAB c x'05' D CRLF c x'0d25' /free fd = open( '/tmp/itemdata.tab' : O_WRONLY + O_TRUNC + O_CREAT + O_CCSID + O_TEXTDATA + O_TEXT_CREAT : M_RDWR : 1252 : 0 ); if (fd < 0); // file open failed. Check __errno() to find out // why, then notify user. endif; read ITMMAST; dow not %eof(ITMMAST); IfsData = %char(SKU) + TAB + %trimr(ItemDesc) + TAB + %char(Weight) + TAB + %trimr(SalesRepName) + CRLF; callp write(fd: %addr(IfsData)+2: %len(IfsData)); read ITMMAST; enddo; callp close(fd); *inlr = *on; /end-free You can get the /copy member (IFSIO_H) from my Web site at: http://www.scottklement.com/rpgandbeyond04/ I've also written a tutorial on IFS programming, which you can read at http://www.scottklement.com/rpg/ifs.html The problem with that tutorial is that it's aimed at V4 RPG programming. So it works, but is a little dated. I've been rewriting it with V5 style as a series of articles in iSeries NEWS. So far, two articles have been published, one in November and one in December. http://www.iseriesnetwork.com/article.cfm?ID=19312 http://www.iseriesnetwork.com/article.cfm?ID=19473 I've also done presentations on this topic at RPG World and at the RPG and Beyond, and I may do one on the iSeries Network in March as well (currently that's not finalized), so I'm getting a little burnt out on the subject, heh... > > Or must this be done using CPYTOIMPF to a file in IFS? > That's another way to do it... That way gives you far less control over the process, is slower, and doesn't give you the chance to do any logic if necessary (for example, getting fields from more than once source, doing any math on the fields, etc.) But, it works, and some people find it easier. -- 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-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.