×
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.
Hi Stephen,
The %lookupxx() BIFs and the LOOKUP op-code have never been enhanced to
understand how to search an array of qualified data structures. I've
complained about this before, but IBM just laughs at me.
The bsearch() API can be used -- but it might be overkill. bsearch()
does require that the array is sorted, since it does a binary tree
lookup (as does %lookup if you've specified ASCEND or DESCEND on the array).
If you don't need the performance boost of a binary tree lookup, you
might write a simple loop:
nWrkIIT = 0;
for x = 1 to nIIT;
if a57832(x).IIT.I1$IIT = xIIT;
nWrkIIT = x;
leave;
endif
endfor;
Granted, that might get ungainly to code if you need to repeat the code
in many places -- so just throw it into a subprocedure, then you can have:
nWrkIIT = findIIT(a57832: 1: nIIT);
Of course, you could just just overlaid arrays or something like that
instead -- but there are many advantages (IMHO) to qualified DS arrays,
and I personally don't mind writing a quick lookup routine.
Coyle, Stephen F. wrote:
Hi All,
If I have a data structure coded as below, how can I do a lookup against
a subfield?
I1$IIT is a subfield of the IIT field. I'd like to find the element that
matches I1$IIT.
The compiler didn't like mine:
nWrkIIT = %Lookup( xIIT:a57832.IIT.I1$IIT:1:nIIT ) ;
D a57832 DS QUALIFIED DIM(20)
D IIT LikeRec(I57832)
D PMcu Like( KgMcu )
D PSub Like( KgSub )
D PObj Like( KgObj )
D OANI Like( GlAni )
D OAA Like( GlAA )
Or is this data structure not defined correctly?
Thanks....
- Steve
As an Amazon Associate we earn from qualifying purchases.
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.