× 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 for the info, Scott.

If I were to lay this out in a single record, this is what the record
looks like:
RecordType, CodeA1, CodeA2....CodeA30,CodeB1,CodeB2....CodeB30
1,N1,S2,....E3,-1,0....-3
2,N6,S3,....S5,-5,2....-2

So instead of being only three fields per record, it is now sixty one
fields.  All I'm trying to do is pivot the table so that the data is
recorded differently.

Thanks for the code.  I'll give it a whirl and see what comes up.

Brian.

-----Original Message-----
From: Scott Klement [mailto:rpg400-l@xxxxxxxxxxxxxxxx] 
Sent: Friday, August 05, 2005 2:40 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: Multiple Field Manipulation Ideas?



> So when I read the table, there are records in it that are 61 fields
> wide.  I need to take the data from all 60 of these fields (based on
the
> value of RecordType) and match up CodeA001, CodeB001 to populate
another
> table.

I've read your message twice, and I still have a very fuzzy idea of how 
your files are laid out and what the RecordType field's purpose is. I'm 
not precisely sure how one file correlates to the other.

> What's the easiest way to extract this data to migrate it to the new
> table?  I mulled over a data area, throwing the files into an array,
> throwing them into a temporary table, etc., but I'm not sure what's
> best.  Fortunately, the tables used are static at 30 fields per code,
> and are not expected to change, so I always know there are 30 fields
for
> CodeA and CodeB.

I think you probably want to do something like the following (I haven't 
tested this code so it's probably chock full of errors, but hopefully
you 
get the idea):

      FINPUTFILE IF   E             DISK    BLOCK(*YES)
      F                                     prefix('INPUT.')
      FOUTPUTFILEO    E             DISK
      F                                     prefix('OUTPUT.')

      D Input         E DS                  extname(INPUTFILE)
      D                                     qualified
      D Output        E DS                  extname(OUTPUTFILE)
      D                                     qualified

      D p_inputCodeA    s               *
      D p_inputCodeB    s               *

      D CodeA           s                   like(Input.CodeA001) dim(30)
      D                                     based(p_InputCodeA)
      D CodeB           s                   like(Input.CodeB001) dim(30)
      D                                     based(p_InputCodeB)

      D f               s             10I 0

       /free

           p_InputCodeA = %addr(Input.CodeA001);
           p_InputCodeB = %addr(Input.CodeB001);

           setll *start InputFile;
           read  InputFile;

           dow not %eof(InputFile);

                for f = 1 to %elem(CodeA);
                     Output.RecordType = Input.RecordType;
                     Output.CodeA      = CodeA(f);
                     Output.CodeB      = CodeB(f);
                     write OutputRec;
                endif;

                read  InputFile;
           enddo;

           *inlr = *on;

       /end-free

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.