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



Thanks Scott.

We have tried CPYFRMIMPF to no avail.

All the records come back with this error code:

   4 - The data for field HDRPRT of the TOFILE does not allow nulls, or
the 
 from file does not have enough fields for the TOFILE. The TOFILE does
not  
 support nulls.            
                                                 
The tab delimited file looks like this:
 

  Record#
....5...10...15...20...25...30...35...40...45...50...55...60...65  
        1  H A 1000005 Scenario 3.1 Domestic PO 11223 1 4 A 1 09
7/13/2003  
        2  H C 1000005 Scenario 3.1 Domestic PO 11223 1 4 A 1 09
7/13/2003  
        3  H A 1000005 Scenario 3.1 Domestic PO 11223 1 4 A 1 09
7/13/2003  
        4  H M 1000005 Scenario 3.1 Domestic PO 11223 1 4 A 1 09
7/13/2003  
        5  H M 1000005 Scenario 3.1 Domestic PO 11223 1 4 A 1 09
7/13/2003  
        6  H M 1000005 Scenario 3.1 Domestic PO 11223 1 4 A 1 09
7/13/2003  
        7  H M 1000005 Scenario 3.1 Domestic PO 11223 1 4 A 1 09
7/13/2003  
 

All spaces between fields are the TABS.

The fields in the receiving physical are not the same length as the
original file as shown below...

Field                  
 Name      Type  Length 
 HDRTYP      A       1  
 HDRACT      A       1  
 HDRPO       A      20  
 HDRDSC      A      60  
 HDRVND      A      20  
 HDRPTY      A       1  
 HDRPRE      A       1  
 HDRPOS      A      20  
 HDRPRT      A       1  
 HDRSHP      A       2  
Etc........                        

-----Original Message-----
From: Scott Klement [mailto:klemscot@xxxxxxxxxxxx] 
Sent: July 10, 2003 4:02 AM
To: RPG programming on the AS400 / iSeries
Subject: Re: FW: help


On Wed, 9 Jul 2003, John Cunha wrote:
>
> We receive files from a third party vendor which are tab delimited as
> shown below.

Hmmm.. I didn't get this sample.  Keep in mind that attachments don't
work on this mailing list.

> We need to move the contents (different record types) of this file
into
> DDS external described files for each type.
>
> Does anyone know how to do this in a clean, fast and reliable way?

The non-RPG method would be the CPYFRMIMPF command.  But, I'm not going
to say much about that, since this is the RPG list and that would be
off-topic. :)

> I.e. not have to read the record byte by byte to remove the tabs from
> the records!

Lesse... you requirements are:

fast:   Don't read the record byte-by-byte, but read a chunk into a
        buffer.  That'll make a big difference in performance.
        Alternatively, use fopen/fgets to read a record at a time, and
        then parse the record.

reliable:  Don't use fscanf() or sscanf() to parse the record, since
        larger than usual data could cause an overflow and make it
        unreliable.  Aside from that, reliability is really based on
        how well you write code :)

clean:  Keep things clean by breaking them into logical procedures.
        i.e. don't have the parsing loop in your mainline, that'll
        make your code messy.   Reading until you get a tab is not
        a difficult thing to do, so I'm not really clear on why
        this is a big concern of yours...

Personally, I prefer using my own routines to parse files rather than
CPYFRMIMPF, I like having more control over the parsing, so I can make
it
work exactly as I want it to.   However, if you really don't want to
search the record byte by byte, then maybe you should consider
CPYFRMIMPF
instead of RPG.  I guess I don't understand what's wrong with reading
it byte-by-byte...

I've got a tutorial on stream files from RPG here:
http://www.scottklement.com/rpg/ifs.html

It doesn't go into fopen/fgets/fclose, etc, though.   If you post the
samples of how your file format works, I may be able to whip up some
sample code that shows how to deal with it...


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