APIs and exit programs: Thousands of lines of free code

Ron Turull
You can shave hours off of your development time by taking advantage of thousands of lines of free code IBM has given all of us. Many of the System i-iSeries system APIs and exit programs take parameters that can get quite complex; that is, a parameter can be formatted as a data structure containing many subfields -- sometimes as many as 30 or 40. Defining these data structures is a time-consuming chore and a waste of your valuable talents. The IBM-provided code contains predefined data structures and constants for most, if not all, of the system APIs and exit programs.

How to take advantage of this code

The free code is in the form of copy members (also known as header files and include files) and can be found in the QSYSINC library, which stands for 'system includes' (the word 'includes' is the C language terminology for copy member). Each language has its own file. The chart below will help you locate the file appropriate for the language you are using.

Quick reference to copy files in QSYSINC

Tips for locating the proper member

Once you have determined which file you need, you'll need to locate the appropriate file member. Because there are so many copy members in each of these files and many of their names apparently have no relation to their contents, finding the right member can be tough. Try these two tricks to lessen the burden:

1. Search through the contents of all the members for the name of the API you are using (e.g., QMHRDQM). To search through all the members in a file, "open" the file in PDM (use the WRKMBRPDM command to get into PDM). Then, type option 25 next to the first member listed and press F13 (this will copy the option 25 to all the members in the list). Next, press Enter and the Search Options screen will appear, where you can type the name of the API (or any other text) you want to search for. Finally, press Enter and the system will start searching through the members.

2. A quicker, but less effective, method involves searching just the text descriptions of the members. You can do this by pressing F17 to bring up the Subset Member List screen and specify criteria to subset the list. To search the text descriptions, type in a search word for the Text field. For example, to locate members having include information for data queue APIs, type "data queue" in the Text field and press Enter.

Once you have located the appropriate member, use the "/COPY" RPG compiler directive to have the compiler copy the contents of the member into your program (COBOL programmers use the COPY statement).

About the author: Ron Turull is editor of Inside Version 5. He has more than 20 years' experience programming for and managing AS/400-iSeries systems.

This was first published in October 2006

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.