Here’s a quick tip for troubleshooting API calls:
If you are calling an API and notice that data you are expecting isn’t being provided, verify that you are allocating enough space for the return values and telling it how much space you’ve allocated.
Many APIs require you to allocate space to hold the returned info – but if you don’t tell the API how much space you’ve provided, it will only return the information that fits in the space it knows about.
Case in point … a co-worker and I were trying to use the QDBRTVFD api … our code was allocating 32k (yeah, a lot more than needed) … but the data length we provided was only 400 bytes (size of the header data structure).
The information we were interested in was actually in one of the sub-structures … but the offset value for that sub-structure was zero.
A bit of digging turned up that the API was returning 400 bytes of data for the call (in the QDBFYRET field)… but there were 1400 bytes of data available (QDBFYAVL field).
The fix was quite simple … we told the API that we were providing 32k of space (same amount we were allocating) and it worked fine.
David is a Principal Software Engineer for PTC, Integrity Business Unit. He cut his teeth on the S/36 and has more than 25 years of experience on the IBM i / System i / iSeries / AS400. He primarily works in Java and ILE RPG specializing in cross platform integrations. David has received the COMMON Distinguished Service award and was named an IBM Power Systems Champion. David is an active volunteer with the American Diabetes Association's Tour de Cure fundraising bike ride. He is currently captain of Team RED Chicago. David runs and maintains midrange.com. His personal blog is Geeky Ramblings.