APIs by Example: Print File Field Description

In this installment of APIs by Example, Carsten Flensburg demonstrates the Retrieve Database File Description (QDBRTVFD) API. This API can be used to retrieve information about a database, which is similar to the information you can get with the DSPFD CL command.

The API is demonstrated in the form of a report program that reads information about the file and prints it. You could, of course, modify this program to use this information for your own purposes. For example, you might be writing an RPG program that needs to know what positions of a record a particular group of fields is in. This API can give you that information, or you may want to look up the column headings for fields in a file so that you can print them on your own report.

The output of the API can be characterized as a series of data structures, each one “pointed to” by another data structure. To take them all in, you have to use a technique that Carsten refers to as “structure jumping.”

Structure jumping involves moving forward in memory by a variable amount using pointer logic.

Download the save file containing the source code.

Read the entire article

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s