×
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.
Kurt,
Would using an array of indicators DIM( 999 ) indexed by Cust work? If you're only working with specific cycle(s) but don't care which cycle a customer is on then you set the indicator array from the table for customers on those cycle(s). Later instead of doing a %Lookup binary search or a file chain/setll it's now just an array index:
D InCycle N DIM( 999 )
If InCycle( Cust );
Paul Morgan
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Kurt Anderson
Sent: Thursday, November 10, 2011 12:09 PM
To: RPG programming on the IBM i / System i (rpg400-l@xxxxxxxxxxxx)
Subject: %lookup on a Data Structure Array
I'm trying to reduce some program I/O for program processing millions of records. I've identified a file that I feel could be loaded into an array instead of having the program chain out for every record. Usually this file is between 100-1000 records. However one of our clients has 20,000 records in the file. So before making the change, I decided to do a little reading on %lookup, to make sure I'd be using it correctly.
http://www.ibmsystemsmag.com/ibmi/developer/rpg/iSeries-EXTRA--Look-Before-You--Lookup/
It turns out that I had misunderstood how to trigger the binary search with a %lookup. I thought sorting the array was enough, however to get the binary search one needs to explicitly specify Ascend or Descend on the array.
So I went to add Ascend to a data structure array, and it won't let me:
D ds_Cust DS Qualified Inz Dim( 50000 ) Ascend
D Cust 3p 0
D Cycle 1a
Error: RNF3501E Keyword is not allowed for a data-structure definition; keyword is ignored.
I tried adding the Ascend keyword to the subfield that I use in the lookup, but it doesn't like that either (I wasn't expecting this to work, but at this point I'm grasping at straws).
I suppose I could make these two fields their own arrays. Though I'm not really a fan of that. I love using data structures to group like-data together.
Is there any way to get the new data structure array lookups to use a binary search?
Kurt Anderson
Sr. Programmer/Analyst
CustomCall Data Systems
As an Amazon Associate we earn from qualifying purchases.