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


  • Subject: Re: File conversion
  • From: PaulMmn@xxxxxxxxxxxxx (PaulMmn)
  • Date: Sat, 12 Jul 1997 23:28:23 -0400

At 4:30 PM 7/10/97, Rob Ward wrote:
>Does anyone have an RPG program that will convert an AS/400 external file
>to a comma delimited file they would care to share.


I wrote one about 3 years ago; it's more ugly than complicated.

The input file is your externally defined file.

The output file is a fixed record length file.  Length is determined by the
length of the input file (UNPACKED) plus a comma between each field (ie
#-of-commas = #-of-fields  -  1).  Plus two bytes for each alpha field (for
the double-quotes they get wrapped with).

Move numeric fields to alpha fields.  Don't worry about decimals; your PC
program has to understand how many decimals in each field.

Alpha fields are included in their entirety (including trailing blanks).
Much easier than scanning for the last non-blank character.

I coded my program using plain ordinary output specs.  If I remember
correctly, they look something like:

OFILENAM     E                   DETAIL
O                                NUMA1     10
O                                          11 ','
O                                NUMA2     16
O                                          17 ','
O                                          18 '"'
O                                ALPH1     45
O                                          46 '"'
O                                          47 ','
O                                ...etc...

Ugly, but it works.  I then used a CPYTOPCD to dump the file into a shared
folder that was accessed as an I: drive from a PC, which then did strange
and marvelous things to the file.  The CPYTOPCD does the EBCDIC --> ASCII
conversion.  As long as the numbers are SIGNED, and not PACKED, the
conversion goes smoothly.

This is where your days of reading about how the data is stored internally
pay off!

OH!  Be careful about negative numbers; you may have to extract a sign and
include it as a '-' on the output!  I didn't have to deal with them in my
program; I was mostly dealing with dates and estimated hours for projects.


--Paul E Musselman
PaulMmn@ix.netcom.com


* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the Midrange System Mailing List!  To submit a new message,   *
* send your mail to "MIDRANGE-L@midrange.com".  To unsubscribe from     *
* this list send email to MAJORDOMO@midrange.com and specify            *
* 'unsubscribe MIDRANGE-L' in the body of your message.  Questions      *
* should be directed to the list owner / operator: david@midrange.com   *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.