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



Hello Bryan,

You wrote:
>My initial thought is that since the offset is mentioned I should be able
>to "point" to that area using the eval stmt.   In my case this returnes no
>data.

Because you haven't given the API enough space to include that data.  If
you check the values of Q01BytRetr and Q02BytAvail you should find that
Q01BytRetr is equal to the size of QTOD020000 but Q02BytAvail is a larger
value indicating how much information the API could have given you if you
had provided enough space for that information.

>If I increase the size of the data structure QTOD020000 by 62 bytes(size
>of the data I want) I get the data I want.

Because now the RcvVar has enough room for the data.  It will still fail if
there are more entries in the list.

>The proble with this approach is that there could be multiple occurences
>of that data structure.

You must either create a bloody big chunck of space or dynamically allocate
the needed storage.  Dynamic allocation is preferred.  Make QTOD020000 a
based structure:

     DQTOD020000       DS      BASED(@QTOD020000)

One approach is:

Allocate 8 bytes:
     C                  ALLOC   8               @QTOD020000

Place one call to the API with RcvVarLen set to 8.  Check the Q02BytAvail
value and reallocate the space for that amount:
     C                  REALLOC Q02BytAvail   @QTOD020000

Then call the API again.  (You might have to check the Q02BytAvail field
again depending on how dynamic the data is, i.e., there might be more on
the second call than the first call indicated because new connections been
established.)

Once the Q02BytAvail value indicates you have all the available data then
process the data.

A better approach:

Allocate enough space for the normally expected amount of data (e.g., 20
entries).  Call the API with RcvVarLen set to the allocated amount.  Check
the Q02BytAvail value and if greater than the Q02BytRetr value, reallocate
by that amount plus some slack, then call the API again.  Otherwise process
the data.

There are numerous APIs that provide dymanic lists of data and they cann
all be processed in a generic style.  The pseudo-code is:

Allocate room for expected entries

Do until all data retrieved

        call API

        if more data available
                allocate more storage

Enddo

Process the data

Regards,
Simon Coulter.

--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists
   http://www.flybynight.com.au/

   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175   mailto: shc@flybynight.com.au   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



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.