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



Hi Richard,

I'm not sure if using a service program is in your realm of possibility, but I created a service program (that uses Scott Klement's IFS service program underneath it) to easily create delimited files on the IFS. I could send the source over to you if you're interested.

Kurt Anderson
Sr. Programmer/Analyst – Application Development, Service Delivery Platform

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Richard Reeve
Sent: Thursday, July 17, 2014 3:51 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: Help creating a pipe delimited file

Henrik,

The data will look more like
01|"fFILE DESCRIPTION"|20140717|"HOSPF001"|" "|" "|" "|" "|
10|123456789|123456789|111223333|"LAST NAME"|"FIRST NAME"|"MIDDLE NAME"|"SUFFIX"|"ALIAS LST NAME"|"NICKNAME"|
11|19640202|"M"|"ADDRESS LN 1"|"ADDRESS LN 2"|"CITY"|"ST"|"ZIP CODE"|"COUNTRY"
12|" t "|"CHECKING"|"BANK"|"ACCOUNT"|"C" |
.......and so on with many more record types, each format having its own use and format.

. The purpose of this exercise is that my client is moving from one vendors software package to another package and the target package needs this extract.

Basically, what I'm doing is reading multiple files in a db2 database
(using RPG) and building these output records as I go Where I am getting
tripped up is:
1. Should I just create data structures for each record type and write to a file defined with a record length of say 400 (the longest of the record types plus 50 for the delimiters that I'll be adding or would it be wiser to create actual files for each record type (adding employee # to each as a hidden field so that I can properly order the extract file).

2. I am confused as to how to get the pipe delimiter in the extract file efficiently and removing trailing blanks.

Thanks again to all of you for your guidance and suggestions. I truly appreciate it.

Rich


On Thu, Jul 17, 2014 at 1:04 PM, Henrik Rützou <hr@xxxxxxxxxxxx> wrote:

Richard

is this the style you are looking for ?

01|123456|"Acme Ltd"|
02|123456|5001235|10|
02|123456|5001235|10|
02|123456|5001235|10|
02|123456|5001235|10|
02|123456|5001235|10|
02|123456|5001235|10|
02|123456|5001235|10|
02|123456|5001235|10|
02|123456|5001235|10|
02|123456|5001235|10|


On Thu, Jul 17, 2014 at 6:55 PM, John Yeung
<gallium.arsenide@xxxxxxxxx>
wrote:

On Thu, Jul 17, 2014 at 12:02 PM, Mike Cunningham
<mike.cunningham@xxxxxxx> wrote:
We just finished a project doing this.

We made a work file defined as
[...]

In RPG did this
[...]

Good so far.

In CL did this
/* Copy the temporary import work file to the IFS directory */
CPYTOIMPF FROMFILE(QTEMP/UTPIMPF) TOSTMF(&TOSTMF) +
MBROPT(*REPLACE) STMFCODPAG(*PCASCII) +
RCDDLM(*CRLF) DTAFMT(*DLM) STRDLM(*NONE) +
STRESCCHR(*NONE) RMVBLANK(*TRAILING) +
FLDDLM(*TAB)

I doubt CPYTOIMPF is the best tool here. The intent of CPYTOIMPF is
to take an externally described file with a bunch of regular fields
(typically not all text), and put the delimiters between those
fields for you. In your case, you've got a file with just one field
defined, so CPYTOIMPF is left with nothing to do but copy that one
field (thus no delimiters for it to insert) to the output.

The process flow you're describing (where you use RPG to insert
delimiters into a flat file) fits better with CPYTOSTMF. In effect,
what you've done is to provide Jeff Young's answer, except with some
code samples (which are valuable, don't get me wrong!).

Richard, if you're comfortable with RPG, I think this approach is
probably the most expedient. Your RPG code will of course be more
complex than Mike's, because you'll have to write multiple formats,
but the basic flow is there. Of course you need to use pipe instead
of tab, and I recommend using CPYTOSTMF instead of CPYTOIMPF at the
end.

John Y.
--
This is the RPG programming on the IBM i (AS/400 and 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.




--
Regards,
Henrik Rützou

http://powerEXT.com <http://powerext.com/>
--
This is the RPG programming on the IBM i (AS/400 and 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.


--
This is the RPG programming on the IBM i (AS/400 and 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 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.