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



>>> This is exactly what I meant to do, but for the lack of %lookup
support.
Would it be possible to write a generic procedure, you can pass an array
(could be an array of data structure) that could look up this array... I
am just thinking loud here.

Search archive.midrange.com for qsort and bsearch C APIs.  These will
work great for your data structure array.  (It's what I use.) 


Kurt Anderson
Application Developer
Highsmith Inc

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of praveen gunda
Sent: Wednesday, April 19, 2006 1:00 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: How can I Improve this procedure...

Scott,
Thanks for the suggestions. I have a few more questions based on ur
suggestions, quoted in your reply.


On 4/19/06, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> wrote:
>
>
> > How can I improve this procedure for performance? I am a little 
> > worried about how the ReasonDS is declared.
> > Basically I need an Array of the Datastructure that the procedure 
> > can return. I also need to be able to look up this array with 
> > @RsnCode as
> the
> > key.
>
> The best way to improve performance is to pass the data structure as a

> parameter instead of as a return value.  The return value is much less

> efficient, and I personally would never use it for anything larger 
> than 30 bytes (or so) if performance is a concern.


  >>> can you elaborate on this? I keep hearing it very often but did
not find much explantation as to why?
        Is this the case with procedures too? Also is it any different
if the procedure is in a service program?
        Is it not just a pointer that is returned? Any pointers to
books/IBM resources on this topic will be helpful too.


> * Array of Data structures to hold reason code details
> > D  ReasonDS       DS          5400
> > D   @RsnCode                     2A   Dim(200)
> > D   @Charge                      9  2 Dim(200)
> > D   @Weight                      9  0 Dim(200)
> > D   @Units                       7  0 Dim(200)
>
> This isn't an array of data structures.  It's a data structure that 
> contains 4 arrays, each array is independent of the others.  I also 
> don't understand why you've hardcoded the data structure to be 5400 
> bytes long when it actually only needs 3200 bytes of memory.  I know 
> that 2200 bytes isn't a big deal, but why waste it if it brings you no
benefit at all?
>
> You probably meant to do this:
>
>       D                 DS
>       D ReasonDS                            dim(200)
>       D  @RsnCode                      2A   overlay(ReasonDS:1)
>       D  @Charge                       9P 2 overlay(ReasonDS:*NEXT)
>       D  @Weight                       9P 0 overlay(ReasonDS:*NEXT)
>       D  @Units                        7P 0 overlay(ReasonDS:*NEXT)
>
> In this case, "ReasonDS" is an array of 16A DIM(200).  The other 
> fields overlay positions in that array, so @RsnCode is an array that 
> always overlays positions 1-2 of ReasonDS.  @Charge is an array that 
> overlays positions 3-7 of ReasonDS, etc.


>>> In this case does RPG allow  %lookup('XX': @RsnCode)  ?  I guess not

>>> as
@RsnCode is not an array.
       Anyway I have to try it out. If it works then I will be perplexed
as it is not obvious.

Alternately, you could code it as follows:
>
>       D ReasonDS        ds                  qualified dim(200)
>       D  @RsnCode                      2A
>       D  @Charge                       9P 2
>       D  @Weight                       9P 0
>       D  @Units                        7P 0
>
> In this case, it actually *is* an array of data structures.  You have 
> one DS with 4 subfields, and 200 copies of that DS.  The only problem 
> with this technique is that RPG won't let you use BIFs like %LOOKUP, 
> or op-codes like SORTA on the array, which some people find to be a 
> disadvantage.  Personally, I don't mind coding my own functions to 
> replace %LOOKUP and SORTA, so it doesn't bother me.


>>> This is exactly what I meant to do, but for the lack of %lookup
support.
Would it be possible to write a generic procedure, you can pass an array
(could be an array of datastructure) that could look up this array... I
am just thinking loud here.


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