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



Where's the aspirin... 

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Tony Carolla
Sent: Wednesday, February 28, 2007 3:33 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: CHAIN Versus SETLL and READ When Data Needed

1)  Build three LFs keyed identically as the PF, that contain

     A) only the first key field
     B) the first two key fields
     C) the first three key fields

2)  Build a *SRVPGM prototyped as follows (adjust field types as nec):

     d isThere         pr              n
     d   keyfld1                      3a   const
     d   keyfld2                      9p 2 const options(*nopass)
     d   keyfld2                      4p 0 const options(*nopass)

     A)  runs in it's own activation group
     B)  on the first call, opens up a ridiculously overbuffered copy of
the
three files (OVRDBF SEQONLY(*YES 99999) NBRRCDS(99999))
     C)  for each LF, read in key order every record, manually detecting
unique values,
     D)  place them in an allocated chunk of memory, walking the
structure
using ALLOC, BASED, and pointers
     E)  on subsequent lookups, use qsearch to see if the elements exist
     F)  from your app, use the *SRVPGM as follows:

if isThere(key1 : key2 : key3);
   CHAIN (key1 : key2 : key3) fmt;
elseif isThere(key1 : key2);
   CHAIN (key1: key2:) fmt;
elseif isThere(key1);
   CHAIN key1 fmt;
endif;

Items to consider:
     A)  The data in the tables might change throughout the day --
perhaps
the users should notify each other when they make changes, so that they
can
signoff/sign on and rebuild their "arrays"
     B)  The number of unique fields might cause your *SRVPGM to
allocate
too much memory (in each and every client job) -- consider upgrading
your
RAM
     C)  You will have the privelige of being the only one on the planet
who
knows how to make any changes.

PS.  If you do this, you have probably studied one too many "Sorcerer's
Guides"


On 2/28/07, Shannon O'Donnell <shannon.odonnell@xxxxxxxxxxxxxx> wrote:

I posed this question on MCPressOnline the other day but I would like
to
get more opinions on it so I'll post it here too.   A shop-standard
hangs in the balance.



   Assume that you have an RPG program that has logic such that you
need
to first see if some data is in a file, based on a key, and then if
so,
you do something with that data.



   Further assume that this file has a complex key with three fields.



    The program logic is such that you check the maximum number of
keys
for a match down to the minimum number of keys



     Like this:



              Key1    Klist

                          Kfld              Fld1

                          Kfld              Fld2

                          Kfld              Fld3



              Key2     Klist

                          Kfld              Fld1

                          Kfld              Fld2



              Key3     Klist

                           Kfld             Fld1





   Which one of these logic blocks is most efficient?



   Key1   Setll   file

       If    %FOUND(file)

               Key1   READE file

                       Use Fields

       Else

          Key2    Setll  File

            If   %FOUND(file)

                     Key2 Use Fields

           Else

             Key3  Setll File

                  If   %FOUND(file)

                     Key3 READE file

               Endif

            Endif

          Endif







OR....



               KEY1  Chain file

                          If       %FOUND(file)

                              Use fields

                         Else

              KEY2   Chain  file

                          If      %FOUND(file)

                              Use Fields

                          Else

              KEY3   Chain file

                          If   %FOUND(file)

                             Use Fields

                         Endif

                         Endif

                         Endif





My opinion is that the CHAIN is more efficient from both a
coding/maintenance standpoint and from an I/O standpoint, but I'm open
to opinions.











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